home-hosted 0.10.3 → 0.12.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 +273 -628
- package/dist/chunks/archive-DpCwA8Nf.js +339 -0
- package/dist/chunks/archive-DpCwA8Nf.js.map +1 -0
- package/dist/chunks/atomic-CEfCUfkQ.js +25 -0
- package/dist/chunks/atomic-CEfCUfkQ.js.map +1 -0
- package/dist/chunks/backup-CPrJVPJI.js +797 -0
- package/dist/chunks/backup-CPrJVPJI.js.map +1 -0
- package/dist/chunks/backups-Bd2SF2qd.js +4346 -0
- package/dist/chunks/backups-Bd2SF2qd.js.map +1 -0
- package/dist/chunks/config-text-DifCHhnz.js +50 -0
- package/dist/chunks/config-text-DifCHhnz.js.map +1 -0
- package/dist/chunks/contracts-ku5ypHXJ.js +2256 -0
- package/dist/chunks/contracts-ku5ypHXJ.js.map +1 -0
- package/dist/chunks/daemon-TwXk5vb8.js +215 -0
- package/dist/chunks/daemon-TwXk5vb8.js.map +1 -0
- package/dist/chunks/daemon-log-BVj8cDEo.js +241 -0
- package/dist/chunks/daemon-log-BVj8cDEo.js.map +1 -0
- package/dist/chunks/docker-CGv4Uv7w.js +436 -0
- package/dist/chunks/docker-CGv4Uv7w.js.map +1 -0
- package/dist/chunks/down-BlX5X3bm.js +378 -0
- package/dist/chunks/down-BlX5X3bm.js.map +1 -0
- package/dist/chunks/init-DdmqHVra.js +263 -0
- package/dist/chunks/init-DdmqHVra.js.map +1 -0
- package/dist/chunks/last-stop-BZ08Z89-.js +52 -0
- package/dist/chunks/last-stop-BZ08Z89-.js.map +1 -0
- package/dist/chunks/layout-D74TGUnr.js +24 -0
- package/dist/chunks/layout-D74TGUnr.js.map +1 -0
- package/dist/chunks/log-buffer-HnP0jKhZ.js +350 -0
- package/dist/chunks/log-buffer-HnP0jKhZ.js.map +1 -0
- package/dist/chunks/logger-B5U4GD3j.js +13 -0
- package/dist/chunks/logger-B5U4GD3j.js.map +1 -0
- package/dist/chunks/logs-gI_69Q1P.js +265 -0
- package/dist/chunks/logs-gI_69Q1P.js.map +1 -0
- package/dist/chunks/migrate-BTlsibvF.js +155 -0
- package/dist/chunks/migrate-BTlsibvF.js.map +1 -0
- package/dist/chunks/nanny-20aBXL1o.js +1069 -0
- package/dist/chunks/nanny-20aBXL1o.js.map +1 -0
- package/dist/chunks/nanny-CjnnrIpm.js +132 -0
- package/dist/chunks/nanny-CjnnrIpm.js.map +1 -0
- package/dist/chunks/nanny-DUaAfCV-.js +39 -0
- package/dist/chunks/nanny-DUaAfCV-.js.map +1 -0
- package/dist/chunks/nanny-sweep-Ca9kPAVi.js +104 -0
- package/dist/chunks/nanny-sweep-Ca9kPAVi.js.map +1 -0
- package/dist/chunks/nearest-6KgQEDUe.js +41 -0
- package/dist/chunks/nearest-6KgQEDUe.js.map +1 -0
- package/dist/chunks/parse-B9owE47G.js +383 -0
- package/dist/chunks/parse-B9owE47G.js.map +1 -0
- package/dist/chunks/paths-BT94q6-w.js +172 -0
- package/dist/chunks/paths-BT94q6-w.js.map +1 -0
- package/dist/chunks/port-B8WBTRMk.js +333 -0
- package/dist/chunks/port-B8WBTRMk.js.map +1 -0
- package/dist/chunks/restart-UZgeDukG.js +126 -0
- package/dist/chunks/restart-UZgeDukG.js.map +1 -0
- package/dist/chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/chunks/schema-o7Lgk0V1.js +102 -0
- package/dist/chunks/schema-o7Lgk0V1.js.map +1 -0
- package/dist/chunks/secrets-D7PdYh71.js +544 -0
- package/dist/chunks/secrets-D7PdYh71.js.map +1 -0
- package/dist/chunks/server-BuIeSsRu.js +169 -0
- package/dist/chunks/server-BuIeSsRu.js.map +1 -0
- package/dist/chunks/server-ids-DRuNLVCV.js +32 -0
- package/dist/chunks/server-ids-DRuNLVCV.js.map +1 -0
- package/dist/chunks/set-password-DegMumPh.js +43 -0
- package/dist/chunks/set-password-DegMumPh.js.map +1 -0
- package/dist/chunks/set-token-21d1FTDC.js +78 -0
- package/dist/chunks/set-token-21d1FTDC.js.map +1 -0
- package/dist/chunks/settings-BVSBnIwJ.js +332 -0
- package/dist/chunks/settings-BVSBnIwJ.js.map +1 -0
- package/dist/chunks/setup-temp-XiuAtiW2.js +150 -0
- package/dist/chunks/setup-temp-XiuAtiW2.js.map +1 -0
- package/dist/chunks/shape-DnTKzjQ2.js +24 -0
- package/dist/chunks/shape-DnTKzjQ2.js.map +1 -0
- package/dist/chunks/src-BL97vLVb.js +11153 -0
- package/dist/chunks/src-BL97vLVb.js.map +1 -0
- package/dist/chunks/status-EuWdRq8Q.js +119 -0
- package/dist/chunks/status-EuWdRq8Q.js.map +1 -0
- package/dist/chunks/ui-DbPuwddJ.js +323 -0
- package/dist/chunks/ui-DbPuwddJ.js.map +1 -0
- package/dist/chunks/ui-dir-CsU3uLNV.js +39 -0
- package/dist/chunks/ui-dir-CsU3uLNV.js.map +1 -0
- package/dist/chunks/ui-release-DKzVvlLd.js +312 -0
- package/dist/chunks/ui-release-DKzVvlLd.js.map +1 -0
- package/dist/chunks/ui-revert-BhqOAhmM.js +27 -0
- package/dist/chunks/ui-revert-BhqOAhmM.js.map +1 -0
- package/dist/chunks/ui-switch-CMoslPO2.js +150 -0
- package/dist/chunks/ui-switch-CMoslPO2.js.map +1 -0
- package/dist/chunks/ui-update-TTBBoDik.js +272 -0
- package/dist/chunks/ui-update-TTBBoDik.js.map +1 -0
- package/dist/chunks/up-C4H13hBw.js +196 -0
- package/dist/chunks/up-C4H13hBw.js.map +1 -0
- package/dist/chunks/usage-CSBgLRN5.js +85 -0
- package/dist/chunks/usage-CSBgLRN5.js.map +1 -0
- package/dist/chunks/workspaces-CAln2sQ7.js +221 -0
- package/dist/chunks/workspaces-CAln2sQ7.js.map +1 -0
- package/dist/chunks/wsl-temperature-BiCI4iK6.js +322 -0
- package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +1 -0
- package/dist/cli.js +229 -24861
- package/dist/cli.js.map +1 -1
- package/dist/client.js +120 -0
- package/dist/client.js.map +1 -0
- package/dist/types/api/acme.d.ts +24 -0
- package/dist/types/api/auth/$.routes.d.ts +103 -0
- package/dist/types/api/backups.d.ts +179 -0
- package/dist/types/api/control.d.ts +469 -0
- package/dist/types/api/ddns.d.ts +432 -0
- package/dist/types/api/events.d.ts +21 -0
- package/dist/types/api/health.d.ts +27 -0
- package/dist/types/api/logs.d.ts +95 -0
- package/dist/types/api/metrics.d.ts +19 -0
- package/dist/types/api/notifications.d.ts +141 -0
- package/dist/types/api/proxy.d.ts +1128 -0
- package/dist/types/api/servers/$.routes.d.ts +1318 -0
- package/dist/types/api/settings.d.ts +642 -0
- package/dist/types/api/state.d.ts +492 -0
- package/dist/types/api/static.d.ts +11 -0
- package/dist/types/api/tls.d.ts +112 -0
- package/dist/types/api/workspaces/$.routes.d.ts +797 -0
- package/dist/types/api/wsl-temperature.d.ts +113 -0
- package/dist/types/app.d.ts +6080 -0
- package/dist/types/cli/args.d.ts +75 -0
- package/dist/types/cli/backup-offline.d.ts +23 -0
- package/dist/types/cli/backup.d.ts +79 -0
- package/dist/types/cli/down.d.ts +75 -0
- package/dist/types/cli/init.d.ts +60 -0
- package/dist/types/cli/io.d.ts +65 -0
- package/dist/types/cli/logs.d.ts +64 -0
- package/dist/types/cli/migrate.d.ts +33 -0
- package/dist/types/cli/nanny.d.ts +19 -0
- package/dist/types/cli/nearest.d.ts +10 -0
- package/dist/types/cli/restart.d.ts +42 -0
- package/dist/types/cli/server.d.ts +68 -0
- package/dist/types/cli/set-password.d.ts +14 -0
- package/dist/types/cli/set-token.d.ts +21 -0
- package/dist/types/cli/setup-temp.d.ts +65 -0
- package/dist/types/cli/status.d.ts +14 -0
- package/dist/types/cli/ui-revert.d.ts +3 -0
- package/dist/types/cli/ui-switch.d.ts +27 -0
- package/dist/types/cli/ui-update.d.ts +72 -0
- package/dist/types/cli/up.d.ts +90 -0
- package/dist/types/cli/usage.d.ts +23 -0
- package/dist/types/cli.d.ts +12 -0
- package/dist/types/client.d.ts +6284 -0
- package/dist/types/config/layout.d.ts +11 -0
- package/dist/types/config/migrations.d.ts +69 -0
- package/dist/types/config/parse.d.ts +54 -0
- package/dist/types/config/patch.d.ts +20 -0
- package/dist/types/config/schema.d.ts +318 -0
- package/dist/types/config/secret-parts.d.ts +48 -0
- package/dist/types/config/secrets.d.ts +206 -0
- package/dist/types/config/seed.d.ts +30 -0
- package/dist/types/config/server-ids.d.ts +14 -0
- package/dist/types/config/settings.d.ts +74 -0
- package/dist/types/config/store.d.ts +132 -0
- package/dist/types/config/workspaces.d.ts +96 -0
- package/dist/types/helpers/action-result.d.ts +46 -0
- package/dist/types/helpers/atomic.d.ts +9 -0
- package/dist/types/helpers/backoff.d.ts +7 -0
- package/dist/types/helpers/bind.d.ts +16 -0
- package/dist/types/helpers/config-text.d.ts +23 -0
- package/dist/types/helpers/cookies.d.ts +19 -0
- package/dist/types/helpers/copy-tree.d.ts +15 -0
- package/dist/types/helpers/daemon-log.d.ts +45 -0
- package/dist/types/helpers/daemon.d.ts +122 -0
- package/dist/types/helpers/deferred.d.ts +7 -0
- package/dist/types/helpers/env-file.d.ts +20 -0
- package/dist/types/helpers/error.d.ts +18 -0
- package/dist/types/helpers/factory.d.ts +6 -0
- package/dist/types/helpers/last-stop.d.ts +20 -0
- package/dist/types/helpers/logger.d.ts +7 -0
- package/dist/types/helpers/open.d.ts +2 -0
- package/dist/types/helpers/openapi.d.ts +46 -0
- package/dist/types/helpers/paths.d.ts +94 -0
- package/dist/types/helpers/restore-lock.d.ts +32 -0
- package/dist/types/helpers/runtime.d.ts +18 -0
- package/dist/types/helpers/secret-compare.d.ts +13 -0
- package/dist/types/helpers/shell.d.ts +19 -0
- package/dist/types/helpers/sse.d.ts +23 -0
- package/dist/types/helpers/template.d.ts +8 -0
- package/dist/types/helpers/ui-dir.d.ts +11 -0
- package/dist/types/helpers/validate.d.ts +7 -0
- package/dist/types/helpers/validator.d.ts +12 -0
- package/dist/types/helpers/version.d.ts +10 -0
- package/dist/types/helpers/workspace.d.ts +25 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/middleware/auth.d.ts +37 -0
- package/dist/types/middleware/host.d.ts +29 -0
- package/dist/types/middleware/loopback.d.ts +18 -0
- package/dist/types/openapi-reference.d.ts +22 -0
- package/dist/types/openapi.d.ts +34 -0
- package/dist/types/providers/archive.d.ts +54 -0
- package/dist/types/providers/backup-hook.d.ts +34 -0
- package/dist/types/providers/ddns/cloudflare.d.ts +2 -0
- package/dist/types/providers/ddns/desec.d.ts +2 -0
- package/dist/types/providers/ddns/digitalocean.d.ts +2 -0
- package/dist/types/providers/ddns/duckdns.d.ts +2 -0
- package/dist/types/providers/ddns/dyndns2.d.ts +15 -0
- package/dist/types/providers/ddns/dynu.d.ts +2 -0
- package/dist/types/providers/ddns/freedns.d.ts +2 -0
- package/dist/types/providers/ddns/gandi.d.ts +2 -0
- package/dist/types/providers/ddns/godaddy.d.ts +2 -0
- package/dist/types/providers/ddns/henet.d.ts +3 -0
- package/dist/types/providers/ddns/index.d.ts +12 -0
- package/dist/types/providers/ddns/ip.d.ts +27 -0
- package/dist/types/providers/ddns/namecheap-api.d.ts +13 -0
- package/dist/types/providers/ddns/namecheap.d.ts +6 -0
- package/dist/types/providers/ddns/noip.d.ts +2 -0
- package/dist/types/providers/ddns/porkbun.d.ts +2 -0
- package/dist/types/providers/ddns/spaceship.d.ts +7 -0
- package/dist/types/providers/ddns/types.d.ts +98 -0
- package/dist/types/providers/ddns/zone.d.ts +11 -0
- package/dist/types/providers/docker.d.ts +117 -0
- package/dist/types/providers/entry-state.d.ts +15 -0
- package/dist/types/providers/health-check.d.ts +27 -0
- package/dist/types/providers/host.d.ts +147 -0
- package/dist/types/providers/identity.d.ts +54 -0
- package/dist/types/providers/log-tail.d.ts +29 -0
- package/dist/types/providers/nanny-sweep.d.ts +51 -0
- package/dist/types/providers/nanny.d.ts +94 -0
- package/dist/types/providers/port.d.ts +142 -0
- package/dist/types/providers/proc.d.ts +116 -0
- package/dist/types/providers/process.d.ts +61 -0
- package/dist/types/providers/proxy/caddy.d.ts +2 -0
- package/dist/types/providers/proxy/index.d.ts +7 -0
- package/dist/types/providers/proxy/types.d.ts +54 -0
- package/dist/types/providers/server-vars.d.ts +4 -0
- package/dist/types/providers/telegram.d.ts +32 -0
- package/dist/types/providers/ui-release.d.ts +113 -0
- package/dist/types/providers/webhook.d.ts +64 -0
- package/dist/types/providers/wsl-temperature.d.ts +69 -0
- package/dist/types/services/acme-challenge.d.ts +44 -0
- package/dist/types/services/auth.d.ts +145 -0
- package/dist/types/services/backups.d.ts +352 -0
- package/dist/types/services/config-watch.d.ts +40 -0
- package/dist/types/services/control-server.d.ts +58 -0
- package/dist/types/services/ddns.d.ts +67 -0
- package/dist/types/services/dependencies.d.ts +21 -0
- package/dist/types/services/events.d.ts +17 -0
- package/dist/types/services/exposure.d.ts +33 -0
- package/dist/types/services/history.d.ts +36 -0
- package/dist/types/services/host-monitor.d.ts +32 -0
- package/dist/types/services/init.d.ts +71 -0
- package/dist/types/services/log-buffer.d.ts +28 -0
- package/dist/types/services/log-files.d.ts +87 -0
- package/dist/types/services/log-relay.d.ts +36 -0
- package/dist/types/services/nanny.d.ts +14 -0
- package/dist/types/services/notifications.d.ts +124 -0
- package/dist/types/services/panel.d.ts +194 -0
- package/dist/types/services/proxy-config.d.ts +83 -0
- package/dist/types/services/proxy.d.ts +454 -0
- package/dist/types/services/state.d.ts +41 -0
- package/dist/types/services/supervisor/compose.d.ts +17 -0
- package/dist/types/services/supervisor/entry.d.ts +139 -0
- package/dist/types/services/supervisor/health.d.ts +55 -0
- package/dist/types/services/supervisor/pending-load.d.ts +6 -0
- package/dist/types/services/supervisor/persistent.d.ts +55 -0
- package/dist/types/services/supervisor/port-preflight.d.ts +45 -0
- package/dist/types/services/supervisor/records.d.ts +38 -0
- package/dist/types/services/supervisor/spawn.d.ts +15 -0
- package/dist/types/services/supervisor/view.d.ts +4 -0
- package/dist/types/services/supervisor.d.ts +113 -0
- package/dist/types/services/tls.d.ts +48 -0
- package/dist/types/services/ui-update.d.ts +44 -0
- package/dist/types/services/ui.d.ts +50 -0
- package/dist/types/shared/api-client.d.ts +137 -0
- package/dist/types/shared/backup-scope.d.ts +109 -0
- package/dist/types/shared/clone.d.ts +14 -0
- package/dist/types/shared/contracts.d.ts +4233 -0
- package/dist/types/shared/cpu-scale.d.ts +25 -0
- package/dist/types/shared/ddns-form.d.ts +62 -0
- package/dist/types/shared/endpoint.d.ts +8 -0
- package/dist/types/shared/error-message.d.ts +8 -0
- package/dist/types/shared/fields.d.ts +21 -0
- package/dist/types/shared/generated.d.ts +26 -0
- package/dist/types/shared/host-readings.d.ts +185 -0
- package/dist/types/shared/patch-diff.d.ts +94 -0
- package/dist/types/shared/probe-latency.d.ts +25 -0
- package/dist/types/shared/proxy-form.d.ts +182 -0
- package/dist/types/shared/server-attention.d.ts +37 -0
- package/dist/types/shared/server-key.d.ts +13 -0
- package/dist/types/shared/server-readings.d.ts +55 -0
- package/dist/types/shared/server-url.d.ts +43 -0
- package/dist/types/shared/shape.d.ts +17 -0
- package/dist/types/shared/ui-format.d.ts +89 -0
- package/docs/API.md +180 -0
- package/docs/BACKUPS.md +97 -0
- package/docs/CLI.md +122 -0
- package/docs/DDNS.md +12 -3
- package/docs/NOTIFICATIONS.md +3 -1
- package/docs/RESTORE_DEMO.md +6 -4
- package/docs/REVERSE_PROXY.md +2 -2
- package/docs/SECURITY.md +82 -0
- package/docs/SERVERS.md +47 -15
- package/docs/UI_CREATION.md +82 -286
- package/package.json +18 -9
- package/uis/stock/dist/assets/de-DyGrM1KK.js +1 -0
- package/uis/stock/dist/assets/es-BebHdc0E.js +1 -0
- package/uis/stock/dist/assets/fr-DsDTrxhI.js +1 -0
- package/uis/stock/dist/assets/index-6LANO2Ua.css +2 -0
- package/uis/stock/dist/assets/index-D06cUZbM.js +56 -0
- package/uis/stock/dist/assets/ja-D3RARJjW.js +1 -0
- package/uis/stock/dist/assets/ko-CKI3dFoD.js +1 -0
- package/uis/stock/dist/assets/ru-DEU5ujXt.js +1 -0
- package/uis/stock/dist/assets/vi-ULKPnasj.js +1 -0
- package/uis/stock/dist/assets/zh-CN-tCvnOxWy.js +1 -0
- package/uis/stock/dist/index.html +2 -2
- package/uis/stock/dist/ui.json +3 -3
- package/AGENTS.md +0 -403
- package/uis/stock/dist/assets/de-CiSKBON6.js +0 -1
- package/uis/stock/dist/assets/es-BgNQbboq.js +0 -1
- package/uis/stock/dist/assets/fr-WzBF8AXI.js +0 -1
- package/uis/stock/dist/assets/index-CXDl25BP.js +0 -53
- package/uis/stock/dist/assets/index-Cok5msAO.css +0 -2
- package/uis/stock/dist/assets/ja-DMQqF4ip.js +0 -1
- package/uis/stock/dist/assets/ko-DgfSg9v_.js +0 -1
- package/uis/stock/dist/assets/ru-DjIByX61.js +0 -1
- package/uis/stock/dist/assets/vi-DOB8nYFC.js +0 -1
- package/uis/stock/dist/assets/zh-CN-DZ3WlUgy.js +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Minimal cookie helpers, enough for one httpOnly session cookie. */
|
|
2
|
+
export interface CookieOptions {
|
|
3
|
+
maxAgeMs?: number;
|
|
4
|
+
httpOnly?: boolean;
|
|
5
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
6
|
+
secure?: boolean;
|
|
7
|
+
path?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function parseCookies(header: string | null | undefined): Record<string, string>;
|
|
10
|
+
export declare function serializeCookie(name: string, value: string, options?: CookieOptions): string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether this response's cookie may carry `Secure`, from the configured policy and the protocol the
|
|
13
|
+
* request actually arrived on.
|
|
14
|
+
*
|
|
15
|
+
* One home, because two responses now set the session cookie — the login route and the guard that
|
|
16
|
+
* slides an active session forward. `auto` is the proxy case: behind TLS the panel sees `https:` only
|
|
17
|
+
* because srvx rewrote it from `x-forwarded-proto` (see `.agentDocs/GOTCHAS.md`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function secureCookieFor(mode: 'auto' | 'always' | 'never', protocol: string): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A checkpoint that yields to the event loop once `SLICE_MS` of synchronous work has passed.
|
|
3
|
+
*
|
|
4
|
+
* Sync calls in slices, not `fs.promises`: every async call is a thread-pool round trip, which made a
|
|
5
|
+
* tree of small files 10-20x slower to copy and walk than the sync calls it replaced.
|
|
6
|
+
*/
|
|
7
|
+
export declare function eventLoopSlicer(): () => Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* `fs.cpSync(source, target, { recursive: true, force: true, filter })`, yielding between entries.
|
|
10
|
+
*
|
|
11
|
+
* Every non-directory entry is still copied by `cpSync`, so links, modes and special files behave as
|
|
12
|
+
* they did; only the directory recursion is here, in cp's order — a directory this call creates gets
|
|
13
|
+
* its source mode after its contents are written.
|
|
14
|
+
*/
|
|
15
|
+
export declare function copyTree(source: string, target: string, filter: (source: string, target: string) => boolean): Promise<void>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare function rotateLog(file: string): void;
|
|
2
|
+
/**
|
|
3
|
+
* The last `lines` lines, or `''` when there is no log to read.
|
|
4
|
+
*
|
|
5
|
+
* Split on the trailing newline rather than after it: a log file ends with one, so a plain
|
|
6
|
+
* `split('\n').slice(-lines)` counts that empty last element as a line and quietly returns
|
|
7
|
+
* one fewer than asked for.
|
|
8
|
+
*/
|
|
9
|
+
export declare function tailLog(file: string, lines?: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* The last `lines` lines across the whole rotation, oldest first.
|
|
12
|
+
*
|
|
13
|
+
* A panel console log keeps one rotation (`.1`), so this reads the current file and `.1` — but a
|
|
14
|
+
* **server's** log is rotated by the panel to `.log.<keep>`, three deep by default, and the two
|
|
15
|
+
* used to share this one implementation. `readLog` therefore printed the newest third of a
|
|
16
|
+
* server's log while the Logs page served all of it. `readRotated` walks the directory instead,
|
|
17
|
+
* which covers one file, two, or eleven.
|
|
18
|
+
*
|
|
19
|
+
* Reads only the tail it needs when it can. The log is capped at 5 MB per file *by rotation*, so a
|
|
20
|
+
* panel that has been up a while keeps a large current file — and the old version read it in full,
|
|
21
|
+
* split every line and threw all but the last fifty away: 24 ms and 28 MB of heap to print fifty
|
|
22
|
+
* lines, on the *default* invocation of a diagnostic command. Most of a tail is not looked at, so
|
|
23
|
+
* it is not read.
|
|
24
|
+
*/
|
|
25
|
+
export declare function readLog(file: string, lines: number): string[];
|
|
26
|
+
/**
|
|
27
|
+
* Does this log exist at all — the current file or any rotation of it?
|
|
28
|
+
*
|
|
29
|
+
* Distinct from "has it lines", which is what `readLog` answers: a log the panel opened and has
|
|
30
|
+
* not yet written to is a real log, and a caller deciding "this entry has never run" must not read
|
|
31
|
+
* an empty file as absence. Rotations count on their own because `rotateLog` renames the current
|
|
32
|
+
* file away, so a log that has just rotated has no current file until the next write.
|
|
33
|
+
*/
|
|
34
|
+
export declare function logExists(file: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Prints the last `lines` of the log, then keeps printing whatever is appended.
|
|
37
|
+
*
|
|
38
|
+
* Polled rather than watched on purpose. `config-watch` documents why: an editor's save
|
|
39
|
+
* replaces the inode, and `fs.watch` is undependable on some filesystems. A foreground
|
|
40
|
+
* command also has to notice the rotation `up` performs, which shows up simply as the file
|
|
41
|
+
* getting *smaller* — and a poll sees that without any special case.
|
|
42
|
+
*
|
|
43
|
+
* Resolves when the caller's signal arrives, so the command exits the way a pager would.
|
|
44
|
+
*/
|
|
45
|
+
export declare function followLog(file: string, lines: number, write: (chunk: string) => void, pollMs?: number): Promise<void>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { ProcessLiveness } from '../providers/port.js';
|
|
2
|
+
/**
|
|
3
|
+
* `run.json` is how `status`/`down` find the live control plane and how they are
|
|
4
|
+
* allowed to stop it without a password: the file is mode 0600, and the token in
|
|
5
|
+
* it is what `POST /_hh/shutdown` checks.
|
|
6
|
+
*/
|
|
7
|
+
export declare const runtimeSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
8
|
+
version: string;
|
|
9
|
+
pid: number;
|
|
10
|
+
url: string;
|
|
11
|
+
probeUrl: string;
|
|
12
|
+
protocol: string;
|
|
13
|
+
port: number;
|
|
14
|
+
bindHost: string;
|
|
15
|
+
startedAt: number;
|
|
16
|
+
projectDir: string;
|
|
17
|
+
dataRoot: string;
|
|
18
|
+
configPath: string;
|
|
19
|
+
logFile: string;
|
|
20
|
+
token: string;
|
|
21
|
+
}, {}>;
|
|
22
|
+
export type Runtime = typeof runtimeSchema.infer;
|
|
23
|
+
export declare function readRuntime(): Runtime | null;
|
|
24
|
+
export declare function writeRuntime(runtime: Runtime): void;
|
|
25
|
+
export declare function clearRuntime(): void;
|
|
26
|
+
export declare function newToken(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Re-exported from `providers/port.ts` so the two cannot drift on `EPERM` again.
|
|
29
|
+
*
|
|
30
|
+
* They already had: this copy treated a process owned by another user as alive (correct) while the
|
|
31
|
+
* port one treated it as gone, which made a live nanny look absent. One definition, one answer.
|
|
32
|
+
*/
|
|
33
|
+
export { isProcessAlive } from '../providers/port.js';
|
|
34
|
+
/**
|
|
35
|
+
* What became of the daemon this record describes: the verdict `run.json`'s pid cannot give on
|
|
36
|
+
* its own. See `processLiveness` in `providers/port.ts` for why the pid is not an identity.
|
|
37
|
+
*/
|
|
38
|
+
export declare function runtimeLiveness(runtime: Runtime): Promise<ProcessLiveness>;
|
|
39
|
+
/**
|
|
40
|
+
* Is the daemon this record describes still the one running?
|
|
41
|
+
*
|
|
42
|
+
* `readRuntime()` answers "does a record exist", never "is the panel behind it alive" — and a pid
|
|
43
|
+
* alone cannot answer that either. The OS reuses pids, and a zombie still answers signal 0, so a
|
|
44
|
+
* bare `isProcessAlive(runtime.pid)` reported a stale `run.json` as a live panel: `up` refused with
|
|
45
|
+
* "already running", `status` said "running, but not answering", and `down` signalled whatever
|
|
46
|
+
* unrelated process had since inherited the pid.
|
|
47
|
+
*
|
|
48
|
+
* Every caller must read this one predicate, because a caller that re-derives it slightly differently
|
|
49
|
+
* is how a `down` comes to signal a stranger.
|
|
50
|
+
*/
|
|
51
|
+
export declare function runtimeIsAlive(runtime: Runtime): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Only `'live'` and `'unknown'` count as alive. `'unknown'` means the platform could not read a start
|
|
54
|
+
* time, so the live pid is all there is — dismissing it would clear a record the running panel still
|
|
55
|
+
* owns. `'recycled'` is emphatically **not** alive: the pid belongs to somebody else now.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isLiveLiveness(liveness: ProcessLiveness): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Is the record positively pointing at nothing at all — no process behind the pid?
|
|
60
|
+
*
|
|
61
|
+
* This is the **only** condition under which deleting `run.json` is safe, so it is deliberately
|
|
62
|
+
* narrower than `!runtimeIsAlive`. The start-time check can be wrong in one direction: Linux derives
|
|
63
|
+
* a process's birth epoch from `btime`, which the kernel computes from the wall clock
|
|
64
|
+
* (`getboottime64`: "calls to settimeofday will affect the value returned"), so a forward clock step
|
|
65
|
+
* — common when a laptop or a WSL host wakes from sleep — makes a *live* panel look recycled. Deleting
|
|
66
|
+
* its record over that would orphan a running panel: still supervising servers, no longer stoppable by
|
|
67
|
+
* `down`. A record that some process may still own is left alone and simply overwritten when a new
|
|
68
|
+
* panel finishes booting.
|
|
69
|
+
*/
|
|
70
|
+
export declare function runtimeIsGone(runtime: Runtime): Promise<boolean>;
|
|
71
|
+
export interface RuntimeProbe {
|
|
72
|
+
/** The panel answered on its own port — stronger than "the pid exists". */
|
|
73
|
+
reachable: boolean;
|
|
74
|
+
/** It answered, but reports a crashed autostart server (`/healthz` is 503). */
|
|
75
|
+
degraded: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* How many entries it supervises, and how many are up — `null` when the panel answered without
|
|
78
|
+
* a count (an older panel, or one that did not accept the token).
|
|
79
|
+
*/
|
|
80
|
+
servers: {
|
|
81
|
+
total: number;
|
|
82
|
+
running: number;
|
|
83
|
+
} | null;
|
|
84
|
+
}
|
|
85
|
+
/** A degraded panel is still answering: a 503 must not read as "not running". */
|
|
86
|
+
export declare function probeRuntime(runtime: Runtime, timeoutMs?: number): Promise<RuntimeProbe>;
|
|
87
|
+
/**
|
|
88
|
+
* Where a panel is answering, when no `run.json` says it should be — or `null`.
|
|
89
|
+
*
|
|
90
|
+
* Every command that answers "is it running" has to consult this, not the record alone: with
|
|
91
|
+
* `run.json` deleted, `status` printed "home-hosted is not running" while `GET /healthz` on the
|
|
92
|
+
* same port answered `200`, and `down` had already learned the same lesson (it refuses instead of
|
|
93
|
+
* letting `down && up` start a second panel over a live one). The port comes from the state root's
|
|
94
|
+
* own `settings.json`, because that is the only record left once `run.json` is gone.
|
|
95
|
+
*
|
|
96
|
+
* It **probes, and never signals**: without a record there is no pid this process can prove it
|
|
97
|
+
* owns. A settings file that is missing or does not parse is not evidence either way, so this
|
|
98
|
+
* reports nothing rather than inventing a port to test — a stranger's service on 3999 must not be
|
|
99
|
+
* reported as this panel.
|
|
100
|
+
*/
|
|
101
|
+
export declare function configuredPanelAddress(): Promise<string | null>;
|
|
102
|
+
/**
|
|
103
|
+
* Asks the daemon to stop through its own endpoint, so supervised servers are
|
|
104
|
+
* shut down cleanly on every platform (a bare signal is not graceful on Windows).
|
|
105
|
+
*/
|
|
106
|
+
export declare function requestShutdown(runtime: Runtime, timeoutMs?: number, options?: {
|
|
107
|
+
withPersistent?: boolean;
|
|
108
|
+
}): Promise<boolean>;
|
|
109
|
+
/** A `/_hh` answer: the status, plus the body when it was JSON. */
|
|
110
|
+
export interface ControlAnswer {
|
|
111
|
+
status: number;
|
|
112
|
+
body: unknown;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Drives a supervised server from this machine (`home-hosted start`/`stop`). The
|
|
116
|
+
* token comes from run.json, so it needs no session, no password and no API token —
|
|
117
|
+
* only the owner of that 0600 file, talking over loopback.
|
|
118
|
+
*
|
|
119
|
+
* The wait is generous on purpose: a start may have to run a bootstrap, which has a
|
|
120
|
+
* 120s default timeout of its own. Past this it is a wedged panel, not a slow one.
|
|
121
|
+
*/
|
|
122
|
+
export declare function requestControl(runtime: Runtime, path: string, timeoutMs?: number, method?: 'GET' | 'POST'): Promise<ControlAnswer | null>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs a task after the current response has been written.
|
|
3
|
+
*
|
|
4
|
+
* Moving the control listener closes the connection serving the request that
|
|
5
|
+
* asked for the move, so those steps must happen once the response is out.
|
|
6
|
+
*/
|
|
7
|
+
export declare function afterResponse(task: () => Promise<void>, onError?: (error: unknown) => void): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** `KEY=value` files, with optional `export `, `#` comments and quoted values. */
|
|
2
|
+
export declare function parseEnvFile(text: string): Record<string, string>;
|
|
3
|
+
/**
|
|
4
|
+
* Missing files are not an error: an env file is an optional override layer.
|
|
5
|
+
*
|
|
6
|
+
* Read through `readStateFile`: an entry's `envFile` is written by a person, not by this panel, so a
|
|
7
|
+
* Windows editor's byte-order mark or UTF-16 save is the normal state of it. A `'utf8'` read made
|
|
8
|
+
* every key carry a NUL — dropped by `resolveSpawn` as "an environment key containing a null byte" —
|
|
9
|
+
* so the process started without the secret the file exists to keep out of the config.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadEnvFile(file: string): {
|
|
12
|
+
env: Record<string, string>;
|
|
13
|
+
path: string;
|
|
14
|
+
error: string | null;
|
|
15
|
+
};
|
|
16
|
+
/** Expands `${VAR}` from the given vars; unknown references are left visible. */
|
|
17
|
+
export declare function expandEnv(value: string, vars: Record<string, string | undefined>): string;
|
|
18
|
+
export declare function expandEnvRecord(record: Record<string, string>, vars: Record<string, string | undefined>): Record<string, string>;
|
|
19
|
+
export declare function expandEnvList(values: string[], vars: Record<string, string | undefined>): string[];
|
|
20
|
+
export declare function resolveEnvFilePath(file: string, cwd: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ErrorHandler as HonoErrorHandler } from 'hono';
|
|
2
|
+
/**
|
|
3
|
+
* The one error envelope this API speaks:
|
|
4
|
+
*
|
|
5
|
+
* ```json
|
|
6
|
+
* { "message": "human readable", "code": "MACHINE_READABLE", "detail": … }
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* `@namesmt/utils`' `DetailedError` is the preferred way to fail — it carries the
|
|
10
|
+
* status, a stable code and structured detail — so a client (and the OpenAPI
|
|
11
|
+
* schema) can rely on the shape.
|
|
12
|
+
*/
|
|
13
|
+
export interface ApiErrorBody {
|
|
14
|
+
message: string;
|
|
15
|
+
code: string;
|
|
16
|
+
detail?: unknown;
|
|
17
|
+
}
|
|
18
|
+
export declare const errorHandler: HonoErrorHandler;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every route is built from this factory and chained (`app.get(...).post(...)`)
|
|
3
|
+
* so Hono keeps the full route map in its type — which is what `AppType` exports
|
|
4
|
+
* for `hc<AppType>` clients and for the generated OpenAPI document.
|
|
5
|
+
*/
|
|
6
|
+
export declare const appFactory: import("hono/factory").Factory<import("hono").Env, string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the panel last stopped — the fact `status` could not report.
|
|
3
|
+
*
|
|
4
|
+
* A clean `down` deletes `run.json`, and so does `up` when it finds a record with nothing behind the
|
|
5
|
+
* pid. So "no record" covered both "you stopped it" and "it died and the next start tidied up", and a
|
|
6
|
+
* script could only tell them apart by inferring from which *keys* were absent. This records the
|
|
7
|
+
* answer instead of leaving it to be guessed.
|
|
8
|
+
*
|
|
9
|
+
* Only a deliberate stop writes it. A panel that was killed has nobody to write anything, which is
|
|
10
|
+
* why a *stale record* stays the signal for that one — see `status`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const lastStopSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
13
|
+
at: number;
|
|
14
|
+
reason: "down";
|
|
15
|
+
}, {}>;
|
|
16
|
+
export type LastStop = typeof lastStopSchema.infer;
|
|
17
|
+
/** Records a deliberate stop. Best-effort: a panel that stopped is stopped, whatever this file does. */
|
|
18
|
+
export declare function recordCleanStop(at?: number): void;
|
|
19
|
+
/** The last deliberate stop, or null when there is none (or it cannot be read). */
|
|
20
|
+
export declare function readLastStop(): LastStop | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ConsolaInstance } from 'consola';
|
|
2
|
+
/**
|
|
3
|
+
* Note: this logger will log the `debug` level logs in development mode.
|
|
4
|
+
*
|
|
5
|
+
* For actual debug logs with `NODE_DEBUG`, it is recommended to use the `debug` package.
|
|
6
|
+
*/
|
|
7
|
+
export declare const logger: ConsolaInstance;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import type { ResolverReturnType } from 'hono-openapi';
|
|
3
|
+
/**
|
|
4
|
+
* A JSON response body for `describeRoute`. The resolver needs a real Standard
|
|
5
|
+
* Schema, so only ArkType schemas go in here — never a hand-written JSON schema.
|
|
6
|
+
*/
|
|
7
|
+
export declare function jsonBody(schema: StandardSchemaV1): {
|
|
8
|
+
'application/json': {
|
|
9
|
+
schema: ResolverReturnType;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
/** The envelope every failing request gets (see `src/helpers/error.ts`). */
|
|
13
|
+
export declare const ERROR_RESPONSES: {
|
|
14
|
+
readonly 400: {
|
|
15
|
+
readonly description: "The request was rejected";
|
|
16
|
+
readonly content: {
|
|
17
|
+
'application/json': {
|
|
18
|
+
schema: ResolverReturnType;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
readonly 401: {
|
|
23
|
+
readonly description: "No valid session";
|
|
24
|
+
readonly content: {
|
|
25
|
+
'application/json': {
|
|
26
|
+
schema: ResolverReturnType;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
readonly 404: {
|
|
31
|
+
readonly description: "Unknown id";
|
|
32
|
+
readonly content: {
|
|
33
|
+
'application/json': {
|
|
34
|
+
schema: ResolverReturnType;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly 413: {
|
|
39
|
+
readonly description: "The body is larger than this route accepts";
|
|
40
|
+
readonly content: {
|
|
41
|
+
'application/json': {
|
|
42
|
+
schema: ResolverReturnType;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where home-hosted keeps everything it owns. `HHOSTED_HOME` overrides it —
|
|
3
|
+
* which is how a project repo keeps its own state directory while the package
|
|
4
|
+
* itself ships no configuration at all.
|
|
5
|
+
*
|
|
6
|
+
* Everything below `dataRoot/.hh`: the global panel state at its top level, and
|
|
7
|
+
* one directory per workspace. A workspace owns its settings, servers, secrets,
|
|
8
|
+
* logs and nanny state; only what is genuinely panel-wide (listener, auth,
|
|
9
|
+
* host vitals, backups, TLS, UI, run.json) stays global.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveDataRoot(): string;
|
|
12
|
+
export declare const dataRoot: string;
|
|
13
|
+
/**
|
|
14
|
+
* The directory home-hosted was started from. Relative entry paths (`cwd`,
|
|
15
|
+
* declared data directories) resolve against it, so the project's own launcher
|
|
16
|
+
* decides the base instead of wherever the package happens to be installed.
|
|
17
|
+
* `HHOSTED_PROJECT` pins it explicitly.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveProjectDir(): string;
|
|
20
|
+
export declare const projectDir: string;
|
|
21
|
+
/** The internal state root: global files here, one directory per workspace. */
|
|
22
|
+
export declare const hhDir: string;
|
|
23
|
+
export declare const DEFAULT_WORKSPACE_ID = "default";
|
|
24
|
+
/** Panel-wide settings: listener, auth, TLS policy, host vitals, backups. */
|
|
25
|
+
export declare const globalSettingsPath: string;
|
|
26
|
+
/** Password hash + API token hash; written with mode 0600. */
|
|
27
|
+
export declare const globalSecretsPath: string;
|
|
28
|
+
/** The workspace registry: ids and labels. */
|
|
29
|
+
export declare const workspacesPath: string;
|
|
30
|
+
/** Uploaded TLS PEM pair (the key is written 0600). */
|
|
31
|
+
export declare const tlsDir: string;
|
|
32
|
+
/** The panel's own console log. */
|
|
33
|
+
export declare const daemonLogPath: string;
|
|
34
|
+
/** `run.json` records the live control plane. */
|
|
35
|
+
export declare const runtimePath: string;
|
|
36
|
+
/** The installed UI; `UiService` owns everything under it. */
|
|
37
|
+
export declare const uiDir: string;
|
|
38
|
+
/** Everything the reverse proxy owns: engine binary, its data, its state and logs. */
|
|
39
|
+
export declare const proxyDir: string;
|
|
40
|
+
/** The engine binary the panel installed, plus the record of what it installed. */
|
|
41
|
+
export declare const proxyBinDir: string;
|
|
42
|
+
/** The engine's own data and configuration directories, pinned away from `$HOME`. */
|
|
43
|
+
export declare const proxyEngineDir: string;
|
|
44
|
+
/** The generated engine configuration, rewritten on every change. */
|
|
45
|
+
export declare const proxyConfigPath: string;
|
|
46
|
+
/** The last configuration that applied, kept so a rejected change can be reverted. */
|
|
47
|
+
export declare const proxyPreviousConfigPath: string;
|
|
48
|
+
/** The nanny's spec and state for the engine process, so it outlives the panel. */
|
|
49
|
+
export declare const proxyStateDir: string;
|
|
50
|
+
/** How the panel reaches a running engine's admin endpoint. */
|
|
51
|
+
export declare const proxyAdminPath: string;
|
|
52
|
+
/** The PEM pair a route with `tls: "manual"` serves. */
|
|
53
|
+
export declare const proxyTlsDir: string;
|
|
54
|
+
/** The credentials the engine presents to the panel's DNS-01 endpoint, 0600. */
|
|
55
|
+
export declare const proxyChallengeAuthPath: string;
|
|
56
|
+
export declare function workspaceDir(id: string): string;
|
|
57
|
+
/** Workspace-scoped settings: server defaults, logs, notifications, DDNS. */
|
|
58
|
+
export declare function workspaceSettingsPath(id: string): string;
|
|
59
|
+
/** The servers a workspace supervises. */
|
|
60
|
+
export declare function workspaceServersPath(id: string): string;
|
|
61
|
+
/** Workspace secrets: Telegram bot token and DDNS credentials. Mode 0600. */
|
|
62
|
+
export declare function workspaceSecretsPath(id: string): string;
|
|
63
|
+
/** Rotated per-server JSONL logs. */
|
|
64
|
+
export declare function workspaceLogsDir(id: string): string;
|
|
65
|
+
/** Persisted restart/crash history for one workspace. */
|
|
66
|
+
export declare function workspaceHistoryPath(id: string): string;
|
|
67
|
+
/** Per-entry nanny state and spawn specs — how a persistent server survives a restart. */
|
|
68
|
+
export declare function workspaceStateDir(id: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* The last public address each DDNS target was confirmed to serve.
|
|
71
|
+
*
|
|
72
|
+
* A name no server id can produce (ids carry no `.`): `ddns.json` is also the nanny state of a
|
|
73
|
+
* persistent entry with the id `ddns`, and each overwrote the other.
|
|
74
|
+
*/
|
|
75
|
+
export declare function workspaceDdnsStatePath(id: string): string;
|
|
76
|
+
/** Where releases before `ddns.cache.json` kept that cache, read once and then removed. */
|
|
77
|
+
export declare function workspaceLegacyDdnsStatePath(id: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Where a pre-workspace `$HHOSTED_HOME` kept its config and secrets: directly
|
|
80
|
+
* under `dataRoot`. Nothing reads these; they only identify an instance this
|
|
81
|
+
* release refuses to start against.
|
|
82
|
+
*/
|
|
83
|
+
export declare const legacy: {
|
|
84
|
+
readonly configPath: string;
|
|
85
|
+
readonly secretsPath: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* True when a pre-workspace instance left state at the old paths **and** never
|
|
89
|
+
* crossed into `.hh`: `workspaces.json` means the layout is current, so a stray
|
|
90
|
+
* root-level copy beside it is not an old instance.
|
|
91
|
+
*/
|
|
92
|
+
export declare function hasLegacyLayout(): boolean;
|
|
93
|
+
/** Expands `~` and resolves relative paths against `base`, for config-declared paths. */
|
|
94
|
+
export declare function resolveUserPath(target: string, base?: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface LockRecord {
|
|
2
|
+
pid: number;
|
|
3
|
+
startedAt: number;
|
|
4
|
+
action: string;
|
|
5
|
+
/**
|
|
6
|
+
* The holder's own birth time where the platform reports one.
|
|
7
|
+
*
|
|
8
|
+
* `startedAt` is when the lock was taken, which says nothing about whether the pid still names the
|
|
9
|
+
* same process — comparing the two made a long-held lock look recycled. This is the value that
|
|
10
|
+
* answers the question directly, so a stale-reader compares like with like.
|
|
11
|
+
*/
|
|
12
|
+
birthAt?: number | null;
|
|
13
|
+
}
|
|
14
|
+
export interface RestoreLock {
|
|
15
|
+
/** Releases the lock. Safe to call twice. */
|
|
16
|
+
release: () => void;
|
|
17
|
+
/** The holder, when the lock was taken over from a dead one. */
|
|
18
|
+
replaced?: LockRecord;
|
|
19
|
+
}
|
|
20
|
+
/** Wall-clock start of a pid in ms, or null where the platform cannot report one. */
|
|
21
|
+
export declare function processBirthSync(pid: number): number | null;
|
|
22
|
+
/** The live holder of the restore lock, without taking it; null when nobody is restoring. */
|
|
23
|
+
export declare function restoreLockHolder(hhDir: string): LockRecord | null;
|
|
24
|
+
/**
|
|
25
|
+
* Take the restore lock, or explain who holds it.
|
|
26
|
+
*
|
|
27
|
+
* `null` means somebody else is restoring. The caller reports it rather than queueing: a restore is
|
|
28
|
+
* an interactive decision, and waiting on one you did not start is not what a person asked for.
|
|
29
|
+
*/
|
|
30
|
+
export declare function acquireRestoreLock(hhDir: string, action?: string): RestoreLock | {
|
|
31
|
+
heldBy: LockRecord;
|
|
32
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How to run this CLI again in the same runtime. Under tsx that means passing the
|
|
3
|
+
* resolved loader too, because a spawned child's working directory is the project's,
|
|
4
|
+
* not the package's. Shared by `up` (which re-spawns itself detached) and by the
|
|
5
|
+
* panel (which spawns a persistent entry's nanny).
|
|
6
|
+
*
|
|
7
|
+
* Nothing here reads a state directory, which is why the CLI can import it before
|
|
8
|
+
* `--home`/`--project` have been applied.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runtimeArgs(): string[];
|
|
11
|
+
/**
|
|
12
|
+
* The hidden command a persistent entry runs under. It is spawned by the panel and
|
|
13
|
+
* never typed by a person, so it stays out of the curated CLI surface (help, the
|
|
14
|
+
* unknown-command message, flag refusal) — but the argv has to be one definition,
|
|
15
|
+
* because process identity reads it back: see `providers/identity.ts`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const NANNY_COMMAND = "__nanny";
|
|
18
|
+
export declare function nannyArgv(entry: string, id: string, specPath: string, statePath: string): string[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two secrets without leaking their contents through timing.
|
|
3
|
+
*
|
|
4
|
+
* `a !== b` short-circuits at the first differing byte, so an attacker who can measure response time
|
|
5
|
+
* recovers a secret one byte at a time. That matters wherever the secret is the *only* thing standing
|
|
6
|
+
* between a caller and a privileged action — the `/_hh` control channel, which is deliberately outside
|
|
7
|
+
* `/api` and guarded by nothing else.
|
|
8
|
+
*
|
|
9
|
+
* Length is compared first because `timingSafeEqual` **throws** on differing lengths. That leaks only
|
|
10
|
+
* the length, which is not secret here (the token has a fixed shape and a `hh_` prefix); rejecting it
|
|
11
|
+
* is what keeps a truncated header from becoming a 500.
|
|
12
|
+
*/
|
|
13
|
+
export declare function secretEqual(actual: string, expected: string): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A value quoted for the shell it will be pasted into.
|
|
3
|
+
*
|
|
4
|
+
* One rule for every string this package prints for a person to copy: a directory, an id, a
|
|
5
|
+
* workspace. `init` printed `cd my servers && npm run up` for the default `./my-servers`-style
|
|
6
|
+
* directory a person picks, which the shell answers `cd: too many arguments` — a failure in the one
|
|
7
|
+
* line the scaffold exists to hand over.
|
|
8
|
+
*
|
|
9
|
+
* POSIX gets single quotes, with an embedded quote closed and reopened (`'\''`), the one form that is
|
|
10
|
+
* safe inside a single-quoted string. Windows' `cmd.exe` has no single-quote quoting at all, so it
|
|
11
|
+
* gets double quotes: that is what it understands, and a path whose name contains a `"` is not
|
|
12
|
+
* representable there either way.
|
|
13
|
+
*
|
|
14
|
+
* It cannot use the platform to *decide the shell*, only to pick the dialect: a POSIX path is
|
|
15
|
+
* quoted for `sh` even when the process is running on Windows (the panel's CLI under Git Bash), and
|
|
16
|
+
* a Windows path for `cmd.exe`. `process.platform` is the only signal available, so the rule is
|
|
17
|
+
* documented rather than guessed at each call site.
|
|
18
|
+
*/
|
|
19
|
+
export declare function shellQuote(value: string): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SSEStreamingApi } from 'hono/streaming';
|
|
2
|
+
/**
|
|
3
|
+
* One subscriber's outbound queue, bounded whatever the client does.
|
|
4
|
+
*
|
|
5
|
+
* A client that stops reading without disconnecting must not grow the panel's memory: a queued
|
|
6
|
+
* `state` or `server` frame is replaced by the newer one (only the latest snapshot matters), and log
|
|
7
|
+
* frames are dropped once too many are waiting.
|
|
8
|
+
*/
|
|
9
|
+
export declare function sseChannel(stream: SSEStreamingApi): {
|
|
10
|
+
readonly closed: boolean;
|
|
11
|
+
close(): void;
|
|
12
|
+
/** Queue a frame: `key` makes it supersede a queued frame with the same key; `droppable` caps it. */
|
|
13
|
+
send(event: string, data: string, options?: {
|
|
14
|
+
key?: string;
|
|
15
|
+
droppable?: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
};
|
|
18
|
+
/** The coalescing key for a hub message: snapshots supersede, logs and one-offs do not. */
|
|
19
|
+
export declare function frameKey(message: {
|
|
20
|
+
type: string;
|
|
21
|
+
workspaceId?: string;
|
|
22
|
+
serverId?: string;
|
|
23
|
+
}): string | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type TemplateVars = Record<string, string | number>;
|
|
2
|
+
/**
|
|
3
|
+
* Replaces `{name}` placeholders. Unknown placeholders are left untouched so a
|
|
4
|
+
* typo surfaces in the child's args instead of silently becoming an empty string.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveTemplate(value: string, vars: TemplateVars): string;
|
|
7
|
+
export declare function resolveTemplates<T extends string | string[]>(value: T, vars: TemplateVars): T;
|
|
8
|
+
export declare function resolveRecord(record: Record<string, string>, vars: TemplateVars): Record<string, string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where an installed UI lives and whether one is there — deliberately free of the schema module, so
|
|
3
|
+
* a CLI command that only *names* the UI (`status`) does not pay for compiling every contract.
|
|
4
|
+
*/
|
|
5
|
+
export declare function uiDirectory(dataRoot: string): string;
|
|
6
|
+
export declare function customUiInstalled(dataRoot: string): boolean;
|
|
7
|
+
/** `name`/`version` from `ui.json` when they are strings; the full, validated read is `UiService.readMeta`. */
|
|
8
|
+
export declare function uiIdentity(dataRoot: string): {
|
|
9
|
+
name: string | null;
|
|
10
|
+
version: string | null;
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a value that is not a request target (a query string, a URL
|
|
3
|
+
* parameter, a payload read by hand) and fails with the standard error envelope.
|
|
4
|
+
* Request bodies and queries that a route reads once go through the `validate()`
|
|
5
|
+
* middleware instead, which also carries the type into the handler.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseOrThrow<T>(schema: (input: unknown) => unknown, input: unknown, label: string): T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import type { ValidationTargets } from 'hono';
|
|
3
|
+
/**
|
|
4
|
+
* ArkType-backed request validation. On success Hono stores the *parsed* value,
|
|
5
|
+
* so `c.req.valid('json')` is fully typed and already normalized; on failure it
|
|
6
|
+
* becomes a `DetailedError`, which the global error handler turns into the one
|
|
7
|
+
* error envelope this API speaks.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validate<Target extends keyof ValidationTargets, Schema extends StandardSchemaV1>(target: Target, schema: Schema): import("hono").MiddlewareHandler<import("hono").Env, string, {
|
|
10
|
+
in: (undefined extends StandardSchemaV1.InferInput<Schema> ? true : false) extends true ? { [K in Target]?: ([StandardSchemaV1.InferInput<Schema>] extends [ValidationTargets[K]] ? StandardSchemaV1.InferInput<Schema> : import("hono/validator").InferInput<StandardSchemaV1.InferInput<Schema>, K, import("hono/types").ParsedFormValue>) | undefined; } : { [K_1 in Target]: [StandardSchemaV1.InferInput<Schema>] extends [ValidationTargets[K_1]] ? StandardSchemaV1.InferInput<Schema> : import("hono/validator").InferInput<StandardSchemaV1.InferInput<Schema>, K_1, import("hono/types").ParsedFormValue>; };
|
|
11
|
+
out: { [K_2 in Target]: StandardSchemaV1.InferOutput<Schema>; };
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The running release, read from the package manifest. */
|
|
2
|
+
export declare function appVersion(): string;
|
|
3
|
+
/** Where the package is installed: the base for files it ships (`uis/stock/dist`). */
|
|
4
|
+
export declare function packageRoot(): string;
|
|
5
|
+
/**
|
|
6
|
+
* The one line to add when this CLI and the panel it is talking to are not the same
|
|
7
|
+
* release — which is what a linked checkout, a global install and a project pin
|
|
8
|
+
* produce. `null` when they agree.
|
|
9
|
+
*/
|
|
10
|
+
export declare function versionMismatchNote(panelVersion: string): string | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { WorkspaceRuntime } from '../services/panel.js';
|
|
2
|
+
/**
|
|
3
|
+
* Every workspace-scoped route reads its target from this one query key.
|
|
4
|
+
*
|
|
5
|
+
* **Strict, like every other request schema.** ArkType is permissive by default, so a key this
|
|
6
|
+
* schema did not name was silently dropped and the request ran against the **default** workspace:
|
|
7
|
+
* measured on the built panel, `POST /api/servers/<id>/stop?worspace=staging` answered
|
|
8
|
+
* `200 {"ok":true}` having stopped that entry in `default` — a destructive action applied to the
|
|
9
|
+
* wrong workspace because of one transposed letter, with nothing naming the typo. A misspelt
|
|
10
|
+
* workspace must be a refused key, never a different workspace.
|
|
11
|
+
*
|
|
12
|
+
* A route that reads a second query key merges its own schema with this one **as the argument**
|
|
13
|
+
* (`extra.merge(workspaceQuerySchema)`): `merge` keeps the argument's `onUndeclaredKey`, so that
|
|
14
|
+
* spelling inherits the rejection while the reverse would lose it.
|
|
15
|
+
*/
|
|
16
|
+
export declare const workspaceQuerySchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
17
|
+
workspace?: string | undefined;
|
|
18
|
+
}, {}>;
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the workspace a request is about. Omitting it means the panel's
|
|
21
|
+
* default workspace, which keeps `curl /api/servers` working the way it always
|
|
22
|
+
* did on a single-workspace instance; naming one that does not exist is a 404,
|
|
23
|
+
* never a silent fallback to another workspace's servers.
|
|
24
|
+
*/
|
|
25
|
+
export declare function requireWorkspace(select: (id?: string) => WorkspaceRuntime, id?: string): WorkspaceRuntime;
|