home-hosted 0.13.0 → 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-CZcVca2a.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-pKbGCW9d.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-B-Eu0sFW.js → nanny-BWh7nuvv.js} +21 -14
- package/dist/chunks/nanny-BWh7nuvv.js.map +1 -0
- package/dist/chunks/{nanny-ChMtq1Zl.js → nanny-BjF2-1pv.js} +3 -3
- package/dist/chunks/{nanny-ChMtq1Zl.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-DErnlPY1.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-B8WBTRMk.js → port-CnsrxKNR.js} +27 -71
- 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-Des4DrAN.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-BtWMFmzZ.js → src-BnzkVy_M.js} +12548 -10576
- package/dist/chunks/src-BnzkVy_M.js.map +1 -0
- package/dist/chunks/{status-DT1EsA-B.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-Pdz-l6IH.js → up-BQSnYxYd.js} +47 -53
- package/dist/chunks/up-BQSnYxYd.js.map +1 -0
- package/dist/chunks/{usage-DFrCVXpT.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-CZcVca2a.js.map +0 -1
- package/dist/chunks/backups-CFRaWe_m.js +0 -4691
- package/dist/chunks/backups-CFRaWe_m.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-log-BVj8cDEo.js +0 -241
- package/dist/chunks/daemon-log-BVj8cDEo.js.map +0 -1
- package/dist/chunks/daemon-qKVECISl.js +0 -247
- package/dist/chunks/daemon-qKVECISl.js.map +0 -1
- package/dist/chunks/docker-Cy9Lyvda.js.map +0 -1
- package/dist/chunks/down-pKbGCW9d.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-B-Eu0sFW.js.map +0 -1
- package/dist/chunks/nanny-BtWfy0QH.js +0 -1167
- package/dist/chunks/nanny-BtWfy0QH.js.map +0 -1
- package/dist/chunks/nanny-sweep-DErnlPY1.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-B8WBTRMk.js.map +0 -1
- package/dist/chunks/restart-Des4DrAN.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-Bge2r2qQ.js +0 -169
- package/dist/chunks/server-Bge2r2qQ.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-obPiEJYk.js +0 -78
- package/dist/chunks/set-token-obPiEJYk.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-BtWMFmzZ.js.map +0 -1
- package/dist/chunks/status-DT1EsA-B.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-Pdz-l6IH.js.map +0 -1
- package/dist/chunks/usage-DFrCVXpT.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts-CxZ7u1L3.js","names":[],"sources":["../../src/shared/contracts/accounts.ts","../../src/shared/contracts/backups.ts","../../src/shared/contracts/ddns.ts","../../src/shared/contracts/proxy.ts","../../src/shared/host-readings.ts","../../src/shared/query-params.ts","../../src/shared/contracts/frames.ts","../../src/shared/contracts/logs.ts","../../src/shared/contracts.ts"],"sourcesContent":["/** Accounts: one credential that signs in to the panel and authenticates the API. */\nimport { type } from 'arktype'\nimport { lazy } from '../lazy'\n\n/** Must match `API_TOKEN_SCOPES` (`#src/config/secrets`), which the guard reads; `test/shared/contracts.test.ts` pins the two. */\nexport const apiTokenScopeSchema = lazy(() => type.enumerated('read', 'lifecycle', 'config', 'proxy', 'admin'))\n\n/** Signing in takes an id and a secret; the lengths are sanity caps, not policy. */\nexport const loginSchema = lazy(() => type({\n id: '1 <= string <= 64',\n secret: '1 <= string <= 512',\n}).onUndeclaredKey('reject'))\nexport type LoginRequest = typeof loginSchema.infer\n\n/** Any non-empty secret is allowed; only a sanity cap on the length. */\nexport const passwordValueSchema = lazy(() => type('1 <= string <= 512'))\n\n/** Changing your own secret, proving the current one. */\nexport const accountSecretSchema = lazy(() => type({\n currentSecret: passwordValueSchema,\n newSecret: passwordValueSchema,\n}).onUndeclaredKey('reject'))\nexport type AccountSecretRequest = typeof accountSecretSchema.infer\n\nexport const accountViewSchema = lazy(() => type({\n 'id': 'string',\n 'label': 'string',\n 'scopes': apiTokenScopeSchema.array(),\n 'workspaces?': 'string[]',\n 'enabled': 'boolean',\n 'isDefault': 'boolean',\n /** Its secret is shorter than the exposure bar, so a non-loopback bind stays refused. */\n 'short': 'boolean',\n 'createdAt': 'number',\n 'updatedAt': 'number',\n 'lastUsedAt?': 'number',\n}).onDeepUndeclaredKey('ignore'))\nexport type AccountView = typeof accountViewSchema.infer\n\n/** One scope; `workspaceLimited` is `false` for a scope a workspace limit cannot narrow (`proxy`, `admin`). */\nexport const scopeInfoSchema = lazy(() => type({\n scope: apiTokenScopeSchema,\n workspaceLimited: 'boolean',\n}))\n\nexport const accountListSchema = lazy(() => type({\n 'accounts': accountViewSchema.array(),\n /** Optional for an older panel. */\n 'scopes?': scopeInfoSchema.array(),\n}))\n\nexport const accountIdBodySchema = lazy(() => type({ account: accountViewSchema }))\n\n/** Absent `secret` means the panel generates one and shows it once. */\nexport const accountCreateSchema = lazy(() => type({\n 'id': '1 <= string <= 64',\n 'label?': '1 <= string <= 120',\n 'scopes': apiTokenScopeSchema.array().atLeastLength(1),\n 'workspaces?': 'string[]',\n 'secret?': passwordValueSchema,\n}).onUndeclaredKey('reject'))\nexport type AccountCreateRequest = typeof accountCreateSchema.infer\n\n/** Ids are immutable. */\nexport const accountPatchSchema = lazy(() => type({\n 'label?': '1 <= string <= 120',\n 'scopes?': apiTokenScopeSchema.array().atLeastLength(1),\n 'workspaces?': type('string[]').or(type('null')),\n 'enabled?': 'boolean',\n}).onUndeclaredKey('reject'))\nexport type AccountPatchRequest = typeof accountPatchSchema.infer\n\n/** The create answer: the account, and its secret **once**. */\nexport const accountCreatedBodySchema = lazy(() => type({\n account: accountViewSchema,\n secret: 'string',\n}))\n","/** Backups: the archive list, the capture tree, the restore plan and both request shapes. */\nimport { type } from 'arktype'\nimport { backupScheduleSchema } from '../contracts'\nimport { lazy } from '../lazy'\nimport { passwordValueSchema } from './accounts'\n\nexport const backupFileSchema = lazy(() => type({\n name: 'string',\n sizeBytes: 'number',\n createdAt: 'number',\n encrypted: 'boolean',\n}))\n\nexport type BackupFile = typeof backupFileSchema.infer\n\n/** One selectable backup entry: a global item, or a workspace whose `items` are its sub-choices. */\nexport const backupEntrySchema = lazy(() => type({\n /** `global:settings` | `global:secrets` | `global:tls` | `workspace:<id>`. */\n 'id': 'string',\n /** The panel's English wording, for older or single-language UIs; a translated UI uses `labelKey`. */\n 'label': 'string',\n /** A catalog key for `label`, with its placeholder values, so a UI can render its own language. */\n 'labelKey?': 'string',\n 'labelParams?': 'Record<string, string>',\n 'kind': '\"settings\" | \"secrets\" | \"tls\" | \"workspace\"',\n 'workspaceId?': 'string',\n 'note': 'string | null',\n 'noteKey?': 'string',\n 'noteParams?': 'Record<string, string>',\n 'items': type({\n 'id': 'string',\n 'label': 'string',\n 'labelKey?': 'string',\n 'labelParams?': 'Record<string, string>',\n 'kind': '\"settings\" | \"servers\" | \"secrets\" | \"jobs\" | \"data\"',\n /** Which secret a `secrets` leaf carries (`password`, `apiToken`, `telegram`, `ddns`, …). */\n 'secret?': 'string',\n 'path?': 'string',\n /** Who declared a data path: `global`, `<serverId>:backupPaths` or `<serverId>:<ENV>`. */\n 'origin?': 'string',\n 'included': 'boolean',\n 'note': 'string | null',\n 'noteKey?': 'string',\n 'noteParams?': 'Record<string, string>',\n 'ignoreGenerated?': 'boolean',\n }).array(),\n}))\nexport type BackupEntry = typeof backupEntrySchema.infer\n\n/** The schedule as a response carries it: undeclared keys are accepted at every level (`scope` is nested). */\nexport const backupScheduleViewSchema = lazy(() => backupScheduleSchema.onDeepUndeclaredKey('ignore'))\n\nexport const backupsViewSchema = lazy(() => type({\n 'enabled': 'boolean',\n 'dir': 'string',\n 'keep': 'number',\n /** Optional for an older panel; read as the schema defaults when absent. */\n 'schedule?': backupScheduleViewSchema,\n /** When the last automatic archive was written; null until one has run. */\n 'lastAutomaticAt?': 'number | null',\n /** Why the last scheduled pass failed, and when; null once a pass succeeds. */\n 'scheduleError?': type({\n message: 'string',\n at: 'number',\n }),\n 'includePaths': type('string[]'),\n /** Sent only by an older panel; the selection model now lives at `GET /api/backups`. */\n 'entries?': backupEntrySchema.array(),\n 'files?': backupFileSchema.array(),\n}))\nexport type BackupsView = typeof backupsViewSchema.infer\n\n/** What a capture could include and what is on disk; its own route because building it is too costly per frame. */\nexport const backupSelectionSchema = lazy(() => type({\n dir: 'string',\n entries: backupEntrySchema.array(),\n files: backupFileSchema.array(),\n}))\nexport type BackupSelection = typeof backupSelectionSchema.infer\n\n/** One restorable slice of an archive: a global item, a workspace item, or a data path. */\nexport const restoreItemSchema = lazy(() => type({\n /** A backup entry or leaf id (`workspace:<id>:servers`, `data:<path>`, ...). */\n 'id': 'string',\n 'label': 'string',\n 'labelKey?': 'string',\n 'labelParams?': 'Record<string, string>',\n 'kind': '\"settings\" | \"secrets\" | \"servers\" | \"jobs\" | \"tls\" | \"data\"',\n 'workspaceId?': 'string',\n /** false when the current instance does not declare it, or it is not in the archive. */\n 'restorable': 'boolean',\n 'selected': 'boolean',\n 'note': 'string | null',\n 'noteKey?': 'string',\n 'noteParams?': 'Record<string, string>',\n}))\nexport type RestoreItem = typeof restoreItemSchema.infer\n\n/** Why one thing was skipped, in parts, so a translated UI can word it; `skipped` keeps the English sentences. */\nexport const restoreSkipSchema = lazy(() => type({\n 'label': 'string',\n 'labelKey?': 'string',\n 'labelParams?': 'Record<string, string>',\n /** A catalog key for the parenthesis, e.g. `not selected`; absent when there is none. */\n 'reasonKey?': 'string',\n 'reasonParams?': 'Record<string, string>',\n}))\nexport type RestoreSkip = typeof restoreSkipSchema.infer\n\nexport const restorePlanSchema = lazy(() => type({\n 'dryRun': 'boolean',\n 'encrypted': 'boolean',\n 'needsPassword': 'boolean',\n /** Where the archive says it came from; absent for an older archive or panel. */\n 'archive?': type({\n 'writtenBy?': 'string',\n 'schema?': 'number',\n }),\n 'items': restoreItemSchema.array(),\n /** One row per backup hook that ran; `output` is a bounded tail, not a log. */\n 'hooks?': type({\n 'serverId': 'string',\n 'workspaceId': 'string',\n 'action': '\"dump\" | \"load\"',\n 'ok': 'boolean',\n 'output?': 'string',\n }).array(),\n 'applied': type('string[]'),\n /** The ids `applied` names, so a UI can render its own labels. */\n 'appliedIds?': type('string[]'),\n 'skipped': type('string[]'),\n 'skippedItems?': restoreSkipSchema.array(),\n /** Only the panel's own listener needs a restart; its servers are re-read live. */\n 'restartRequired': 'boolean',\n 'reloaded': 'boolean',\n /** Running servers whose declared data path this restore overwrote: anything written since the archive is gone. */\n 'replacedUnderRunning?': type({\n workspaceId: 'string',\n serverId: 'string',\n path: 'string',\n }).array(),\n /** Workspaces this restore created because the archive named them and the host did not have them. */\n 'createdWorkspaces?': type('string[]'),\n 'error': 'string?',\n}))\nexport type RestorePlan = typeof restorePlanSchema.infer\n\nexport const backupCreateSchema = lazy(() => type({\n /** Optional: encrypts the archive. Never stored. */\n password: passwordValueSchema.optional(),\n /** Leaf ids to capture (`global:settings`, `workspace:<id>:servers`, `data:<path>`, ...); omitted means everything. */\n include: type('string[] >= 1').optional(),\n /** Leaf ids to leave out, applied after `include`. Empty is refused as ambiguous, like `include`. */\n exclude: type('string[] >= 1').optional(),\n}).onUndeclaredKey('reject'))\nexport type BackupCreate = typeof backupCreateSchema.infer\n\nexport const restoreRequestSchema = lazy(() => type({\n name: 'string?',\n password: passwordValueSchema.optional(),\n /** Item ids to restore; omitted means every restorable item. */\n include: type('string[]').optional(),\n /** Item ids to leave out, applied after `include`. Empty is refused as ambiguous. */\n exclude: type('string[] >= 1').optional(),\n}).onUndeclaredKey('reject'))\nexport type RestoreRequest = typeof restoreRequestSchema.infer\n","/** Dynamic DNS: accounts and domains, pass results, and provider metadata. */\nimport { type } from 'arktype'\nimport { lazy } from '../lazy'\n\nconst ddnsRecordTypeSchema = lazy(() => type.enumerated('A', 'AAAA'))\nexport type DdnsRecordType = typeof ddnsRecordTypeSchema.infer\n\n/** One DNS provider account; its credentials live in the secrets file keyed by `id`, never in the config. */\nconst ddnsAccountSchema = lazy(() => type({\n id: '/^[a-z0-9][a-z0-9_-]*$/',\n provider: 'string >= 1',\n label: 'string = \"\"',\n}).onUndeclaredKey('reject'))\nexport type DdnsAccount = typeof ddnsAccountSchema.infer\n\n/** A hostname to keep pointed at this machine. */\nexport const ddnsDomainSchema = lazy(() => type({\n host: '/^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/',\n account: 'string >= 1',\n /** Records to keep current; `A` unless the host needs IPv6 too. */\n types: ddnsRecordTypeSchema.array().default(() => ['A' as const]),\n /** The registered apex, only where a provider cannot look it up and the guess is wrong. */\n zone: 'string?',\n /** Seconds; `1` means \"automatic\" where the provider supports it. */\n ttl: 'number.integer >= 1?',\n /** Cloudflare only. */\n proxied: 'boolean = false',\n enabled: 'boolean = true',\n}).onUndeclaredKey('reject'))\nexport type DdnsDomain = typeof ddnsDomainSchema.infer\n\n/** Which public IP families to detect; a provider is only called for the ones declared. */\nconst ddnsIpv4Schema = lazy(() => type({\n enabled: 'boolean = true',\n /** Override the public-IP endpoint; empty uses the built-in list. */\n url: 'string = \"\"',\n}).onUndeclaredKey('reject'))\n\nconst ddnsIpv6Schema = lazy(() => type({\n enabled: 'boolean = false',\n url: 'string = \"\"',\n}).onUndeclaredKey('reject'))\n\n/** A provider is called only when the address it last confirmed differs, to stay inside rate limits. */\nexport const ddnsConfigSchema = lazy(() => type({\n enabled: 'boolean = false',\n intervalMs: 'number >= 60000 = 300000',\n ipv4: ddnsIpv4Schema.default(() => ({})),\n ipv6: ddnsIpv6Schema.default(() => ({})),\n ttl: 'number.integer >= 1 = 1',\n accounts: ddnsAccountSchema.array().default(() => []),\n domains: ddnsDomainSchema.array().default(() => []),\n}).onUndeclaredKey('reject'))\nexport type DdnsConfig = typeof ddnsConfigSchema.infer\n\nconst ddnsRecordStateSchema = lazy(() => type('\"pending\" | \"ok\" | \"unchanged\" | \"error\" | \"skipped\"'))\nexport type DdnsRecordState = typeof ddnsRecordStateSchema.infer\n\nconst ddnsRecordViewSchema = lazy(() => type({\n 'host': 'string',\n 'account': 'string',\n 'provider': 'string',\n 'type': ddnsRecordTypeSchema,\n 'ip': 'string | null',\n 'state': ddnsRecordStateSchema,\n 'message': 'string | null',\n 'updatedAt': 'number | null',\n /** The provider refused permanently; no retry until the hostname, account or credentials change, or a check. */\n 'stopped?': 'boolean',\n}))\nexport type DdnsRecordView = typeof ddnsRecordViewSchema.infer\n\n/** Live DDNS state, as the state frame and the settings page read it. */\nexport const ddnsStatusSchema = lazy(() => type({\n enabled: 'boolean',\n running: 'boolean',\n lastRunAt: 'number | null',\n lastResult: 'string | null',\n ipv4: 'string | null',\n ipv6: 'string | null',\n records: ddnsRecordViewSchema.array(),\n}))\nexport type DdnsStatus = typeof ddnsStatusSchema.infer\n\nexport const ddnsProviderFieldSchema = lazy(() => type({\n key: 'string',\n label: 'string',\n hint: 'string = \"\"',\n optional: 'boolean = false',\n}))\nexport type DdnsProviderField = typeof ddnsProviderFieldSchema.infer\n\nexport const ddnsProviderInfoSchema = lazy(() => type({\n id: 'string',\n label: 'string',\n docsUrl: 'string',\n families: ddnsRecordTypeSchema.array(),\n fields: ddnsProviderFieldSchema.array(),\n ttl: 'boolean',\n proxied: 'boolean',\n /** These credentials can also answer an ACME DNS-01 challenge (a TXT record). */\n txt: 'boolean',\n}))\nexport type DdnsProviderInfo = typeof ddnsProviderInfoSchema.infer\n\n/** `GET /api/ddns`: the policy, the live state, and the providers this build knows. */\nexport const ddnsViewSchema = lazy(() => type({\n config: ddnsConfigSchema,\n status: ddnsStatusSchema,\n providers: ddnsProviderInfoSchema.array(),\n credentials: type('string[]'),\n}).onDeepUndeclaredKey('ignore'))\nexport type DdnsView = typeof ddnsViewSchema.infer\n\n/** `PUT /api/ddns/credentials/:id`; the provider travels along because the account may be an unsaved draft. */\nexport const ddnsCredentialsSchema = lazy(() => type({\n provider: 'string >= 1',\n credentials: type('Record<string, string>'),\n}).onUndeclaredKey('reject'))\n\n/** No defaults; `accounts`/`domains` are replaced whole, while `ipv4`/`ipv6` merge. */\nexport const ddnsPatchSchema = lazy(() => type({\n enabled: 'boolean?',\n intervalMs: 'number >= 60000?',\n ipv4: type({ enabled: 'boolean?', url: 'string?' }).onUndeclaredKey('reject').optional(),\n ipv6: type({ enabled: 'boolean?', url: 'string?' }).onUndeclaredKey('reject').optional(),\n ttl: 'number.integer >= 1?',\n accounts: ddnsAccountSchema.array().optional(),\n domains: ddnsDomainSchema.array().optional(),\n}).onUndeclaredKey('reject'))\nexport type DdnsPatch = typeof ddnsPatchSchema.infer\n","/** The reverse proxy: routes, certificates, engine state, and the config and patch shapes. */\nimport { type } from 'arktype'\nimport { lazy } from '../lazy'\n\n/** One engine ships today; the field keeps a config valid if a second one lands. */\nconst proxyEngineSchema = lazy(() => type.enumerated('caddy'))\n\n/** What a route forwards to: a supervised entry, the panel itself, or a literal upstream. */\nconst proxyTargetSchema = lazy(() => type.enumerated('server', 'panel', 'external'))\nexport type ProxyTarget = typeof proxyTargetSchema.infer\n\n/** `auto` lets the engine decide: a public name gets ACME, a local one its own CA. */\nconst proxyTlsModeSchema = lazy(() => type.enumerated('auto', 'off', 'manual'))\nexport type ProxyTlsMode = typeof proxyTlsModeSchema.infer\n\n/** One public hostname and where it goes; routes are panel-wide, so a server target names its workspace too. */\nexport const proxyRouteSchema = lazy(() => type({\n 'id': '/^[a-z0-9][a-z0-9_-]*$/',\n 'host': '/^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/',\n 'enabled': 'boolean = true',\n 'target': proxyTargetSchema.default(() => 'server' as const),\n /** `target: \"server\"` — an id is only unique inside its workspace. */\n 'workspace': 'string = \"\"',\n 'server': 'string = \"\"',\n /** `target: \"external\"` — a literal upstream such as `http://10.0.0.5:8080`. */\n 'url': 'string = \"\"',\n /** Optional path prefix; empty serves the whole host. */\n 'path': 'string = \"\"',\n 'tls': proxyTlsModeSchema.default(() => 'auto' as const),\n /** `<workspace>/<account>` answering DNS-01 for this host; empty picks the workspace's only TXT-capable account. */\n 'dnsAccount': 'string = \"\"',\n /** Skip verifying an `https://` upstream's certificate; no default, so an untouched config is not rewritten. */\n 'upstreamSkipVerify?': 'boolean',\n}).onUndeclaredKey('reject'))\nexport type ProxyRoute = typeof proxyRouteSchema.infer\n\n/** Names an uploaded PEM pair; the pair itself lives on disk (0600). */\nexport const proxyCertificateSchema = lazy(() => type({\n id: '/^[a-z0-9][a-z0-9_-]*$/',\n label: 'string = \"\"',\n}).onUndeclaredKey('reject'))\n\n/** `fallback` is a public name the CA would not issue for, so the engine serves its own CA. */\nconst proxyCertificateStateSchema = lazy(() => type.enumerated('off', 'local', 'uploaded', 'issued', 'pending', 'failed', 'fallback'))\nexport type ProxyCertificateState = typeof proxyCertificateStateSchema.infer\n\n/** DNS-01, answered by the panel over ACMEProxy so the engine never holds DNS credentials. */\nconst proxyDns01Schema = lazy(() => type({\n enabled: 'boolean = false',\n /** Nameservers Caddy checks the TXT record against; empty uses its own defaults. */\n resolvers: type('string[]').default(() => []),\n}).onUndeclaredKey('reject'))\n\nexport const proxyConfigSchema = lazy(() => type({\n enabled: 'boolean = false',\n engine: proxyEngineSchema.default(() => 'caddy' as const),\n /** Cleartext side: ACME HTTP-01 challenges and the redirect to HTTPS. */\n httpPort: '1 <= number.integer <= 65535 = 80',\n httpsPort: '1 <= number.integer <= 65535 = 443',\n /** ACME account address; a public certificate needs one. */\n email: 'string = \"\"',\n /** The ACME staging endpoint: untrusted certificates, no rate-limit burn. */\n staging: 'boolean = false',\n dns01: proxyDns01Schema.default(() => ({})),\n /** PEM pairs a route with `tls: \"manual\"` may serve; the engine picks by SNI. */\n certificates: proxyCertificateSchema.array().default(() => []),\n routes: proxyRouteSchema.array().default(() => []),\n}).onUndeclaredKey('reject'))\nexport type ProxyConfig = typeof proxyConfigSchema.infer\n\nconst proxyEngineSourceSchema = lazy(() => type.enumerated('downloaded', 'custom'))\n\nexport const proxyEngineStatusSchema = lazy(() => type({\n id: proxyEngineSchema,\n installed: 'boolean',\n /** The version the binary reports; `null` until it has been probed. */\n version: 'string | null',\n source: proxyEngineSourceSchema.or(type('null')),\n path: 'string | null',\n bytes: 'number | null',\n error: 'string | null',\n}))\nexport type ProxyEngineStatus = typeof proxyEngineStatusSchema.infer\n\nconst proxyEngineInfoSchema = lazy(() => type({\n id: proxyEngineSchema,\n label: 'string',\n docsUrl: 'string',\n releaseUrl: 'string',\n acme: 'boolean',\n internalCa: 'boolean',\n dns01: 'boolean',\n tcp: 'boolean',\n}))\nexport type ProxyEngineInfo = typeof proxyEngineInfoSchema.infer\n\nconst proxyRouteStatusSchema = lazy(() => type.enumerated('ok', 'disabled', 'no-upstream', 'error'))\nexport type ProxyRouteStatus = typeof proxyRouteStatusSchema.infer\n\nexport const proxyRouteViewSchema = lazy(() => type({\n 'route': proxyRouteSchema,\n 'status': proxyRouteStatusSchema,\n 'upstream': 'string | null',\n 'message': 'string | null',\n /** Where this hostname's certificate stands. Optional: an older panel omits it. */\n 'certificate?': type({\n 'state': proxyCertificateStateSchema,\n 'message': 'string | null',\n /** For `fallback`: minutes until the engine retries the CA by itself. */\n 'retryInMinutes?': 'number',\n }),\n}).onDeepUndeclaredKey('ignore'))\nexport type ProxyRouteView = typeof proxyRouteViewSchema.infer\n\nconst proxyRunStateSchema = lazy(() => type.enumerated('off', 'stopped', 'starting', 'running', 'error', 'unsupported'))\nexport type ProxyRunState = typeof proxyRunStateSchema.infer\n\nexport const proxyStatusSchema = lazy(() => type({\n state: proxyRunStateSchema,\n pid: 'number | null',\n urls: type('string[]'),\n /** Days until the soonest publicly-issued certificate expires; `null` when none. */\n certExpiryDays: 'number | null',\n since: 'number | null',\n lastError: 'string | null',\n}))\nexport type ProxyStatus = typeof proxyStatusSchema.infer\n\nconst proxyCertificateViewSchema = lazy(() => type({\n id: 'string',\n label: 'string',\n present: 'boolean',\n /** The engine would serve this pair for at least one manual route. */\n used: 'boolean',\n subject: 'string | null',\n issuer: 'string | null',\n validTo: 'string | null',\n daysRemaining: 'number | null',\n hosts: type('string[]'),\n error: 'string | null',\n}))\nexport type ProxyCertificateView = typeof proxyCertificateViewSchema.infer\n\n/** A DNS account a route may name, flattened across workspaces. */\nconst proxyDnsAccountViewSchema = lazy(() => type({\n 'workspace': 'string',\n 'account': 'string',\n 'provider': 'string',\n 'label': 'string',\n /** The credentials can write a TXT record, so this account can answer a challenge. */\n 'writesTxt': 'boolean',\n 'hasCredentials': 'boolean',\n /** Zones the account is known to hold; \"automatic\" uses it only for names inside one. */\n 'zones?': 'string[]',\n}))\nexport type ProxyDnsAccountView = typeof proxyDnsAccountViewSchema.infer\n\n/** `GET /api/proxy`: the policy, the engine, the live state and the resolved routes. */\nexport const proxyViewSchema = lazy(() => type({\n 'config': proxyConfigSchema,\n 'engine': proxyEngineStatusSchema,\n 'engines': proxyEngineInfoSchema.array(),\n 'status': proxyStatusSchema,\n 'routes': proxyRouteViewSchema.array(),\n 'certificates': proxyCertificateViewSchema.array(),\n /** Every DNS account a route may name. Optional: an older panel omits it. */\n 'dnsAccounts?': proxyDnsAccountViewSchema.array(),\n /** On a write's answer only: the change was saved, but the engine did not apply it, and this says why. */\n 'applyError?': 'string',\n}).onDeepUndeclaredKey('ignore'))\nexport type ProxyView = typeof proxyViewSchema.infer\n\n/** A route as a patch sends it: every field but `id`/`host` optional. */\nconst proxyRoutePatchSchema = lazy(() => type({\n id: 'string',\n host: 'string',\n enabled: 'boolean?',\n target: proxyTargetSchema.optional(),\n workspace: 'string?',\n server: 'string?',\n url: 'string?',\n path: 'string?',\n tls: proxyTlsModeSchema.optional(),\n dnsAccount: 'string?',\n upstreamSkipVerify: 'boolean?',\n}).onUndeclaredKey('reject'))\nexport type ProxyRoutePatch = typeof proxyRoutePatchSchema.infer\n\n/** No defaults; `routes` and `certificates` are replaced whole, since a merge cannot remove one. */\nexport const proxyPatchSchema = lazy(() => type({\n enabled: 'boolean?',\n engine: proxyEngineSchema.optional(),\n httpPort: '1 <= number.integer <= 65535?',\n httpsPort: '1 <= number.integer <= 65535?',\n email: 'string?',\n staging: 'boolean?',\n /** Merged key by key; an explicit `null` clears a key. */\n dns01: type({\n enabled: 'boolean | null?',\n resolvers: 'string[] | null?',\n }).onUndeclaredKey('reject').optional(),\n certificates: proxyCertificateSchema.array().optional(),\n routes: proxyRoutePatchSchema.array().optional(),\n}).onUndeclaredKey('reject'))\nexport type ProxyPatch = typeof proxyPatchSchema.infer\n\n/** `PUT /api/proxy/certificates/:id`: the pair itself, plus what to call it. */\nexport const proxyCertificateUploadSchema = lazy(() => type({\n label: 'string = \"\"',\n certificate: 'string >= 1',\n privateKey: 'string >= 1',\n}).onUndeclaredKey('reject'))\n\n/** `POST /api/proxy/engine`: which release to install; empty means the current one. */\nexport const proxyEngineInstallSchema = lazy(() => type({\n version: 'string = \"\"',\n}).onUndeclaredKey('reject'))\n","/**\n * The host's measurements, and the one place that decides a sample exists. `sampledAt === null` means\n * nothing was measured: the wire keeps zeros for older UIs, so absence is decided here.\n */\n\nexport const LOAD_ALERT_PER_CPU_DEFAULT = 2\n\nexport const HOST_ALERT_DEFAULTS = { diskUsedPercent: 90, memoryUsedPercent: 90, swapUsedPercent: 50, tempCelsius: 85 } as const\n\ninterface HostAlertThresholds {\n /** `0` disables the alert. */\n diskUsedPercentAlert?: number\n memoryUsedPercentAlert?: number\n swapUsedPercentAlert?: number\n tempCelsiusAlert?: number\n}\n\ninterface HostDiskReading {\n path: string\n totalBytes: number\n freeBytes: number\n usedPercent: number\n /** Against the configured `host.diskUsedPercent` alert, per path; `null` when nothing was measured. */\n band: HostBand\n}\n\nexport interface HostReadingSource extends HostAlertThresholds {\n sampledAt: number | null\n /** `false` once sampling is switched off: whatever the frame still carries is no longer current. */\n enabled?: boolean\n /** Readings this sample could not take (Windows load, a failed macOS read); each is absent. */\n unmeasured?: readonly string[]\n cpus: number\n loadAlertPerCpu?: number\n cpuUsedPercent?: number | null\n memoryUsedPercent: number\n swapUsedPercent: number\n loadAvg: number[]\n tempCelsius: number | null\n disks: Array<{ path: string, totalBytes: number, freeBytes: number, usedPercent: number }>\n}\n\nexport interface HostReadings {\n sampled: boolean\n /**\n * Readings the **platform** could not take (`load` on Windows): \"measured, no such number\", unlike\n * `sampled: false`. `[]` when everything was taken.\n */\n unmeasured: readonly string[]\n /** Unsampled, but the panel holds a sample it is not showing (sampling off, or stale): its stamp. */\n staleSince: number | null\n cpuUsedPercent: number | null\n memoryUsedPercent: number | null\n swapUsedPercent: number | null\n load1m: number | null\n load5m: number | null\n load15m: number | null\n /** The 1-minute load per core: a count of runnable tasks, never a percentage. */\n loadPerCpu: number | null\n tempCelsius: number | null\n disks: HostDiskReading[]\n /** `null` when nothing was measured, else the band against the configured alert. */\n loadBand: HostBand\n /** The same, each against the threshold the panel **notifies** on — never a literal. */\n memoryBand: HostBand\n swapBand: HostBand\n tempBand: HostBand\n}\n\n/** `null` when there is no reading to judge. */\nexport type HostBand = 'ok' | 'warn' | 'danger' | null\n\nconst NOTHING_SAMPLED: HostReadings = {\n sampled: false,\n unmeasured: [],\n staleSince: null,\n cpuUsedPercent: null,\n memoryUsedPercent: null,\n swapUsedPercent: null,\n load1m: null,\n load5m: null,\n load15m: null,\n loadPerCpu: null,\n tempCelsius: null,\n disks: [],\n loadBand: null,\n memoryBand: null,\n swapBand: null,\n tempBand: null,\n}\n\nfunction present(value: number | null | undefined): number | null {\n return typeof value === 'number' && Number.isFinite(value) ? value : null\n}\n\n/** The host CPU share has no configurable alert, so its band is one chosen pair. */\nconst HOST_CPU_BAND = { warnAt: 80, dangerAt: 95 } as const\n\nexport function hostCpuBand(percent: number | null): HostBand {\n if (percent === null || !Number.isFinite(percent))\n return null\n if (percent >= HOST_CPU_BAND.dangerAt)\n return 'danger'\n if (percent >= HOST_CPU_BAND.warnAt)\n return 'warn'\n return 'ok'\n}\n\n/** A temperature dial's full scale is the alert threshold; `0` (disabled) falls back to the default. */\nexport function tempScale(alertAt: number | undefined): number {\n return alertAt === undefined || !Number.isFinite(alertAt) || alertAt <= 0 ? HOST_ALERT_DEFAULTS.tempCelsius : alertAt\n}\n\n/** A share of `tempScale`, `null` when nothing was measured. */\nexport function tempDialPercent(temp: number | null | undefined, alertAt: number | undefined): number | null {\n const value = present(temp)\n if (value === null)\n return null\n return (value / tempScale(alertAt)) * 100\n}\n\n/** `danger` *at* the threshold, where the alert fires; `0` disables the alert, so the band is `ok`. */\nfunction thresholdBand(value: number | null, alertAt: number | undefined, fallback: number): HostBand {\n if (value === null || !Number.isFinite(value))\n return null\n // An older panel sends no threshold and alerted on the default.\n const threshold = alertAt === undefined || !Number.isFinite(alertAt) ? fallback : alertAt\n if (threshold <= 0)\n return 'ok'\n if (value >= threshold)\n return 'danger'\n if (value >= threshold * 0.7)\n return 'warn'\n return 'ok'\n}\n\n/** A missing frame is the same as an unsampled one. */\nexport function hostReadings(host: HostReadingSource | null | undefined): HostReadings {\n if (host === null || host === undefined)\n return NOTHING_SAMPLED\n // A frame kept after sampling was switched off is the last reading, not a current one.\n const sampled = host.sampledAt !== null && host.enabled !== false\n if (!sampled) {\n // Keep the stamp, so a surface can say \"last sampled 4m ago\" instead of waiting forever.\n return { ...NOTHING_SAMPLED, staleSince: host.sampledAt, disks: [] }\n }\n // A sampled zero is a reading (an idle box), unless the platform could not take it.\n const unmeasured = new Set(host.unmeasured ?? [])\n const measured = (name: string, value: number | null | undefined): number | null => unmeasured.has(name) ? null : present(value)\n const load1m = measured('load', host.loadAvg[0])\n const cpus = present(host.cpus)\n const loadPerCpu = load1m === null ? null : load1m / Math.max(1, cpus ?? 1)\n const memoryUsedPercent = measured('memory', host.memoryUsedPercent)\n const swapUsedPercent = measured('swap', host.swapUsedPercent)\n const tempCelsius = present(host.tempCelsius)\n return {\n sampled: true,\n // Only the three the wire names, so an unbanded future reading is not advertised.\n unmeasured: [...unmeasured].filter(name => ['load', 'memory', 'swap'].includes(name)),\n staleSince: null,\n cpuUsedPercent: present(host.cpuUsedPercent),\n memoryUsedPercent,\n swapUsedPercent,\n load1m,\n load5m: measured('load', host.loadAvg[1]),\n load15m: measured('load', host.loadAvg[2]),\n loadPerCpu,\n loadBand: thresholdBand(loadPerCpu, host.loadAlertPerCpu, LOAD_ALERT_PER_CPU_DEFAULT),\n memoryBand: thresholdBand(memoryUsedPercent, host.memoryUsedPercentAlert, HOST_ALERT_DEFAULTS.memoryUsedPercent),\n swapBand: thresholdBand(swapUsedPercent, host.swapUsedPercentAlert, HOST_ALERT_DEFAULTS.swapUsedPercent),\n tempBand: thresholdBand(tempCelsius, host.tempCelsiusAlert, HOST_ALERT_DEFAULTS.tempCelsius),\n tempCelsius,\n disks: host.disks.map(disk => ({\n ...disk,\n band: thresholdBand(present(disk.usedPercent), host.diskUsedPercentAlert, HOST_ALERT_DEFAULTS.diskUsedPercent),\n })),\n }\n}\n","import { type } from 'arktype'\nimport { lazy } from './lazy'\n\n/**\n * Query values parsed at the boundary: anything outside the accepted spellings or bounds is a\n * `400 INVALID_INPUT`, never a silent default. `yes`/`no`/`on`/`off` are refused deliberately.\n */\n\n/** A flag: `0`, `1`, `true` or `false`, parsed to a boolean. */\nexport const booleanParam = lazy(() => type('\"0\" | \"1\" | \"true\" | \"false\"').pipe(value => value === '1' || value === 'true'))\n\n/** A whole decimal integer within `min`–`max`, parsed to a number; out of bounds is refused, not clamped. */\nexport function integerParam(min: number, max: number) {\n return lazy(() => type('string.integer.parse').pipe(type(`${min} <= number <= ${max}`)))\n}\n","/** The SSE frames, and the `event:` names derived from them. */\nimport { type } from 'arktype'\nimport { appStateSchema, logLineSchema, serverViewSchema } from '../contracts'\nimport { lazy } from '../lazy'\n\n/** One SSE frame, discriminated by `type`; each is exported because the spec's `GET /api/events` names it in a `oneOf`. */\nexport const sseStateFrameSchema = lazy(() => type({\n type: '\"hello\" | \"state\"',\n ts: 'number',\n state: appStateSchema,\n}).onDeepUndeclaredKey('ignore'))\nexport const sseServerFrameSchema = lazy(() => type({\n 'type': '\"server\"',\n 'ts': 'number',\n 'workspaceId?': 'string',\n 'serverId': 'string',\n 'server': serverViewSchema,\n}).onDeepUndeclaredKey('ignore'))\nexport const sseLogFrameSchema = lazy(() => type({\n 'type': '\"log\"',\n 'ts': 'number',\n 'workspaceId?': 'string',\n 'serverId': 'string',\n 'lines': logLineSchema.array(),\n}).onDeepUndeclaredKey('ignore'))\n/** The keep-alive: proxies close a stream that stays silent for 30 s. */\nexport const ssePingFrameSchema = lazy(() => type({\n type: '\"ping\"',\n ts: 'number',\n}).onDeepUndeclaredKey('ignore'))\n/** Every `event:` name the streams send, derived from the frames; a cached function so import never builds the `lazy()` schemas. */\nlet sseEventNamesCache: string[] | null = null\nexport function sseEventNames(): string[] {\n if (sseEventNamesCache !== null)\n return sseEventNamesCache\n sseEventNamesCache = [\n ...new Set([sseStateFrameSchema, sseServerFrameSchema, sseLogFrameSchema, ssePingFrameSchema]\n .flatMap((schema) => {\n // A single literal renders as `const`, a union as `enum`; the frames use both.\n const type = (schema.toJsonSchema() as { properties?: { type?: { const?: string, enum?: string[] } } })\n .properties\n ?.type\n return type?.enum ?? (type?.const === undefined ? [] : [type.const])\n })),\n ].sort()\n return sseEventNamesCache\n}\n\nexport const sseMessageSchema = lazy(() => sseStateFrameSchema.or(sseServerFrameSchema).or(sseLogFrameSchema).or(ssePingFrameSchema))\nexport type SseMessage = typeof sseMessageSchema.infer\n","/** The log shapes: buffered lines, on-disk history, and what a page needs to explain an empty answer. */\nimport { type } from 'arktype'\nimport { logLineSchema, serverStatusSchema } from '../contracts'\nimport { lazy } from '../lazy'\nimport { integerParam } from '../query-params'\n\n/** `GET /api/servers/:id/logs` — the buffered lines, straight from memory: no window, no rotation. */\nexport const bufferedLogsResponseSchema = lazy(() => type({\n lines: logLineSchema.array(),\n}))\n\n/** One job's log; `enabled` is `logs.persist`, so a page can say \"nothing kept\" rather than \"nothing printed\". */\nexport const jobLogViewSchema = lazy(() => type({\n jobId: 'string',\n enabled: 'boolean',\n sizeBytes: 'number',\n files: 'string[]',\n lines: logLineSchema.array(),\n}))\nexport type JobLogView = typeof jobLogViewSchema.infer\n\nexport const logHistoryQuerySchema = lazy(() => type({\n /** Lines to show, 50–5000; outside the range is a `400`, not a clamp. */\n 'tail?': integerParam(50, 5000),\n /** Case-insensitive filter, applied (like `stream`) to a window wider than `tail`; `searched` reports how many lines were read. */\n 'search': 'string?',\n 'stream': '\"stdout\" | \"stderr\" | \"system\"?',\n /** Lines after this cursor (a line's `ts`); with neither `since` nor `before`, the tail. */\n 'since?': integerParam(0, 9_999_999_999_999),\n /** Return the lines **before** this cursor — the other direction, for backfill. */\n 'before?': integerParam(0, 9_999_999_999_999),\n}))\n\n/**\n * A position in a log, for `GET /api/logs/:id`. `<ts>:<n>` is one line's `cursor` — the `n`th line\n * logged in millisecond `ts` — so paging never skips a line that shares its millisecond. A bare `<ts>`\n * is the older spelling and stands for that whole millisecond.\n */\nexport interface LogCursor {\n ts: number\n /** `null` for a bare millisecond. */\n n: number | null\n}\n\nconst logCursorParam = lazy(() => type(/^\\d{1,13}(?::\\d{1,9})?$/).pipe((raw): LogCursor => {\n const [ts, n] = raw.split(':')\n return { ts: Number(ts), n: n === undefined ? null : Number(n) }\n}))\n\n/**\n * `GET /api/logs/:id`'s query. `after` and `before` are **log cursors**, not the `?since=<seq>` of the\n * event streams; `since` is kept as the older name for `after`.\n */\nexport const logPageQuerySchema = lazy(() => type({\n /** Lines to show, 50–5000; outside the range is a `400`, not a clamp. */\n 'tail?': integerParam(50, 5000),\n 'search': 'string?',\n 'stream': '\"stdout\" | \"stderr\" | \"system\"?',\n /** Lines after this cursor, oldest first. */\n 'after?': logCursorParam,\n /** The older name for `after`; send one or the other. */\n 'since?': logCursorParam,\n /** Lines before this cursor, newest last — the other direction, for backfill. */\n 'before?': logCursorParam,\n}))\n\nconst logFileInfoSchema = lazy(() => type({\n name: 'string',\n sizeBytes: 'number',\n}))\n\nconst logServerViewSchema = lazy(() => type({\n serverId: 'string',\n label: 'string',\n status: serverStatusSchema,\n enabled: 'boolean',\n sizeBytes: 'number',\n files: logFileInfoSchema.array(),\n}))\nexport type LogServerView = typeof logServerViewSchema.infer\n\nexport const logServersViewSchema = lazy(() => type({\n servers: logServerViewSchema.array(),\n}))\n\n/** One entry's log **from disk**, with its rotation and search window — the shape the UIs parse. */\nexport const logHistoryViewSchema = lazy(() => type({\n serverId: 'string',\n enabled: 'boolean',\n sizeBytes: 'number',\n files: type('string[]'),\n /** How many lines the search looked at, or null when not searching. */\n searched: 'number | null',\n lines: logLineSchema.array(),\n}))\nexport type LogHistoryView = typeof logHistoryViewSchema.infer\n\n/** The same answer under the name the route table used; one schema, so the two cannot drift. */\nexport const logLinesResponseSchema = logHistoryViewSchema\n","import { type } from 'arktype'\nimport { backupEntrySchema, backupFileSchema, backupsViewSchema } from './contracts/backups'\nimport { ddnsStatusSchema } from './contracts/ddns'\nimport { proxyViewSchema } from './contracts/proxy'\nimport { HOST_ALERT_DEFAULTS, LOAD_ALERT_PER_CPU_DEFAULT } from './host-readings'\n\nimport { lazy } from './lazy'\n\nimport { integerParam } from './query-params'\n\n/** Schemas shared by the control plane and the UIs: server entries, panel settings, API DTOs, SSE frames. */\n\n/** `local` -> 127.0.0.1, `lan` -> 0.0.0.0, or an explicit IPv4 to bind. */\nconst bindSchema = lazy(() => type('\"local\" | \"lan\" | /^\\\\d{1,3}(?:\\\\.\\\\d{1,3}){3}$/'))\nexport type Bind = typeof bindSchema.infer\n\n/** A workspace id is its directory under `.hh/` and never changes; the label may be renamed. */\nexport const workspaceIdSchema = lazy(() => type('/^[a-z0-9][a-z0-9_-]*$/'))\n/** A new workspace id: at most 40 chars, never a Windows device name. Separate so older, longer ids still load. */\nexport const newWorkspaceIdSchema = lazy(() => type(/^(?!(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$)[a-z0-9][a-z0-9_-]{0,39}$/)\n .describe('a lowercase id of at most 40 letters, digits, - or _, starting with a letter or digit, and not a Windows device name (con, prn, aux, nul, com1-9, lpt1-9)'))\nexport const workspaceSchema = lazy(() => type({\n id: workspaceIdSchema,\n label: '1 <= string <= 60',\n}).onUndeclaredKey('reject'))\nexport type Workspace = typeof workspaceSchema.infer\n\n/** `id` is optional; when omitted it is derived from the label. */\nexport const workspaceCreateSchema = lazy(() => type({\n 'id?': newWorkspaceIdSchema,\n 'label?': '1 <= string <= 60',\n}).onUndeclaredKey('reject'))\nexport type WorkspaceCreate = typeof workspaceCreateSchema.infer\n\nexport const workspaceRenameSchema = lazy(() => type({\n label: '1 <= string <= 60',\n}).onUndeclaredKey('reject'))\n\nexport function parseBind(value: string): Bind | null {\n const parsed = bindSchema(value)\n return parsed instanceof type.errors ? null : parsed\n}\n\n/** `null` means \"no port\": no readiness probe, no health supervision, no preflight. */\nexport const portSchema = lazy(() => type('1 <= number.integer <= 65535 | null'))\n\n/** `follow`/`reclaim` act only on this entry's own detached successor (POSIX); `kill` stops any holder outside the panel's tree. */\nexport const onPortConflictSchema = lazy(() => type.enumerated('block', 'warn', 'follow', 'reclaim', 'kill'))\nexport type OnPortConflict = typeof onPortConflictSchema.infer\n\nexport const restartSchema = lazy(() => type({\n enabled: 'boolean = true',\n maxRetries: 'number.integer >= 0 = 3',\n baseDelayMs: 'number >= 0 = 1000',\n factor: 'number >= 1 = 2',\n maxDelayMs: 'number >= 0 = 30000',\n /** A process alive this long is considered healthy again and the retry counter resets. */\n resetAfterMs: 'number >= 0 = 60000',\n}).onUndeclaredKey('reject'))\n\nexport type RestartConfig = typeof restartSchema.infer\n\nconst httpCheckSchema = lazy(() => type({\n /** `https` is for a backend that serves TLS itself; pair it with `allowInvalidCert` when it is self-signed. */\n scheme: '\"http\" | \"https\" = \"http\"',\n /** Accept any certificate: self-signed is the normal case, and the probe is local. */\n allowInvalidCert: 'boolean = false',\n path: 'string = \"/\"',\n method: '\"GET\" | \"HEAD\" = \"GET\"',\n /** Exact status to accept; `null` or omitted means any status below `expectStatusBelow`. */\n expectStatus: '100 <= number.integer <= 599 | null?',\n expectStatusBelow: '101 <= number.integer <= 600 = 400',\n expectBody: 'string = \"\"',\n}).onUndeclaredKey('reject'))\nexport type HttpCheckConfig = typeof httpCheckSchema.infer\n\nconst resourcesSchema = lazy(() => type({\n /** Restart when the tree's RSS exceeds this; 0 disables. */\n maxRssBytes: 'number.integer >= 0 = 0',\n}).onUndeclaredKey('reject'))\n\nexport const healthSchema = lazy(() => type({\n enabled: 'boolean = true',\n /** `port` = TCP connect only; `http` = fetch `http.path` and assert the response. */\n mode: '\"port\" | \"http\" = \"port\"',\n http: httpCheckSchema.default(() => ({})),\n intervalMs: 'number >= 500 = 5000',\n timeoutMs: 'number >= 100 = 1500',\n /** Consecutive failed probes before the warning state is shown. */\n unhealthyThreshold: 'number.integer >= 1 = 3',\n /** 0 disables it; otherwise a port stuck unhealthy this long forces a restart. */\n forceRestartAfterMs: 'number >= 0 = 0',\n startTimeoutMs: 'number >= 0 = 20000',\n}).onUndeclaredKey('reject'))\n\nexport type HealthConfig = typeof healthSchema.infer\n\nexport const stopSchema = lazy(() => type({\n signal: '\"SIGTERM\" | \"SIGINT\" | \"SIGKILL\" = \"SIGTERM\"',\n killGroup: 'boolean = true',\n graceMs: 'number >= 0 = 5000',\n /** Last resort for wrappers that detach their real server. */\n killPortHolders: 'boolean = false',\n}).onUndeclaredKey('reject'))\n\nexport type StopConfig = typeof stopSchema.infer\n\n/** One deploy step. `cwd` resolves against the entry's own working directory; absent means that directory. */\nconst deployStepSchema = lazy(() => type({\n 'command': 'string >= 1',\n 'args': type('string[]').default(() => []),\n 'cwd?': 'string',\n 'timeoutMs': 'number >= 1000 = 300000',\n}).onUndeclaredKey('reject'))\n\n/** Ordered steps, then a restart. A failed step stops the deploy and keeps the old process running. */\nconst deploySchema = lazy(() => type({\n steps: deployStepSchema.array().atLeastLength(1),\n restart: 'boolean = true',\n}).onUndeclaredKey('reject'))\n\n/** Patch form of `deploy`: no defaults, because the group is replaced whole and a default would re-arm an untouched deploy. */\nconst deployStepPatchSchema = lazy(() => type({\n 'command': 'string >= 1?',\n 'args': 'string[]?',\n 'cwd?': 'string',\n 'timeoutMs': 'number >= 1000?',\n}).onUndeclaredKey('reject'))\nconst deployPatchSchema = lazy(() => type({\n 'steps?': deployStepPatchSchema.array(),\n 'restart?': 'boolean',\n}).onUndeclaredKey('reject'))\nconst deployOrNullSchema = lazy(() => deploySchema.or(type('null')))\nconst deployPatchOrNullSchema = lazy(() => deployPatchSchema.or(type('null')))\n\nconst deployStatusSchema = lazy(() => type({\n 'running': 'boolean',\n 'lastAt?': 'number',\n 'lastOutcome?': '\"ok\" | \"failed\"',\n 'lastError?': 'string',\n}))\n\nconst bootstrapSchema = lazy(() => type({\n command: 'string',\n args: type('string[]').default(() => []),\n env: type('Record<string, string>').default(() => ({})),\n timeoutMs: 'number >= 1000 = 120000',\n /** Run once per `up` session; whatever it installs persists on disk. */\n runOnce: 'boolean = true',\n}).onUndeclaredKey('reject'))\nexport const bootstrapOrNullSchema = lazy(() => bootstrapSchema.or(type('null')))\n\n/** Patch form of `bootstrap`: no defaults, because the group is replaced whole (not in `SERVER_MERGE_KEYS`). */\nconst bootstrapPatchSchema = lazy(() => type({\n command: 'string >= 1?',\n args: 'string[]?',\n env: 'Record<string, string>?',\n timeoutMs: 'number >= 1000?',\n runOnce: 'boolean?',\n}).onUndeclaredKey('reject'))\nconst bootstrapPatchOrNullSchema = lazy(() => bootstrapPatchSchema.or(type('null')))\n\n/**\n * A command run around a backup, for engines that need it for a consistent copy (e.g. `mongodump`).\n * `{dumpDir}` is created before `dump` and refilled before `load`, so both hooks see one path.\n */\nconst backupHookSchema = lazy(() => type({\n // Non-empty: a `dump` hook that cannot start would refuse every backup.\n command: 'string >= 1',\n args: type('string[]').default(() => []),\n env: type('Record<string, string>').default(() => ({})),\n timeoutMs: 'number >= 1000 = 600000',\n /** `load` only, for an entry with no `port`: how long to wait for it to answer first. */\n waitMs: 'number >= 0 = 2000',\n}).onUndeclaredKey('reject'))\nconst backupHookOrNullSchema = lazy(() => backupHookSchema.or(type('null')))\n\n/** Patch form of `dump`/`load`: no defaults, because both hooks are replaced whole. */\nconst backupHookPatchSchema = lazy(() => type({\n command: 'string >= 1?',\n args: 'string[]?',\n env: 'Record<string, string>?',\n timeoutMs: 'number >= 1000?',\n waitMs: 'number >= 0?',\n}).onUndeclaredKey('reject'))\nconst backupHookPatchOrNullSchema = lazy(() => backupHookPatchSchema.or(type('null')))\n\nexport type BackupHookConfig = typeof backupHookSchema.infer\n\n/** `null` means no label; displays fall back with `label ?? id`. */\nconst labelOrNullSchema = lazy(() => type('string | null'))\n\nexport const logBufferLinesSchema = lazy(() => type('50 <= number.integer <= 100000'))\n\n/** An environment-variable name every shell and OS accepts. */\nexport const secretEnvNameSchema = lazy(() => type('/^[A-Za-z_][A-Za-z0-9_]*$/')\n .describe('an environment-variable name: a letter or underscore, then letters, digits or underscores'))\n\n/** Secret env var names, unique; the values live in the workspace's `.secrets.json`, never in a config. */\nexport const secretEnvNamesSchema = lazy(() => type(secretEnvNameSchema.array()))\n\n/** Uniqueness is checked here, not by a schema narrow, so the schema still renders to JSON Schema. */\nexport function duplicateSecretEnvNames(names: readonly string[]): string[] {\n const seen = new Set<string>()\n const duplicates = new Set<string>()\n for (const name of names) {\n if (seen.has(name))\n duplicates.add(name)\n seen.add(name)\n }\n return [...duplicates]\n}\n\n/** Only the shape (exactly five fields); `cronProblem()` checks the contents at every write. */\nexport const cronExpressionSchema = lazy(() => type(/^\\S+(?: +\\S+){4}$/)\n .describe('a 5-field cron expression (minute hour day-of-month month day-of-week); no seconds field, no @macros'))\n\n/** The refusal for a servers entry that still carries a job field (`kind`/`schedule`); `null` when it carries neither. */\nexport function entryHasJobFields(entry: Record<string, unknown>, command?: string): string | null {\n const hasKind = typeof entry.kind === 'string'\n const hasSchedule = typeof entry.schedule === 'string'\n if (!hasKind && !hasSchedule)\n return null\n // The caller supplies the command: `src/shared` cannot call `invocation()`, which carries `--home`.\n const migrate = command === undefined ? 'the migrate command' : `\\`${command} migrate\\``\n if (entry.kind === 'job') {\n return `this entry is a \\`job\\`, which now lives in jobs.config.json — run ${migrate} to move it, then remove \\`kind\\`/\\`schedule\\` here`\n }\n return `\\`kind\\` and \\`schedule\\` belong to a job now, not a server — remove them (a server is always a supervised service), or run ${migrate} if this entry is a job`\n}\n\n/** The longest one run may take: a day. Bounds a hung script, not a slow backup. */\nexport const JOB_TIMEOUT_MAX_SECONDS = 86_400\n\n/** A short-lived command on a cron schedule; it has no `port`, `health`, `restart` or `persistent`. */\nexport const jobSchema = lazy(() => type({\n 'id': '/^[a-z0-9][a-z0-9_-]*$/',\n 'label?': labelOrNullSchema,\n 'description?': 'string',\n 'enabled': 'boolean = true',\n 'command': 'string >= 1',\n 'args': type('string[]').default(() => []),\n 'cwd': 'string = \".\"',\n 'env': type('Record<string, string>').default(() => ({})),\n 'secretEnv': secretEnvNamesSchema.default(() => []),\n /** 5-field cron expression, in the host's local timezone. */\n 'schedule': cronExpressionSchema,\n /** How long one run may take before the panel ends it, in seconds. */\n 'timeoutSeconds': type('1 <= number.integer <= 86400').default(3600),\n /** Run a missed occurrence once when the panel starts (the most recent one only). */\n 'catchUp': 'boolean = true',\n}).onUndeclaredKey('reject'))\nexport type JobConfig = typeof jobSchema.infer\n\n/** A workspace's jobs file; `jobs: []` is the normal state of a workspace with no jobs. */\nexport const jobsFileSchema = lazy(() => type({\n 'meta?': type({\n 'writtenBy?': 'string',\n 'schema?': 'number',\n }),\n 'jobs': jobSchema.array(),\n}).onUndeclaredKey('reject'))\n\n/** What started a run: its schedule, a person or client, or the boot catch-up of a missed occurrence. */\nexport const jobTriggerSchema = lazy(() => type('\"schedule\" | \"manual\" | \"catch-up\"'))\nexport type JobTrigger = typeof jobTriggerSchema.infer\n\n/**\n * How a run ended. `timeout` is the panel ending it at `timeoutSeconds`, `cancelled` a stop,\n * `spawn-error` a command that never started, `interrupted` a run the panel stopped watching because\n * it exited mid-run. `running` only on the run in flight.\n */\nexport const jobOutcomeSchema = lazy(() => type('\"running\" | \"ok\" | \"failed\" | \"timeout\" | \"cancelled\" | \"spawn-error\" | \"interrupted\"'))\nexport type JobOutcome = typeof jobOutcomeSchema.infer\n\n/** One run, as the job's durable run ledger keeps it. */\nexport const jobRunSchema = lazy(() => type({\n 'runId': 'string',\n 'trigger': jobTriggerSchema,\n /** The occurrence a scheduled or catch-up run was for, epoch ms. */\n 'scheduledFor?': 'number',\n 'startedAt': 'number',\n 'endedAt': 'number | null',\n 'outcome': jobOutcomeSchema,\n 'exitCode': 'number | null',\n 'signal': 'string | null',\n /** Why a `spawn-error` run never started. */\n 'error?': 'string',\n}).onDeepUndeclaredKey('ignore'))\nexport type JobRun = typeof jobRunSchema.infer\n\nexport const jobEntryViewSchema = lazy(() => type({\n 'id': 'string',\n 'label?': 'string',\n 'description?': 'string',\n 'enabled': 'boolean',\n 'command': 'string',\n 'args': 'string[]',\n 'schedule': 'string',\n /** The next time this will run, epoch ms — `null` when disabled, broken, or the expression cannot occur. */\n 'nextRunAt?': 'number | null',\n 'running': 'boolean',\n /** The run in flight. */\n 'current?': type({ runId: 'string', startedAt: 'number', trigger: jobTriggerSchema }).onUndeclaredKey('ignore'),\n /** The latest finished run. */\n 'last?': type({\n runId: 'string',\n outcome: jobOutcomeSchema,\n exitCode: 'number | null',\n signal: 'string | null',\n startedAt: 'number',\n endedAt: 'number',\n durationMs: 'number',\n }).onUndeclaredKey('ignore'),\n /** Why this entry of the jobs file cannot run; the rest of the file still does. */\n 'problem?': 'string',\n /** For older clients: the same facts as `last.endedAt` and `last.exitCode`. */\n 'lastRunAt?': 'number',\n 'lastExitCode?': 'number | null',\n /** The job's JSONL log in the workspace's `jobs/` log directory. */\n 'logPath?': 'string',\n /** Declared secret env names; `secretEnvSet` says which have a stored value. Values never travel. */\n 'secretEnv?': 'string[]',\n 'secretEnvSet?': 'string[]',\n 'timeoutSeconds?': 'number',\n 'catchUp?': 'boolean',\n 'cwd?': 'string',\n 'env?': 'Record<string, string>',\n}).onDeepUndeclaredKey('ignore'))\nexport type JobEntryView = typeof jobEntryViewSchema.infer\n\nexport const jobsListSchema = lazy(() => type({\n 'jobs': jobEntryViewSchema.array(),\n /** Why the jobs file as a whole cannot be read; none of its jobs run until it is fixed. */\n 'fileError?': 'string',\n}).onDeepUndeclaredKey('ignore'))\nexport type JobsList = typeof jobsListSchema.infer\n\n/** Creating a job. Everything the schema defaults is omittable; the schedule is not. */\nexport const jobCreateSchema = lazy(() => type({\n 'id': '/^[a-z0-9][a-z0-9_-]*$/',\n 'label?': labelOrNullSchema,\n 'description?': 'string',\n 'enabled?': 'boolean',\n 'command': 'string >= 1',\n 'args?': 'string[]',\n 'cwd?': 'string',\n 'env?': 'Record<string, string>',\n 'secretEnv?': 'string[]',\n 'schedule': cronExpressionSchema,\n 'timeoutSeconds?': '1 <= number.integer <= 86400',\n 'catchUp?': 'boolean',\n}).onUndeclaredKey('reject'))\nexport type JobCreate = typeof jobCreateSchema.infer\n\n/** Hand-written, never `.partial()`: a derived patch would carry the defaults. `null` clears a label or description. */\nexport const jobPatchSchema = lazy(() => type({\n 'label?': labelOrNullSchema.or(type('null')),\n 'description?': 'string | null',\n 'enabled?': 'boolean',\n 'command?': 'string >= 1',\n 'args?': 'string[]',\n 'cwd?': 'string',\n 'env?': 'Record<string, string>',\n 'secretEnv?': 'string[]',\n 'schedule?': cronExpressionSchema,\n 'timeoutSeconds?': '1 <= number.integer <= 86400',\n 'catchUp?': 'boolean',\n}).onUndeclaredKey('reject'))\nexport type JobPatch = typeof jobPatchSchema.infer\n\n/** `POST /api/jobs/:id/run`: the run started (`202`), or, waited for, how it ended (`200`). */\nexport const jobRunStartedSchema = lazy(() => type({\n 'runId': 'string',\n /** Present once the run has ended. */\n 'run?': jobRunSchema,\n}).onDeepUndeclaredKey('ignore'))\nexport type JobRunStarted = typeof jobRunStartedSchema.infer\n\nexport const jobRunsListSchema = lazy(() => type({ runs: jobRunSchema.array() }).onDeepUndeclaredKey('ignore'))\n\nexport const serverSchema = lazy(() => type({\n id: '/^[a-z0-9][a-z0-9_-]*$/',\n label: labelOrNullSchema.optional(),\n enabled: 'boolean = true',\n autostart: 'boolean = false',\n /** Owned by a nanny process, so it survives the panel stopping; only an explicit stop or restart ends it. */\n persistent: 'boolean = false',\n command: 'string >= 1',\n args: type('string[]').default(() => []),\n cwd: 'string = \".\"',\n env: type('Record<string, string>').default(() => ({})),\n /** `ENV=path` pairs: exported to the process (overriding `env`) and backed up automatically. */\n dataEnvs: type('Record<string, string>').default(() => ({})),\n bootstrap: bootstrapOrNullSchema.optional(),\n /** Absent means no deploy action (`POST /api/servers/:id/deploy` answers `400 NO_DEPLOY`). */\n deploy: deployOrNullSchema.optional(),\n /** Run before this entry's data is captured, writing into `{dumpDir}`; a failed dump refuses the backup. */\n dump: backupHookOrNullSchema.optional(),\n /** Run after this entry's data is restored, reading from `{dumpDir}`. Its server is stopped first. */\n load: backupHookOrNullSchema.optional(),\n port: portSchema.optional(),\n bind: bindSchema.default(() => 'local' as const),\n // The stored forms carry the default; a patch must not (see the patch schemas below).\n onPortConflict: onPortConflictSchema.default('block'),\n restart: restartSchema.default(() => ({})),\n health: healthSchema.default(() => ({})),\n stop: stopSchema.default(() => ({})),\n logBufferLines: logBufferLinesSchema.default(() => 500),\n /** Ids this server needs running first (and healthy); `stop-all` stops dependents before it. */\n dependsOn: type('string[]').default(() => []),\n /** Optional KEY=value file loaded at spawn; its values override `env`. */\n envFile: 'string = \"\"',\n resources: resourcesSchema.default(() => ({})),\n backupPaths: type('string[]').default(() => []),\n /** Skip build output and dependency directories (`node_modules`, `dist`, caches, …) inside declared paths. */\n backupIgnoreGenerated: 'boolean = true',\n secretEnv: secretEnvNamesSchema.default(() => []),\n}).onUndeclaredKey('reject'))\nexport type ServerConfig = Omit<typeof serverSchema.infer, 'port'> & { port: number | null }\n\n/** Panel authentication policy; the password's scrypt hash lives in the secrets file, never here. */\nexport const authSchema = lazy(() => type({\n enabled: 'boolean = true',\n /** Idle timeout: a session dies this long after its **last** request, not after login. */\n sessionTtlMs: 'number >= 60000 = 604800000',\n /** `auto` adds `Secure` when the request arrived over https (proxy-aware). */\n cookieSecure: '\"auto\" | \"always\" | \"never\" = \"auto\"',\n /** Trust `x-forwarded-*` from a reverse proxy; also drives the client IP. */\n trustProxy: 'boolean | \"loopback\" = \"loopback\"',\n maxLoginAttempts: 'number.integer >= 1 = 5',\n lockoutMs: 'number >= 1000 = 60000',\n}).onUndeclaredKey('reject'))\nexport type AuthConfig = typeof authSchema.infer\n\n/** Event toggles and throttle a target may inherit; `enabled` is the target's own and never inherited. */\nconst notificationPolicyShape = {\n onCrash: 'boolean = true',\n onUnhealthy: 'boolean = true',\n onForcedRestart: 'boolean = true',\n onRecovered: 'boolean = false',\n /** Host vitals breaches (disk, memory, swap, load, temperature). */\n onHost: 'boolean = true',\n onDdns: 'boolean = true',\n /** Per server *and* reason, so a flapping server cannot spam the chat. */\n cooldownMs: 'number >= 0 = 120000',\n} as const\n\nexport const notificationDefaultsSchema = lazy(() => type({\n ...notificationPolicyShape,\n}).onUndeclaredKey('reject'))\nexport type NotificationDefaults = typeof notificationDefaultsSchema.infer\n\n/** The same block as a response: tolerates keys this release does not know. */\nconst notificationDefaultsViewSchema = lazy(() => type({\n ...notificationPolicyShape,\n}))\n\n/** Defaults to `true` so a config written before inheritance existed keeps its own toggles. */\nconst useOwnSettingsSchema = 'boolean = true'\n\n/** One Telegram destination; its bot token is a secret keyed by `id` in the workspace's `.secrets.json`. */\nconst telegramDestinationSchema = lazy(() => type({\n kind: '\"telegram\"',\n id: '/^[a-z0-9][a-z0-9_-]*$/',\n /** Off until configured: a bare `enabled: true` with no chat would fail every send. */\n enabled: 'boolean = false',\n chatId: 'string = \"\"',\n useOwnSettings: useOwnSettingsSchema,\n ...notificationPolicyShape,\n // Rejecting other keys keeps a plaintext `botToken` out of the config file.\n}).onUndeclaredKey('reject'))\n\n/** One webhook destination; `headers` lets it serve ntfy, bearer-token or JSON receivers alike. */\nconst webhookTargetSchema = lazy(() => type({\n kind: '\"webhook\"',\n id: '/^[a-z0-9][a-z0-9_-]*$/',\n /** Empty only while the target is a draft; the page will not save one without it. */\n url: 'string = \"\"',\n enabled: 'boolean = true',\n method: '\"POST\" | \"PUT\" = \"POST\"',\n /** Payload format: `json` sends the event as JSON, `text` sends the plain message. */\n format: '\"json\" | \"text\" = \"json\"',\n /** Extra headers, `Name: value` per line. */\n headers: 'string = \"\"',\n useOwnSettings: useOwnSettingsSchema,\n ...notificationPolicyShape,\n}).onUndeclaredKey('reject'))\nexport type WebhookTarget = typeof webhookTargetSchema.infer\n\nconst notificationTargetSchema = lazy(() => telegramDestinationSchema.or(webhookTargetSchema))\nexport type NotificationTarget = typeof notificationTargetSchema.infer\n\n/** `id` must be unique across kinds (it keys cooldowns, results and tokens); `duplicateWebhookIds` enforces it at write. */\nconst destinationListSchema = lazy(() => notificationTargetSchema.array())\n\nexport const notificationsSchema = lazy(() => type({\n defaults: notificationDefaultsSchema.default(() => ({})),\n /** Replaced by a patch, the same way `ddns.accounts` is: a merge cannot express removing one. */\n destinations: destinationListSchema.default(() => []),\n}).onUndeclaredKey('reject'))\n\n/** Ids that appear more than once, so a write can refuse them (a schema narrow would break JSON Schema). */\nexport function duplicateWebhookIds(targets: ReadonlyArray<{ id: string }>): string[] {\n const seen = new Set<string>()\n const duplicates = new Set<string>()\n for (const target of targets) {\n if (seen.has(target.id))\n duplicates.add(target.id)\n seen.add(target.id)\n }\n return [...duplicates]\n}\nexport type NotificationsConfig = typeof notificationsSchema.infer\n\nexport const logsSchema = lazy(() => type({\n persist: 'boolean = true',\n /** Per server, before rotating to `.1`, `.2`, ... */\n maxBytes: '10000 <= number <= 100000000 = 2000000',\n keep: '1 <= number.integer <= 10 = 3',\n}).onUndeclaredKey('reject'))\nexport type LogsConfig = typeof logsSchema.infer\n\nexport const tlsSchema = lazy(() => type({\n enabled: 'boolean = false',\n}).onUndeclaredKey('reject'))\n\nexport const hostSchema = lazy(() => type({\n enabled: 'boolean = true',\n intervalMs: 'number >= 5000 = 15000',\n /** Filesystems reported and alerted on; templates and `~` are expanded. */\n diskPaths: type('string[]').default(() => ['.']),\n /** 0 disables an individual alert. Defaults come from `HOST_ALERT_DEFAULTS`, the one home for them. */\n diskUsedPercent: `number >= 0 = ${HOST_ALERT_DEFAULTS.diskUsedPercent}`,\n memoryUsedPercent: `number >= 0 = ${HOST_ALERT_DEFAULTS.memoryUsedPercent}`,\n swapUsedPercent: `number >= 0 = ${HOST_ALERT_DEFAULTS.swapUsedPercent}`,\n /** Per-cpu load to notify on; the frame's `loadAlertPerCpu` carries it. */\n loadPerCpu: type('number >= 0').default(LOAD_ALERT_PER_CPU_DEFAULT),\n tempCelsius: `number >= 0 = ${HOST_ALERT_DEFAULTS.tempCelsius}`,\n /** A command printing the CPU temperature in °C, for when the kernel exposes no sensor; empty uses the built-in probe. */\n tempCommand: 'string <= 512 = \"\"',\n /** How long that command may run before it is killed, so a hung helper cannot stall a sample. */\n tempCommandTimeoutMs: '100 <= number <= 30000 = 5000',\n}).onUndeclaredKey('reject'))\nexport type HostConfig = typeof hostSchema.infer\n\n/**\n * What an automatic backup captures: `only` is `--include`, `except` is `--all --exclude`, and a\n * coarse id covers every leaf under it. An empty `ids` is refused as ambiguous.\n */\nconst backupScopeSchema = lazy(() => type({\n mode: '\"only\" | \"except\"',\n ids: type('string >= 1').array().atLeastLength(1),\n}).onUndeclaredKey('reject'))\nexport type BackupScope = typeof backupScopeSchema.infer\n\nexport const backupScheduleSchema = lazy(() => type({\n /** 0 turns the schedule off; otherwise the gap between automatic archives. */\n intervalMs: 'number.integer >= 0 = 0',\n /** How many automatic archives to keep. Manual ones are never pruned by it. */\n keep: 'number.integer >= 1 = 7',\n /** Absent means the whole default scope; not defaulted, so an untouched file stays distinguishable. */\n scope: backupScopeSchema.optional(),\n}).onUndeclaredKey('reject'))\nexport type BackupScheduleConfig = typeof backupScheduleSchema.infer\n\nexport const backupsSchema = lazy(() => type({\n enabled: 'boolean = true',\n dir: 'string = \".backups\"',\n /** How many archives to keep in total, newest first. */\n keep: 'number.integer >= 1 = 5',\n includePaths: type('string[]').default(() => []),\n schedule: backupScheduleSchema.default(() => ({})),\n}).onUndeclaredKey('reject'))\nexport type BackupsConfig = typeof backupsSchema.infer\n\nconst allowedHostsSchema = lazy(() => type(/^(?:\\*\\.)?[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i).array().atMostLength(64))\n\nexport const controlSchema = lazy(() => type({\n label: '1 <= string <= 60 = \"home-hosted\"',\n port: '1 <= number.integer <= 65535 = 3999',\n /** Where the control panel itself listens; keep it `local` unless you mean it. */\n host: bindSchema.default(() => 'local' as const),\n openBrowser: 'boolean = false',\n /** Public hostnames besides IPs, local names and proxy routes; `*.example.com` matches subdomains. */\n allowedHosts: allowedHostsSchema.default(() => []),\n auth: authSchema.default(() => ({})),\n tls: tlsSchema.default(() => ({})),\n}).onUndeclaredKey('reject'))\nexport type ControlConfig = typeof controlSchema.infer\n\n/** Applied to every server entry; whatever an entry sets wins. */\nexport const defaultsSchema = lazy(() => type({\n enabled: 'boolean = true',\n autostart: 'boolean = false',\n bind: bindSchema.default(() => 'local' as const),\n // The stored forms carry the default; a patch must not (see the patch schemas below).\n onPortConflict: onPortConflictSchema.default('block'),\n restart: restartSchema.default(() => ({})),\n health: healthSchema.default(() => ({})),\n stop: stopSchema.default(() => ({})),\n logBufferLines: logBufferLinesSchema.default(() => 500),\n}).onUndeclaredKey('reject'))\nexport type ServerDefaults = typeof defaultsSchema.infer\n\n// Patch variants stay default-free: a partial nested group must not pull in the code defaults.\nconst restartPatchSchema = lazy(() => type({\n enabled: 'boolean?',\n maxRetries: 'number.integer >= 0?',\n baseDelayMs: 'number >= 0?',\n factor: 'number >= 1?',\n maxDelayMs: 'number >= 0?',\n resetAfterMs: 'number >= 0?',\n}).onUndeclaredKey('reject'))\n\nconst httpCheckPatchSchema = lazy(() => type({\n scheme: '\"http\" | \"https\"?',\n allowInvalidCert: 'boolean?',\n path: 'string?',\n method: '\"GET\" | \"HEAD\"?',\n expectStatus: 'number.integer | null?',\n expectStatusBelow: 'number.integer?',\n expectBody: 'string?',\n}).onUndeclaredKey('reject'))\n\nconst resourcesPatchSchema = lazy(() => type({\n maxRssBytes: 'number.integer >= 0?',\n}).onUndeclaredKey('reject'))\n\nconst healthPatchSchema = lazy(() => type({\n enabled: 'boolean?',\n mode: '\"port\" | \"http\"?',\n http: httpCheckPatchSchema.optional(),\n intervalMs: 'number >= 500?',\n timeoutMs: 'number >= 100?',\n unhealthyThreshold: 'number.integer >= 1?',\n forceRestartAfterMs: 'number >= 0?',\n startTimeoutMs: 'number >= 0?',\n}).onUndeclaredKey('reject'))\n\nconst stopPatchSchema = lazy(() => type({\n signal: '\"SIGTERM\" | \"SIGINT\" | \"SIGKILL\"?',\n killGroup: 'boolean?',\n graceMs: 'number >= 0?',\n killPortHolders: 'boolean?',\n}).onUndeclaredKey('reject'))\n\nconst authPatchSchema = lazy(() => type({\n enabled: 'boolean?',\n sessionTtlMs: 'number >= 60000?',\n cookieSecure: '\"auto\" | \"always\" | \"never\"?',\n trustProxy: 'boolean | \"loopback\"?',\n maxLoginAttempts: 'number.integer >= 1?',\n lockoutMs: 'number >= 1000?',\n}).onUndeclaredKey('reject'))\n\nconst notificationPolicyPatchShape = {\n onCrash: 'boolean?',\n onUnhealthy: 'boolean?',\n onForcedRestart: 'boolean?',\n onRecovered: 'boolean?',\n onHost: 'boolean?',\n onDdns: 'boolean?',\n cooldownMs: 'number >= 0?',\n} as const\n\n/** `kind` is required: a patch cannot change a destination's kind (that would drop its credential). */\nconst destinationPatchSchema = lazy(() => type({\n kind: '\"telegram\" | \"webhook\"',\n id: '/^[a-z0-9][a-z0-9_-]*$/',\n enabled: 'boolean?',\n useOwnSettings: 'boolean?',\n /** Telegram only. */\n chatId: 'string?',\n /** Webhook only. */\n url: 'string?',\n method: '\"POST\" | \"PUT\"?',\n format: '\"json\" | \"text\"?',\n headers: 'string?',\n ...notificationPolicyPatchShape,\n}).onUndeclaredKey('reject'))\n\nconst notificationsPatchSchema = lazy(() => type({\n /** Merged key by key; no defaults, so one toggle does not overwrite the rest. */\n defaults: type({ ...notificationPolicyPatchShape }).onUndeclaredKey('reject').optional(),\n /** Replaced whole, so a removed destination stays removed. */\n destinations: destinationPatchSchema.array().optional(),\n}).onUndeclaredKey('reject'))\n\nconst hostPatchSchema = lazy(() => type({\n enabled: 'boolean?',\n intervalMs: 'number >= 5000?',\n diskPaths: type('string[]').optional(),\n diskUsedPercent: 'number >= 0?',\n memoryUsedPercent: 'number >= 0?',\n swapUsedPercent: 'number >= 0?',\n loadPerCpu: 'number >= 0?',\n tempCelsius: 'number >= 0?',\n tempCommand: 'string <= 512?',\n tempCommandTimeoutMs: '100 <= number <= 30000?',\n}).onUndeclaredKey('reject'))\n\nconst backupSchedulePatchSchema = lazy(() => type({\n intervalMs: 'number.integer >= 0?',\n keep: 'number.integer >= 1?',\n /** `null` clears it back to the full default scope; omitted leaves it as it is. */\n scope: backupScopeSchema.or(type('null')).optional(),\n}).onUndeclaredKey('reject'))\n\nconst backupsPatchSchema = lazy(() => type({\n enabled: 'boolean?',\n dir: 'string?',\n keep: 'number.integer >= 1?',\n includePaths: type('string[]').optional(),\n schedule: backupSchedulePatchSchema.optional(),\n}).onUndeclaredKey('reject'))\n\nconst logsPatchSchema = lazy(() => type({\n persist: 'boolean?',\n maxBytes: '10000 <= number <= 100000000?',\n keep: '1 <= number.integer <= 10?',\n}).onUndeclaredKey('reject'))\n\nconst tlsPatchSchema = lazy(() => type({\n enabled: 'boolean?',\n}).onUndeclaredKey('reject'))\n\nconst controlPatchSchema = lazy(() => type({\n label: '1 <= string <= 60 | null?',\n port: '1 <= number.integer <= 65535?',\n host: bindSchema.optional(),\n openBrowser: 'boolean?',\n allowedHosts: allowedHostsSchema.optional(),\n auth: authPatchSchema.optional(),\n tls: tlsPatchSchema.optional(),\n}).onUndeclaredKey('reject'))\n\nconst defaultsPatchSchema = lazy(() => type({\n enabled: 'boolean?',\n autostart: 'boolean?',\n bind: bindSchema.optional(),\n onPortConflict: onPortConflictSchema.optional(),\n restart: restartPatchSchema.optional(),\n health: healthPatchSchema.optional(),\n stop: stopPatchSchema.optional(),\n logBufferLines: logBufferLinesSchema.optional(),\n}).onUndeclaredKey('reject'))\n\n/** A function, so the schemas it names are built only when a patch schema is. */\nfunction editableFields() {\n return {\n /** `null` clears it, the spelling `serverSchema` accepts and `label ?? id` needs. */\n label: labelOrNullSchema.optional(),\n enabled: 'boolean?',\n autostart: 'boolean?',\n persistent: 'boolean?',\n command: 'string?',\n args: 'string[]?',\n cwd: 'string?',\n env: 'Record<string, string>?',\n dataEnvs: 'Record<string, string>?',\n bootstrap: bootstrapPatchOrNullSchema.optional(),\n deploy: deployPatchOrNullSchema.optional(),\n dump: backupHookPatchOrNullSchema.optional(),\n load: backupHookPatchOrNullSchema.optional(),\n port: portSchema.optional(),\n bind: bindSchema.optional(),\n onPortConflict: onPortConflictSchema.optional(),\n restart: restartPatchSchema.optional(),\n health: healthPatchSchema.optional(),\n stop: stopPatchSchema.optional(),\n logBufferLines: logBufferLinesSchema.optional(),\n dependsOn: type('string[]').optional(),\n envFile: 'string?',\n resources: resourcesPatchSchema.optional(),\n backupPaths: type('string[]').optional(),\n backupIgnoreGenerated: 'boolean?',\n secretEnv: secretEnvNamesSchema.optional(),\n } as const\n}\n\nexport const serverPatchSchema = lazy(() => type(editableFields()).onUndeclaredKey('reject'))\nexport type ServerPatch = typeof serverPatchSchema.infer\n\nexport const serverCreateSchema = lazy(() => type({\n id: '/^[a-z0-9][a-z0-9_-]*$/',\n ...editableFields(),\n command: 'string',\n}).onUndeclaredKey('reject'))\nexport type ServerCreate = typeof serverCreateSchema.infer\n\n/** The stored entry plus run-time problems; `warnings` is absent when there is nothing to say, and is not a refusal. */\nexport const serverWriteResponseSchema = lazy(() => type({\n 'server': serverSchema,\n 'warnings?': 'string[]',\n}).onDeepUndeclaredKey('ignore'))\nexport type ServerWriteResponse = typeof serverWriteResponseSchema.infer\n\n/** What the panel hands a persistent entry's nanny, written 0600 and unlinked on read; everything is pre-resolved. */\nexport const nannySpecSchema = lazy(() => type({\n serverId: 'string',\n command: 'string',\n args: 'string[]',\n cwd: 'string',\n env: 'Record<string, string>',\n /** Directory of the JSONL the nanny writes; `<dir>/<id>.log`, exactly as the panel names it. */\n logDir: 'string',\n logs: logsSchema,\n stop: stopSchema,\n // These files cross panel versions, so an unknown key is ignored at every level.\n}).onDeepUndeclaredKey('ignore'))\nexport type NannySpec = typeof nannySpecSchema.infer\n\nconst nannyExitSchema = lazy(() => type({\n code: 'number | null',\n signal: 'string | null',\n at: 'number',\n runtimeMs: 'number',\n}).onDeepUndeclaredKey('ignore'))\nexport type NannyExit = typeof nannyExitSchema.infer\n\n/** A persistent entry's process state, written by its nanny (with a heartbeat) and read by the panel to re-adopt it. */\nexport const nannyStateSchema = lazy(() => type({\n 'serverId': 'string',\n 'nannyPid': 'number',\n 'childPid': 'number | null',\n 'startedAt': 'number',\n 'logFile': 'string',\n 'heartbeatAt': 'number',\n 'lastExit?': nannyExitSchema,\n}).onDeepUndeclaredKey('ignore'))\nexport type NannyState = typeof nannyStateSchema.infer\n\n/** Supervision state that must outlast a panel restart (retry budgets, `runOnce`). */\nexport const entryStateSchema = lazy(() => type({\n /** Attempts spent on the current crash sequence; reset once the process stays up. */\n 'restarts': 'number.integer >= 0',\n /** Force restarts spent on the current unhealthy sequence, separate from crash `restarts`. */\n 'healthRestarts?': 'number.integer >= 0',\n 'bootstrapDone': 'boolean',\n /** A restored dump still to load once the entry is up (the load hook needs a running server). */\n 'pendingLoad?': 'string | null',\n /** The last child spawned for a non-persistent entry, so a later boot recognizes its own survivor. */\n 'lastPid?': 'number | null',\n 'lastStartedAt?': 'number | null',\n}))\nexport type EntryState = typeof entryStateSchema.infer\n\nexport const settingsPatchSchema = lazy(() => type({\n control: controlPatchSchema.optional(),\n host: hostPatchSchema.optional(),\n backups: backupsPatchSchema.optional(),\n}).onUndeclaredKey('reject'))\nexport type SettingsPatch = typeof settingsPatchSchema.infer\n\nexport const workspaceSettingsPatchSchema = lazy(() => type({\n defaults: defaultsPatchSchema.optional(),\n logs: logsPatchSchema.optional(),\n notifications: notificationsPatchSchema.optional(),\n}).onUndeclaredKey('reject'))\nexport type WorkspaceSettingsPatch = typeof workspaceSettingsPatchSchema.infer\n\nconst authStatusSchema = lazy(() => type({\n enabled: 'boolean',\n passwordSet: 'boolean',\n passwordUpdatedAt: 'number | null',\n /** An API token is set (a flag, never the value). Optional for an older panel. */\n apiTokenSet: 'boolean?',\n /** Still the boot-time default; the login page says so and exposure stays blocked. */\n usingDefaultPassword: 'boolean',\n exposed: 'boolean',\n /** Non-null when that exposure is not backed by a password. */\n blockedReason: 'string | null',\n sessionTtlMs: 'number',\n cookieSecure: 'string',\n trustProxy: 'boolean | \"loopback\"',\n maxLoginAttempts: 'number',\n lockoutMs: 'number',\n}))\nexport type AuthStatus = typeof authStatusSchema.infer\n\nconst tlsStatusSchema = lazy(() => type({\n enabled: 'boolean',\n certPresent: 'boolean',\n subject: 'string | null',\n issuer: 'string | null',\n validFrom: 'string | null',\n validTo: 'string | null',\n daysRemaining: 'number | null',\n fingerprint: 'string | null',\n keyMatches: 'boolean | null',\n error: 'string | null',\n}))\nexport type TlsStatus = typeof tlsStatusSchema.infer\n\nconst notificationPolicyStatusShape = {\n onCrash: 'boolean',\n onUnhealthy: 'boolean',\n onForcedRestart: 'boolean',\n onRecovered: 'boolean',\n onHost: 'boolean',\n /** Dynamic DNS, when this panel knows about it (optional for an older panel). */\n onDdns: 'boolean?',\n cooldownMs: 'number',\n} as const\n\n/** One destination with its effective policy (inherited when `useOwnSettings` is false) and last send outcome. */\nconst destinationStatusSchema = lazy(() => type({\n 'id': 'string',\n 'kind': '\"telegram\" | \"webhook\"',\n 'enabled': 'boolean',\n 'useOwnSettings': 'boolean',\n ...notificationPolicyStatusShape,\n /** Telegram only, null on a webhook. */\n 'chatId': 'string | null',\n 'tokenSet': 'boolean',\n /** Webhook only, null on a Telegram destination. */\n 'url': 'string | null',\n 'method': '\"POST\" | \"PUT\" | null',\n 'format': '\"json\" | \"text\" | null',\n 'headers': 'string | null',\n /** Last delivery outcome, for the page. Optional: a newer panel may not have sent one yet. */\n 'lastResult?': 'string | null',\n 'lastResultAt?': 'number | null',\n}))\nexport type DestinationStatusView = typeof destinationStatusSchema.infer\n\n/** The chats a bot can see, as `POST /notifications/destinations/:id/detect-chats` answers them. */\nexport const telegramChatsSchema = lazy(() => type({\n chats: type({ id: 'string | number', title: 'string' }).array(),\n}))\n\nconst notificationViewSchema = lazy(() => type({\n 'defaults?': notificationDefaultsViewSchema,\n 'destinations?': destinationStatusSchema.array(),\n}))\nexport type NotificationView = typeof notificationViewSchema.infer\n\n/** What answered a request: the browser's session cookie, an API token, or this machine with auth unarmed. */\nexport const credentialKindSchema = lazy(() => type.enumerated('session', 'token', 'local'))\nexport type CredentialKind = typeof credentialKindSchema.infer\n\n/** Which credential answered; `name` is an API token's readable head, absent otherwise. */\nexport const credentialViewSchema = lazy(() => type({\n 'kind': credentialKindSchema,\n 'name?': 'string',\n}))\nexport type CredentialView = typeof credentialViewSchema.infer\n\nexport const sessionViewSchema = lazy(() => type({\n 'authenticated': 'boolean',\n 'authRequired': 'boolean',\n /** Whether any account can sign in — what arms authentication. */\n 'passwordSet': 'boolean',\n /** Whether any account exists. Kept for a client that branched on the old token field. */\n 'apiTokenSet': 'boolean?',\n 'usingDefaultPassword': 'boolean',\n 'accountId?': 'string',\n /** Never sent over the API (the first-run password is shown on the machine), so always absent. */\n 'defaultPassword?': 'string',\n 'sessionTtlMs': 'number',\n 'credential?': credentialViewSchema,\n}))\nexport type SessionView = typeof sessionViewSchema.infer\n\n/** `GET /api/meta`: release, API version, the caller's credential and refusals, live features, error codes and event names. */\nexport const metaViewSchema = lazy(() => type({\n version: 'string',\n /** The response-shape version; bumped only when an older client cannot read a change. */\n apiVersion: 'number.integer',\n credential: credentialViewSchema,\n /** Who this is, as a history event names them: `user`, `agent` or `policy`. */\n actor: 'string',\n /** Actions this credential may not take: empty for a session and `local`; an API token is refused the takeover paths. */\n refused: 'string[]',\n features: type({\n proxy: 'boolean',\n /** Dynamic DNS, on if any workspace has it enabled (`workspace.ddns.enabled`). */\n ddns: 'boolean',\n /** The WSL2 temperature bridge is configured (`host.tempCommand` names one). */\n temperature: 'boolean',\n }),\n errorCodes: 'string[]',\n events: 'string[]',\n}).onDeepUndeclaredKey('ignore'))\nexport type MetaView = typeof metaViewSchema.infer\n\nexport const serverStatusSchema = lazy(() => type('\"stopped\" | \"starting\" | \"running\" | \"stopping\" | \"backoff\" | \"crashed\" | \"conflict\"'))\nexport type ServerStatus = typeof serverStatusSchema.infer\n\nconst healthStateSchema = lazy(() => type('\"disabled\" | \"unknown\" | \"healthy\" | \"unhealthy\"'))\nexport type HealthState = typeof healthStateSchema.infer\n\nconst portStateSchema = lazy(() => type('\"unknown\" | \"free\" | \"in-use\"'))\nexport type PortState = typeof portStateSchema.infer\n\nexport const logStreamSchema = lazy(() => type('\"stdout\" | \"stderr\" | \"system\"'))\nexport type LogStream = typeof logStreamSchema.infer\n\nexport const logLineSchema = lazy(() => type({\n 'ts': 'number',\n 'stream': logStreamSchema,\n 'text': 'string',\n /** `GET /api/logs/:id` only: this line's position, to pass back as `?after=`/`?before=`. */\n 'cursor?': 'string',\n}))\nexport type LogLine = typeof logLineSchema.infer\n\n/** One run and the lines it wrote; `truncated` when only the newest of them are here. */\nexport const jobRunDetailSchema = lazy(() => type({\n 'run': jobRunSchema,\n 'lines': logLineSchema.array(),\n 'truncated?': 'boolean',\n}).onDeepUndeclaredKey('ignore'))\nexport type JobRunDetail = typeof jobRunDetailSchema.infer\n\n/** Who caused an event: `policy` is the panel itself, `user` a session, `agent` an API token, `boot` autostart. */\nconst historyActorSchema = lazy(() => type.enumerated('policy', 'user', 'agent', 'boot'))\nexport type HistoryActor = typeof historyActorSchema.infer\n\nconst historyEventSchema = lazy(() => type({\n 'serverId': 'string',\n 'ts': 'number',\n 'type': '\"start\" | \"exit\" | \"crash\" | \"forced-restart\" | \"unhealthy\" | \"recovered\" | \"deploy\"',\n 'detail': 'string',\n /** How long the process had been up, recorded on exit, crash and deploy. */\n 'runtimeMs': 'number?',\n /** How a `deploy` ended. */\n 'outcome?': '\"ok\" | \"failed\"',\n 'actor?': historyActorSchema,\n}))\nexport type HistoryEvent = typeof historyEventSchema.infer\n\nconst serverHistorySchema = lazy(() => type({\n windowMs: 'number',\n /** Share of the window the process was up (null when nothing is known yet). */\n uptimeRatio: 'number | null',\n restarts: 'number',\n crashes: 'number',\n forcedRestarts: 'number',\n lastCrashAt: 'number | null',\n lastExitAt: 'number | null',\n lastRuntimeMs: 'number | null',\n events: historyEventSchema.array(),\n}))\nexport type ServerHistory = typeof serverHistorySchema.infer\n\nconst processResourcesSchema = lazy(() => type({\n cpuPercent: 'number | null',\n /** RSS of the process and its descendants. */\n rssBytes: 'number | null',\n processes: 'number',\n sampledAt: 'number',\n}))\nexport type ProcessResources = typeof processResourcesSchema.infer\n\nconst hostDiskSchema = lazy(() => type({\n path: 'string',\n totalBytes: 'number',\n freeBytes: 'number',\n usedPercent: 'number',\n}))\n\nconst hostViewSchema = lazy(() => type({\n 'enabled': 'boolean',\n 'cpus': 'number',\n 'loadAvg': type('number[]'),\n /** Share of CPU capacity in use over the last interval, 0–100; `null` on the first sample. */\n 'cpuUsedPercent?': 'number | null',\n 'uptimeMs': 'number',\n 'memoryUsedPercent': 'number',\n 'swapUsedPercent': 'number',\n 'tempCelsius': 'number | null',\n 'disks': hostDiskSchema.array(),\n 'alerts': type('string[]'),\n 'sampledAt': 'number | null',\n /** `host.loadPerCpu`, the per-cpu load the alert fires at; `0` disables it. */\n 'loadAlertPerCpu?': 'number',\n /** The percentage alert thresholds from `host.*`, so a UI bands against the configured value; `0` disables. */\n 'memoryUsedPercentAlert?': 'number',\n 'swapUsedPercentAlert?': 'number',\n 'tempCelsiusAlert?': 'number',\n /** `host.diskUsedPercent`, sent once for the frame because it applies to every disk. */\n 'diskUsedPercentAlert?': 'number',\n /**\n * Readings not taken on this sample (`load`, `memory`, `swap`). Their wire value stays `0` for older\n * UIs; `hostReadings` reports them as absent.\n */\n 'unmeasured?': type('string[]'),\n}))\nexport type HostView = typeof hostViewSchema.infer\n\n/** The WSL2 temperature bridge; `supported` is false off WSL, so the UI hides the block. */\nexport const wslTemperatureSchema = lazy(() => type({\n 'wsl': 'boolean',\n /** The setup can work here — the same as `wsl` today, separate so a future bridge can differ. */\n 'supported': 'boolean',\n 'configured': 'boolean',\n 'scriptWritten': 'boolean',\n 'libraryPresent': 'boolean',\n 'scriptPath': 'string | null',\n 'tempCommand?': 'string | null',\n 'lastReadingCelsius?': 'number | null',\n 'lastError?': 'string | null',\n /** The library is missing and downloading it needs the person's consent. */\n 'needsDownload?': 'boolean',\n}))\nexport type WslTemperatureStatus = typeof wslTemperatureSchema.infer\n\nexport const serverViewSchema = lazy(() => type({\n 'id': 'string',\n 'workspaceId?': 'string',\n 'config': serverSchema,\n 'bindHost': 'string',\n 'url': 'string | null',\n 'status': serverStatusSchema,\n 'health': healthStateSchema,\n 'portState': portStateSchema,\n 'pid': 'number | null',\n /** True when the process serving this entry was adopted, not spawned by the panel. */\n 'adopted': 'boolean?',\n /** The panel stopped this entry because it could not serve, not because someone asked. */\n 'stoppedByPanel?': 'boolean',\n 'startedAt': 'number | null',\n 'exitCode': 'number | null',\n 'exitSignal': 'string | null',\n 'restarts': 'number',\n 'maxRetries': 'number',\n 'lastError': 'string | null',\n /** The failed run's last few stderr lines, oldest first, while the entry is crashed or backing off. */\n 'lastStderr?': 'string[]',\n 'nextRetryAt': 'number | null',\n 'unhealthySince': 'number | null',\n 'bufferedLines': 'number',\n 'history': serverHistorySchema,\n 'responseMs': 'number | null',\n 'resources': processResourcesSchema.or(type('null')),\n /** The declared secret names that have a stored value: names only, never a value. */\n 'secretEnvSet?': 'string[]',\n 'deploy?': deployStatusSchema,\n /** The running process was started from a config that differs in a field a restart re-reads. */\n 'restartRequired?': 'boolean',\n}).onDeepUndeclaredKey('ignore'))\n// `config` is emitted normalized (port is always `number | null`); the schema accepts both forms.\nexport type ServerView = Omit<typeof serverViewSchema.infer, 'config'> & { config: ServerConfig }\n\n/** What `/healthz` answers on 200 and 503; the detail fields are only for an authenticated caller. */\nexport const healthResponseSchema = lazy(() => type({\n 'status': '\"ok\" | \"degraded\"',\n 'uptimeMs': 'number',\n 'servers?': type({ total: 'number', running: 'number', crashed: 'number', unhealthy: 'number' }),\n 'hostAlerts?': 'string[]',\n /** Which state root this panel serves, as a fingerprint — only to a loopback caller (the CLI). */\n 'home?': 'string',\n}))\n\nconst controlViewSchema = lazy(() => type({\n 'label': 'string',\n 'port': 'number',\n 'host': 'string',\n 'bindHost': 'string',\n 'url': 'string',\n 'openBrowser': 'boolean',\n 'allowedHosts?': 'string[]',\n /** The live listener differs from the configured host/port. */\n 'restartRequired': 'boolean',\n 'protocol': 'string',\n 'auth': authStatusSchema,\n 'tls': tlsStatusSchema,\n}))\nexport type ControlView = typeof controlViewSchema.infer\n\n/** A user-supplied UI's `ui.json`; every field optional because a hand-written one carries only the author fields. */\nexport const uiMetaSchema = lazy(() => type({\n 'name?': 'string',\n 'version?': 'string | null',\n 'uploadedAt?': 'number',\n 'files?': 'number.integer >= 1',\n /** `owner/name` of the UI's own repository, for `ui-update`. */\n 'repo?': 'string',\n /** The release tag this build came from, e.g. `v0.6.0`. Stamped by the build, never committed. */\n 'tag?': 'string',\n 'asset?': 'string',\n /** When the UI was built, in unix epoch seconds. Stamped by the build, never committed. */\n 'unix?': 'number.integer >= 0',\n}))\nexport type UiMeta = typeof uiMetaSchema.infer\n\nconst uiStatusSchema = lazy(() => type({\n custom: 'boolean',\n dir: 'string',\n meta: uiMetaSchema.or(type('null')),\n}))\nexport type UiStatus = typeof uiStatusSchema.infer\n\n/** One process a panel spawned that no configured entry claims any more. */\nconst serverOrphanSchema = lazy(() => type({\n serverId: 'string',\n pid: 'number',\n /** When the panel spawned it; null when the record predates the stamp. */\n startedAt: 'number | null',\n}))\nexport type ServerOrphan = typeof serverOrphanSchema.infer\n\nexport const workspaceViewSchema = lazy(() => type({\n 'id': 'string',\n 'label': 'string',\n 'configPath': 'string',\n 'settingsPath': 'string',\n 'configError': 'string | null',\n /** Keys a newer release wrote that this one ignores. */\n 'configWarnings?': type('string[]'),\n 'logsDir': 'string',\n 'defaults': defaultsSchema,\n 'logs': logsSchema,\n 'notifications': notificationViewSchema,\n 'ddns?': ddnsStatusSchema,\n 'serverCount': 'number',\n 'runningCount': 'number',\n 'crashedCount': 'number',\n /** Processes this panel started that no current entry owns (renamed or deleted while running). */\n 'orphans?': serverOrphanSchema.array(),\n 'servers': serverViewSchema.array(),\n /** The workspace's jobs, live: what runs now, what runs next, how the last run ended. */\n 'jobs?': jobEntryViewSchema.array(),\n 'jobsError?': 'string',\n}).onDeepUndeclaredKey('ignore'))\nexport type WorkspaceView = typeof workspaceViewSchema.infer\n\n/** The whole panel in one frame: global state plus every workspace. */\nexport const appStateSchema = lazy(() => type({\n 'control': controlViewSchema,\n 'host': hostViewSchema,\n 'backups': backupsViewSchema,\n 'ui': uiStatusSchema,\n 'workspaces': workspaceViewSchema.array(),\n 'proxy?': proxyViewSchema,\n /** The directory the panel was started from; relative entry paths use it. */\n 'projectDir': 'string',\n 'dataRoot': 'string',\n /** The panel-wide `settings.json`, as the OS spells it. */\n 'settingsPath?': 'string',\n 'version?': 'string',\n /** Why the panel-wide `settings.json` could not be applied (the running settings are kept); `null` when fine. */\n 'settingsError?': type({ message: 'string', path: 'string' }).or('null'),\n}).onDeepUndeclaredKey('ignore'))\nexport type AppState = typeof appStateSchema.infer\n\n/** `?limit=` on the buffered log route: a whole number of lines, 1–100000. */\nexport const logQuerySchema = lazy(() => type({\n 'limit?': integerParam(1, 100_000),\n}))\n\n/** A per-server lifecycle action's answer; `code` is absent on success. */\nexport const actionResultSchema = lazy(() => type({\n 'ok': 'boolean',\n 'error?': 'string',\n 'message?': 'string',\n 'code?': 'string',\n /** On a successful stop: entries still running that declare `dependsOn` the one stopped. */\n 'dependents?': 'string[]',\n}))\nexport type ActionResultBody = typeof actionResultSchema.infer\n\nexport const deliveryResultSchema = lazy(() => type({\n 'ok': 'boolean',\n 'error?': 'string',\n}))\n\n/** What both TLS mutation routes answer: the listener and the move in flight. */\nexport const tlsReviewResponseSchema = lazy(() => type({\n control: controlViewSchema,\n rebinding: 'boolean',\n targetUrl: 'string',\n}))\n\n/** The plain acknowledgement most mutations answer with. */\nexport const okResponseSchema = lazy(() => type({ ok: 'boolean' }))\n\nexport const backupFilesResponseSchema = lazy(() => type({\n ok: 'boolean',\n files: backupFileSchema.array(),\n}))\n\nexport const uiInstallResponseSchema = lazy(() => type({\n 'ok': 'boolean',\n 'meta?': uiStatusSchema.get('meta'),\n 'ui': uiStatusSchema,\n /** Revert only: whether there was a custom UI to remove. */\n 'removed?': 'boolean',\n}))\n\nexport const backupCreatedResponseSchema = lazy(() => type({\n 'file': backupFileSchema,\n 'files': backupFileSchema.array(),\n /** Captured but worth a look: a declared path that holds no files. Optional: older panels never send it. */\n 'warnings?': 'string[]',\n}))\n\n/** `POST /_hh/backups` without `confirm=true`: what a backup would capture, with nothing written. */\nconst backupPlanResponseSchema = lazy(() => type({\n apply: 'false',\n entries: backupEntrySchema.array(),\n includePaths: 'string[]',\n}))\nexport type BackupPlanResponse = typeof backupPlanResponseSchema.infer\n\nexport const backupLocalResponseSchema = lazy(() => backupPlanResponseSchema.or(backupCreatedResponseSchema))\n\nexport const notificationActionSchema = lazy(() => type({\n /** Optional override, so the token can be tried before it is saved. */\n botToken: 'string?',\n chatId: 'string?',\n}).onUndeclaredKey('reject'))\n\n/** A destination id; validated because it also keys a bot token in the secrets file. */\nexport const destinationIdParamSchema = lazy(() => type({\n id: '/^[a-z0-9][a-z0-9_-]*$/',\n}))\n\n/** `POST /api/notifications/test-webhook`: the webhook to try, as an unsaved draft or by id. */\nexport const destinationTestSchema = lazy(() => type({\n target: webhookTargetSchema.omit('kind', 'id').and(type({ id: 'string?', kind: '\"webhook\"?' })),\n id: 'string?',\n}).onUndeclaredKey('reject'))\n\nexport const telegramTokenSchema = lazy(() => type({\n botToken: 'string >= 1',\n}).onUndeclaredKey('reject'))\n\n/** The error envelope every route answers failures with; `detail` is usually absent. */\nexport const apiErrorSchema = lazy(() => type({\n 'message': 'string',\n /** Stable, machine-readable; `AUTH_REQUIRED` also drives the login redirect. */\n 'code': 'string',\n 'detail?': 'unknown',\n}))\n\n/** `PUT /api/servers/:id/secrets`: values to set and names to remove; undeclared names are refused by the route. */\nexport const serverSecretsSchema = lazy(() => type({\n 'set?': type({ '[string]': 'string' }),\n 'unset?': type('string[]'),\n}).onUndeclaredKey('reject'))\n\nexport const tlsUploadSchema = lazy(() => type({\n certificate: 'string >= 1',\n privateKey: 'string >= 1',\n}).onUndeclaredKey('reject'))\n\nexport const settingsViewSchema = lazy(() => type({\n control: controlViewSchema,\n host: hostSchema,\n backups: backupsViewSchema,\n ui: uiStatusSchema,\n}).onDeepUndeclaredKey('ignore'))\nexport type SettingsView = typeof settingsViewSchema.infer\n\nexport const settingsSavedSchema = lazy(() => settingsViewSchema.and(type({\n /** The listener is moving; reconnect at `targetUrl` when it stops being null. */\n rebinding: 'boolean',\n targetUrl: 'string | null',\n})))\nexport type SettingsSaved = typeof settingsSavedSchema.infer\n\n/** `GET /api/settings/workspace?workspace=<id>`: what a workspace owns; panel-wide settings are not here. */\nexport const workspaceSettingsViewSchema = lazy(() => type({\n id: 'string',\n label: 'string',\n settingsPath: 'string',\n configPath: 'string',\n configError: 'string | null',\n defaults: defaultsSchema,\n logs: logsSchema,\n notifications: notificationViewSchema,\n}).onDeepUndeclaredKey('ignore'))\nexport type WorkspaceSettingsView = typeof workspaceSettingsViewSchema.infer\n\nexport const workspaceSettingsSavedSchema = workspaceSettingsViewSchema\n\nexport {\n accountCreatedBodySchema,\n accountCreateSchema,\n accountIdBodySchema,\n accountListSchema,\n accountPatchSchema,\n accountSecretSchema,\n accountViewSchema,\n apiTokenScopeSchema,\n loginSchema,\n passwordValueSchema,\n scopeInfoSchema,\n} from './contracts/accounts'\nexport type {\n AccountCreateRequest,\n AccountPatchRequest,\n AccountSecretRequest,\n AccountView,\n LoginRequest,\n} from './contracts/accounts'\n\nexport {\n backupCreateSchema,\n backupEntrySchema,\n backupFileSchema,\n backupScheduleViewSchema,\n backupSelectionSchema,\n backupsViewSchema,\n restoreItemSchema,\n restorePlanSchema,\n restoreRequestSchema,\n restoreSkipSchema,\n} from './contracts/backups'\nexport type {\n BackupCreate,\n BackupEntry,\n BackupFile,\n BackupSelection,\n BackupsView,\n RestoreItem,\n RestorePlan,\n RestoreRequest,\n RestoreSkip,\n} from './contracts/backups'\n\n/** One server's live resource reading for `home-hosted usage`; an absent reading is not zero. */\nconst usageEntrySchema = lazy(() => type({\n 'id': 'string',\n 'workspaceId': 'string',\n 'label': 'string',\n 'status': serverStatusSchema,\n /** Absent when nothing is running or the sampler has no sample yet. */\n 'cpuPercent?': 'number',\n 'rssBytes?': 'number',\n 'processes?': 'number',\n 'sampledAt?': 'number',\n /** Behaviour over the history window, from `ServerView.history`; absent when nothing is known yet. */\n 'restarts?': 'number',\n 'crashes?': 'number',\n 'uptimeRatio?': 'number',\n 'lastExitAt?': 'number',\n}))\n\nexport const usageViewSchema = lazy(() => type({\n 'servers': usageEntrySchema.array(),\n 'sampledAt?': 'number',\n}))\n\nexport const freePortResultSchema = lazy(() => type({\n ok: 'boolean',\n port: 'number | null',\n /** Asked to leave with SIGTERM, and the ones that ignored it. */\n terminated: 'number[]',\n forced: 'number[]',\n /** Listeners this panel supervises; never signalled. */\n skipped: 'number[]',\n free: 'boolean',\n}))\nexport type FreePortResult = typeof freePortResultSchema.infer\n\nexport {\n ddnsConfigSchema,\n ddnsCredentialsSchema,\n ddnsDomainSchema,\n ddnsPatchSchema,\n ddnsProviderFieldSchema,\n ddnsProviderInfoSchema,\n ddnsStatusSchema,\n ddnsViewSchema,\n} from './contracts/ddns'\nexport type {\n DdnsAccount,\n DdnsConfig,\n DdnsDomain,\n DdnsPatch,\n DdnsProviderField,\n DdnsProviderInfo,\n DdnsRecordState,\n DdnsRecordType,\n DdnsRecordView,\n DdnsStatus,\n DdnsView,\n} from './contracts/ddns'\n\nexport { sseEventNames, sseLogFrameSchema, sseMessageSchema, ssePingFrameSchema, sseServerFrameSchema, sseStateFrameSchema } from './contracts/frames'\nexport type { SseMessage } from './contracts/frames'\n\nexport {\n bufferedLogsResponseSchema,\n jobLogViewSchema,\n logHistoryQuerySchema,\n logHistoryViewSchema,\n logLinesResponseSchema,\n logPageQuerySchema,\n logServersViewSchema,\n} from './contracts/logs'\nexport type { JobLogView, LogCursor, LogHistoryView, LogServerView } from './contracts/logs'\n\nexport {\n proxyCertificateSchema,\n proxyCertificateUploadSchema,\n proxyConfigSchema,\n proxyEngineInstallSchema,\n proxyEngineStatusSchema,\n proxyPatchSchema,\n proxyRouteSchema,\n proxyRouteViewSchema,\n proxyStatusSchema,\n proxyViewSchema,\n} from './contracts/proxy'\nexport type {\n ProxyCertificateState,\n ProxyCertificateView,\n ProxyConfig,\n ProxyDnsAccountView,\n ProxyEngineInfo,\n ProxyEngineStatus,\n ProxyPatch,\n ProxyRoute,\n ProxyRoutePatch,\n ProxyRouteStatus,\n ProxyRouteView,\n ProxyRunState,\n ProxyStatus,\n ProxyTarget,\n ProxyTlsMode,\n ProxyView,\n} from './contracts/proxy'\n"],"mappings":";;;;;;AAKA,IAAa,sBAAsB,WAAW,KAAK,WAAW,QAAQ,aAAa,UAAU,SAAS,OAAO,CAAC;;AAG9G,IAAa,cAAc,WAAW,KAAK;CACzC,IAAI;CACJ,QAAQ;AACV,CAAC,CAAC,CAAC,gBAAgB,QAAQ,CAAC;;AAI5B,IAAa,sBAAsB,WAAW,KAAK,oBAAoB,CAAC;;AAGxE,IAAa,sBAAsB,WAAW,KAAK;CACjD,eAAe;CACf,WAAW;AACb,CAAC,CAAC,CAAC,gBAAgB,QAAQ,CAAC;AAG5B,IAAa,oBAAoB,WAAW,KAAK;CAC/C,MAAM;CACN,SAAS;CACT,UAAU,oBAAoB,MAAM;CACpC,eAAe;CACf,WAAW;CACX,aAAa;;CAEb,SAAS;CACT,aAAa;CACb,aAAa;CACb,eAAe;AACjB,CAAC,CAAC,CAAC,oBAAoB,QAAQ,CAAC;;AAIhC,IAAa,kBAAkB,WAAW,KAAK;CAC7C,OAAO;CACP,k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AAoB,QAAQ,CAAC;AAGhC,IAAa,+BAA+B;;AAgD5C,IAAM,mBAAmB,WAAW,KAAK;CACvC,MAAM;CACN,eAAe;CACf,SAAS;CACT,UAAU;;CAEV,eAAe;CACf,aAAa;CACb,cAAc;CACd,cAAc;;CAEd,aAAa;CACb,YAAY;CACZ,gBAAgB;CAChB,eAAe;AACjB,CAAC,CAAC;AAEF,IAAa,kBAAkB,WAAW,KAAK;CAC7C,WAAW,iBAAiB,MAAM;CAClC,cAAc;AAChB,CAAC,CAAC;AAEF,IAAa,uBAAuB,WAAW,KAAK;CAClD,IAAI;CACJ,MAAM;;CAEN,YAAY;CACZ,QAAQ;;CAER,SAAS;CACT,MAAM;AACR,CAAC,CAAC"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { S as runtimePath } from "./paths-C34-TJLh.js";
|
|
2
|
+
import { t as writeFileAtomic } from "./atomic-SZUwDtGD.js";
|
|
3
|
+
import { t as lazy } from "./lazy-kfcBNeqj.js";
|
|
4
|
+
import { c as processLiveness, r as isProcessAlive } from "./port-CnsrxKNR.js";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import { Buffer } from "node:buffer";
|
|
7
|
+
import { randomBytes } from "node:crypto";
|
|
8
|
+
import { type } from "arktype";
|
|
9
|
+
import http from "node:http";
|
|
10
|
+
import https from "node:https";
|
|
11
|
+
//#region src/helpers/daemon.ts
|
|
12
|
+
/**
|
|
13
|
+
* `run.json` is how `status`/`down` find the live control plane and stop it without a password:
|
|
14
|
+
* the file is 0600, and its token is what `POST /_hh/shutdown` checks.
|
|
15
|
+
*/
|
|
16
|
+
var runtimeSchema = lazy(() => type({
|
|
17
|
+
version: "string",
|
|
18
|
+
pid: "number.integer >= 1",
|
|
19
|
+
url: "string",
|
|
20
|
+
/** Always a reachable loopback address, for probes (`lan` binds to 0.0.0.0). */
|
|
21
|
+
probeUrl: "string",
|
|
22
|
+
protocol: "string",
|
|
23
|
+
port: "1 <= number.integer <= 65535",
|
|
24
|
+
bindHost: "string",
|
|
25
|
+
startedAt: "number",
|
|
26
|
+
projectDir: "string",
|
|
27
|
+
dataRoot: "string",
|
|
28
|
+
configPath: "string",
|
|
29
|
+
logFile: "string",
|
|
30
|
+
token: "string >= 1"
|
|
31
|
+
}).onUndeclaredKey("reject"));
|
|
32
|
+
function readRuntime() {
|
|
33
|
+
try {
|
|
34
|
+
const parsed = runtimeSchema(JSON.parse(fs.readFileSync(runtimePath, "utf8")));
|
|
35
|
+
return parsed instanceof type.errors ? null : parsed;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function writeRuntime(runtime) {
|
|
41
|
+
writeFileAtomic(runtimePath, `${JSON.stringify(runtime, null, 2)}\n`, { mode: 384 });
|
|
42
|
+
}
|
|
43
|
+
function clearRuntime() {
|
|
44
|
+
fs.rmSync(runtimePath, { force: true });
|
|
45
|
+
}
|
|
46
|
+
function newToken() {
|
|
47
|
+
return randomBytes(32).toString("base64url");
|
|
48
|
+
}
|
|
49
|
+
/** What became of the daemon this record describes; see `processLiveness` in `providers/port.ts`. */
|
|
50
|
+
async function runtimeLiveness(runtime) {
|
|
51
|
+
return await processLiveness(runtime.pid, runtime.startedAt);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Is the daemon this record describes still the one running? A pid alone cannot say — pids are
|
|
55
|
+
* reused and a zombie answers signal 0 — and every caller must use this one predicate.
|
|
56
|
+
*/
|
|
57
|
+
async function runtimeIsAlive(runtime) {
|
|
58
|
+
return isLiveLiveness(await runtimeLiveness(runtime));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* `'unknown'` (no readable start time) counts as alive, so a running panel's record is not cleared;
|
|
62
|
+
* `'recycled'` does not.
|
|
63
|
+
*/
|
|
64
|
+
function isLiveLiveness(liveness) {
|
|
65
|
+
return liveness === "live" || liveness === "unknown";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Is there positively no process behind the pid? The only condition under which deleting `run.json`
|
|
69
|
+
* is safe, narrower than `!runtimeIsAlive`: Linux derives birth time from the wall clock, so a forward
|
|
70
|
+
* clock step (a laptop or WSL waking) can make a live panel look recycled.
|
|
71
|
+
*/
|
|
72
|
+
async function runtimeIsGone(runtime) {
|
|
73
|
+
return await runtimeLiveness(runtime) === "gone";
|
|
74
|
+
}
|
|
75
|
+
/** A degraded panel is still answering: a 503 must not read as "not running". */
|
|
76
|
+
async function probeRuntime(runtime, timeoutMs = 2500) {
|
|
77
|
+
const answer = await localCall(runtime.probeUrl, "/healthz", "GET", runtime.token, timeoutMs);
|
|
78
|
+
return {
|
|
79
|
+
reachable: answer !== null,
|
|
80
|
+
degraded: answer?.status === 503,
|
|
81
|
+
servers: readServerCounts(answer?.body)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function readServerCounts(body) {
|
|
85
|
+
if (body === void 0) return null;
|
|
86
|
+
try {
|
|
87
|
+
const { total, running } = JSON.parse(body).servers ?? {};
|
|
88
|
+
return typeof total === "number" && typeof running === "number" ? {
|
|
89
|
+
total,
|
|
90
|
+
running
|
|
91
|
+
} : null;
|
|
92
|
+
} catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* What is listening on this home's configured port when no `run.json` says a panel should be, or
|
|
98
|
+
* `null`. Without it, a deleted `run.json` reads as "not running" over a live panel.
|
|
99
|
+
*
|
|
100
|
+
* A listener is only this home's panel when `/healthz` says so (`homeFingerprint`); anything else is
|
|
101
|
+
* `other`. It probes and never signals: without a record there is no pid this process can prove it owns.
|
|
102
|
+
*/
|
|
103
|
+
async function configuredPanelAddress() {
|
|
104
|
+
const { readStateFile } = await import("./config-text-DxMOQQnk.js").then((n) => n.t);
|
|
105
|
+
const { globalSettingsPath, homeFingerprint } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
106
|
+
const { probePort } = await import("./port-CnsrxKNR.js").then((n) => n.o);
|
|
107
|
+
const { globalSettingsSchema } = await import("./schema-CZ6f-PHD.js").then((n) => n.s);
|
|
108
|
+
let port;
|
|
109
|
+
try {
|
|
110
|
+
const parsed = globalSettingsSchema(JSON.parse(readStateFile(globalSettingsPath)));
|
|
111
|
+
if (parsed instanceof type.errors) return null;
|
|
112
|
+
port = parsed.control.port;
|
|
113
|
+
} catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
if (!await probePort("127.0.0.1", port)) return null;
|
|
117
|
+
for (const protocol of ["http", "https"]) {
|
|
118
|
+
const base = `${protocol}://127.0.0.1:${port}`;
|
|
119
|
+
const answer = await localCall(base, "/healthz", "GET", void 0, 2500);
|
|
120
|
+
if (answer === null) continue;
|
|
121
|
+
return answeredHome(answer.body) === homeFingerprint() ? {
|
|
122
|
+
kind: "panel",
|
|
123
|
+
url: base
|
|
124
|
+
} : {
|
|
125
|
+
kind: "other",
|
|
126
|
+
port
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
kind: "other",
|
|
131
|
+
port
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function answeredHome(body) {
|
|
135
|
+
try {
|
|
136
|
+
const home = JSON.parse(body).home;
|
|
137
|
+
return typeof home === "string" ? home : null;
|
|
138
|
+
} catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** Asks the daemon to stop through its endpoint: a bare signal is not graceful on Windows. */
|
|
143
|
+
async function requestShutdown(runtime, timeoutMs = 4e3, options = {}) {
|
|
144
|
+
const query = options.withPersistent === true ? "?withPersistent=true" : "";
|
|
145
|
+
const answer = await localCall(runtime.probeUrl, `/_hh/shutdown${query}`, "POST", runtime.token, timeoutMs);
|
|
146
|
+
return answer !== null && answer.status >= 200 && answer.status < 300;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Drives a supervised server from this machine, authorised by run.json's token: only the owner of
|
|
150
|
+
* that 0600 file, over loopback. The wait is generous because a start may run a 120 s bootstrap.
|
|
151
|
+
*/
|
|
152
|
+
async function requestControl(runtime, path, timeoutMs = 15e4, method = "POST", payload, headers = {}) {
|
|
153
|
+
const answer = await localCall(runtime.probeUrl, path, method, runtime.token, timeoutMs, payload === void 0 ? void 0 : JSON.stringify(payload), headers);
|
|
154
|
+
if (answer === null) return null;
|
|
155
|
+
let body = null;
|
|
156
|
+
try {
|
|
157
|
+
body = JSON.parse(answer.body);
|
|
158
|
+
} catch {}
|
|
159
|
+
return {
|
|
160
|
+
status: answer.status,
|
|
161
|
+
body
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Talks to the panel over loopback with http/https directly: Node's `fetch` cannot accept the
|
|
166
|
+
* self-signed certificate an uploaded TLS pair usually is.
|
|
167
|
+
*/
|
|
168
|
+
function localCall(base, path, method, token, timeoutMs, payload, extra = {}) {
|
|
169
|
+
return new Promise((resolve) => {
|
|
170
|
+
const url = new URL(`${base}${path}`);
|
|
171
|
+
const secure = url.protocol === "https:";
|
|
172
|
+
const request = (secure ? https : http).request({
|
|
173
|
+
hostname: url.hostname,
|
|
174
|
+
port: url.port,
|
|
175
|
+
path: `${url.pathname}${url.search}`,
|
|
176
|
+
method,
|
|
177
|
+
...secure ? { rejectUnauthorized: false } : {},
|
|
178
|
+
headers: {
|
|
179
|
+
...extra,
|
|
180
|
+
...token === void 0 ? {} : { "x-home-hosted-token": token },
|
|
181
|
+
...payload === void 0 ? {} : {
|
|
182
|
+
"content-type": "application/json",
|
|
183
|
+
"content-length": String(Buffer.byteLength(payload))
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
timeout: timeoutMs
|
|
187
|
+
}, (response) => {
|
|
188
|
+
let body = "";
|
|
189
|
+
response.setEncoding("utf8");
|
|
190
|
+
response.on("data", (chunk) => {
|
|
191
|
+
body += chunk;
|
|
192
|
+
});
|
|
193
|
+
response.once("end", () => resolve({
|
|
194
|
+
status: response.statusCode ?? 0,
|
|
195
|
+
body
|
|
196
|
+
}));
|
|
197
|
+
response.once("aborted", () => resolve(null));
|
|
198
|
+
response.once("error", () => resolve(null));
|
|
199
|
+
});
|
|
200
|
+
request.once("error", () => resolve(null));
|
|
201
|
+
request.once("timeout", () => {
|
|
202
|
+
request.destroy();
|
|
203
|
+
resolve(null);
|
|
204
|
+
});
|
|
205
|
+
request.end(payload);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
export { clearRuntime, configuredPanelAddress, isLiveLiveness, isProcessAlive, newToken, probeRuntime, readRuntime, requestControl, requestShutdown, runtimeIsAlive, runtimeIsGone, runtimeLiveness, writeRuntime };
|
|
210
|
+
|
|
211
|
+
//# sourceMappingURL=daemon-BAAYUYQC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-BAAYUYQC.js","names":[],"sources":["../../src/helpers/daemon.ts"],"sourcesContent":["import type { ProcessLiveness } from '#src/providers/port'\nimport { Buffer } from 'node:buffer'\nimport { randomBytes } from 'node:crypto'\nimport fs from 'node:fs'\nimport http from 'node:http'\nimport https from 'node:https'\nimport { type } from 'arktype'\nimport { writeFileAtomic } from '#src/helpers/atomic'\nimport { runtimePath } from '#src/helpers/paths'\nimport { processLiveness } from '#src/providers/port'\nimport { lazy } from '#src/shared/lazy'\n\n/**\n * `run.json` is how `status`/`down` find the live control plane and stop it without a password:\n * the file is 0600, and its token is what `POST /_hh/shutdown` checks.\n */\nexport const runtimeSchema = lazy(() => type({\n version: 'string',\n pid: 'number.integer >= 1',\n url: 'string',\n /** Always a reachable loopback address, for probes (`lan` binds to 0.0.0.0). */\n probeUrl: 'string',\n protocol: 'string',\n port: '1 <= number.integer <= 65535',\n bindHost: 'string',\n startedAt: 'number',\n projectDir: 'string',\n dataRoot: 'string',\n configPath: 'string',\n logFile: 'string',\n token: 'string >= 1',\n}).onUndeclaredKey('reject'))\nexport type Runtime = typeof runtimeSchema.infer\n\nexport function readRuntime(): Runtime | null {\n try {\n const parsed = runtimeSchema(JSON.parse(fs.readFileSync(runtimePath, 'utf8')))\n return parsed instanceof type.errors ? null : parsed\n }\n catch {\n return null\n }\n}\n\nexport function writeRuntime(runtime: Runtime): void {\n writeFileAtomic(runtimePath, `${JSON.stringify(runtime, null, 2)}\\n`, { mode: 0o600 })\n}\n\nexport function clearRuntime(): void {\n fs.rmSync(runtimePath, { force: true })\n}\n\nexport function newToken(): string {\n return randomBytes(32).toString('base64url')\n}\n\n/** One definition with `providers/port.ts`, so the two agree on `EPERM`. */\nexport { isProcessAlive } from '#src/providers/port'\n\n/** What became of the daemon this record describes; see `processLiveness` in `providers/port.ts`. */\nexport async function runtimeLiveness(runtime: Runtime): Promise<ProcessLiveness> {\n return await processLiveness(runtime.pid, runtime.startedAt)\n}\n\n/**\n * Is the daemon this record describes still the one running? A pid alone cannot say — pids are\n * reused and a zombie answers signal 0 — and every caller must use this one predicate.\n */\nexport async function runtimeIsAlive(runtime: Runtime): Promise<boolean> {\n return isLiveLiveness(await runtimeLiveness(runtime))\n}\n\n/**\n * `'unknown'` (no readable start time) counts as alive, so a running panel's record is not cleared;\n * `'recycled'` does not.\n */\nexport function isLiveLiveness(liveness: ProcessLiveness): boolean {\n return liveness === 'live' || liveness === 'unknown'\n}\n\n/**\n * Is there positively no process behind the pid? The only condition under which deleting `run.json`\n * is safe, narrower than `!runtimeIsAlive`: Linux derives birth time from the wall clock, so a forward\n * clock step (a laptop or WSL waking) can make a live panel look recycled.\n */\nexport async function runtimeIsGone(runtime: Runtime): Promise<boolean> {\n return await runtimeLiveness(runtime) === 'gone'\n}\n\nexport interface RuntimeProbe {\n /** The panel answered on its own port — stronger than \"the pid exists\". */\n reachable: boolean\n degraded: boolean\n /** `null` when the panel answered without a count (an older panel, or the token was not accepted). */\n servers: { total: number, running: number } | null\n}\n\n/** A degraded panel is still answering: a 503 must not read as \"not running\". */\nexport async function probeRuntime(runtime: Runtime, timeoutMs = 2500): Promise<RuntimeProbe> {\n // The token is what makes `/healthz` include the per-server counts.\n const answer = await localCall(runtime.probeUrl, '/healthz', 'GET', runtime.token, timeoutMs)\n return { reachable: answer !== null, degraded: answer?.status === 503, servers: readServerCounts(answer?.body) }\n}\n\nfunction readServerCounts(body: string | undefined): RuntimeProbe['servers'] {\n if (body === undefined)\n return null\n try {\n const parsed = JSON.parse(body) as { servers?: { total?: unknown, running?: unknown } }\n const { total, running } = parsed.servers ?? {}\n return typeof total === 'number' && typeof running === 'number' ? { total, running } : null\n }\n catch {\n return null\n }\n}\n\nexport type ConfiguredListener\n = | { kind: 'panel', url: string }\n | { kind: 'other', port: number }\n\n/**\n * What is listening on this home's configured port when no `run.json` says a panel should be, or\n * `null`. Without it, a deleted `run.json` reads as \"not running\" over a live panel.\n *\n * A listener is only this home's panel when `/healthz` says so (`homeFingerprint`); anything else is\n * `other`. It probes and never signals: without a record there is no pid this process can prove it owns.\n */\nexport async function configuredPanelAddress(): Promise<ConfiguredListener | null> {\n const { readStateFile } = await import('#src/helpers/config-text')\n const { globalSettingsPath, homeFingerprint } = await import('#src/helpers/paths')\n const { probePort } = await import('#src/providers/port')\n const { globalSettingsSchema } = await import('#src/config/schema')\n\n let port: number\n try {\n const parsed = globalSettingsSchema(JSON.parse(readStateFile(globalSettingsPath)) as unknown)\n // ArkType's errors are not `Error`s.\n if (parsed instanceof type.errors)\n return null\n port = parsed.control.port\n }\n catch {\n return null\n }\n\n if (!await probePort('127.0.0.1', port))\n return null\n // https only when plain http got no answer at all: the panel may serve TLS on its own port.\n for (const protocol of ['http', 'https']) {\n const base = `${protocol}://127.0.0.1:${port}`\n const answer = await localCall(base, '/healthz', 'GET', undefined, 2500)\n if (answer === null)\n continue\n return answeredHome(answer.body) === homeFingerprint() ? { kind: 'panel', url: base } : { kind: 'other', port }\n }\n return { kind: 'other', port }\n}\n\nfunction answeredHome(body: string): string | null {\n try {\n const home = (JSON.parse(body) as { home?: unknown }).home\n return typeof home === 'string' ? home : null\n }\n catch {\n return null\n }\n}\n\n/** Asks the daemon to stop through its endpoint: a bare signal is not graceful on Windows. */\nexport async function requestShutdown(runtime: Runtime, timeoutMs = 4000, options: { withPersistent?: boolean } = {}): Promise<boolean> {\n // The request helper sends no body, so `withPersistent` rides the query like `workspace`.\n const query = options.withPersistent === true ? '?withPersistent=true' : ''\n const answer = await localCall(runtime.probeUrl, `/_hh/shutdown${query}`, 'POST', runtime.token, timeoutMs)\n return answer !== null && answer.status >= 200 && answer.status < 300\n}\n\nexport interface ControlAnswer {\n status: number\n body: unknown\n}\n\n/**\n * Drives a supervised server from this machine, authorised by run.json's token: only the owner of\n * that 0600 file, over loopback. The wait is generous because a start may run a 120 s bootstrap.\n */\nexport async function requestControl(runtime: Runtime, path: string, timeoutMs = 150000, method: 'GET' | 'POST' = 'POST', payload?: unknown, headers: Record<string, string> = {}): Promise<ControlAnswer | null> {\n const answer = await localCall(runtime.probeUrl, path, method, runtime.token, timeoutMs, payload === undefined ? undefined : JSON.stringify(payload), headers)\n if (answer === null)\n return null\n\n let body: unknown = null\n try {\n body = JSON.parse(answer.body)\n }\n catch {\n }\n return { status: answer.status, body }\n}\n\n/**\n * Talks to the panel over loopback with http/https directly: Node's `fetch` cannot accept the\n * self-signed certificate an uploaded TLS pair usually is.\n */\nfunction localCall(base: string, path: string, method: 'GET' | 'POST', token: string | undefined, timeoutMs: number, payload?: string, extra: Record<string, string> = {}): Promise<{ status: number, body: string } | null> {\n return new Promise((resolve) => {\n const url = new URL(`${base}${path}`)\n const secure = url.protocol === 'https:'\n const request = (secure ? https : http).request({\n hostname: url.hostname,\n port: url.port,\n path: `${url.pathname}${url.search}`,\n method,\n // Only ever pointed at our own listener on this machine.\n ...(secure ? { rejectUnauthorized: false } : {}),\n headers: {\n ...extra,\n ...(token === undefined ? {} : { 'x-home-hosted-token': token }),\n ...(payload === undefined ? {} : { 'content-type': 'application/json', 'content-length': String(Buffer.byteLength(payload)) }),\n },\n timeout: timeoutMs,\n }, (response) => {\n let body = ''\n response.setEncoding('utf8')\n response.on('data', (chunk: string) => {\n body += chunk\n })\n response.once('end', () => resolve({ status: response.statusCode ?? 0, body }))\n // The request `timeout` stops covering the call once headers arrive; a socket dying mid-body would\n // otherwise leave this promise unsettled.\n response.once('aborted', () => resolve(null))\n response.once('error', () => resolve(null))\n })\n\n request.once('error', () => resolve(null))\n request.once('timeout', () => {\n request.destroy()\n resolve(null)\n })\n request.end(payload)\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,IAAa,gBAAgB,WAAW,KAAK;CAC3C,SAAS;CACT,KAAK;CACL,KAAK;;CAEL,UAAU;CACV,UAAU;CACV,MAAM;CACN,UAAU;CACV,WAAW;CACX,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,SAAS;CACT,OAAO;AACT,CAAC,CAAC,CAAC,gBAAgB,QAAQ,CAAC;AAG5B,SAAgB,cAA8B;CAC5C,IAAI;EACF,MAAM,SAAS,cAAc,KAAK,MAAM,GAAG,aAAa,aAAa,MAAM,CAAC,CAAC;EAC7E,OAAO,kBAAkB,KAAK,SAAS,OAAO;CAChD,QACM;EACJ,OAAO;CACT;AACF;AAEA,SAAgB,aAAa,SAAwB;CACnD,gBAAgB,aAAa,GAAG,KAAK,UAAU,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,IAAM,CAAC;AACvF;AAEA,SAAgB,eAAqB;CACnC,GAAG,OAAO,aAAa,EAAE,OAAO,KAAK,CAAC;AACxC;AAEA,SAAgB,WAAmB;CACjC,OAAO,YAAY,EAAE,CAAC,CAAC,SAAS,WAAW;AAC7C;;AAMA,eAAsB,gBAAgB,SAA4C;CAChF,OAAO,MAAM,gBAAgB,QAAQ,KAAK,QAAQ,SAAS;AAC7D;;;;;AAMA,eAAsB,eAAe,SAAoC;CACvE,OAAO,eAAe,MAAM,gBAAgB,OAAO,CAAC;AACtD;;;;;AAMA,SAAgB,eAAe,UAAoC;CACjE,OAAO,aAAa,UAAU,aAAa;AAC7C;;;;;;AAOA,eAAsB,cAA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