home-hosted 0.11.0 → 0.13.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 +319 -628
- package/dist/chunks/archive-DP-XQR8X.js +352 -0
- package/dist/chunks/archive-DP-XQR8X.js.map +1 -0
- package/dist/chunks/atomic-C1PfJpE7.js +26 -0
- package/dist/chunks/atomic-C1PfJpE7.js.map +1 -0
- package/dist/chunks/backup-CZcVca2a.js +822 -0
- package/dist/chunks/backup-CZcVca2a.js.map +1 -0
- package/dist/chunks/backups-CFRaWe_m.js +4691 -0
- package/dist/chunks/backups-CFRaWe_m.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-CMBD1TF9.js +2230 -0
- package/dist/chunks/contracts-CMBD1TF9.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/daemon-qKVECISl.js +247 -0
- package/dist/chunks/daemon-qKVECISl.js.map +1 -0
- package/dist/chunks/docker-Cy9Lyvda.js +437 -0
- package/dist/chunks/docker-Cy9Lyvda.js.map +1 -0
- package/dist/chunks/down-pKbGCW9d.js +383 -0
- package/dist/chunks/down-pKbGCW9d.js.map +1 -0
- package/dist/chunks/init-BZ7hK9Vf.js +276 -0
- package/dist/chunks/init-BZ7hK9Vf.js.map +1 -0
- package/dist/chunks/last-stop-C-BXz_XI.js +53 -0
- package/dist/chunks/last-stop-C-BXz_XI.js.map +1 -0
- package/dist/chunks/layout-DwTtmund.js +24 -0
- package/dist/chunks/layout-DwTtmund.js.map +1 -0
- package/dist/chunks/lazy-Ce5zEAq1.js +66 -0
- package/dist/chunks/lazy-Ce5zEAq1.js.map +1 -0
- package/dist/chunks/log-buffer-Dy9HHDMD.js +414 -0
- package/dist/chunks/log-buffer-Dy9HHDMD.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---TI_bxM.js +267 -0
- package/dist/chunks/logs---TI_bxM.js.map +1 -0
- package/dist/chunks/migrate-Cfoq-Vgh.js +155 -0
- package/dist/chunks/migrate-Cfoq-Vgh.js.map +1 -0
- package/dist/chunks/nanny-B-Eu0sFW.js +132 -0
- package/dist/chunks/nanny-B-Eu0sFW.js.map +1 -0
- package/dist/chunks/nanny-BtWfy0QH.js +1167 -0
- package/dist/chunks/nanny-BtWfy0QH.js.map +1 -0
- package/dist/chunks/nanny-ChMtq1Zl.js +39 -0
- package/dist/chunks/nanny-ChMtq1Zl.js.map +1 -0
- package/dist/chunks/nanny-sweep-DErnlPY1.js +105 -0
- package/dist/chunks/nanny-sweep-DErnlPY1.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-DhmG26fI.js +383 -0
- package/dist/chunks/parse-DhmG26fI.js.map +1 -0
- package/dist/chunks/paths-CGlGDrOU.js +206 -0
- package/dist/chunks/paths-CGlGDrOU.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-Des4DrAN.js +92 -0
- package/dist/chunks/restart-Des4DrAN.js.map +1 -0
- package/dist/chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/chunks/schema-B240VXcV.js +103 -0
- package/dist/chunks/schema-B240VXcV.js.map +1 -0
- package/dist/chunks/secrets-BieELnZh.js +562 -0
- package/dist/chunks/secrets-BieELnZh.js.map +1 -0
- package/dist/chunks/server-Bge2r2qQ.js +169 -0
- package/dist/chunks/server-Bge2r2qQ.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-D5vZqqSX.js +43 -0
- package/dist/chunks/set-password-D5vZqqSX.js.map +1 -0
- package/dist/chunks/set-token-obPiEJYk.js +78 -0
- package/dist/chunks/set-token-obPiEJYk.js.map +1 -0
- package/dist/chunks/settings-xu-XTfWg.js +423 -0
- package/dist/chunks/settings-xu-XTfWg.js.map +1 -0
- package/dist/chunks/setup-temp-CAN4_bA-.js +150 -0
- package/dist/chunks/setup-temp-CAN4_bA-.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-BtWMFmzZ.js +12338 -0
- package/dist/chunks/src-BtWMFmzZ.js.map +1 -0
- package/dist/chunks/status-DT1EsA-B.js +123 -0
- package/dist/chunks/status-DT1EsA-B.js.map +1 -0
- package/dist/chunks/ui-D562aqw5.js +325 -0
- package/dist/chunks/ui-D562aqw5.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-EkBBwRTt.js +27 -0
- package/dist/chunks/ui-revert-EkBBwRTt.js.map +1 -0
- package/dist/chunks/ui-switch-BnZTdMDd.js +150 -0
- package/dist/chunks/ui-switch-BnZTdMDd.js.map +1 -0
- package/dist/chunks/ui-update-_xryLYxw.js +272 -0
- package/dist/chunks/ui-update-_xryLYxw.js.map +1 -0
- package/dist/chunks/up-Pdz-l6IH.js +210 -0
- package/dist/chunks/up-Pdz-l6IH.js.map +1 -0
- package/dist/chunks/usage-DFrCVXpT.js +111 -0
- package/dist/chunks/usage-DFrCVXpT.js.map +1 -0
- package/dist/chunks/workspaces-DYcfvKV_.js +229 -0
- package/dist/chunks/workspaces-DYcfvKV_.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 +441 -25418
- package/dist/cli.js.map +1 -1
- package/dist/client.js +144 -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 +184 -0
- package/dist/types/api/control.d.ts +470 -0
- package/dist/types/api/ddns.d.ts +432 -0
- package/dist/types/api/events.d.ts +22 -0
- package/dist/types/api/health.d.ts +28 -0
- package/dist/types/api/logs.d.ts +95 -0
- package/dist/types/api/metrics.d.ts +21 -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 +498 -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 +6095 -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 +86 -0
- package/dist/types/cli/down.d.ts +80 -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 +76 -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 +41 -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 +96 -0
- package/dist/types/cli/usage.d.ts +23 -0
- package/dist/types/cli.d.ts +12 -0
- package/dist/types/client.d.ts +11891 -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 +208 -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 +120 -0
- package/dist/types/config/store.d.ts +145 -0
- package/dist/types/config/workspaces.d.ts +99 -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 +20 -0
- package/dist/types/helpers/daemon-log.d.ts +45 -0
- package/dist/types/helpers/daemon.d.ts +135 -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 +26 -0
- package/dist/types/helpers/event-stream.d.ts +21 -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 +34 -0
- package/dist/types/helpers/paths.d.ts +112 -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/utf8-chunks.d.ts +15 -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 +53 -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 +56 -0
- package/dist/types/providers/nanny-sweep.d.ts +54 -0
- package/dist/types/providers/nanny.d.ts +104 -0
- package/dist/types/providers/port.d.ts +142 -0
- package/dist/types/providers/proc.d.ts +125 -0
- package/dist/types/providers/process.d.ts +78 -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 +74 -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 +65 -0
- package/dist/types/services/acme-challenge.d.ts +44 -0
- package/dist/types/services/auth.d.ts +177 -0
- package/dist/types/services/backups.d.ts +476 -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 +72 -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 +86 -0
- package/dist/types/services/history.d.ts +37 -0
- package/dist/types/services/host-monitor.d.ts +33 -0
- package/dist/types/services/init.d.ts +71 -0
- package/dist/types/services/log-buffer.d.ts +39 -0
- package/dist/types/services/log-files.d.ts +77 -0
- package/dist/types/services/log-relay.d.ts +35 -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 +213 -0
- package/dist/types/services/proxy-certificates/certificates.d.ts +116 -0
- package/dist/types/services/proxy-config.d.ts +83 -0
- package/dist/types/services/proxy.d.ts +431 -0
- package/dist/types/services/state.d.ts +38 -0
- package/dist/types/services/supervisor/compose.d.ts +17 -0
- package/dist/types/services/supervisor/entry.d.ts +149 -0
- package/dist/types/services/supervisor/health.d.ts +56 -0
- package/dist/types/services/supervisor/output.d.ts +126 -0
- package/dist/types/services/supervisor/pending-load.d.ts +6 -0
- package/dist/types/services/supervisor/persistent.d.ts +58 -0
- package/dist/types/services/supervisor/port-preflight.d.ts +45 -0
- package/dist/types/services/supervisor/records.d.ts +118 -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 +145 -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/action-outcome.d.ts +25 -0
- package/dist/types/shared/api-client.d.ts +351 -0
- package/dist/types/shared/backup-scope.d.ts +167 -0
- package/dist/types/shared/clone.d.ts +14 -0
- package/dist/types/shared/contracts.d.ts +4175 -0
- package/dist/types/shared/cpu-scale.d.ts +25 -0
- package/dist/types/shared/ddns-form.d.ts +75 -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/form-repair.d.ts +6 -0
- package/dist/types/shared/generated.d.ts +26 -0
- package/dist/types/shared/host-readings.d.ts +185 -0
- package/dist/types/shared/lazy.d.ts +4 -0
- package/dist/types/shared/live-frames.d.ts +22 -0
- package/dist/types/shared/live-series.d.ts +21 -0
- package/dist/types/shared/live-store.d.ts +72 -0
- package/dist/types/shared/patch-diff.d.ts +105 -0
- package/dist/types/shared/probe-latency.d.ts +25 -0
- package/dist/types/shared/proxy-form.d.ts +184 -0
- package/dist/types/shared/server-attention.d.ts +37 -0
- package/dist/types/shared/server-form.d.ts +121 -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/stream-access.d.ts +20 -0
- package/dist/types/shared/ui-format.d.ts +89 -0
- package/docs/API.md +209 -0
- package/docs/BACKUPS.md +117 -0
- package/docs/CLI.md +95 -0
- package/docs/DDNS.md +11 -1
- package/docs/NOTIFICATIONS.md +7 -1
- package/docs/REVERSE_PROXY.md +9 -3
- package/docs/SECURITY.md +93 -0
- package/docs/SERVERS.md +141 -34
- package/docs/UI_CREATION.md +91 -291
- package/docs/demo/blank-host-restore.sh +4 -3
- package/package.json +22 -14
- package/uis/stock/dist/assets/CopyButton-BUBKRJyY.js +1 -0
- package/uis/stock/dist/assets/GlobalSettingsView-yYMcRWvt.js +1 -0
- package/uis/stock/dist/assets/LogViewer-DIliXy62.js +1 -0
- package/uis/stock/dist/assets/LogsView-B7Z-7RNg.js +1 -0
- package/uis/stock/dist/assets/Modal-DmKa5Qpp.js +39 -0
- package/uis/stock/dist/assets/ProxyView-DvZiNkwb.js +1 -0
- package/uis/stock/dist/assets/ServerDetailView-6idGT_EX.js +2 -0
- package/uis/stock/dist/assets/SettingsShell-CeGtleYI.js +1 -0
- package/uis/stock/dist/assets/SettingsView-BrhJIrmk.js +2 -0
- package/uis/stock/dist/assets/de-BRITeb0H.js +1 -0
- package/uis/stock/dist/assets/es-B2zIEssV.js +1 -0
- package/uis/stock/dist/assets/fr-s0ZOBEqh.js +1 -0
- package/uis/stock/dist/assets/index-C1MehbKy.css +2 -0
- package/uis/stock/dist/assets/index-CnBN54wF.js +15 -0
- package/uis/stock/dist/assets/ja-CU7MR85V.js +1 -0
- package/uis/stock/dist/assets/ko-tL5Me6d-.js +1 -0
- package/uis/stock/dist/assets/ru-92yrvkNJ.js +1 -0
- package/uis/stock/dist/assets/vi-CzvY16k2.js +1 -0
- package/uis/stock/dist/assets/zh-CN-DDwFW_uW.js +1 -0
- package/uis/stock/dist/index.html +3 -2
- package/uis/stock/dist/ui.json +3 -3
- package/docs/RESTORE_DEMO.md +0 -306
- package/uis/stock/dist/assets/de-0YLueNal.js +0 -1
- package/uis/stock/dist/assets/es-FCHhRmn2.js +0 -1
- package/uis/stock/dist/assets/fr-C69Z8o0z.js +0 -1
- package/uis/stock/dist/assets/index-Cok5msAO.css +0 -2
- package/uis/stock/dist/assets/index-KdyqrVv8.js +0 -53
- package/uis/stock/dist/assets/ja-Chz9YOqR.js +0 -1
- package/uis/stock/dist/assets/ko-CtXZ2x1l.js +0 -1
- package/uis/stock/dist/assets/ru-D_jE64xN.js +0 -1
- package/uis/stock/dist/assets/vi-sxSffss7.js +0 -1
- package/uis/stock/dist/assets/zh-CN-ChTpf29X.js +0 -1
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/** True when something accepts TCP connections on host:port. */
|
|
2
|
+
export declare function probePort(host: string, port: number, timeoutMs?: number): Promise<boolean>;
|
|
3
|
+
/** A port is free when nothing is listening on it (loopback is enough to detect conflicts). */
|
|
4
|
+
export declare function isPortFree(port: number, host?: string, timeoutMs?: number): Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* Kills whatever holds the port, minus `exclude` (the panel's own process tree).
|
|
7
|
+
* Only used as a last resort for wrappers that spawn their real server detached,
|
|
8
|
+
* where a process-group signal cannot reach it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function killPortHolders(port: number, exclude?: ReadonlySet<number>): Promise<number[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Signal 0 asks the OS whether the pid still exists, without touching it.
|
|
13
|
+
*
|
|
14
|
+
* `EPERM` means the process is there but is **not ours to signal** — a port holder owned by another
|
|
15
|
+
* user is exactly that. Returning `false` for it made `nannyIsAlive` report a live nanny as gone, so
|
|
16
|
+
* `resumePersistent` consumed its state file and started a second copy of the entry while the first ran
|
|
17
|
+
* on untracked. `helpers/daemon.ts` already had this right; the two predicates now agree.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isProcessAlive(pid: number): boolean;
|
|
20
|
+
/** When a process started, and whether it has exited but is not reaped yet. */
|
|
21
|
+
export interface ProcessBirth {
|
|
22
|
+
/** Epoch ms the process started, as the OS reports it. */
|
|
23
|
+
startMs: number;
|
|
24
|
+
/** A zombie: exited, still answering signal 0, and nobody's to signal. */
|
|
25
|
+
zombie: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* `/proc/<pid>/stat` field 22 is the start time in clock ticks since boot, which only
|
|
29
|
+
* becomes an epoch by adding `btime` from `/proc/stat`. Field 3 is the state.
|
|
30
|
+
*
|
|
31
|
+
* The comm field is parenthesised and may itself hold spaces and parentheses, so the
|
|
32
|
+
* fields are counted from after the **last** `)`. Counting from the first would shift
|
|
33
|
+
* every offset for a process whose name contains a `)`, and this value decides whether a
|
|
34
|
+
* live-looking pid is really the daemon.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseProcBirth(content: string, btimeSeconds: number, hz?: number): ProcessBirth | null;
|
|
37
|
+
/**
|
|
38
|
+
* One `ps -o state=,lstart=` row, e.g. `S Wed Oct 7 19:43:26 2026` (macOS, other POSIX).
|
|
39
|
+
* The leading weekday is stripped before parsing: `Date.parse` is not obliged to accept it
|
|
40
|
+
* and it says nothing the date does not.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parsePsBirth(output: string): ProcessBirth | null;
|
|
43
|
+
/**
|
|
44
|
+
* FILETIME ticks (100ns since **1601**, UTC) to a Unix epoch in ms — the shape
|
|
45
|
+
* `DateTime.ToFileTimeUtc()` returns.
|
|
46
|
+
*
|
|
47
|
+
* The epoch matters: `DateTime.Ticks` counts from **0001**, not 1601, and the two differ by
|
|
48
|
+
* 1600 years. Reading the wrong one put every Windows panel ~1600 years in the future, which
|
|
49
|
+
* `processLiveness` then called `recycled` — a live panel that could never signal-stop itself.
|
|
50
|
+
* The PowerShell call below therefore asks for `ToFileTimeUtc()` explicitly, and this is exported
|
|
51
|
+
* so the conversion is pinned by a test.
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseFiletime(ticks: number): number | null;
|
|
54
|
+
/**
|
|
55
|
+
* When the pid started, from the platform's own process table. `null` when the platform
|
|
56
|
+
* cannot say — an unreadable `/proc`, no `ps`, or no PowerShell — which the caller must
|
|
57
|
+
* read as "unknown", never as "gone".
|
|
58
|
+
*/
|
|
59
|
+
export declare function processBirth(pid: number): Promise<ProcessBirth | null>;
|
|
60
|
+
/** Is the process at `pid` the one a record stamped `startedAt` describes? */
|
|
61
|
+
export type ProcessLiveness = 'live'
|
|
62
|
+
/** Nothing is running behind the pid: absent, or a zombie nobody has reaped. */
|
|
63
|
+
| 'gone'
|
|
64
|
+
/** A live pid, but born *after* the record was written — the OS recycled it. */
|
|
65
|
+
| 'recycled'
|
|
66
|
+
/** The platform would not report a birth time, so the live pid is all there is to go on. */
|
|
67
|
+
| 'unknown';
|
|
68
|
+
/**
|
|
69
|
+
* A pid is **not** an identity. The OS hands a dead process's pid to an unrelated one later, and a
|
|
70
|
+
* zombie — exited but not yet reaped by its parent — still answers signal 0. So `isProcessAlive`
|
|
71
|
+
* alone can report a long-dead daemon as live, which is what let `up` say "already running" and
|
|
72
|
+
* `status` say "running, but not answering" against a stale `run.json`, and what let `down` signal
|
|
73
|
+
* whatever stranger had inherited the pid.
|
|
74
|
+
*
|
|
75
|
+
* `startedAt` settles it in one direction, with no threshold to guess at: the daemon writes its
|
|
76
|
+
* record *during its own boot*, so its process is necessarily born **before** that stamp. A pid born
|
|
77
|
+
* after it is not that process, whoever else it now is. The comparison is deliberately one-sided —
|
|
78
|
+
* the other direction would have to tell a recycled pid from a wall clock that merely moved, and it
|
|
79
|
+
* cannot, so a record is never called stale for being *older* than its process.
|
|
80
|
+
*
|
|
81
|
+
* `'unknown'` is not `'gone'`: a platform that cannot report a birth time must not have its live pid
|
|
82
|
+
* dismissed, or a running panel's record would be cleared out from under it.
|
|
83
|
+
*/
|
|
84
|
+
export declare function processLiveness(pid: number, startedAt: number, options?: {
|
|
85
|
+
toleranceMs?: number;
|
|
86
|
+
readBirth?: (pid: number) => Promise<ProcessBirth | null>;
|
|
87
|
+
}): Promise<ProcessLiveness>;
|
|
88
|
+
/**
|
|
89
|
+
* Asks specific pids to leave, politely first: a stray dev server stops on
|
|
90
|
+
* SIGTERM, and only what ignores it is killed. Deciding *which* pids may be
|
|
91
|
+
* touched belongs to the caller — this only does the signalling.
|
|
92
|
+
*/
|
|
93
|
+
export declare function terminatePids(pids: number[], options?: {
|
|
94
|
+
graceMs?: number;
|
|
95
|
+
}): Promise<{
|
|
96
|
+
stopped: number[];
|
|
97
|
+
forced: number[];
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* One filtered `netstat` per family. `-p TCP` alone lists IPv4 only, while Node's default `listen()`
|
|
101
|
+
* binds `[::]`; an unfiltered `-ano` lists every connection and UDP socket, which is slow enough on a
|
|
102
|
+
* busy machine to hit the lookup's timeout — and a timeout reads as "nothing holds the port".
|
|
103
|
+
*/
|
|
104
|
+
export declare const NETSTAT_LISTENER_ARGS: ReadonlyArray<readonly string[]>;
|
|
105
|
+
/** `netstat -ano` lines: ` TCP 127.0.0.1:4010 0.0.0.0:0 LISTENING 1234`; UDP rows are skipped. */
|
|
106
|
+
export declare function parseNetstatListeners(output: string, port: number): number[];
|
|
107
|
+
/**
|
|
108
|
+
* The container publishing a host port, when docker is holding it.
|
|
109
|
+
*
|
|
110
|
+
* A published port is bound by `docker-proxy`, which runs as **root** — so `lsof`/`fuser` return
|
|
111
|
+
* nothing for it, and `listPortHolders` reports an empty list for a port that is plainly refusing
|
|
112
|
+
* every bind. Docker itself answers the question without privileges, and names the stack too, so
|
|
113
|
+
* the caller can say *whose* stack it is instead of "nothing is listening".
|
|
114
|
+
*/
|
|
115
|
+
export interface DockerPortHolder {
|
|
116
|
+
/** `com.docker.compose.project.working_dir` when the container came from compose. */
|
|
117
|
+
composeDir: string | null;
|
|
118
|
+
/** `com.docker.compose.project`, so a caller can tell this entry's own stack from a stranger's. */
|
|
119
|
+
project: string | null;
|
|
120
|
+
container: string;
|
|
121
|
+
port: number;
|
|
122
|
+
}
|
|
123
|
+
export declare function findDockerPortHolder(port: number): Promise<DockerPortHolder | null>;
|
|
124
|
+
/**
|
|
125
|
+
* Stops the container publishing a host port, which is how docker's port is freed.
|
|
126
|
+
*
|
|
127
|
+
* The socket belongs to a root-owned `docker-proxy`, so there is no pid this process may signal —
|
|
128
|
+
* but the container is the panel's to stop through docker itself, which needs no privileges
|
|
129
|
+
* beyond the socket the user already has. `docker stop` releases the published port and leaves the
|
|
130
|
+
* stack's other services alone.
|
|
131
|
+
*/
|
|
132
|
+
export declare function releaseDockerPort(holder: DockerPortHolder, timeoutMs?: number): Promise<boolean>;
|
|
133
|
+
export declare function listPortHolders(port: number): Promise<number[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Pids from `lsof -ti` (one per line) or `fuser` (space-separated, on one line, with a leading
|
|
136
|
+
* space) — both shapes arrive here, which is why the split is on `\s+` rather than `\n`.
|
|
137
|
+
*
|
|
138
|
+
* Exported for its test: this feeds `killPortHolders`, which sends SIGKILL, so a parser that
|
|
139
|
+
* picked up the wrong number would kill an unrelated process. The filter is not decorative —
|
|
140
|
+
* `Number.parseInt('')` is NaN for the empty leading cell, and a pid of 0 or our own is dropped.
|
|
141
|
+
*/
|
|
142
|
+
export declare function parsePids(stdout: string): number[];
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { ProcessResources } from '../shared/contracts.js';
|
|
2
|
+
interface ProcRow {
|
|
3
|
+
pid: number;
|
|
4
|
+
ppid: number;
|
|
5
|
+
rssKb: number;
|
|
6
|
+
/** Cumulative CPU seconds, when the platform reports it (Linux, Windows). */
|
|
7
|
+
cpuSeconds?: number;
|
|
8
|
+
/** Instantaneous/decaying CPU percent, when the platform reports it (macOS). */
|
|
9
|
+
cpuPercent?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function parsePsOutput(text: string): ProcRow[];
|
|
12
|
+
/** CSV from `Get-CimInstance ... | ConvertTo-Csv`, or wmic's `/format:csv`. */
|
|
13
|
+
export declare function parseWindowsCsv(text: string): ProcRow[];
|
|
14
|
+
/** Test hook: how many real process-table scans have run. */
|
|
15
|
+
export declare function processScanCount(): number;
|
|
16
|
+
/** Test hook: the next read scans afresh. */
|
|
17
|
+
export declare function forgetProcessScan(): void;
|
|
18
|
+
/**
|
|
19
|
+
* CPU time a tree used over one interval, from per-pid cumulative counters.
|
|
20
|
+
*
|
|
21
|
+
* Pure, and separated from the scan because this is where both CPU bugs lived — and a scan of the
|
|
22
|
+
* live process table cannot pin arithmetic that depends on a child appearing or vanishing between
|
|
23
|
+
* two reads.
|
|
24
|
+
*
|
|
25
|
+
* `previous` is the **whole process table** of the prior scan, not just this tree: that is what
|
|
26
|
+
* lets a process which joins the tree later be charged only its interval, and what the caller
|
|
27
|
+
* guarantees.
|
|
28
|
+
*
|
|
29
|
+
* Three rules make the answer a real interval:
|
|
30
|
+
*
|
|
31
|
+
* - A pid in both maps contributes the difference. `next >= previous` is required: a recycled pid
|
|
32
|
+
* reports less than the process that used to hold it, and that is not a delta.
|
|
33
|
+
* - A pid only in `next` was **born inside the window**, so its whole counter accrued in it.
|
|
34
|
+
* - A pid only in `previous` **exited inside the window**; its time is already accounted for by the
|
|
35
|
+
* samples where it was alive, and it contributes nothing. The old code summed the tree on both
|
|
36
|
+
* sides, so an exit made the total *drop*, the delta went negative and the reading was discarded
|
|
37
|
+
* — the gap. Summing only pids present in `next` is what removes it.
|
|
38
|
+
*
|
|
39
|
+
* `null` when the map has nothing usable, so a caller reports "unknown" instead of `0`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function treeCpuUsedSeconds(previous: Map<number, number>, next: Map<number, number>, treePids: number[]): number | null;
|
|
42
|
+
/**
|
|
43
|
+
* The same walk, keeping *which root* each pid belongs to.
|
|
44
|
+
*
|
|
45
|
+
* A refusal has to name the server to go and stop, and a pid on its own is not that: the panel
|
|
46
|
+
* supervised 14 entries and told the operator "held by pid 135113, which this panel supervises —
|
|
47
|
+
* stop that server instead", with no way to tell which of the 14 it meant. The tree loses that
|
|
48
|
+
* fact, so the attribution is collected here, where the walk already happens, rather than by a
|
|
49
|
+
* second scan.
|
|
50
|
+
*
|
|
51
|
+
* Ownership has to mean the *tree*: a persistent entry runs under a nanny, and a wrapper entry
|
|
52
|
+
* spawns the real server one generation down. Both keep the pid the panel recorded, but the process
|
|
53
|
+
* holding the port is a descendant of it — and a descendant classified as a stranger is one
|
|
54
|
+
* `kill`/`free-port` away from stopping a server this panel is responsible for.
|
|
55
|
+
*
|
|
56
|
+
* A backend that cannot run answers with the roots alone, which is the old, narrower behaviour
|
|
57
|
+
* rather than a wrong one.
|
|
58
|
+
*
|
|
59
|
+
* When two roots are nested, the ancestor keeps the pid: it is the older claim and still true.
|
|
60
|
+
*/
|
|
61
|
+
export declare function processTreeOwners(roots: number[]): Promise<Map<number, number>>;
|
|
62
|
+
/**
|
|
63
|
+
* Samples CPU and RSS for a process *and its descendants*.
|
|
64
|
+
*
|
|
65
|
+
* Descendants matter: a wrapper that spawns the real server detached owns the
|
|
66
|
+
* tree, and only the tree's RSS means anything.
|
|
67
|
+
*
|
|
68
|
+
* Backends: `/proc` on Linux, `ps` on macOS/other POSIX, and Win32_Process via
|
|
69
|
+
* PowerShell (wmic as a fallback) on Windows. When a backend cannot run, samples
|
|
70
|
+
* are null rather than wrong.
|
|
71
|
+
*/
|
|
72
|
+
export declare class ProcessSampler {
|
|
73
|
+
private readonly reuseMs;
|
|
74
|
+
/** `reuseMs`: accept a process scan this recent from any sampler (0 = always scan fresh). */
|
|
75
|
+
constructor(reuseMs?: number);
|
|
76
|
+
/**
|
|
77
|
+
* Cumulative CPU seconds per pid, from the **whole process table** of the last scan.
|
|
78
|
+
*
|
|
79
|
+
* A tree is not a fixed set of processes: a wrapper spawns and reaps children continuously, so
|
|
80
|
+
* "the sum over whatever is in the tree now" is not comparable with the previous sum. Measuring
|
|
81
|
+
* that rule against a wrapper respawning a 1.5 s worker, **two samples in every three were
|
|
82
|
+
* discarded**: the child's exit made the sum drop, the delta went negative, and the reading was
|
|
83
|
+
* thrown away — the gaps a person sees on a live server.
|
|
84
|
+
*
|
|
85
|
+
* Baselining every pid the scan saw, rather than only the tree's, is what makes each delta a
|
|
86
|
+
* real interval. A process that was already running has a previous counter even if it only
|
|
87
|
+
* joined this tree afterwards, so it cannot be charged its whole lifetime; and a pid absent from
|
|
88
|
+
* the previous scan was born inside the window, so its counter really did accrue in it.
|
|
89
|
+
*/
|
|
90
|
+
private previousTable;
|
|
91
|
+
/**
|
|
92
|
+
* Roots whose next sample must not be differenced, stamped with when they were forgotten.
|
|
93
|
+
*
|
|
94
|
+
* `forget` is called when an entry stops, exits or is restarted: the pid is gone, so the reading
|
|
95
|
+
* after it must be `null` rather than a delta against a previous life. The baseline is one table
|
|
96
|
+
* for the whole scan, so this is the per-root suppression. Pruned at each scan, which bounds it
|
|
97
|
+
* to the restarts that happened since the last one.
|
|
98
|
+
*/
|
|
99
|
+
private readonly forgotten;
|
|
100
|
+
/** Each root's latest reading, answered again when the only scan available is one already used. */
|
|
101
|
+
private readonly lastReadings;
|
|
102
|
+
sample(rootPid: number, now?: number): Promise<ProcessResources | null>;
|
|
103
|
+
sampleMany(rootPids: number[], now?: number): Promise<Map<number, ProcessResources | null>>;
|
|
104
|
+
/**
|
|
105
|
+
* Marks a root's next reading as the first of a new life.
|
|
106
|
+
*
|
|
107
|
+
* Called when an entry stops, exits or is restarted. Without it a recycled pid — or the very
|
|
108
|
+
* next sample of the same root — would be differenced against a counter from the previous run,
|
|
109
|
+
* which is not an interval. The scan-wide table cannot be cleared per root, so the suppression
|
|
110
|
+
* is remembered here and consumed by that root's next sample.
|
|
111
|
+
*/
|
|
112
|
+
forget(rootPid: number): void;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Does this process carry the environment the supervisor gave the entry?
|
|
116
|
+
*
|
|
117
|
+
* A program that restarts itself — especially a plugin doing it — leaves behind a
|
|
118
|
+
* detached process that still inherits `HHOSTED_SERVER_ID`, and that marker is what
|
|
119
|
+
* tells a legitimate successor apart from a stranger squatting on the port.
|
|
120
|
+
*
|
|
121
|
+
* Linux reads `/proc`; macOS asks `ps -E`; Windows has no per-process environment,
|
|
122
|
+
* so the answer is always "no" there and ownership falls back to the port policy.
|
|
123
|
+
*/
|
|
124
|
+
export declare function processCarriesServerId(pid: number, serverId: string): Promise<boolean>;
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ChildProcess } from 'node:child_process';
|
|
2
|
+
export interface SpawnSpec {
|
|
3
|
+
command: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
cwd: string;
|
|
6
|
+
env: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a bare command through the entry's own directory and the project's
|
|
10
|
+
* `node_modules/.bin` first, so a server installed as a project dependency is
|
|
11
|
+
* found even when the launcher's PATH has no pnpm-injected bin dir.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveCommand(command: string, ...searchDirs: string[]): string;
|
|
14
|
+
/**
|
|
15
|
+
* Does this program exist where `spawn` would look it up, and where?
|
|
16
|
+
*
|
|
17
|
+
* Used only to tell a **pasted command line** apart from a missing program: `spawn` answers both
|
|
18
|
+
* with the same `ENOENT`, and the two have opposite fixes. `null` means it was not found anywhere
|
|
19
|
+
* this process would search.
|
|
20
|
+
*
|
|
21
|
+
* A bare name is searched on `PATH` (plus `.exe`/`.cmd`/`.bat` on Windows, because that is what
|
|
22
|
+
* the OS appends); anything with a separator is a path and is stat'd as written.
|
|
23
|
+
*/
|
|
24
|
+
export declare function findProgram(command: string, cwd?: string): string | null;
|
|
25
|
+
/** Relative entry paths belong to the project that launched the panel. */
|
|
26
|
+
export declare function resolveCwd(cwd: string, base?: string): string;
|
|
27
|
+
/** Node cannot spawn a Windows `.cmd`/`.bat` shim without a shell (EINVAL). */
|
|
28
|
+
export declare function needsShell(command: string): boolean;
|
|
29
|
+
export interface SpawnOptions {
|
|
30
|
+
/**
|
|
31
|
+
* A supervised child gets its own process group, so one `kill(-pid)` stops the tree.
|
|
32
|
+
* A child spawned by a nanny does not: it shares the nanny's group, which is the
|
|
33
|
+
* group the panel signals — so the same one-signal semantics still reach both.
|
|
34
|
+
*/
|
|
35
|
+
detached?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Open descriptors for the child's output, instead of a pipe this process reads.
|
|
38
|
+
*
|
|
39
|
+
* A pipe makes this process its **read end**, so the child does not survive us: kill the panel,
|
|
40
|
+
* the read end closes, and the child's next write to stdout fails with `EPIPE` — which ends a
|
|
41
|
+
* process that was supposed to outlive the panel. A file the child opens takes this process out of
|
|
42
|
+
* the chain: the descriptor belongs to the child, and the panel reads the bytes back afterwards.
|
|
43
|
+
*
|
|
44
|
+
* The caller owns these (it opens them with `openOutput` and closes its own copies after the
|
|
45
|
+
* spawn); `spawn` duplicates them onto the child's table.
|
|
46
|
+
*/
|
|
47
|
+
output?: {
|
|
48
|
+
stdout: number;
|
|
49
|
+
stderr: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export declare function spawnManaged(spec: SpawnSpec, options?: SpawnOptions): ChildProcess;
|
|
53
|
+
export interface TerminateOptions {
|
|
54
|
+
signal: NodeJS.Signals;
|
|
55
|
+
killGroup: boolean;
|
|
56
|
+
graceMs: number;
|
|
57
|
+
/** The SIGKILL escalation reaches the group even when the graceful signal went to the pid alone. */
|
|
58
|
+
escalateGroup?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** SIGTERM (default) to the child, escalating to SIGKILL after the grace period. */
|
|
61
|
+
export declare function terminate(child: ChildProcess, options: TerminateOptions): Promise<'exited' | 'force-killed'>;
|
|
62
|
+
/**
|
|
63
|
+
* Windows has no process groups and no SIGTERM: `taskkill /T` walks the tree and
|
|
64
|
+
* `/F` is the only reliable way to stop a console process.
|
|
65
|
+
*/
|
|
66
|
+
export declare function killTreeWindows(pid: number): Promise<void>;
|
|
67
|
+
/** SIGKILL to a `spawnManaged` child and everything it started: its group, or its tree on Windows. */
|
|
68
|
+
export declare function forceKillTree(child: ChildProcess): void;
|
|
69
|
+
/**
|
|
70
|
+
* The same shutdown a supervised child gets, for a process we adopted instead of
|
|
71
|
+
* spawned: a detached successor is not our child, so it is signalled by pid (and
|
|
72
|
+
* by process group when asked) and its exit is polled rather than awaited.
|
|
73
|
+
*
|
|
74
|
+
* Liveness comes from `isProcessAlive`, never a local signal-0 copy: a second definition returned
|
|
75
|
+
* `false` for `EPERM`, so a process that was there but not ours to signal read as "exited" and
|
|
76
|
+
* `'force-killed'` was returned for one still running. One predicate, one answer.
|
|
77
|
+
*/
|
|
78
|
+
export declare function terminatePid(pid: number, options: TerminateOptions): Promise<'exited' | 'force-killed'>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ProxyEngine } from './types.js';
|
|
2
|
+
import type { ProxyEngineInfo } from '../../shared/contracts.js';
|
|
3
|
+
/** Registry order is what the page offers; one engine ships today. */
|
|
4
|
+
export declare const PROXY_ENGINES: readonly ProxyEngine[];
|
|
5
|
+
export declare function proxyEngine(id: string): ProxyEngine | null;
|
|
6
|
+
export declare function proxyEngineInfos(): ProxyEngineInfo[];
|
|
7
|
+
export type { ProxyAdminTransport, ProxyEngine, ProxyEngineDownload, ProxyEngineRun, ProxyEngineTarget } from './types.js';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ProxyEngineInfo } from '../../shared/contracts.js';
|
|
2
|
+
/**
|
|
3
|
+
* How the panel reaches a running engine's admin endpoint. A unix socket is the
|
|
4
|
+
* default where there is one — the engine's admin API is unauthenticated, so file
|
|
5
|
+
* permissions are the only real control. Windows gets loopback TCP plus the
|
|
6
|
+
* engine's own origin check, which the client must then satisfy.
|
|
7
|
+
*/
|
|
8
|
+
export type ProxyAdminTransport = {
|
|
9
|
+
kind: 'unix';
|
|
10
|
+
path: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'tcp';
|
|
13
|
+
host: string;
|
|
14
|
+
port: number;
|
|
15
|
+
origin: string;
|
|
16
|
+
};
|
|
17
|
+
export interface ProxyEngineTarget {
|
|
18
|
+
platform: NodeJS.Platform;
|
|
19
|
+
arch: string;
|
|
20
|
+
/** The release to install; empty asks for the build service's current one. */
|
|
21
|
+
version: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ProxyEngineDownload {
|
|
24
|
+
url: string;
|
|
25
|
+
/**
|
|
26
|
+
* The release that was asked for; empty when the current one was. What actually
|
|
27
|
+
* arrived is read from the binary, never assumed from this.
|
|
28
|
+
*/
|
|
29
|
+
version: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ProxyEngineRun {
|
|
32
|
+
/** The generated configuration the engine boots from. */
|
|
33
|
+
configPath: string;
|
|
34
|
+
/** The directory the engine may write inside; nothing else is its. */
|
|
35
|
+
engineDir: string;
|
|
36
|
+
admin: ProxyAdminTransport;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One reverse-proxy engine. Deliberately thin: the route model is the panel's,
|
|
40
|
+
* so an engine only has to say where it comes from and how to start it.
|
|
41
|
+
*/
|
|
42
|
+
export interface ProxyEngine {
|
|
43
|
+
readonly info: ProxyEngineInfo;
|
|
44
|
+
/** The platform's executable name for this engine. */
|
|
45
|
+
binaryName: (platform: NodeJS.Platform) => string;
|
|
46
|
+
/** Where to fetch it; `null` when this platform is not supported. */
|
|
47
|
+
download: (target: ProxyEngineTarget) => ProxyEngineDownload | null;
|
|
48
|
+
/** The argument vector that runs it against the generated config. */
|
|
49
|
+
runArgs: (run: ProxyEngineRun) => string[];
|
|
50
|
+
/** Environment keeping its data inside `engineDir` on this platform. */
|
|
51
|
+
env: (run: ProxyEngineRun) => Record<string, string>;
|
|
52
|
+
/** Reads a version out of the engine's own `version` output. */
|
|
53
|
+
parseVersion: (output: string) => string | null;
|
|
54
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TemplateVars } from '../helpers/template.js';
|
|
2
|
+
import type { ServerConfig } from '../shared/contracts.js';
|
|
3
|
+
/** The `{placeholder}` values an entry's args, env and hooks expand — the table in `docs/SERVERS.md`. */
|
|
4
|
+
export declare function serverTemplateVars(config: ServerConfig): TemplateVars;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** A Bot API refusal, shaped like Telegram's own error body so `describeTelegramError` reads it. */
|
|
2
|
+
export declare class TelegramApiError extends Error {
|
|
3
|
+
readonly description: string;
|
|
4
|
+
readonly error_code: number;
|
|
5
|
+
readonly parameters?: {
|
|
6
|
+
retry_after?: number;
|
|
7
|
+
} | undefined;
|
|
8
|
+
name: string;
|
|
9
|
+
constructor(description: string, error_code: number, parameters?: {
|
|
10
|
+
retry_after?: number;
|
|
11
|
+
} | undefined);
|
|
12
|
+
}
|
|
13
|
+
export interface TelegramUser {
|
|
14
|
+
id: number;
|
|
15
|
+
is_bot: boolean;
|
|
16
|
+
first_name: string;
|
|
17
|
+
username?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface TelegramChatRef {
|
|
20
|
+
id: number;
|
|
21
|
+
type: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
username?: string;
|
|
24
|
+
first_name?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TelegramUpdate {
|
|
27
|
+
update_id: number;
|
|
28
|
+
message?: {
|
|
29
|
+
chat: TelegramChatRef;
|
|
30
|
+
};
|
|
31
|
+
channel_post?: {
|
|
32
|
+
chat: TelegramChatRef;
|
|
33
|
+
};
|
|
34
|
+
edited_message?: {
|
|
35
|
+
chat: TelegramChatRef;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface TelegramBot {
|
|
39
|
+
api: {
|
|
40
|
+
sendMessage: (chatId: string, text: string, options?: Record<string, unknown>) => Promise<unknown>;
|
|
41
|
+
getMe: () => Promise<TelegramUser>;
|
|
42
|
+
getUpdates: (options?: Record<string, unknown>) => Promise<TelegramUpdate[]>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export declare function getBot(token: string): TelegramBot;
|
|
46
|
+
export declare function forgetBots(): void;
|
|
47
|
+
export declare function escapeHtml(value: string): string;
|
|
48
|
+
export declare function formatTelegramMessage(title: string, lines: string[]): string;
|
|
49
|
+
export interface TelegramOutcome {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
error?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Turns a grammY error into something worth showing in the settings page. */
|
|
54
|
+
export declare function describeTelegramError(error: unknown): string;
|
|
55
|
+
export declare function sendTelegramMessage(token: string, chatId: string, html: string): Promise<TelegramOutcome>;
|
|
56
|
+
export declare function verifyTelegramToken(token: string): Promise<{
|
|
57
|
+
ok: boolean;
|
|
58
|
+
username?: string;
|
|
59
|
+
error?: string;
|
|
60
|
+
}>;
|
|
61
|
+
export interface TelegramChat {
|
|
62
|
+
id: number | string;
|
|
63
|
+
title: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Recent chats that talked to the bot, so a chat id can be picked instead of
|
|
67
|
+
* hunted down by hand. Telegram only reports chats with pending updates, so the
|
|
68
|
+
* caller is told to message the bot first.
|
|
69
|
+
*/
|
|
70
|
+
export declare function listTelegramChats(token: string): Promise<{
|
|
71
|
+
ok: boolean;
|
|
72
|
+
chats: TelegramChat[];
|
|
73
|
+
error?: string;
|
|
74
|
+
}>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The GitHub-release side of installing a UI: which repo, which tag, which asset, how
|
|
3
|
+
* to read the release metadata and how to download one. `ui-switch` picks a release by
|
|
4
|
+
* hand and `ui-update` follows what an installed UI declared, but both go through this
|
|
5
|
+
* one implementation — the failure messages and the asset matching are the same problem.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_REPO = "NamesMT/home-hosted";
|
|
8
|
+
/** Mirrors the cap `UiService` enforces uncompressed — the same body, before it is parsed. */
|
|
9
|
+
export declare const MAX_DOWNLOAD_BYTES: number;
|
|
10
|
+
export interface RepoSlug {
|
|
11
|
+
owner: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
export interface GithubAsset {
|
|
15
|
+
name?: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
browser_download_url?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface GithubRelease {
|
|
20
|
+
tag_name?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
draft?: boolean;
|
|
23
|
+
prerelease?: boolean;
|
|
24
|
+
published_at?: string;
|
|
25
|
+
assets?: GithubAsset[];
|
|
26
|
+
}
|
|
27
|
+
/** What both commands need from the CLI that owns the readline prompts and the colours. */
|
|
28
|
+
export interface UiSourceIo {
|
|
29
|
+
write: (text: string) => void;
|
|
30
|
+
prompt?: (question: string) => Promise<string>;
|
|
31
|
+
style: {
|
|
32
|
+
bold: (text: string) => string;
|
|
33
|
+
dim: (text: string) => string;
|
|
34
|
+
green: (text: string) => string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface UiSourceContext {
|
|
38
|
+
io: UiSourceIo;
|
|
39
|
+
version: string;
|
|
40
|
+
token: string | null;
|
|
41
|
+
/** Suppress progress lines: the startup hook runs with nobody watching. */
|
|
42
|
+
quiet?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** `owner/name`, the only slug GitHub releases are addressed by. */
|
|
45
|
+
export declare function parseRepoSlug(value: string): RepoSlug | null;
|
|
46
|
+
export declare function repoSlug(repo: RepoSlug): string;
|
|
47
|
+
/** The repo the default tag rule is about; `DEFAULT_REPO` is its only definition. */
|
|
48
|
+
export declare function isOwnRepo(repo: RepoSlug): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Our own release tag matches this CLI's version, so a UI is paired with the panel
|
|
51
|
+
* it was built for. Another repo has no such pairing, so its latest release is used.
|
|
52
|
+
* `null` means "latest".
|
|
53
|
+
*/
|
|
54
|
+
export declare function defaultReleaseTag(repo: RepoSlug, version: string): string | null;
|
|
55
|
+
export declare function releaseApiUrl(repo: RepoSlug, tag: string | null): string;
|
|
56
|
+
/** Every published release, newest first, as GitHub orders them. */
|
|
57
|
+
export declare function releasesApiUrl(repo: RepoSlug, perPage?: number): string;
|
|
58
|
+
/** Generous and predictable: a UI bundle is an asset whose name ends in `.zip`. */
|
|
59
|
+
export declare function isUiAsset(name: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Resolves a wanted asset: an exact name, a case-insensitive name, or a single
|
|
62
|
+
* unambiguous substring (`--asset stock` for `home-hosted-ui-stock.zip`).
|
|
63
|
+
*/
|
|
64
|
+
export declare function matchAsset(names: readonly string[], query: string): {
|
|
65
|
+
ok: true;
|
|
66
|
+
name: string;
|
|
67
|
+
} | {
|
|
68
|
+
ok: false;
|
|
69
|
+
error: string;
|
|
70
|
+
};
|
|
71
|
+
/** `^https?://` means a URL; anything else is a filesystem path with `~` expanded. */
|
|
72
|
+
export declare function parseFileSource(value: string): {
|
|
73
|
+
kind: 'url';
|
|
74
|
+
url: string;
|
|
75
|
+
} | {
|
|
76
|
+
kind: 'path';
|
|
77
|
+
path: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* A token is only ever sent to GitHub: `--file <url>` may point anywhere, and a
|
|
81
|
+
* credential must not leak to a host the user did not vouch for.
|
|
82
|
+
*/
|
|
83
|
+
export declare function isGithubHost(url: string): boolean;
|
|
84
|
+
/** What `UiService` names the install when the archive carries no `ui.json`. */
|
|
85
|
+
export declare function fallbackUiName(source: string): string;
|
|
86
|
+
/** One release's assets, or a message that says what was wrong with the answer. */
|
|
87
|
+
export declare function fetchRelease(repo: RepoSlug, tag: string | null, context: UiSourceContext): Promise<{
|
|
88
|
+
tag: string;
|
|
89
|
+
assets: GithubAsset[];
|
|
90
|
+
}>;
|
|
91
|
+
/** Every published release, newest first. Drafts and unusable entries are dropped. */
|
|
92
|
+
export declare function fetchReleases(repo: RepoSlug, context: UiSourceContext, perPage?: number): Promise<Array<{
|
|
93
|
+
tag: string;
|
|
94
|
+
assets: GithubAsset[];
|
|
95
|
+
publishedAt: string | null;
|
|
96
|
+
}>>;
|
|
97
|
+
export declare function assetDownloadUrl(asset: GithubAsset): string;
|
|
98
|
+
/** Streams to `os.tmpdir()` so a large body is never buffered in memory. */
|
|
99
|
+
export declare function downloadToTemp(url: string, headers: Record<string, string>, context: UiSourceContext): Promise<{
|
|
100
|
+
dir: string;
|
|
101
|
+
file: string;
|
|
102
|
+
}>;
|
|
103
|
+
export declare function apiHeaders(context: UiSourceContext): Record<string, string>;
|
|
104
|
+
export declare function noAssetsMessage(where: string, skipped: string[], tag: string | null): string;
|
|
105
|
+
export declare function describeReleaseFailure(status: number, repo: RepoSlug, tag: string | null): string;
|
|
106
|
+
export declare function formatBytes(bytes: number): string;
|
|
107
|
+
export declare function describeError(error: unknown): string;
|
|
108
|
+
/**
|
|
109
|
+
* Tag ordering: `v1.2.3` beats `v1.2.2`, a prerelease loses to its release, and anything
|
|
110
|
+
* that is not a version sorts below every version that is. Enough to answer "is this
|
|
111
|
+
* release newer than the one the UI came from" without a semver dependency.
|
|
112
|
+
*/
|
|
113
|
+
export declare function compareTags(a: string, b: string): number;
|