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 @@
|
|
|
1
|
+
{"version":3,"file":"usage-CSBgLRN5.js","names":[],"sources":["../../src/cli/usage.ts"],"sourcesContent":["import process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { bold, dim, fail, invocation, paint } from '#src/cli/io'\nimport { errorMessage } from '#src/shared/error-message'\n\n/**\n * `usage` answers \"which of my servers is eating the machine\" without a browser.\n *\n * It reads one server's live CPU and memory from the panel it supervises, over the same local\n * token-plus-loopback channel `down` uses — no session, no API token, and no new `/api` route. An\n * entry with no sample says so instead of printing `0`, because a zero on a CPU column reads as\n * \"idle\" and hides a server nobody is measuring.\n */\n\nexport const usageArgs = {\n json: { type: 'boolean', description: 'print machine-readable JSON' },\n} as const\n\ninterface UsageEntry {\n id: string\n workspaceId: string\n label: string\n status: string\n cpuPercent?: number\n rssBytes?: number\n processes?: number\n /** Behaviour over the panel's history window; absent when nothing is known yet. */\n restarts?: number\n crashes?: number\n uptimeRatio?: number\n}\n\n/** Bytes as a short human figure; `MB`/`GB` with one decimal, the unit an operator reads. */\nfunction formatBytes(bytes: number): string {\n const mb = bytes / 1024 / 1024\n if (mb < 1024)\n return `${mb.toFixed(1)} MB`\n return `${(mb / 1024).toFixed(2)} GB`\n}\n\n/** One reading, or a dash — never `0` for something that was not measured. */\nfunction cell(read: number | undefined, render: (value: number) => string): string {\n return read === undefined ? dim('—') : render(read)\n}\n\nexport async function runUsage(input: { json?: boolean }): Promise<void> {\n const { readRuntime, requestControl, runtimeIsAlive, runtimeIsGone, clearRuntime } = await import('#src/helpers/daemon')\n\n const runtime = readRuntime()\n if (runtime === null || !await runtimeIsAlive(runtime)) {\n if (runtime !== null && await runtimeIsGone(runtime))\n clearRuntime()\n fail(`home-hosted is not running — start it with \\`${invocation()} up\\``)\n }\n\n const answer = await requestControl(runtime, '/_hh/usage', 15_000, 'GET')\n if (answer === null)\n fail(`the control panel is not answering on ${runtime.probeUrl}`)\n if (answer.status !== 200)\n fail(`the panel answered ${answer.status} — it may predate this command; restart it on this release`)\n\n const body = (answer.body ?? {}) as { servers?: UsageEntry[], sampledAt?: number }\n const servers = body.servers ?? []\n\n if (input.json === true) {\n process.stdout.write(`${JSON.stringify(body, null, 2)}\\n`)\n return\n }\n\n if (servers.length === 0) {\n process.stdout.write(`${dim('no servers are configured in this panel')}\\n`)\n return\n }\n\n // Sorted loudest first: the question is \"what is eating the machine\", so the answer leads.\n const ranked = [...servers].sort((a, b) => (b.rssBytes ?? 0) - (a.rssBytes ?? 0))\n const rows = ranked.map(entry => [\n entry.workspaceId === 'default' ? entry.id : `${entry.workspaceId}/${entry.id}`,\n entry.status,\n cell(entry.cpuPercent, value => `${value.toFixed(1)}%`),\n cell(entry.rssBytes, formatBytes),\n cell(entry.processes, value => String(value)),\n // The window, not the instant: a flapping entry uses almost nothing at any sample and is\n // still the one thing on this list worth fixing.\n cell(entry.crashes, value => (value === 0 ? dim('0') : paint('31', String(value)))),\n cell(entry.uptimeRatio, value => `${Math.round(value * 100)}%`),\n ])\n\n const headers = ['SERVER', 'STATUS', 'CPU', 'MEMORY', 'PROCS', 'CRASH', 'UP']\n const widths = headers.map((header, index) =>\n Math.max(header.length, ...rows.map(row => (row[index] ?? '').length)))\n const line = (columns: string[]): string =>\n columns.map((column, index) => column.padEnd(widths[index]!)).join(' ').trimEnd()\n\n process.stdout.write(`${bold(line(headers))}\\n`)\n for (const row of rows)\n process.stdout.write(`${line(row)}\\n`)\n\n if (body.sampledAt === undefined)\n process.stdout.write(`${dim('no host sample yet — readings appear once the panel has sampled')}\\n`)\n}\n\nexport const usageCommand = defineCommand({\n meta: { name: 'usage' },\n args: usageArgs,\n async run({ args }) {\n try {\n await runUsage({ json: args.json })\n }\n catch (error) {\n fail(errorMessage(error))\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;AAcA,IAAa,YAAY,EACvB,MAAM;CAAE,MAAM;CAAW,aAAa;AAA8B,EACtE;;AAiBA,SAAS,YAAY,OAAuB;CAC1C,MAAM,KAAK,QAAQ,OAAO;CAC1B,IAAI,KAAK,MACP,OAAO,GAAG,GAAG,QAAQ,CAAC,EAAE;CAC1B,OAAO,IAAI,KAAK,KAAA,CAAM,QAAQ,CAAC,EAAE;AACnC;;AAGA,SAAS,KAAK,MAA0B,QAA2C;CACjF,OAAO,SAAS,KAAA,IAAY,IAAI,GAAG,IAAI,OAAO,IAAI;AACpD;AAEA,eAAsB,SAAS,OAA0C;CACvE,MAAM,EAAE,aAAa,gBAAgB,gBAAgB,eAAe,iBAAiB,MAAM,OAAO;CAElG,MAAM,UAAU,YAAY;CAC5B,IAAI,YAAY,QAAQ,CAAC,MAAM,eAAe,OAAO,GAAG;EACtD,IAAI,YAAY,QAAQ,MAAM,cAAc,OAAO,GACjD,aAAa;EACf,KAAK,gDAAgD,WAAW,EAAE,MAAM;CAC1E;CAEA,MAAM,SAAS,MAAM,eAAe,SAAS,cAAc,MAAQ,KAAK;CACxE,IAAI,WAAW,MACb,KAAK,yCAAyC,QAAQ,UAAU;CAClE,IAAI,OAAO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GAAG,KAAK,KAAK,OAAO,CAAC,EAAE,GAAG;CAC/C,KAAK,MAAM,OAAO,MAChB,QAAQ,OAAO,MAAM,GAAG,KAAK,GAAG,EAAE,GAAG;CAEvC,IAAI,KAAK,cAAc,KAAA,GACrB,QAAQ,OAAO,MAAM,GAAG,IAAI,iEAAiE,EAAE,GAAG;AACtG;AAEA,IAAa,eAAe,cAAc;CACxC,MAAM,EAAE,MAAM,QAAQ;CACtB,MAAM;CACN,MAAM,IAAI,EAAE,QAAQ;EAClB,IAAI;GACF,MAAM,SAAS,EAAE,MAAM,KAAK,KAAK,CAAC;EACpC,SACO,OAAO;GACZ,KAAK,aAAa,KAAK,CAAC;EAC1B;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { t as appVersion } from "../cli.js";
|
|
3
|
+
import { t as writeFileAtomic } from "./atomic-CEfCUfkQ.js";
|
|
4
|
+
import { n as readStateFile } from "./config-text-DifCHhnz.js";
|
|
5
|
+
import { dt as workspaceSchema } from "./contracts-ku5ypHXJ.js";
|
|
6
|
+
import { o as metaSchema } from "./schema-o7Lgk0V1.js";
|
|
7
|
+
import { j as workspacesPath, t as DEFAULT_WORKSPACE_ID } from "./paths-BT94q6-w.js";
|
|
8
|
+
import { type } from "arktype";
|
|
9
|
+
//#region src/config/workspaces.ts
|
|
10
|
+
var workspaces_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
WorkspaceError: () => WorkspaceError,
|
|
12
|
+
WorkspaceRegistry: () => WorkspaceRegistry,
|
|
13
|
+
defaultWorkspaceId: () => defaultWorkspaceId,
|
|
14
|
+
readDefaultWorkspaceId: () => readDefaultWorkspaceId,
|
|
15
|
+
readWorkspaceIds: () => readWorkspaceIds,
|
|
16
|
+
slugifyWorkspaceId: () => slugifyWorkspaceId,
|
|
17
|
+
workspacesFileSchema: () => workspacesFileSchema
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* The workspace registry: which workspaces exist, in the order the selector shows
|
|
21
|
+
* them. Kept apart from any workspace's own files so it can be read before they
|
|
22
|
+
* are, and so creating or removing one is a single small write.
|
|
23
|
+
*/
|
|
24
|
+
var workspacesFileSchema = type({
|
|
25
|
+
$schema: "string?",
|
|
26
|
+
meta: metaSchema.optional(),
|
|
27
|
+
workspaces: workspaceSchema.array()
|
|
28
|
+
}).onUndeclaredKey("reject");
|
|
29
|
+
/**
|
|
30
|
+
* The workspace a command acts in when none was named: `default` if the host declares it, else the
|
|
31
|
+
* first one it declares.
|
|
32
|
+
*
|
|
33
|
+
* **The panel already answers this question, and the CLI was answering a different one.** Every
|
|
34
|
+
* workspace-scoped `/api` and `/_hh` route resolves an omitted `?workspace` through
|
|
35
|
+
* `PanelService.requireWorkspace` → `WorkspaceRegistry.defaultId`, i.e. this rule. The two CLI
|
|
36
|
+
* commands that take a workspace id read `DEFAULT_WORKSPACE_ID` literally instead — so on a host
|
|
37
|
+
* whose registry lists one workspace that is not called `default` (a colleague's panel, or one
|
|
38
|
+
* where `default` was removed), `start <id>` reached that workspace while `logs <id>` looked in
|
|
39
|
+
* `.hh/default/.logs/`, a directory that does not exist. Measured: `logs` answered "no output yet"
|
|
40
|
+
* and exited 0 for a log that was on disk, on the one command a diagnostic session starts with.
|
|
41
|
+
*
|
|
42
|
+
* One function, called by every surface that asks, so a third caller cannot re-derive it.
|
|
43
|
+
*/
|
|
44
|
+
function defaultWorkspaceId(workspaces) {
|
|
45
|
+
return workspaces.find((entry) => entry.id === "default")?.id ?? workspaces[0]?.id ?? "default";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* `defaultWorkspaceId`, for a command that has a registry file and no panel.
|
|
49
|
+
*
|
|
50
|
+
* Tolerant for the same reason the panel's own startup guard is the one that refuses a broken
|
|
51
|
+
* registry: a diagnostic command reading one log must not be the thing that fails loudly about a
|
|
52
|
+
* file it only needed one id from. Missing, unparseable or empty falls back to `default`, which is
|
|
53
|
+
* what the seed declares.
|
|
54
|
+
*/
|
|
55
|
+
function readDefaultWorkspaceId(file) {
|
|
56
|
+
try {
|
|
57
|
+
const parsed = workspacesFileSchema(JSON.parse(readStateFile(file)));
|
|
58
|
+
if (parsed instanceof type.errors || parsed.workspaces.length === 0) return DEFAULT_WORKSPACE_ID;
|
|
59
|
+
return defaultWorkspaceId(parsed.workspaces);
|
|
60
|
+
} catch {
|
|
61
|
+
return DEFAULT_WORKSPACE_ID;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The workspace ids a registry declares — or `null` when it cannot answer.
|
|
66
|
+
*
|
|
67
|
+
* `readDefaultWorkspaceId`'s sibling for a command that must tell "that workspace does not exist"
|
|
68
|
+
* from "I cannot tell": a diagnostic that answers an empty log for a typo'd `--workspace` is the
|
|
69
|
+
* same false answer as one that answers it for a typo'd server id. `null` keeps the caller silent
|
|
70
|
+
* on a registry it could not read, because unreadable is not "it names none".
|
|
71
|
+
*
|
|
72
|
+
* An **empty** registry is `null` too, for the same reason its sibling falls back to `default`: a
|
|
73
|
+
* registry listing nothing is what a hand-edit or a partially written file looks like, and the panel
|
|
74
|
+
* treats it as `default` rather than as "no workspace exists". Answering `[]` there made `logs <id>`
|
|
75
|
+
* refuse the default workspace that `start` and the panel both serve.
|
|
76
|
+
*/
|
|
77
|
+
function readWorkspaceIds(file) {
|
|
78
|
+
try {
|
|
79
|
+
const parsed = workspacesFileSchema(JSON.parse(readStateFile(file)));
|
|
80
|
+
if (parsed instanceof type.errors || parsed.workspaces.length === 0) return null;
|
|
81
|
+
return parsed.workspaces.map((workspace) => workspace.id);
|
|
82
|
+
} catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
var WorkspaceError = class extends Error {
|
|
87
|
+
name = "WorkspaceError";
|
|
88
|
+
code;
|
|
89
|
+
constructor(message, code) {
|
|
90
|
+
super(message);
|
|
91
|
+
this.code = code;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var seed = () => [{
|
|
95
|
+
id: DEFAULT_WORKSPACE_ID,
|
|
96
|
+
label: "Default"
|
|
97
|
+
}];
|
|
98
|
+
/** `My Project AB!` -> `my-project-ab`, and never an empty id. */
|
|
99
|
+
function slugifyWorkspaceId(label, taken = []) {
|
|
100
|
+
const base = label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
|
|
101
|
+
const used = new Set(taken);
|
|
102
|
+
const candidate = base.length > 0 ? base : "workspace";
|
|
103
|
+
if (!used.has(candidate)) return candidate;
|
|
104
|
+
for (let index = 2; index < 1e3; index++) {
|
|
105
|
+
const next = `${candidate}-${index}`;
|
|
106
|
+
if (!used.has(next)) return next;
|
|
107
|
+
}
|
|
108
|
+
throw new WorkspaceError("could not derive a unique workspace id");
|
|
109
|
+
}
|
|
110
|
+
var WorkspaceRegistry = class {
|
|
111
|
+
file;
|
|
112
|
+
list = [];
|
|
113
|
+
error = null;
|
|
114
|
+
listeners = /* @__PURE__ */ new Set();
|
|
115
|
+
constructor(file = workspacesPath) {
|
|
116
|
+
this.file = file;
|
|
117
|
+
}
|
|
118
|
+
get path() {
|
|
119
|
+
return this.file;
|
|
120
|
+
}
|
|
121
|
+
/** Blocking problems; the caller refuses to start on one, exactly as for configs. */
|
|
122
|
+
get configError() {
|
|
123
|
+
return this.error;
|
|
124
|
+
}
|
|
125
|
+
all() {
|
|
126
|
+
return [...this.list];
|
|
127
|
+
}
|
|
128
|
+
get(id) {
|
|
129
|
+
return this.list.find((entry) => entry.id === id);
|
|
130
|
+
}
|
|
131
|
+
has(id) {
|
|
132
|
+
return this.get(id) !== void 0;
|
|
133
|
+
}
|
|
134
|
+
/** The id a workspace-scoped request resolves to when none is given. */
|
|
135
|
+
get defaultId() {
|
|
136
|
+
return defaultWorkspaceId(this.list);
|
|
137
|
+
}
|
|
138
|
+
onChange(listener) {
|
|
139
|
+
this.listeners.add(listener);
|
|
140
|
+
return () => this.listeners.delete(listener);
|
|
141
|
+
}
|
|
142
|
+
load() {
|
|
143
|
+
let parsed;
|
|
144
|
+
try {
|
|
145
|
+
parsed = JSON.parse(readStateFile(this.file));
|
|
146
|
+
} catch (error) {
|
|
147
|
+
if (error.code === "ENOENT") {
|
|
148
|
+
this.commit(seed());
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
this.error = `cannot read ${this.file}: ${error.message}`;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const validated = workspacesFileSchema(parsed);
|
|
155
|
+
if (validated instanceof type.errors) {
|
|
156
|
+
this.error = `${this.file}: ${validated.summary}`;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (validated.workspaces.length === 0) {
|
|
160
|
+
this.error = `${this.file} declares no workspace — at least one is required`;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.error = null;
|
|
164
|
+
this.list = validated.workspaces.map((entry) => ({ ...entry }));
|
|
165
|
+
this.notify();
|
|
166
|
+
}
|
|
167
|
+
create(input) {
|
|
168
|
+
const label = (input.label ?? input.id ?? "").trim();
|
|
169
|
+
const id = input.id ?? slugifyWorkspaceId(label, this.list.map((entry) => entry.id));
|
|
170
|
+
const validated = workspaceSchema({
|
|
171
|
+
id,
|
|
172
|
+
label: label.length > 0 ? label : id
|
|
173
|
+
});
|
|
174
|
+
if (validated instanceof type.errors) throw new WorkspaceError(validated.summary);
|
|
175
|
+
if (this.has(id)) throw new WorkspaceError(`workspace "${id}" already exists`, "WORKSPACE_EXISTS");
|
|
176
|
+
const next = [...this.list, validated];
|
|
177
|
+
this.commit(next);
|
|
178
|
+
return validated;
|
|
179
|
+
}
|
|
180
|
+
rename(id, label) {
|
|
181
|
+
const index = this.list.findIndex((entry) => entry.id === id);
|
|
182
|
+
if (index < 0) throw new WorkspaceError(`unknown workspace "${id}"`, "UNKNOWN_WORKSPACE");
|
|
183
|
+
const validated = workspaceSchema({
|
|
184
|
+
id,
|
|
185
|
+
label: label.trim()
|
|
186
|
+
});
|
|
187
|
+
if (validated instanceof type.errors) throw new WorkspaceError(validated.summary);
|
|
188
|
+
const next = [...this.list];
|
|
189
|
+
next[index] = validated;
|
|
190
|
+
this.commit(next);
|
|
191
|
+
return validated;
|
|
192
|
+
}
|
|
193
|
+
remove(id) {
|
|
194
|
+
const entry = this.get(id);
|
|
195
|
+
if (entry === void 0) throw new WorkspaceError(`unknown workspace "${id}"`, "UNKNOWN_WORKSPACE");
|
|
196
|
+
if (this.list.length <= 1) throw new WorkspaceError("cannot remove the only workspace");
|
|
197
|
+
this.commit(this.list.filter((candidate) => candidate.id !== id));
|
|
198
|
+
return entry;
|
|
199
|
+
}
|
|
200
|
+
commit(next) {
|
|
201
|
+
const stamped = {
|
|
202
|
+
$schema: "./workspaces.schema.json",
|
|
203
|
+
meta: {
|
|
204
|
+
writtenBy: appVersion(),
|
|
205
|
+
schema: 1
|
|
206
|
+
},
|
|
207
|
+
workspaces: next
|
|
208
|
+
};
|
|
209
|
+
writeFileAtomic(this.file, `${JSON.stringify(stamped, null, 2)}\n`);
|
|
210
|
+
this.list = next.map((entry) => ({ ...entry }));
|
|
211
|
+
this.error = null;
|
|
212
|
+
this.notify();
|
|
213
|
+
}
|
|
214
|
+
notify() {
|
|
215
|
+
for (const listener of this.listeners) listener();
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
//#endregion
|
|
219
|
+
export { workspaces_exports as i, WorkspaceRegistry as n, workspacesFileSchema as r, WorkspaceError as t };
|
|
220
|
+
|
|
221
|
+
//# sourceMappingURL=workspaces-CAln2sQ7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces-CAln2sQ7.js","names":[],"sources":["../../src/config/workspaces.ts"],"sourcesContent":["import type { Workspace } from '#src/shared/contracts'\nimport { type } from 'arktype'\nimport { metaSchema } from '#src/config/schema'\nimport { writeFileAtomic } from '#src/helpers/atomic'\nimport { readStateFile } from '#src/helpers/config-text'\nimport { DEFAULT_WORKSPACE_ID, workspacesPath } from '#src/helpers/paths'\nimport { appVersion } from '#src/helpers/version'\nimport { workspaceSchema } from '#src/shared/contracts'\n\n/**\n * The workspace registry: which workspaces exist, in the order the selector shows\n * them. Kept apart from any workspace's own files so it can be read before they\n * are, and so creating or removing one is a single small write.\n */\nexport const workspacesFileSchema = type({\n $schema: 'string?',\n meta: metaSchema.optional(),\n workspaces: workspaceSchema.array(),\n}).onUndeclaredKey('reject')\n\n/**\n * The *kind* of registry failure, when a caller has to branch on it rather than just report it.\n * The workspaces route answers 404 for an unknown id, 409 for a conflict and 400 otherwise, and it\n * decided that by matching the message text.\n */\nexport type WorkspaceErrorCode = 'UNKNOWN_WORKSPACE' | 'WORKSPACE_EXISTS'\n\n/**\n * The workspace a command acts in when none was named: `default` if the host declares it, else the\n * first one it declares.\n *\n * **The panel already answers this question, and the CLI was answering a different one.** Every\n * workspace-scoped `/api` and `/_hh` route resolves an omitted `?workspace` through\n * `PanelService.requireWorkspace` → `WorkspaceRegistry.defaultId`, i.e. this rule. The two CLI\n * commands that take a workspace id read `DEFAULT_WORKSPACE_ID` literally instead — so on a host\n * whose registry lists one workspace that is not called `default` (a colleague's panel, or one\n * where `default` was removed), `start <id>` reached that workspace while `logs <id>` looked in\n * `.hh/default/.logs/`, a directory that does not exist. Measured: `logs` answered \"no output yet\"\n * and exited 0 for a log that was on disk, on the one command a diagnostic session starts with.\n *\n * One function, called by every surface that asks, so a third caller cannot re-derive it.\n */\nexport function defaultWorkspaceId(workspaces: ReadonlyArray<Readonly<{ id: string }>>): string {\n return workspaces.find(entry => entry.id === DEFAULT_WORKSPACE_ID)?.id ?? workspaces[0]?.id ?? DEFAULT_WORKSPACE_ID\n}\n\n/**\n * `defaultWorkspaceId`, for a command that has a registry file and no panel.\n *\n * Tolerant for the same reason the panel's own startup guard is the one that refuses a broken\n * registry: a diagnostic command reading one log must not be the thing that fails loudly about a\n * file it only needed one id from. Missing, unparseable or empty falls back to `default`, which is\n * what the seed declares.\n */\nexport function readDefaultWorkspaceId(file: string): string {\n try {\n const parsed = workspacesFileSchema(JSON.parse(readStateFile(file)) as unknown)\n if (parsed instanceof type.errors || parsed.workspaces.length === 0)\n return DEFAULT_WORKSPACE_ID\n return defaultWorkspaceId(parsed.workspaces)\n }\n catch {\n return DEFAULT_WORKSPACE_ID\n }\n}\n\n/**\n * The workspace ids a registry declares — or `null` when it cannot answer.\n *\n * `readDefaultWorkspaceId`'s sibling for a command that must tell \"that workspace does not exist\"\n * from \"I cannot tell\": a diagnostic that answers an empty log for a typo'd `--workspace` is the\n * same false answer as one that answers it for a typo'd server id. `null` keeps the caller silent\n * on a registry it could not read, because unreadable is not \"it names none\".\n *\n * An **empty** registry is `null` too, for the same reason its sibling falls back to `default`: a\n * registry listing nothing is what a hand-edit or a partially written file looks like, and the panel\n * treats it as `default` rather than as \"no workspace exists\". Answering `[]` there made `logs <id>`\n * refuse the default workspace that `start` and the panel both serve.\n */\nexport function readWorkspaceIds(file: string): string[] | null {\n try {\n const parsed = workspacesFileSchema(JSON.parse(readStateFile(file)) as unknown)\n if (parsed instanceof type.errors || parsed.workspaces.length === 0)\n return null\n return parsed.workspaces.map(workspace => workspace.id)\n }\n catch {\n return null\n }\n}\n\nexport class WorkspaceError extends Error {\n override name = 'WorkspaceError'\n readonly code: WorkspaceErrorCode | undefined\n\n constructor(message: string, code?: WorkspaceErrorCode) {\n super(message)\n this.code = code\n }\n}\n\nconst seed = (): Workspace[] => [{ id: DEFAULT_WORKSPACE_ID, label: 'Default' }]\n\n/** `My Project AB!` -> `my-project-ab`, and never an empty id. */\nexport function slugifyWorkspaceId(label: string, taken: Iterable<string> = []): string {\n const base = label\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 40)\n const used = new Set(taken)\n const candidate = base.length > 0 ? base : 'workspace'\n if (!used.has(candidate))\n return candidate\n for (let index = 2; index < 1000; index++) {\n const next = `${candidate}-${index}`\n if (!used.has(next))\n return next\n }\n throw new WorkspaceError('could not derive a unique workspace id')\n}\n\nexport class WorkspaceRegistry {\n private list: Workspace[] = []\n private error: string | null = null\n private readonly listeners = new Set<() => void>()\n\n constructor(private readonly file: string = workspacesPath) {}\n\n get path(): string {\n return this.file\n }\n\n /** Blocking problems; the caller refuses to start on one, exactly as for configs. */\n get configError(): string | null {\n return this.error\n }\n\n all(): Workspace[] {\n return [...this.list]\n }\n\n get(id: string): Workspace | undefined {\n return this.list.find(entry => entry.id === id)\n }\n\n has(id: string): boolean {\n return this.get(id) !== undefined\n }\n\n /** The id a workspace-scoped request resolves to when none is given. */\n get defaultId(): string {\n return defaultWorkspaceId(this.list)\n }\n\n onChange(listener: () => void): () => void {\n this.listeners.add(listener)\n return () => this.listeners.delete(listener)\n }\n\n load(): void {\n let parsed: unknown\n try {\n parsed = JSON.parse(readStateFile(this.file))\n }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n this.commit(seed())\n return\n }\n this.error = `cannot read ${this.file}: ${(error as Error).message}`\n return\n }\n\n const validated = workspacesFileSchema(parsed)\n if (validated instanceof type.errors) {\n this.error = `${this.file}: ${validated.summary}`\n return\n }\n if (validated.workspaces.length === 0) {\n this.error = `${this.file} declares no workspace — at least one is required`\n return\n }\n\n this.error = null\n this.list = validated.workspaces.map(entry => ({ ...entry }))\n this.notify()\n }\n\n create(input: { id?: string, label?: string }): Workspace {\n const label = (input.label ?? input.id ?? '').trim()\n const id = input.id ?? slugifyWorkspaceId(label, this.list.map(entry => entry.id))\n\n const validated = workspaceSchema({ id, label: label.length > 0 ? label : id })\n if (validated instanceof type.errors)\n throw new WorkspaceError(validated.summary)\n if (this.has(id))\n throw new WorkspaceError(`workspace \"${id}\" already exists`, 'WORKSPACE_EXISTS')\n\n const next = [...this.list, validated]\n this.commit(next)\n return validated\n }\n\n rename(id: string, label: string): Workspace {\n const index = this.list.findIndex(entry => entry.id === id)\n if (index < 0)\n throw new WorkspaceError(`unknown workspace \"${id}\"`, 'UNKNOWN_WORKSPACE')\n\n const validated = workspaceSchema({ id, label: label.trim() })\n if (validated instanceof type.errors)\n throw new WorkspaceError(validated.summary)\n\n const next = [...this.list]\n next[index] = validated\n this.commit(next)\n return validated\n }\n\n remove(id: string): Workspace {\n const entry = this.get(id)\n if (entry === undefined)\n throw new WorkspaceError(`unknown workspace \"${id}\"`, 'UNKNOWN_WORKSPACE')\n if (this.list.length <= 1)\n throw new WorkspaceError('cannot remove the only workspace')\n\n this.commit(this.list.filter(candidate => candidate.id !== id))\n return entry\n }\n\n private commit(next: Workspace[]): void {\n const stamped = {\n $schema: './workspaces.schema.json',\n meta: { writtenBy: appVersion(), schema: 1 },\n workspaces: next,\n }\n writeFileAtomic(this.file, `${JSON.stringify(stamped, null, 2)}\\n`)\n this.list = next.map(entry => ({ ...entry }))\n this.error = null\n this.notify()\n }\n\n private notify(): void {\n for (const listener of this.listeners) listener()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAa,uBAAuB,KAAK;CACvC,SAAS;CACT,MAAM,WAAW,SAAS;CAC1B,YAAY,gBAAgB,MAAM;AACpC,CAAC,CAAC,CAAC,gBAAgB,QAAQ;;;;;;;;;;;;;;;;AAwB3B,SAAgB,mBAAmB,YAA6D;CAC9F,OAAO,WAAW,MAAK,UAAS,MAAM,OAAA,SAA2B,CAAC,EAAE,MAAM,WAAW,EAAE,EAAE,MAAA;AAC3F;;;;;;;;;AAUA,SAAgB,uBAAuB,MAAsB;CAC3D,IAAI;EACF,MAAM,SAAS,qBAAqB,KAAK,MAAM,cAAc,IAAI,CAAC,CAAY;EAC9E,IAAI,kBAAkB,KAAK,UAAU,OAAO,WAAW,WAAW,GAChE,OAAO;EACT,OAAO,mBAAmB,OAAO,UAAU;CAC7C,QACM;EACJ,OAAO;CACT;AACF;;;;;;;;;;;;;;AAeA,SAAgB,iBAAiB,MAA+B;CAC9D,IAAI;EACF,MAAM,SAAS,qBAAq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EAChB,OAAO;CACT;CAEA,OAAO,IAAY,OAA0B;EAC3C,MAAM,QAAQ,KAAK,KAAK,WAAU,UAAS,MAAM,OAAO,EAAE;EAC1D,IAAI,QAAQ,GACV,MAAM,IAAI,eAAe,sBAAsB,GAAG,IAAI,mBAAmB;EAE3E,MAAM,YAAY,gBAAgB;GAAE;GAAI,OAAO,MAAM,KAAK;EAAE,CAAC;EAC7D,IAAI,qBAAqB,KAAK,QAC5B,MAAM,IAAI,eAAe,UAAU,OAAO;EAE5C,MAAM,OAAO,CAAC,GAAG,KAAK,IAAI;EAC1B,KAAK,SAAS;EACd,KAAK,OAAO,IAAI;EAChB,OAAO;CACT;CAEA,OAAO,IAAuB;EAC5B,MAAM,QAAQ,KAAK,IAAI,EAAE;EACzB,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,eAAe,sBAAsB,GAAG,IAAI,mBAAmB;EAC3E,IAAI,KAAK,KAAK,UAAU,GACtB,MAAM,IAAI,eAAe,kCAAkC;EAE7D,KAAK,OAAO,KAAK,KAAK,QAAO,cAAa,UAAU,OAAO,EAAE,CAAC;EAC9D,OAAO;CACT;CAEA,OAAe,MAAyB;EACtC,MAAM,UAAU;GACd,SAAS;GACT,MAAM;IAAE,WAAW,WAAW;IAAG,QAAQ;GAAE;GAC3C,YAAY;EACd;EACA,gBAAgB,KAAK,MAAM,GAAG,KAAK,UAAU,SAAS,MAAM,CAAC,EAAE,GAAG;EAClE,KAAK,OAAO,KAAK,KAAI,WAAU,EAAE,GAAG,MAAM,EAAE;EAC5C,KAAK,QAAQ;EACb,KAAK,OAAO;CACd;CAEA,SAAuB;EACrB,KAAK,MAAM,YAAY,KAAK,WAAW,SAAS;CAClD;AACF"}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { t as logger } from "./logger-B5U4GD3j.js";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import { Buffer } from "node:buffer";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import cp from "node:child_process";
|
|
9
|
+
import { promisify } from "node:util";
|
|
10
|
+
//#region src/providers/wsl-temperature.ts
|
|
11
|
+
var wsl_temperature_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
LHM_RELEASE: () => LHM_RELEASE,
|
|
13
|
+
LHM_SUBDIR: () => LHM_SUBDIR,
|
|
14
|
+
installLibreHardwareMonitor: () => installLibreHardwareMonitor,
|
|
15
|
+
isWsl: () => isWsl,
|
|
16
|
+
lhmDirectory: () => lhmDirectory,
|
|
17
|
+
lhmDirectoryWindows: () => lhmDirectoryWindows,
|
|
18
|
+
lhmInstalled: () => lhmInstalled,
|
|
19
|
+
probeWslTemperature: () => probeWslTemperature,
|
|
20
|
+
removeWslTemperatureScript: () => removeWslTemperatureScript,
|
|
21
|
+
tempCommandFor: () => tempCommandFor,
|
|
22
|
+
toGuestPath: () => toGuestPath,
|
|
23
|
+
windowsScriptPath: () => windowsScriptPath,
|
|
24
|
+
writeWslTemperatureScript: () => writeWslTemperatureScript,
|
|
25
|
+
wslScriptPath: () => wslScriptPath,
|
|
26
|
+
wslTemperatureStatus: () => wslTemperatureStatus
|
|
27
|
+
});
|
|
28
|
+
var execFileAsync = promisify(cp.execFile);
|
|
29
|
+
/**
|
|
30
|
+
* The WSL2 temperature bridge: a PowerShell helper that becomes `host.tempCommand`.
|
|
31
|
+
*
|
|
32
|
+
* A WSL2 guest has no sensor the kernel can read, and Windows' own ACPI class answers a constant
|
|
33
|
+
* 20 °C whatever the load. LibreHardwareMonitor reads the real value. Opt-in and reversible.
|
|
34
|
+
*/
|
|
35
|
+
/** The script that prints the CPU temperature, written beside the panel's own state. */
|
|
36
|
+
var SCRIPT_NAME = "cpu-temp.ps1";
|
|
37
|
+
/**
|
|
38
|
+
* `%ProgramData%`, not `%LOCALAPPDATA%`: a boot-started panel is SYSTEM in session 0, whose per-user
|
|
39
|
+
* path differs. Not the drive root either — that clutters every account's Explorer.
|
|
40
|
+
*/
|
|
41
|
+
var LHM_SUBDIR = "home-hosted\\LibreHardwareMonitor";
|
|
42
|
+
/**
|
|
43
|
+
* The last successful read of the Windows side, kept for this process's life.
|
|
44
|
+
*
|
|
45
|
+
* A **success** is permanent because `%ProgramData%` is a property of the host and cannot move under
|
|
46
|
+
* a running panel. A failure is never stored: `powershell.exe` missing from this process's `PATH`, or
|
|
47
|
+
* a transient interop hiccup, says nothing about the machine, and caching it would make one bad
|
|
48
|
+
* moment permanent. A failed read costs an `ENOENT` — the 360 ms is the successful spawn.
|
|
49
|
+
*/
|
|
50
|
+
var windowsBase = null;
|
|
51
|
+
/**
|
|
52
|
+
* `$env:ProgramData` from the Windows side, read **once**.
|
|
53
|
+
*
|
|
54
|
+
* `powershell.exe` across the 9p mount measured ~360 ms here, and this is a **synchronous** spawn: it
|
|
55
|
+
* stops the whole event loop, so the tick, the SSE hub and every in-flight request wait behind it.
|
|
56
|
+
* Every bridge-state read did it twice — once for the install directory, once for the library — which
|
|
57
|
+
* made `GET /api/host/temperature` block the panel for ~720 ms, on a route the settings page calls
|
|
58
|
+
* whenever it opens. Same rule as `lanAddress()`: a host read on a request path is cached, never
|
|
59
|
+
* paid per call.
|
|
60
|
+
*/
|
|
61
|
+
function windowsProgramData() {
|
|
62
|
+
if (windowsBase !== null) return windowsBase;
|
|
63
|
+
try {
|
|
64
|
+
const base = cp.execFileSync("powershell.exe", [
|
|
65
|
+
"-NoProfile",
|
|
66
|
+
"-NonInteractive",
|
|
67
|
+
"-Command",
|
|
68
|
+
"$env:ProgramData"
|
|
69
|
+
], {
|
|
70
|
+
timeout: 1e4,
|
|
71
|
+
windowsHide: true,
|
|
72
|
+
encoding: "utf8"
|
|
73
|
+
}).trim();
|
|
74
|
+
if (base.length > 0) windowsBase = base;
|
|
75
|
+
} catch {}
|
|
76
|
+
return windowsBase;
|
|
77
|
+
}
|
|
78
|
+
/** The install directory in Windows terms, read from the environment (the system drive may not be `C:`). */
|
|
79
|
+
function lhmDirectoryWindows() {
|
|
80
|
+
const base = windowsProgramData();
|
|
81
|
+
return base === null ? null : path.win32.join(base, LHM_SUBDIR);
|
|
82
|
+
}
|
|
83
|
+
/** A Windows path as a path this process can read: `C:\x` -> `/mnt/c/x`. */
|
|
84
|
+
function toGuestPath(windowsPath) {
|
|
85
|
+
const match = /^([a-z]):\\(.*)$/i.exec(windowsPath);
|
|
86
|
+
if (match === null) return null;
|
|
87
|
+
return path.posix.join("/mnt", match[1].toLowerCase(), ...match[2].split("\\"));
|
|
88
|
+
}
|
|
89
|
+
/** The install directory as a guest path, or null when the Windows side cannot be reached. */
|
|
90
|
+
function lhmDirectory() {
|
|
91
|
+
const windows = lhmDirectoryWindows();
|
|
92
|
+
return windows === null ? null : toGuestPath(windows);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Whether this process is a WSL2 guest.
|
|
96
|
+
*
|
|
97
|
+
* `os.release()` carries `microsoft-standard-WSL2`, and `/proc/version` the same — checked on both
|
|
98
|
+
* because a future WSL may rename the release while the version line keeps the vendor.
|
|
99
|
+
*/
|
|
100
|
+
function isWsl() {
|
|
101
|
+
if (process.platform !== "linux") return false;
|
|
102
|
+
try {
|
|
103
|
+
return /microsoft/i.test(fs.readFileSync("/proc/version", "utf8"));
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** A `/mnt/c/...` path as the `C:\...` path `powershell.exe` needs. Untranslatable paths pass through. */
|
|
109
|
+
function windowsScriptPath(scriptPath) {
|
|
110
|
+
const match = /^\/mnt\/([a-z])\/(.*)$/i.exec(scriptPath);
|
|
111
|
+
if (match === null) return scriptPath;
|
|
112
|
+
return `${match[1].toUpperCase()}:\\${match[2].replaceAll("/", "\\")}`;
|
|
113
|
+
}
|
|
114
|
+
/** The helper script, written beside the library so every account resolves the same file. */
|
|
115
|
+
function wslScriptPath() {
|
|
116
|
+
if (!isWsl()) return null;
|
|
117
|
+
const base = lhmDirectoryWindows();
|
|
118
|
+
const guest = base === null ? null : toGuestPath(path.win32.dirname(base));
|
|
119
|
+
if (guest === null) return null;
|
|
120
|
+
return path.join(guest, SCRIPT_NAME);
|
|
121
|
+
}
|
|
122
|
+
/** The `powershell.exe` invocation that runs `scriptPath` and prints the temperature. */
|
|
123
|
+
function tempCommandFor(scriptPath) {
|
|
124
|
+
return `powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${windowsScriptPath(scriptPath)}"`;
|
|
125
|
+
}
|
|
126
|
+
/** The script's body. Kept tiny: it runs on every host sample. */
|
|
127
|
+
function scriptBody() {
|
|
128
|
+
return `# CPU temperature for home-hosted. Written by \`home-hosted setup-temp --wsl\`; safe to delete.
|
|
129
|
+
$dir = Join-Path $env:ProgramData 'home-hosted\\LibreHardwareMonitor'
|
|
130
|
+
if (-not (Test-Path (Join-Path $dir 'LibreHardwareMonitorLib.dll'))) {
|
|
131
|
+
[Console]::Error.WriteLine("LibreHardwareMonitor not found in $dir")
|
|
132
|
+
exit 1
|
|
133
|
+
}
|
|
134
|
+
[System.Reflection.Assembly]::LoadFrom("$dir\\System.Memory.dll") | Out-Null
|
|
135
|
+
[System.Reflection.Assembly]::LoadFrom("$dir\\System.Buffers.dll") | Out-Null
|
|
136
|
+
[System.Reflection.Assembly]::LoadFrom("$dir\\Microsoft.Bcl.AsyncInterfaces.dll") | Out-Null
|
|
137
|
+
Add-Type -Path "$dir\\LibreHardwareMonitorLib.dll"
|
|
138
|
+
$c = New-Object LibreHardwareMonitor.Hardware.Computer
|
|
139
|
+
$c.IsCpuEnabled = $true
|
|
140
|
+
$c.Open()
|
|
141
|
+
$out = $null
|
|
142
|
+
foreach ($hw in $c.Hardware) {
|
|
143
|
+
$hw.Update()
|
|
144
|
+
foreach ($s in $hw.Sensors) {
|
|
145
|
+
if ($s.SensorType -eq 'Temperature' -and $s.Name -match 'Tctl|Package|Core') {
|
|
146
|
+
$out = [math]::Round($s.Value, 1)
|
|
147
|
+
break
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if ($null -ne $out) { break }
|
|
151
|
+
}
|
|
152
|
+
$c.Close()
|
|
153
|
+
if ($null -eq $out) { exit 2 }
|
|
154
|
+
$out
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
/** `configured` (pointed at a command) and `libraryPresent` are separate, so the UI can say "set up, but the library is missing". */
|
|
158
|
+
function wslTemperatureStatus(scriptPath, tempCommand) {
|
|
159
|
+
const wsl = isWsl();
|
|
160
|
+
const scriptWritten = scriptPath !== null && fs.existsSync(scriptPath);
|
|
161
|
+
const configured = tempCommand.trim().length > 0;
|
|
162
|
+
return {
|
|
163
|
+
wsl,
|
|
164
|
+
supported: wsl,
|
|
165
|
+
configured,
|
|
166
|
+
scriptWritten,
|
|
167
|
+
libraryPresent: lhmInstalled(),
|
|
168
|
+
scriptPath: wsl ? scriptPath : null,
|
|
169
|
+
tempCommand: configured ? tempCommand : null
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/** Write the helper script. Idempotent: re-running overwrites it with the current version. */
|
|
173
|
+
function writeWslTemperatureScript(scriptPath) {
|
|
174
|
+
fs.mkdirSync(path.dirname(scriptPath), { recursive: true });
|
|
175
|
+
fs.writeFileSync(scriptPath, scriptBody(), { mode: 384 });
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Delete the helper script, best-effort: a file someone already removed is the outcome they wanted.
|
|
179
|
+
*
|
|
180
|
+
* The one home for it, because `--clear` promises it in the CLI help and in `docs/SERVERS.md` — and
|
|
181
|
+
* the CLI cleared `host.tempCommand` without ever removing the file, so the helper outlived the
|
|
182
|
+
* setting that pointed at it. A command nothing names any more is left for the next person to
|
|
183
|
+
* wonder about, and the route that *did* delete it was the only caller.
|
|
184
|
+
*/
|
|
185
|
+
function removeWslTemperatureScript(scriptPath) {
|
|
186
|
+
if (scriptPath === null) return;
|
|
187
|
+
try {
|
|
188
|
+
fs.rmSync(scriptPath, { force: true });
|
|
189
|
+
} catch {}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Pinned by version **and** sha256: this file is then executed on every sample, and the URL redirects
|
|
193
|
+
* to a third-party CDN. Checked before anything is unpacked. Change all three fields together.
|
|
194
|
+
*/
|
|
195
|
+
var LHM_RELEASE = {
|
|
196
|
+
version: "0.9.6",
|
|
197
|
+
asset: "LibreHardwareMonitor.zip",
|
|
198
|
+
/** From the release's asset `digest` field, `sha256:…`. */
|
|
199
|
+
sha256: "086d9f1b5a99e643edc2cfaaac16051685b551e4c5ac0b32a57c58c0e529c001",
|
|
200
|
+
url: "https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/releases/download/v0.9.6/LibreHardwareMonitor.zip"
|
|
201
|
+
};
|
|
202
|
+
/** Whether the DLL the helper loads is installed where the helper expects it. */
|
|
203
|
+
function lhmInstalled() {
|
|
204
|
+
const dir = lhmDirectory();
|
|
205
|
+
if (dir === null) return false;
|
|
206
|
+
try {
|
|
207
|
+
return fs.existsSync(path.join(dir, "LibreHardwareMonitorLib.dll"));
|
|
208
|
+
} catch {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** Download, verify and unpack LibreHardwareMonitor. A failed attempt leaves nothing installed. */
|
|
213
|
+
async function installLibreHardwareMonitor(options = {}) {
|
|
214
|
+
const report = options.onProgress ?? (() => {});
|
|
215
|
+
const targetWindows = lhmDirectoryWindows();
|
|
216
|
+
const target = lhmDirectory();
|
|
217
|
+
if (targetWindows === null || target === null) return {
|
|
218
|
+
dir: null,
|
|
219
|
+
error: "the Windows ProgramData directory could not be read, so there is nowhere to install to"
|
|
220
|
+
};
|
|
221
|
+
let staging = null;
|
|
222
|
+
try {
|
|
223
|
+
report(`downloading ${LHM_RELEASE.asset} (${LHM_RELEASE.version})…`);
|
|
224
|
+
const response = await fetch(LHM_RELEASE.url, {
|
|
225
|
+
redirect: "follow",
|
|
226
|
+
signal: AbortSignal.timeout(12e4)
|
|
227
|
+
});
|
|
228
|
+
if (!response.ok) return {
|
|
229
|
+
dir: null,
|
|
230
|
+
error: `the download answered ${response.status} for ${LHM_RELEASE.url}`
|
|
231
|
+
};
|
|
232
|
+
const bytes = Buffer.from(await response.arrayBuffer());
|
|
233
|
+
const digest = createHash("sha256").update(bytes).digest("hex");
|
|
234
|
+
if (digest !== LHM_RELEASE.sha256) return {
|
|
235
|
+
dir: null,
|
|
236
|
+
error: `the download did not match its published sha256 (got ${digest.slice(0, 16)}…, expected ${LHM_RELEASE.sha256.slice(0, 16)}…) — nothing was installed`
|
|
237
|
+
};
|
|
238
|
+
const stagingRoot = path.join(path.dirname(target), ".staging");
|
|
239
|
+
await fs.promises.mkdir(stagingRoot, { recursive: true });
|
|
240
|
+
staging = await fs.promises.mkdtemp(path.join(stagingRoot, "run-"));
|
|
241
|
+
const archive = path.join(staging, LHM_RELEASE.asset);
|
|
242
|
+
await fs.promises.writeFile(archive, bytes);
|
|
243
|
+
report(`unpacking into ${targetWindows}…`);
|
|
244
|
+
await fs.promises.rm(target, {
|
|
245
|
+
recursive: true,
|
|
246
|
+
force: true
|
|
247
|
+
});
|
|
248
|
+
await fs.promises.mkdir(target, { recursive: true });
|
|
249
|
+
await execFileAsync("powershell.exe", [
|
|
250
|
+
"-NoProfile",
|
|
251
|
+
"-NonInteractive",
|
|
252
|
+
"-Command",
|
|
253
|
+
`Expand-Archive -LiteralPath '${windowsScriptPath(archive)}' -DestinationPath '${targetWindows}' -Force`
|
|
254
|
+
], {
|
|
255
|
+
timeout: 12e4,
|
|
256
|
+
windowsHide: true
|
|
257
|
+
});
|
|
258
|
+
if (!lhmInstalled()) {
|
|
259
|
+
await fs.promises.rm(target, {
|
|
260
|
+
recursive: true,
|
|
261
|
+
force: true
|
|
262
|
+
}).catch(() => {});
|
|
263
|
+
return {
|
|
264
|
+
dir: null,
|
|
265
|
+
error: `the archive unpacked but LibreHardwareMonitorLib.dll is not in ${targetWindows}`
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
dir: targetWindows,
|
|
270
|
+
error: null
|
|
271
|
+
};
|
|
272
|
+
} catch (error) {
|
|
273
|
+
return {
|
|
274
|
+
dir: null,
|
|
275
|
+
error: error instanceof Error ? error.message : String(error)
|
|
276
|
+
};
|
|
277
|
+
} finally {
|
|
278
|
+
if (staging !== null) {
|
|
279
|
+
await fs.promises.rm(staging, {
|
|
280
|
+
recursive: true,
|
|
281
|
+
force: true
|
|
282
|
+
}).catch(() => {});
|
|
283
|
+
await fs.promises.rmdir(path.dirname(staging)).catch(() => {});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/** Run the helper once, so a setup that cannot work is reported rather than saved. */
|
|
288
|
+
async function probeWslTemperature(tempCommand, timeoutMs) {
|
|
289
|
+
try {
|
|
290
|
+
const { stdout, stderr } = await execFileAsync(tempCommand, {
|
|
291
|
+
timeout: timeoutMs,
|
|
292
|
+
windowsHide: true,
|
|
293
|
+
maxBuffer: 65536,
|
|
294
|
+
shell: true
|
|
295
|
+
});
|
|
296
|
+
const match = /-?\d+(?:\.\d+)?/.exec(stdout);
|
|
297
|
+
if (match === null) return {
|
|
298
|
+
celsius: null,
|
|
299
|
+
error: stderr.trim().length > 0 ? stderr.trim() : "the script printed no number — is LibreHardwareMonitor installed?"
|
|
300
|
+
};
|
|
301
|
+
const celsius = Number.parseFloat(match[0]);
|
|
302
|
+
if (!Number.isFinite(celsius) || celsius <= 0 || celsius >= 150) return {
|
|
303
|
+
celsius: null,
|
|
304
|
+
error: `the script printed ${match[0]}, which is not a temperature`
|
|
305
|
+
};
|
|
306
|
+
return {
|
|
307
|
+
celsius,
|
|
308
|
+
error: null
|
|
309
|
+
};
|
|
310
|
+
} catch (error) {
|
|
311
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
312
|
+
logger.warn(`the WSL temperature probe failed: ${message}`);
|
|
313
|
+
return {
|
|
314
|
+
celsius: null,
|
|
315
|
+
error: message
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
//#endregion
|
|
320
|
+
export { removeWslTemperatureScript as a, writeWslTemperatureScript as c, wsl_temperature_exports as d, probeWslTemperature as i, wslScriptPath as l, lhmDirectoryWindows as n, tempCommandFor as o, lhmInstalled as r, windowsScriptPath as s, installLibreHardwareMonitor as t, wslTemperatureStatus as u };
|
|
321
|
+
|
|
322
|
+
//# sourceMappingURL=wsl-temperature-BiCI4iK6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsl-temperature-BiCI4iK6.js","names":[],"sources":["../../src/providers/wsl-temperature.ts"],"sourcesContent":["import type { WslTemperatureStatus } from '#src/shared/contracts'\nimport { Buffer } from 'node:buffer'\nimport cp from 'node:child_process'\nimport { createHash } from 'node:crypto'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { promisify } from 'node:util'\nimport { logger } from '#src/helpers/logger'\n\nconst execFileAsync = promisify(cp.execFile)\n\n/**\n * The WSL2 temperature bridge: a PowerShell helper that becomes `host.tempCommand`.\n *\n * A WSL2 guest has no sensor the kernel can read, and Windows' own ACPI class answers a constant\n * 20 °C whatever the load. LibreHardwareMonitor reads the real value. Opt-in and reversible.\n */\n\n/** The script that prints the CPU temperature, written beside the panel's own state. */\nconst SCRIPT_NAME = 'cpu-temp.ps1'\n\n/**\n * `%ProgramData%`, not `%LOCALAPPDATA%`: a boot-started panel is SYSTEM in session 0, whose per-user\n * path differs. Not the drive root either — that clutters every account's Explorer.\n */\nexport const LHM_SUBDIR = 'home-hosted\\\\LibreHardwareMonitor'\n\n/**\n * The last successful read of the Windows side, kept for this process's life.\n *\n * A **success** is permanent because `%ProgramData%` is a property of the host and cannot move under\n * a running panel. A failure is never stored: `powershell.exe` missing from this process's `PATH`, or\n * a transient interop hiccup, says nothing about the machine, and caching it would make one bad\n * moment permanent. A failed read costs an `ENOENT` — the 360 ms is the successful spawn.\n */\nlet windowsBase: string | null = null\n\n/**\n * `$env:ProgramData` from the Windows side, read **once**.\n *\n * `powershell.exe` across the 9p mount measured ~360 ms here, and this is a **synchronous** spawn: it\n * stops the whole event loop, so the tick, the SSE hub and every in-flight request wait behind it.\n * Every bridge-state read did it twice — once for the install directory, once for the library — which\n * made `GET /api/host/temperature` block the panel for ~720 ms, on a route the settings page calls\n * whenever it opens. Same rule as `lanAddress()`: a host read on a request path is cached, never\n * paid per call.\n */\nfunction windowsProgramData(): string | null {\n if (windowsBase !== null)\n return windowsBase\n\n try {\n const base = cp.execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', '$env:ProgramData'], { timeout: 10_000, windowsHide: true, encoding: 'utf8' }).trim()\n if (base.length > 0)\n windowsBase = base\n }\n catch {\n // Not cached: see above.\n }\n return windowsBase\n}\n\n/** The install directory in Windows terms, read from the environment (the system drive may not be `C:`). */\nexport function lhmDirectoryWindows(): string | null {\n const base = windowsProgramData()\n return base === null ? null : path.win32.join(base, LHM_SUBDIR)\n}\n\n/** Forgets the cached Windows path. A test that simulates the Windows side calls this first. */\nexport function forgetWslPaths(): void {\n windowsBase = null\n}\n\n/** A Windows path as a path this process can read: `C:\\x` -> `/mnt/c/x`. */\nexport function toGuestPath(windowsPath: string): string | null {\n const match = /^([a-z]):\\\\(.*)$/i.exec(windowsPath)\n if (match === null)\n return null\n // `path.posix`, not `path.join`: this is always a *Linux guest* path, and on a Windows checkout\n // `path.join` would build it with backslashes — which is how the Windows gate caught this.\n return path.posix.join('/mnt', match[1]!.toLowerCase(), ...match[2]!.split('\\\\'))\n}\n\n/** The install directory as a guest path, or null when the Windows side cannot be reached. */\nexport function lhmDirectory(): string | null {\n const windows = lhmDirectoryWindows()\n return windows === null ? null : toGuestPath(windows)\n}\n\n/**\n * Whether this process is a WSL2 guest.\n *\n * `os.release()` carries `microsoft-standard-WSL2`, and `/proc/version` the same — checked on both\n * because a future WSL may rename the release while the version line keeps the vendor.\n */\nexport function isWsl(): boolean {\n if (process.platform !== 'linux')\n return false\n try {\n return /microsoft/i.test(fs.readFileSync('/proc/version', 'utf8'))\n }\n catch {\n return false\n }\n}\n\n/** A `/mnt/c/...` path as the `C:\\...` path `powershell.exe` needs. Untranslatable paths pass through. */\nexport function windowsScriptPath(scriptPath: string): string {\n // `/mnt/c/Users/me/x.ps1` is `C:\\Users\\me\\x.ps1` to powershell.exe.\n const match = /^\\/mnt\\/([a-z])\\/(.*)$/i.exec(scriptPath)\n if (match === null)\n return scriptPath\n return `${match[1]!.toUpperCase()}:\\\\${match[2]!.replaceAll('/', '\\\\')}`\n}\n\n/** The helper script, written beside the library so every account resolves the same file. */\nexport function wslScriptPath(): string | null {\n if (!isWsl())\n return null\n const base = lhmDirectoryWindows()\n const guest = base === null ? null : toGuestPath(path.win32.dirname(base))\n if (guest === null)\n return null\n return path.join(guest, SCRIPT_NAME)\n}\n\n/** Where the helper is, in Windows terms — what the command line has to say. */\nexport function wslScriptPathWindows(): string | null {\n const base = lhmDirectoryWindows()\n return base === null ? null : path.win32.join(path.win32.dirname(base), SCRIPT_NAME)\n}\n\n/** The `powershell.exe` invocation that runs `scriptPath` and prints the temperature. */\nexport function tempCommandFor(scriptPath: string): string {\n return `powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"${windowsScriptPath(scriptPath)}\"`\n}\n\n/** The command for a path already expressed in Windows terms. */\nexport function tempCommandForWindows(windowsPath: string): string {\n return `powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"${windowsPath}\"`\n}\n\n/** The script's body. Kept tiny: it runs on every host sample. */\nfunction scriptBody(): string {\n return `# CPU temperature for home-hosted. Written by \\`home-hosted setup-temp --wsl\\`; safe to delete.\n$dir = Join-Path $env:ProgramData 'home-hosted\\\\LibreHardwareMonitor'\nif (-not (Test-Path (Join-Path $dir 'LibreHardwareMonitorLib.dll'))) {\n [Console]::Error.WriteLine(\"LibreHardwareMonitor not found in $dir\")\n exit 1\n}\n[System.Reflection.Assembly]::LoadFrom(\"$dir\\\\System.Memory.dll\") | Out-Null\n[System.Reflection.Assembly]::LoadFrom(\"$dir\\\\System.Buffers.dll\") | Out-Null\n[System.Reflection.Assembly]::LoadFrom(\"$dir\\\\Microsoft.Bcl.AsyncInterfaces.dll\") | Out-Null\nAdd-Type -Path \"$dir\\\\LibreHardwareMonitorLib.dll\"\n$c = New-Object LibreHardwareMonitor.Hardware.Computer\n$c.IsCpuEnabled = $true\n$c.Open()\n$out = $null\nforeach ($hw in $c.Hardware) {\n $hw.Update()\n foreach ($s in $hw.Sensors) {\n if ($s.SensorType -eq 'Temperature' -and $s.Name -match 'Tctl|Package|Core') {\n $out = [math]::Round($s.Value, 1)\n break\n }\n }\n if ($null -ne $out) { break }\n}\n$c.Close()\nif ($null -eq $out) { exit 2 }\n$out\n`\n}\n\n/** `configured` (pointed at a command) and `libraryPresent` are separate, so the UI can say \"set up, but the library is missing\". */\nexport function wslTemperatureStatus(scriptPath: string | null, tempCommand: string): WslTemperatureStatus {\n const wsl = isWsl()\n const scriptWritten = scriptPath !== null && fs.existsSync(scriptPath)\n const configured = tempCommand.trim().length > 0\n // `lhmInstalled`, not a second path of its own: this had a hardcoded `C:\\Tools` copy, so it reported\n // \"missing\" after the installer had put the library in `%ProgramData%` — and the page told a person\n // to fix something that was already installed.\n const libraryPresent = lhmInstalled()\n return {\n wsl,\n supported: wsl,\n configured,\n scriptWritten,\n libraryPresent,\n scriptPath: wsl ? scriptPath : null,\n tempCommand: configured ? tempCommand : null,\n }\n}\n\n/** Write the helper script. Idempotent: re-running overwrites it with the current version. */\nexport function writeWslTemperatureScript(scriptPath: string): void {\n fs.mkdirSync(path.dirname(scriptPath), { recursive: true })\n fs.writeFileSync(scriptPath, scriptBody(), { mode: 0o600 })\n}\n\n/**\n * Delete the helper script, best-effort: a file someone already removed is the outcome they wanted.\n *\n * The one home for it, because `--clear` promises it in the CLI help and in `docs/SERVERS.md` — and\n * the CLI cleared `host.tempCommand` without ever removing the file, so the helper outlived the\n * setting that pointed at it. A command nothing names any more is left for the next person to\n * wonder about, and the route that *did* delete it was the only caller.\n */\nexport function removeWslTemperatureScript(scriptPath: string | null): void {\n if (scriptPath === null)\n return\n try {\n fs.rmSync(scriptPath, { force: true })\n }\n catch {\n // Left behind; the command is cleared, which is what stops it being used.\n }\n}\n\n/**\n * Pinned by version **and** sha256: this file is then executed on every sample, and the URL redirects\n * to a third-party CDN. Checked before anything is unpacked. Change all three fields together.\n */\nexport const LHM_RELEASE = {\n version: '0.9.6',\n asset: 'LibreHardwareMonitor.zip',\n /** From the release's asset `digest` field, `sha256:…`. */\n sha256: '086d9f1b5a99e643edc2cfaaac16051685b551e4c5ac0b32a57c58c0e529c001',\n url: 'https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/releases/download/v0.9.6/LibreHardwareMonitor.zip',\n} as const\n\n/** Whether the DLL the helper loads is installed where the helper expects it. */\nexport function lhmInstalled(): boolean {\n const dir = lhmDirectory()\n if (dir === null)\n return false\n try {\n return fs.existsSync(path.join(dir, 'LibreHardwareMonitorLib.dll'))\n }\n catch {\n return false\n }\n}\n\n/** Download, verify and unpack LibreHardwareMonitor. A failed attempt leaves nothing installed. */\nexport async function installLibreHardwareMonitor(options: { onProgress?: (message: string) => void } = {}): Promise<{ dir: string | null, error: string | null }> {\n const report = options.onProgress ?? (() => {})\n const targetWindows = lhmDirectoryWindows()\n const target = lhmDirectory()\n if (targetWindows === null || target === null)\n return { dir: null, error: 'the Windows ProgramData directory could not be read, so there is nowhere to install to' }\n\n let staging: string | null = null\n try {\n report(`downloading ${LHM_RELEASE.asset} (${LHM_RELEASE.version})…`)\n const response = await fetch(LHM_RELEASE.url, { redirect: 'follow', signal: AbortSignal.timeout(120_000) })\n if (!response.ok)\n return { dir: null, error: `the download answered ${response.status} for ${LHM_RELEASE.url}` }\n const bytes = Buffer.from(await response.arrayBuffer())\n\n // Verify before unpacking: this file becomes code that runs on every sample.\n const digest = createHash('sha256').update(bytes).digest('hex')\n if (digest !== LHM_RELEASE.sha256) {\n return {\n dir: null,\n error: `the download did not match its published sha256 (got ${digest.slice(0, 16)}…, expected ${LHM_RELEASE.sha256.slice(0, 16)}…) — nothing was installed`,\n }\n }\n\n // Stage beside the target, on the **Windows** drive: `Expand-Archive` runs on the Windows side and\n // cannot open a Linux temp path. `/mnt/c` is shared, so both sides see the same file.\n const stagingRoot = path.join(path.dirname(target), '.staging')\n await fs.promises.mkdir(stagingRoot, { recursive: true })\n staging = await fs.promises.mkdtemp(path.join(stagingRoot, 'run-'))\n const archive = path.join(staging, LHM_RELEASE.asset)\n await fs.promises.writeFile(archive, bytes)\n\n report(`unpacking into ${targetWindows}…`)\n await fs.promises.rm(target, { recursive: true, force: true })\n await fs.promises.mkdir(target, { recursive: true })\n // Windows must unpack its own archive; `unzip` may not exist there.\n await execFileAsync(\n 'powershell.exe',\n ['-NoProfile', '-NonInteractive', '-Command', `Expand-Archive -LiteralPath '${windowsScriptPath(archive)}' -DestinationPath '${targetWindows}' -Force`],\n { timeout: 120_000, windowsHide: true },\n )\n\n if (!lhmInstalled()) {\n await fs.promises.rm(target, { recursive: true, force: true }).catch(() => {})\n return { dir: null, error: `the archive unpacked but LibreHardwareMonitorLib.dll is not in ${targetWindows}` }\n }\n return { dir: targetWindows, error: null }\n }\n catch (error) {\n return { dir: null, error: error instanceof Error ? error.message : String(error) }\n }\n finally {\n // Ours, unlike the install: remove the `run-*` dir *and* its parent, or `.staging` lingers.\n if (staging !== null) {\n await fs.promises.rm(staging, { recursive: true, force: true }).catch(() => {})\n await fs.promises.rmdir(path.dirname(staging)).catch(() => {})\n }\n }\n}\n\n/** Run the helper once, so a setup that cannot work is reported rather than saved. */\nexport async function probeWslTemperature(tempCommand: string, timeoutMs: number): Promise<{ celsius: number | null, error: string | null }> {\n try {\n const { stdout, stderr } = await execFileAsync(tempCommand, { timeout: timeoutMs, windowsHide: true, maxBuffer: 64 * 1024, shell: true })\n const match = /-?\\d+(?:\\.\\d+)?/.exec(stdout)\n if (match === null) {\n return {\n celsius: null,\n error: stderr.trim().length > 0\n ? stderr.trim()\n : 'the script printed no number — is LibreHardwareMonitor installed?',\n }\n }\n const celsius = Number.parseFloat(match[0])\n if (!Number.isFinite(celsius) || celsius <= 0 || celsius >= 150)\n return { celsius: null, error: `the script printed ${match[0]}, which is not a temperature` }\n return { celsius, error: null }\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n logger.warn(`the WSL temperature probe failed: ${message}`)\n return { celsius: null, error: message }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAM,gBAAgB,UAAU,GAAG,QAAQ;;;;;;;;AAU3C,IAAM,cAAc;;;;;AAMpB,IAAa,aAAa;;;;;;;;;AAU1B,IAAI,cAA6B;;;;;;;;;;;AAYjC,SAAS,qBAAoC;CAC3C,IAAI,gBAAgB,MAClB,OAAO;CAET,IAAI;EACF,MAAM,OAAO,GAAG,aAAa,kBAAkB;GAAC;GAAc;GAAmB;GAAY;EAAkB,GAAG;GAAE,SAAS;GAAQ,aAAa;GAAM,UAAU;EAAO,CAAC,CAAC,CAAC,KAAK;EACjL,IAAI,KAAK,SAAS,GAChB,cAAc;CAClB,QACM,CAEN;CACA,OAAO;AACT;;AAGA,SAAgB,sBAAqC;CACnD,MAAM,OAAO,mBAAmB;CAChC,OAAO,SAAS,OAAO,OAAO,KAAK,MAAM,KAAK,MAAM,UAAU;AAChE;;AAQA,SAAgB,YAAY,aAAoC;CAC9D,MAAM,QAAQ,oBAAoB,KAAK,WAAW;CAClD,IAAI,UAAU,MACZ,OAAO;CAGT,OAAO,KAAK,MAAM,KAAK,QAAQ,MAAM,EAAE,CAAE,YAAY,GAAG,GAAG,MAAM,EAAE,CAAE,MAAM,IAAI,CAAC;AAClF;;AAGA,SAAgB,eAA8B;CAC5C,MAAM,UAAU,oBAAoB;CACpC,OAAO,YAAY,OAAO,OAAO,YAAY,OAAO;AACtD;;;;;;;AAQA,SAAgB,QAAiB;CAC/B,IAAI,Q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