home-hosted 0.12.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.
Files changed (221) hide show
  1. package/README.md +95 -49
  2. package/dist/chunks/{archive-DpCwA8Nf.js → archive-DP-XQR8X.js} +15 -2
  3. package/dist/chunks/archive-DP-XQR8X.js.map +1 -0
  4. package/dist/chunks/{atomic-CEfCUfkQ.js → atomic-C1PfJpE7.js} +3 -2
  5. package/dist/chunks/atomic-C1PfJpE7.js.map +1 -0
  6. package/dist/chunks/{backup-CPrJVPJI.js → backup-CZcVca2a.js} +101 -76
  7. package/dist/chunks/backup-CZcVca2a.js.map +1 -0
  8. package/dist/chunks/{backups-Bd2SF2qd.js → backups-CFRaWe_m.js} +881 -536
  9. package/dist/chunks/backups-CFRaWe_m.js.map +1 -0
  10. package/dist/chunks/{contracts-ku5ypHXJ.js → contracts-CMBD1TF9.js} +381 -407
  11. package/dist/chunks/contracts-CMBD1TF9.js.map +1 -0
  12. package/dist/chunks/{daemon-TwXk5vb8.js → daemon-qKVECISl.js} +52 -20
  13. package/dist/chunks/daemon-qKVECISl.js.map +1 -0
  14. package/dist/chunks/{docker-CGv4Uv7w.js → docker-Cy9Lyvda.js} +4 -3
  15. package/dist/chunks/docker-Cy9Lyvda.js.map +1 -0
  16. package/dist/chunks/{down-BlX5X3bm.js → down-pKbGCW9d.js} +22 -17
  17. package/dist/chunks/down-pKbGCW9d.js.map +1 -0
  18. package/dist/chunks/{init-DdmqHVra.js → init-BZ7hK9Vf.js} +19 -6
  19. package/dist/chunks/init-BZ7hK9Vf.js.map +1 -0
  20. package/dist/chunks/{last-stop-BZ08Z89-.js → last-stop-C-BXz_XI.js} +6 -5
  21. package/dist/chunks/last-stop-C-BXz_XI.js.map +1 -0
  22. package/dist/chunks/{layout-D74TGUnr.js → layout-DwTtmund.js} +2 -2
  23. package/dist/chunks/{layout-D74TGUnr.js.map → layout-DwTtmund.js.map} +1 -1
  24. package/dist/chunks/lazy-Ce5zEAq1.js +66 -0
  25. package/dist/chunks/lazy-Ce5zEAq1.js.map +1 -0
  26. package/dist/chunks/{log-buffer-HnP0jKhZ.js → log-buffer-Dy9HHDMD.js} +114 -50
  27. package/dist/chunks/log-buffer-Dy9HHDMD.js.map +1 -0
  28. package/dist/chunks/{logs-gI_69Q1P.js → logs---TI_bxM.js} +23 -21
  29. package/dist/chunks/logs---TI_bxM.js.map +1 -0
  30. package/dist/chunks/{migrate-BTlsibvF.js → migrate-Cfoq-Vgh.js} +5 -5
  31. package/dist/chunks/{migrate-BTlsibvF.js.map → migrate-Cfoq-Vgh.js.map} +1 -1
  32. package/dist/chunks/{nanny-CjnnrIpm.js → nanny-B-Eu0sFW.js} +3 -3
  33. package/dist/chunks/{nanny-CjnnrIpm.js.map → nanny-B-Eu0sFW.js.map} +1 -1
  34. package/dist/chunks/{nanny-20aBXL1o.js → nanny-BtWfy0QH.js} +121 -23
  35. package/dist/chunks/nanny-BtWfy0QH.js.map +1 -0
  36. package/dist/chunks/{nanny-DUaAfCV-.js → nanny-ChMtq1Zl.js} +3 -3
  37. package/dist/chunks/{nanny-DUaAfCV-.js.map → nanny-ChMtq1Zl.js.map} +1 -1
  38. package/dist/chunks/{nanny-sweep-Ca9kPAVi.js → nanny-sweep-DErnlPY1.js} +5 -4
  39. package/dist/chunks/nanny-sweep-DErnlPY1.js.map +1 -0
  40. package/dist/chunks/{parse-B9owE47G.js → parse-DhmG26fI.js} +4 -4
  41. package/dist/chunks/{parse-B9owE47G.js.map → parse-DhmG26fI.js.map} +1 -1
  42. package/dist/chunks/{paths-BT94q6-w.js → paths-CGlGDrOU.js} +36 -2
  43. package/dist/chunks/paths-CGlGDrOU.js.map +1 -0
  44. package/dist/chunks/{restart-UZgeDukG.js → restart-Des4DrAN.js} +25 -59
  45. package/dist/chunks/restart-Des4DrAN.js.map +1 -0
  46. package/dist/chunks/{schema-o7Lgk0V1.js → schema-B240VXcV.js} +11 -10
  47. package/dist/chunks/schema-B240VXcV.js.map +1 -0
  48. package/dist/chunks/{secrets-D7PdYh71.js → secrets-BieELnZh.js} +22 -4
  49. package/dist/chunks/secrets-BieELnZh.js.map +1 -0
  50. package/dist/chunks/{server-BuIeSsRu.js → server-Bge2r2qQ.js} +3 -3
  51. package/dist/chunks/{server-BuIeSsRu.js.map → server-Bge2r2qQ.js.map} +1 -1
  52. package/dist/chunks/{set-password-DegMumPh.js → set-password-D5vZqqSX.js} +7 -7
  53. package/dist/chunks/set-password-D5vZqqSX.js.map +1 -0
  54. package/dist/chunks/{set-token-21d1FTDC.js → set-token-obPiEJYk.js} +7 -7
  55. package/dist/chunks/set-token-obPiEJYk.js.map +1 -0
  56. package/dist/chunks/{settings-BVSBnIwJ.js → settings-xu-XTfWg.js} +126 -35
  57. package/dist/chunks/settings-xu-XTfWg.js.map +1 -0
  58. package/dist/chunks/{setup-temp-XiuAtiW2.js → setup-temp-CAN4_bA-.js} +6 -6
  59. package/dist/chunks/setup-temp-CAN4_bA-.js.map +1 -0
  60. package/dist/chunks/{src-BL97vLVb.js → src-BtWMFmzZ.js} +2246 -1061
  61. package/dist/chunks/src-BtWMFmzZ.js.map +1 -0
  62. package/dist/chunks/{status-EuWdRq8Q.js → status-DT1EsA-B.js} +12 -8
  63. package/dist/chunks/status-DT1EsA-B.js.map +1 -0
  64. package/dist/chunks/{ui-DbPuwddJ.js → ui-D562aqw5.js} +9 -7
  65. package/dist/chunks/ui-D562aqw5.js.map +1 -0
  66. package/dist/chunks/{ui-revert-BhqOAhmM.js → ui-revert-EkBBwRTt.js} +3 -3
  67. package/dist/chunks/{ui-revert-BhqOAhmM.js.map → ui-revert-EkBBwRTt.js.map} +1 -1
  68. package/dist/chunks/{ui-switch-CMoslPO2.js → ui-switch-BnZTdMDd.js} +3 -3
  69. package/dist/chunks/{ui-switch-CMoslPO2.js.map → ui-switch-BnZTdMDd.js.map} +1 -1
  70. package/dist/chunks/{ui-update-TTBBoDik.js → ui-update-_xryLYxw.js} +5 -5
  71. package/dist/chunks/{ui-update-TTBBoDik.js.map → ui-update-_xryLYxw.js.map} +1 -1
  72. package/dist/chunks/{up-C4H13hBw.js → up-Pdz-l6IH.js} +25 -11
  73. package/dist/chunks/up-Pdz-l6IH.js.map +1 -0
  74. package/dist/chunks/{usage-CSBgLRN5.js → usage-DFrCVXpT.js} +29 -3
  75. package/dist/chunks/usage-DFrCVXpT.js.map +1 -0
  76. package/dist/chunks/{workspaces-CAln2sQ7.js → workspaces-DYcfvKV_.js} +16 -8
  77. package/dist/chunks/workspaces-DYcfvKV_.js.map +1 -0
  78. package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +1 -1
  79. package/dist/cli.js +80 -70
  80. package/dist/cli.js.map +1 -1
  81. package/dist/client.js +25 -1
  82. package/dist/client.js.map +1 -1
  83. package/dist/types/api/backups.d.ts +8 -3
  84. package/dist/types/api/control.d.ts +4 -3
  85. package/dist/types/api/events.d.ts +2 -1
  86. package/dist/types/api/health.d.ts +1 -0
  87. package/dist/types/api/metrics.d.ts +3 -1
  88. package/dist/types/api/settings.d.ts +2 -2
  89. package/dist/types/api/state.d.ts +8 -2
  90. package/dist/types/app.d.ts +26 -11
  91. package/dist/types/cli/backup.d.ts +7 -0
  92. package/dist/types/cli/down.d.ts +5 -0
  93. package/dist/types/cli/logs.d.ts +14 -2
  94. package/dist/types/cli/restart.d.ts +0 -1
  95. package/dist/types/cli/set-password.d.ts +2 -2
  96. package/dist/types/cli/up.d.ts +8 -2
  97. package/dist/types/client.d.ts +5618 -11
  98. package/dist/types/config/secrets.d.ts +2 -0
  99. package/dist/types/config/settings.d.ts +54 -8
  100. package/dist/types/config/store.d.ts +16 -3
  101. package/dist/types/config/workspaces.d.ts +4 -1
  102. package/dist/types/helpers/copy-tree.d.ts +5 -0
  103. package/dist/types/helpers/daemon.d.ts +20 -7
  104. package/dist/types/helpers/error.d.ts +8 -0
  105. package/dist/types/helpers/event-stream.d.ts +21 -0
  106. package/dist/types/helpers/openapi.d.ts +12 -24
  107. package/dist/types/helpers/paths.d.ts +18 -0
  108. package/dist/types/helpers/utf8-chunks.d.ts +15 -0
  109. package/dist/types/middleware/auth.d.ts +19 -3
  110. package/dist/types/providers/host.d.ts +1 -1
  111. package/dist/types/providers/log-tail.d.ts +27 -0
  112. package/dist/types/providers/nanny-sweep.d.ts +3 -0
  113. package/dist/types/providers/nanny.d.ts +10 -0
  114. package/dist/types/providers/proc.d.ts +9 -0
  115. package/dist/types/providers/process.d.ts +17 -0
  116. package/dist/types/providers/telegram.d.ts +45 -3
  117. package/dist/types/providers/wsl-temperature.d.ts +0 -4
  118. package/dist/types/services/auth.d.ts +36 -4
  119. package/dist/types/services/backups.d.ts +125 -1
  120. package/dist/types/services/ddns.d.ts +5 -0
  121. package/dist/types/services/exposure.d.ts +54 -1
  122. package/dist/types/services/history.d.ts +1 -0
  123. package/dist/types/services/host-monitor.d.ts +1 -0
  124. package/dist/types/services/log-buffer.d.ts +11 -0
  125. package/dist/types/services/log-files.d.ts +1 -11
  126. package/dist/types/services/log-relay.d.ts +0 -1
  127. package/dist/types/services/panel.d.ts +19 -0
  128. package/dist/types/services/proxy-certificates/certificates.d.ts +116 -0
  129. package/dist/types/services/proxy.d.ts +46 -69
  130. package/dist/types/services/state.d.ts +0 -3
  131. package/dist/types/services/supervisor/entry.d.ts +10 -0
  132. package/dist/types/services/supervisor/health.d.ts +3 -2
  133. package/dist/types/services/supervisor/output.d.ts +126 -0
  134. package/dist/types/services/supervisor/persistent.d.ts +4 -1
  135. package/dist/types/services/supervisor/records.d.ts +81 -1
  136. package/dist/types/services/supervisor.d.ts +32 -0
  137. package/dist/types/shared/action-outcome.d.ts +25 -0
  138. package/dist/types/shared/api-client.d.ts +218 -4
  139. package/dist/types/shared/backup-scope.d.ts +58 -0
  140. package/dist/types/shared/contracts.d.ts +142 -200
  141. package/dist/types/shared/ddns-form.d.ts +13 -0
  142. package/dist/types/shared/form-repair.d.ts +6 -0
  143. package/dist/types/shared/lazy.d.ts +4 -0
  144. package/dist/types/shared/live-frames.d.ts +22 -0
  145. package/dist/types/shared/live-series.d.ts +21 -0
  146. package/dist/types/shared/live-store.d.ts +72 -0
  147. package/dist/types/shared/patch-diff.d.ts +13 -2
  148. package/dist/types/shared/proxy-form.d.ts +2 -0
  149. package/dist/types/shared/server-form.d.ts +121 -0
  150. package/dist/types/shared/stream-access.d.ts +20 -0
  151. package/docs/API.md +45 -16
  152. package/docs/BACKUPS.md +31 -11
  153. package/docs/CLI.md +34 -61
  154. package/docs/DDNS.md +3 -1
  155. package/docs/NOTIFICATIONS.md +7 -1
  156. package/docs/REVERSE_PROXY.md +7 -1
  157. package/docs/SECURITY.md +21 -10
  158. package/docs/SERVERS.md +102 -23
  159. package/docs/UI_CREATION.md +10 -1
  160. package/docs/demo/blank-host-restore.sh +4 -3
  161. package/package.json +5 -7
  162. package/uis/stock/dist/assets/CopyButton-BUBKRJyY.js +1 -0
  163. package/uis/stock/dist/assets/GlobalSettingsView-yYMcRWvt.js +1 -0
  164. package/uis/stock/dist/assets/LogViewer-DIliXy62.js +1 -0
  165. package/uis/stock/dist/assets/LogsView-B7Z-7RNg.js +1 -0
  166. package/uis/stock/dist/assets/Modal-DmKa5Qpp.js +39 -0
  167. package/uis/stock/dist/assets/ProxyView-DvZiNkwb.js +1 -0
  168. package/uis/stock/dist/assets/ServerDetailView-6idGT_EX.js +2 -0
  169. package/uis/stock/dist/assets/SettingsShell-CeGtleYI.js +1 -0
  170. package/uis/stock/dist/assets/SettingsView-BrhJIrmk.js +2 -0
  171. package/uis/stock/dist/assets/de-BRITeb0H.js +1 -0
  172. package/uis/stock/dist/assets/es-B2zIEssV.js +1 -0
  173. package/uis/stock/dist/assets/fr-s0ZOBEqh.js +1 -0
  174. package/uis/stock/dist/assets/index-C1MehbKy.css +2 -0
  175. package/uis/stock/dist/assets/index-CnBN54wF.js +15 -0
  176. package/uis/stock/dist/assets/ja-CU7MR85V.js +1 -0
  177. package/uis/stock/dist/assets/ko-tL5Me6d-.js +1 -0
  178. package/uis/stock/dist/assets/ru-92yrvkNJ.js +1 -0
  179. package/uis/stock/dist/assets/vi-CzvY16k2.js +1 -0
  180. package/uis/stock/dist/assets/zh-CN-DDwFW_uW.js +1 -0
  181. package/uis/stock/dist/index.html +3 -2
  182. package/uis/stock/dist/ui.json +3 -3
  183. package/dist/chunks/archive-DpCwA8Nf.js.map +0 -1
  184. package/dist/chunks/atomic-CEfCUfkQ.js.map +0 -1
  185. package/dist/chunks/backup-CPrJVPJI.js.map +0 -1
  186. package/dist/chunks/backups-Bd2SF2qd.js.map +0 -1
  187. package/dist/chunks/contracts-ku5ypHXJ.js.map +0 -1
  188. package/dist/chunks/daemon-TwXk5vb8.js.map +0 -1
  189. package/dist/chunks/docker-CGv4Uv7w.js.map +0 -1
  190. package/dist/chunks/down-BlX5X3bm.js.map +0 -1
  191. package/dist/chunks/init-DdmqHVra.js.map +0 -1
  192. package/dist/chunks/last-stop-BZ08Z89-.js.map +0 -1
  193. package/dist/chunks/log-buffer-HnP0jKhZ.js.map +0 -1
  194. package/dist/chunks/logs-gI_69Q1P.js.map +0 -1
  195. package/dist/chunks/nanny-20aBXL1o.js.map +0 -1
  196. package/dist/chunks/nanny-sweep-Ca9kPAVi.js.map +0 -1
  197. package/dist/chunks/paths-BT94q6-w.js.map +0 -1
  198. package/dist/chunks/restart-UZgeDukG.js.map +0 -1
  199. package/dist/chunks/schema-o7Lgk0V1.js.map +0 -1
  200. package/dist/chunks/secrets-D7PdYh71.js.map +0 -1
  201. package/dist/chunks/set-password-DegMumPh.js.map +0 -1
  202. package/dist/chunks/set-token-21d1FTDC.js.map +0 -1
  203. package/dist/chunks/settings-BVSBnIwJ.js.map +0 -1
  204. package/dist/chunks/setup-temp-XiuAtiW2.js.map +0 -1
  205. package/dist/chunks/src-BL97vLVb.js.map +0 -1
  206. package/dist/chunks/status-EuWdRq8Q.js.map +0 -1
  207. package/dist/chunks/ui-DbPuwddJ.js.map +0 -1
  208. package/dist/chunks/up-C4H13hBw.js.map +0 -1
  209. package/dist/chunks/usage-CSBgLRN5.js.map +0 -1
  210. package/dist/chunks/workspaces-CAln2sQ7.js.map +0 -1
  211. package/docs/RESTORE_DEMO.md +0 -306
  212. package/uis/stock/dist/assets/de-DyGrM1KK.js +0 -1
  213. package/uis/stock/dist/assets/es-BebHdc0E.js +0 -1
  214. package/uis/stock/dist/assets/fr-DsDTrxhI.js +0 -1
  215. package/uis/stock/dist/assets/index-6LANO2Ua.css +0 -2
  216. package/uis/stock/dist/assets/index-D06cUZbM.js +0 -56
  217. package/uis/stock/dist/assets/ja-D3RARJjW.js +0 -1
  218. package/uis/stock/dist/assets/ko-CKI3dFoD.js +0 -1
  219. package/uis/stock/dist/assets/ru-DEU5ujXt.js +0 -1
  220. package/uis/stock/dist/assets/vi-ULKPnasj.js +0 -1
  221. package/uis/stock/dist/assets/zh-CN-tCvnOxWy.js +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"status-EuWdRq8Q.js","names":[],"sources":["../../src/cli/status.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { bold, dim, firstRunPassword, green, invocation, paint } from '#src/cli/io'\n\n/** `status` answers \"is it running, where, and how do I reach it\". */\n\nexport const statusArgs = {\n json: { type: 'boolean', description: 'print machine-readable JSON' },\n} as const\n\nexport async function runStatus(json: boolean): Promise<void> {\n const { configuredPanelAddress, isLiveLiveness, probeRuntime, readRuntime, runtimeLiveness } = await import('#src/helpers/daemon')\n const { customUiInstalled, uiIdentity } = await import('#src/helpers/ui-dir')\n const { hhDir: dataRoot, workspaceDir, workspacesPath } = await import('#src/helpers/paths')\n const { readLastStop } = await import('#src/helpers/last-stop')\n // The per-server log directory is the **default workspace's**, and \"which one is the default\" is\n // the panel's own rule (`defaultWorkspaceId`), not the `default` id: a host that declares only\n // `[\"media\"]` writes `.hh/media/.logs/<id>.log`, and the literal path printed here named a\n // directory that never existed. Measured against a live panel of that shape, in both outputs.\n const { readDefaultWorkspaceId } = await import('#src/config/workspaces')\n const serverLogsDir = path.join(workspaceDir(readDefaultWorkspaceId(workspacesPath)), '.logs')\n const runtime = readRuntime()\n\n if (runtime === null) {\n // \"Not running\" and \"never set up\" are different answers: the first says wait or start it, the\n // second says there is nothing here yet. `workspaces.json` is what tells them apart — it is\n // written by the first successful `up`/`init`, so its absence means nothing was ever created.\n const initialised = fs.existsSync(workspacesPath)\n // \"You stopped it\" and \"it died\" both leave no record: `down` deletes the record a clean stop\n // ends, and `up` deletes the one a crash left behind. Only a deliberate stop writes\n // `.last-stop.json`, so that file is the difference — reported as a field rather than left for\n // a script to infer from which keys happen to be missing.\n const lastStop = readLastStop()\n // A record is not the machine. With `run.json` gone, this branch printed \"home-hosted is not\n // running\" while the panel on the port its own `settings.json` names answered `GET /healthz`\n // with 200 — so a `status` in a diagnostic session denied the very panel being diagnosed.\n // `down` already probes for this shape (it refuses rather than let `down && up` start a second\n // panel over a live one); the same probe answers here, and nothing is signalled — without a\n // record there is no pid this command can prove it owns, so no pid is reported either.\n const answering = await configuredPanelAddress()\n if (json) {\n // `liveness` is always present, because the contract says so and a script should not have to\n // branch on whether a record exists. No `run.json` is not \"unknown\": nothing is behind the\n // pid, which is exactly `gone` — a fact, not an omission. `answering` is what tells the two\n // situations apart: a stopped panel and one still serving without its record both read\n // `running: false`, and only this field separates them.\n process.stdout.write(`${JSON.stringify({\n running: false,\n initialised,\n liveness: 'gone',\n // True only when a `down` recorded it. A crash writes no marker, so this stays false.\n exitedCleanly: lastStop !== null,\n ...(lastStop === null ? {} : { lastStopAt: lastStop.at }),\n ...(answering === null ? {} : { answeringWithoutRecord: answering }),\n }, null, 2)}\\n`)\n }\n else if (answering !== null) {\n process.stdout.write(`home-hosted is not running, but something is answering on ${answering} — no run.json records which process owns it, so this cannot name or signal a pid; stop it yourself, or free that port, then run \\`${invocation()} up\\`\\n`)\n }\n else if (initialised) {\n process.stdout.write(`home-hosted is not running — start it with \\`${invocation()} up\\`\\n`)\n }\n else {\n process.stdout.write(`home-hosted is not running — nothing is set up here yet; \\`${invocation()} init\\` creates a project, \\`${invocation()} up\\` starts one here\\n`)\n }\n process.exitCode = 1\n return\n }\n\n // A pid that is merely *alive* is not the panel: the OS recycles pids, so the record's own\n // `startedAt` decides whether the process behind it is still this daemon.\n const liveness = await runtimeLiveness(runtime)\n const running = isLiveLiveness(liveness)\n const probe = running ? await probeRuntime(runtime) : { reachable: false, degraded: false, servers: null }\n\n // Read once, above both outputs, so they cannot disagree about which UI is installed — the text\n // form prints it as a row and a script asking for JSON needs it just as much.\n const ui = { custom: customUiInstalled(dataRoot) }\n const uiMeta = uiIdentity(dataRoot)\n const uiLabel = ui.custom ? uiMeta.name ?? 'installed' : 'stock'\n\n if (json) {\n // The token is what authorises a local shutdown; a script only needs the rest.\n const { token: _token, ...safe } = runtime\n // `logsDir` belongs here too: the text output prints it, and a script asking for JSON needs\n // the same paths — the panel console's file is not where a *server's* log lives.\n process.stdout.write(`${JSON.stringify({\n running,\n // The reason `running` is false: a dead pid (`gone`) and one the OS recycled (`recycled`)\n // are different problems, and `answering: false` alone reads as a panel that is up but wedged.\n liveness,\n answering: probe.reachable,\n degraded: probe.degraded,\n // \"Did everything come back after the reboot\" is what `running` cannot answer: a panel up with\n // every entry stopped reads exactly like a healthy one. `null` rather than `0` when the panel\n // did not report a count, so an older panel is not shown as supervising nothing.\n servers: probe.servers,\n // A record still here whose process is not is the other half of the question: nobody stopped\n // this panel, so it died. Reported as a fact rather than inferred from a leftover `pid`.\n exitedCleanly: false,\n ...safe,\n logsDir: serverLogsDir,\n ui: { custom: ui.custom, name: uiLabel, version: uiMeta.version },\n }, null, 2)}\\n`)\n if (!running)\n process.exitCode = 1\n return\n }\n\n const uptime = formatDuration(Date.now() - runtime.startedAt)\n const state = !running\n ? liveness === 'recycled'\n // Distinct from a dead pid: the number in this record now belongs to something else, which is\n // what made `up` refuse with \"already running\" while nothing was actually serving.\n ? paint('31', 'stale (the pid belongs to another process now)')\n : paint('31', 'stale (the process is gone)')\n : probe.degraded\n ? paint('33', 'running — a server needs attention')\n : probe.reachable ? green('running') : paint('33', 'running, but not answering')\n\n const rows: Array<[string, string]> = [\n ['status', state],\n // The inventory: a reboot script's whole question is \"3 of 3 came back\". Shown only while the\n // panel is up, and `n/a` when it answered without a count rather than claiming zero entries.\n ...(running ? [['servers', serversRow(probe.servers)] as [string, string]] : []),\n ['pid', running ? `${runtime.pid} · up ${uptime}` : String(runtime.pid)],\n ['url', `${runtime.url} ${dim(`(${runtime.protocol})`)}`],\n ['version', runtime.version],\n ['project', runtime.projectDir],\n ['state', runtime.dataRoot],\n ['internal', runtime.configPath],\n ['log', runtime.logFile],\n // The per-server logs sit beside the workspace's config, not beside the console log — and\n // the README says `status` prints the paths, so the one an operator needs to read a\n // *server's* log belongs here too. The filename convention is part of the answer: knowing the\n // directory does not tell you that the entry `api` writes `api.log`, and `home-hosted logs`\n // reads the *panel's* console, not a server's, so there is otherwise no CLI hint at all.\n // Shown only when the directory exists, because naming a convention for logs never written\n // would send someone looking for a file that is not there.\n ['serverlogs', fs.existsSync(serverLogsDir) ? `${serverLogsDir} (one file per server: <id>.log)` : serverLogsDir],\n ['ui', ui.custom ? `custom — ${uiLabel} (revert with \\`${invocation()} ui-revert\\`)` : 'stock'],\n ]\n const initial = await firstRunPassword()\n if (initial !== null)\n rows.push(['password', `${paint('33', initial)} ${dim('(first-run password — change it in Global settings → Authentication)')}`])\n\n process.stdout.write(`${bold(`home-hosted ${runtime.version}`)}\\n`)\n // Width from the rows, not a literal: the column was hard-coded at 8 until a 10-character\n // label (\"serverlogs\") was added and pushed every value out of alignment.\n const width = Math.max(...rows.map(([label]) => label.length))\n for (const [label, value] of rows)\n process.stdout.write(` ${dim(label.padEnd(width))} ${value}\\n`)\n if (!running)\n process.exitCode = 1\n}\n\n/**\n * \"3 of 3 up\" — the inventory row, or `n/a` when the panel answered without a count.\n *\n * A stopped entry is not a failure (an operator stops what they do not need), so this reads as\n * neutral; the *degraded* sentence on the status row is what marks something broken.\n */\nfunction serversRow(counts: { total: number, running: number } | null): string {\n if (counts === null)\n return dim('n/a (the panel did not report a count)')\n if (counts.total === 0)\n return 'none configured'\n return counts.running === counts.total\n ? green(`${counts.running} of ${counts.total} up`)\n : `${counts.running} of ${counts.total} up`\n}\n\nfunction formatDuration(ms: number): string {\n const seconds = Math.max(0, Math.round(ms / 1000))\n if (seconds < 60)\n return `${seconds}s`\n const minutes = Math.floor(seconds / 60)\n if (minutes < 60)\n return `${minutes}m`\n const hours = Math.floor(minutes / 60)\n if (hours < 24)\n return `${hours}h ${minutes % 60}m`\n return `${Math.floor(hours / 24)}d ${hours % 24}h`\n}\n\nexport const statusCommand = defineCommand({\n meta: { name: 'status' },\n args: statusArgs,\n run: async ({ args }) => {\n await runStatus(args.json === true)\n },\n})\n"],"mappings":";;;;;;;AAQA,IAAa,aAAa,EACxB,MAAM;CAAE,MAAM;CAAW,aAAa;AAA8B,EACtE;AAEA,eAAsB,UAAU,MAA8B;CAC5D,MAAM,EAAE,wBAAwB,gBAAgB,cAAc,aAAa,oBAAoB,MAAM,OAAO;CAC5G,MAAM,EAAE,mBAAmB,eAAe,MAAM,OAAO,uBAAA,CAAA,MAAA,MAAA,EAAA,CAAA;CACvD,MAAM,EAAE,OAAO,UAAU,cAAc,mBAAmB,MAAM,OAAO,sBAAA,CAAA,MAAA,MAAA,EAAA,CAAA;CACvE,MAAM,EAAE,iBAAiB,MAAM,OAAO,0BAAA,CAAA,MAAA,MAAA,EAAA,CAAA;CAKtC,MAAM,EAAE,2BAA2B,MAAM,OAAO,2BAAA,CAAA,MAAA,MAAA,EAAA,CAAA;CAChD,MAAM,gBAAgB,KAAK,KAAK,aAAa,uBAAuB,cAAc,CAAC,GAAG,OAAO;CAC7F,MAAM,UAAU,YAAY;CAE5B,IAAI,YAAY,MAAM;EAIpB,MAAM,cAAc,GAAG,WAAW,cAAc;EAKhD,MAAM,WAAW,aAAa;EAO9B,MAAM,YAAY,MA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;;;;;;;AAQA,SAAS,WAAW,QAA2D;CAC7E,IAAI,WAAW,MACb,OAAO,IAAI,wCAAwC;CACrD,IAAI,OAAO,UAAU,GACnB,OAAO;CACT,OAAO,OAAO,YAAY,OAAO,QAC7B,MAAM,GAAG,OAAO,QAAQ,MAAM,OAAO,MAAM,IAAI,IAC/C,GAAG,OAAO,QAAQ,MAAM,OAAO,MAAM;AAC3C;AAEA,SAAS,eAAe,IAAoB;CAC1C,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,GAAI,CAAC;CACjD,IAAI,UAAU,IACZ,OAAO,GAAG,QAAQ;CACpB,MAAM,UAAU,KAAK,MAAM,UAAU,EAAE;CACvC,IAAI,UAAU,IACZ,OAAO,GAAG,QAAQ;CACpB,MAAM,QAAQ,KAAK,MAAM,UAAU,EAAE;CACrC,IAAI,QAAQ,IACV,OAAO,GAAG,MAAM,IAAI,UAAU,GAAG;CACnC,OAAO,GAAG,KAAK,MAAM,QAAQ,EAAE,EAAE,IAAI,QAAQ,GAAG;AAClD;AAEA,IAAa,gBAAgB,cAAc;CACzC,MAAM,EAAE,MAAM,SAAS;CACvB,MAAM;CACN,KAAK,OAAO,EAAE,WAAW;EACvB,MAAM,UAAU,KAAK,SAAS,IAAI;CACpC;AACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui-DbPuwddJ.js","names":[],"sources":["../../src/services/ui.ts"],"sourcesContent":["import type { ArchiveEntry } from '#src/providers/archive'\nimport type { UiMeta, UiStatus } from '#src/shared/contracts'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { type } from 'arktype'\nimport { writeFileAtomic } from '#src/helpers/atomic'\nimport { readStateFile } from '#src/helpers/config-text'\nimport { customUiInstalled, uiDirectory } from '#src/helpers/ui-dir'\nimport { extractZip, isZipArchive, listZip } from '#src/providers/archive'\nimport { uiMetaSchema } from '#src/shared/contracts'\nimport { errorMessage } from '#src/shared/error-message'\n\n/**\n * The panel's UI is replaceable: the stock SPA ships in the package, and a user\n * can put their own build in `$HHOSTED_HOME/.ui` — by hand, or by uploading a zip\n * in the settings page. Everything that serves files asks `resolveDir()` per\n * request, so an install (or `home-hosted ui-revert`) applies on the next refresh.\n */\n\nconst META = 'ui.json'\n/** A UI is static files; these caps keep a hostile or accidental archive harmless. */\nconst MAX_ENTRIES = 20_000\nconst MAX_BYTES = 512 * 1024 * 1024\nconst MAX_NAME = 120\n\n/** What a UI author may declare in a root `ui.json` inside their archive. */\nconst manifestSchema = type({\n 'name?': 'string',\n 'version?': 'string',\n 'repo?': 'string',\n 'tag?': 'string',\n 'asset?': 'string',\n 'unix?': 'number.integer >= 0',\n})\n\n/**\n * A UI archive is a static site: relative paths only, no traversal, no absolute\n * paths, no drive letters, and an `index.html` to serve. Symlinks are dropped by\n * the extractor.\n */\nexport function isSafeUiEntry(entry: string): boolean {\n if (entry.length === 0 || entry.length > MAX_NAME)\n return false\n if (entry.startsWith('/') || entry.includes('\\\\') || entry.includes('\\0'))\n return false\n\n const cleaned = entry.replace(/^\\.\\//, '').replace(/\\/+$/, '')\n if (cleaned.length === 0)\n return false\n return cleaned.split('/').every(segment => segment !== '' && segment !== '.' && segment !== '..' && !segment.includes(':'))\n}\n\nexport type UiInstallResult\n = | { ok: true, meta: UiMeta }\n | { ok: false, error: string }\n\nexport class UiService {\n constructor(private readonly options: { dataRoot: string, stockDir?: string }) {}\n\n /** `$HHOSTED_HOME/.ui` — the only place a user UI is ever read from. */\n get directory(): string {\n return uiDirectory(this.options.dataRoot)\n }\n\n /** True when a user UI is installed and complete. */\n get custom(): boolean {\n return customUiInstalled(this.options.dataRoot)\n }\n\n /** What the panel should serve right now. */\n resolveDir(): string {\n if (this.custom)\n return this.directory\n return this.options.stockDir ?? this.directory\n }\n\n status(): UiStatus {\n return { custom: this.custom, dir: this.directory, meta: this.readMeta() }\n }\n\n readMeta(): UiMeta | null {\n try {\n // Through `readStateFile`: `ui.json` is written by a UI author, and a Windows editor puts a\n // BOM on it — which fails `JSON.parse` as `Unexpected token '\\uFEFF'`, so the panel reported\n // an installed UI as unnamed and `ui-update` claimed \"the stock UI is in use\".\n const parsed = uiMetaSchema(JSON.parse(readStateFile(path.join(this.directory, META))))\n return parsed instanceof type.errors ? null : parsed\n }\n catch {\n return null\n }\n }\n\n /**\n * Installs a UI from a zip. The archive is extracted beside `.ui` and only then\n * swapped in, so a failed upload leaves the previous UI (or the stock one)\n * serving.\n */\n async install(archivePath: string, fallbackName = 'custom-ui', installedTag?: string): Promise<UiInstallResult> {\n if (!isZipArchive(archivePath))\n return { ok: false, error: 'the upload is not a zip archive' }\n\n // Unique per attempt, not just per millisecond: two installs starting together would\n // otherwise stage into the same directory and rename each other's tree away.\n const staging = path.join(this.options.dataRoot, `.ui-staging-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`)\n\n try {\n return await this.stage(archivePath, staging, fallbackName, installedTag)\n }\n catch (error) {\n return { ok: false, error: errorMessage(error) }\n }\n finally {\n fs.rmSync(staging, { recursive: true, force: true })\n }\n }\n\n /** Removes the user UI, putting the stock panel back. */\n revert(): boolean {\n const existed = fs.existsSync(this.directory)\n fs.rmSync(this.directory, { recursive: true, force: true })\n return existed\n }\n\n private async stage(archivePath: string, staging: string, fallbackName: string, installedTag?: string): Promise<UiInstallResult> {\n let entries: ArchiveEntry[]\n try {\n entries = await listZip(archivePath)\n }\n catch (error) {\n return { ok: false, error: `the archive could not be read: ${errorMessage(error)}` }\n }\n\n if (entries.length === 0)\n return { ok: false, error: 'the archive is empty' }\n if (entries.length > MAX_ENTRIES)\n return { ok: false, error: `the archive has more than ${MAX_ENTRIES} entries` }\n\n const bytes = entries.reduce((total, entry) => total + entry.size, 0)\n if (bytes > MAX_BYTES)\n return { ok: false, error: `the archive is larger than ${Math.round(MAX_BYTES / 1024 / 1024)}MB uncompressed` }\n\n const unusable = entries.find(entry => !isSafeUiEntry(entry.name))\n if (unusable !== undefined)\n return { ok: false, error: `the archive contains an unusable path: ${unusable.name}` }\n\n fs.mkdirSync(staging, { recursive: true })\n await extractZip(archivePath, staging, { names: entries.map(entry => entry.name) })\n\n const root = resolveRoot(staging)\n if (root === null)\n return { ok: false, error: 'the archive has no index.html at its root' }\n\n const manifest = readManifest(root)\n const meta: UiMeta = {\n name: manifest?.name ?? fallbackName,\n version: manifest?.version ?? null,\n uploadedAt: Date.now(),\n files: countFiles(root),\n // The declared identity is carried into the installed metadata, so `ui-update` can\n // still tell which release this UI came from long after the zip is gone. Omitted\n // rather than defaulted: a UI that declares nothing has nothing to say here.\n ...(manifest?.repo === undefined ? {} : { repo: manifest.repo }),\n // The caller that fetched this from a release knows the tag better than the archive\n // does: a UI zip is built *before* the release is cut, so its own `tag` is the\n // previous release at best. Recording the archive's value here is what made a panel\n // re-download and re-install the same UI on every boot.\n ...(installedTag !== undefined ? { tag: installedTag } : manifest?.tag === undefined ? {} : { tag: manifest.tag }),\n ...(manifest?.asset === undefined ? {} : { asset: manifest.asset }),\n ...(manifest?.unix === undefined ? {} : { unix: manifest.unix }),\n }\n\n // Metadata is written while the tree is still in staging, so the swap below is two\n // renames and nothing else — the window where `.ui` does not exist shrinks to that.\n writeFileAtomic(path.join(root, META), `${JSON.stringify(meta, null, 2)}\\n`)\n\n return commitSwap(this.options.dataRoot, this.directory, root, meta)\n }\n\n /**\n * Puts a half-finished install back together, and is safe to call on every boot.\n *\n * An install that was interrupted between its two renames — a kill, a power cut, a\n * crash — leaves `.ui` missing with the user's only copy sitting in a `.previous-*`\n * sibling. Without this the panel would quietly serve the stock UI forever, because\n * `custom` is false and nothing ever looked at the backup.\n */\n recover(): { restored: string | null, swept: number } {\n const resting = this.directory\n let restored: string | null = null\n\n if (!fs.existsSync(path.join(resting, 'index.html'))) {\n const backup = newestBackup(this.options.dataRoot, resting)\n if (backup !== null) {\n fs.rmSync(resting, { recursive: true, force: true })\n fs.renameSync(backup, resting)\n restored = path.basename(backup)\n }\n }\n\n // Only after the live tree is whole again: a leftover backup is the last resort.\n return { restored, swept: sweepJunk(this.options.dataRoot) }\n }\n}\n\n/**\n * Serializes installs per data root. `Settings → Interface`, the boot hook and a second\n * panel can all reach the same `.ui`, and two interleaved swaps could leave it absent.\n * The key is the directory rather than the instance: every caller builds its own\n * `UiService`. Cross-process overlap is still possible, which is why the swap is\n * crash-recoverable — this closes the window that was open *within* a process.\n */\nconst installLocks = new Map<string, Promise<unknown>>()\n\nfunction withInstallLock<T>(dataRoot: string, run: () => Promise<T>): Promise<T> {\n const key = path.resolve(dataRoot)\n const previous = installLocks.get(key) ?? Promise.resolve()\n // Chain whether or not the predecessor succeeded: a failed install must not wedge the lock.\n const next = previous.then(run, run)\n installLocks.set(key, next.catch(() => {}))\n return next\n}\n\n/** Renames the staged tree into place, keeping the old one until that has certainly worked. */\nfunction commitSwap(dataRoot: string, resting: string, staged: string, meta: UiMeta): Promise<UiInstallResult> {\n return withInstallLock(dataRoot, async () => {\n // One rename, and no window at all: POSIX renames a directory onto an existing one.\n try {\n fs.renameSync(staged, resting)\n }\n catch {\n // Windows refuses that when the target is a non-empty directory, so the old tree\n // steps aside first — immediately, with no I/O in between.\n const previous = `${resting}.previous-${process.pid}-${Date.now()}`\n const hadPrevious = fs.existsSync(resting)\n if (hadPrevious)\n fs.renameSync(resting, previous)\n\n try {\n fs.renameSync(staged, resting)\n }\n catch (error) {\n // Put the user's UI back before reporting. If even that fails, keep the backup\n // and say where it is — deleting it would destroy the only copy.\n try {\n fs.rmSync(resting, { recursive: true, force: true })\n if (hadPrevious && fs.existsSync(previous))\n fs.renameSync(previous, resting)\n fs.rmSync(previous, { recursive: true, force: true })\n }\n catch {\n return { ok: false, error: `${describeError(error)} — the previous UI is kept at ${previous}` }\n }\n return { ok: false, error: describeError(error) }\n }\n\n fs.rmSync(previous, { recursive: true, force: true })\n }\n\n // Any backup older than this successful swap is now unreferenced; sweep them so an\n // interrupted install cannot leave a pile of stale full copies behind.\n sweepBackups(dataRoot, resting)\n return { ok: true, meta }\n })\n}\n\nfunction sweepBackups(dataRoot: string, resting: string): void {\n const prefix = `${path.basename(resting)}.previous-`\n for (const entry of readDataRoot(dataRoot)) {\n if (entry.startsWith(prefix))\n fs.rmSync(path.join(dataRoot, entry), { recursive: true, force: true })\n }\n}\n\n/** The most recently abandoned UI tree, or null when there is not one. */\nfunction newestBackup(dataRoot: string, resting: string): string | null {\n const prefix = `${path.basename(resting)}.previous-`\n let best: string | null = null\n let bestStamp = -1\n\n for (const entry of readDataRoot(dataRoot)) {\n if (!entry.startsWith(prefix))\n continue\n const full = path.join(dataRoot, entry)\n if (!fs.existsSync(path.join(full, 'index.html')))\n continue\n // `<name>.previous-<pid>-<stamp>`: the longest stamp is the newest attempt.\n const stamp = Number(entry.slice(prefix.length).split('-').pop() ?? '')\n if (Number.isFinite(stamp) && stamp > bestStamp) {\n bestStamp = stamp\n best = full\n }\n }\n return best\n}\n\n/** Dropped staging trees and superseded backups, once the live UI is whole. */\nfunction sweepJunk(dataRoot: string): number {\n let swept = 0\n for (const entry of readDataRoot(dataRoot)) {\n if (!entry.startsWith('.ui-staging-') && !entry.startsWith(`.ui.previous-`))\n continue\n fs.rmSync(path.join(dataRoot, entry), { recursive: true, force: true })\n swept += 1\n }\n return swept\n}\n\nfunction readDataRoot(dataRoot: string): string[] {\n try {\n return fs.readdirSync(dataRoot)\n }\n catch {\n return []\n }\n}\n\nfunction describeError(error: unknown): string {\n return errorMessage(error)\n}\n\n/**\n * Where the site actually starts: the archive root, or a single wrapper directory\n * (`zip -r ui.zip dist` is a common way to build one).\n */\nfunction resolveRoot(staging: string): string | null {\n if (fs.existsSync(path.join(staging, 'index.html')))\n return staging\n\n const directories = fs.readdirSync(staging, { withFileTypes: true }).filter(entry => entry.isDirectory())\n if (directories.length !== 1)\n return null\n\n const inner = path.join(staging, directories[0]!.name)\n return fs.existsSync(path.join(inner, 'index.html')) ? inner : null\n}\n\nfunction readManifest(root: string): typeof manifestSchema.infer | null {\n try {\n const parsed = manifestSchema(JSON.parse(readStateFile(path.join(root, META))))\n return parsed instanceof type.errors ? null : parsed\n }\n catch {\n return null\n }\n}\n\nfunction countFiles(root: string): number {\n let total = 0\n for (const entry of fs.readdirSync(root, { withFileTypes: true, recursive: true })) {\n if (entry.isFile() && entry.name !== META)\n total += 1\n }\n return Math.max(1, total)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,IAAM,OAAO;;AAEb,IAAM,cAAc;AACpB,IAAM,YAAY;AAClB,IAAM,WAAW;;AAGjB,IAAM,iBAAiB,KAAK;CAC1B,SAAS;CACT,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,UAAU;CACV,SAAS;AACX,CAAC;;;;;;AAOD,SAAgB,cAAc,OAAwB;CACpD,IAAI,MAAM,WAAW,KAAK,MAAM,SAAS,UACvC,OAAO;CACT,IAAI,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,IAAI,KAAK,MAAM,SAAS,IAAI,GACtE,OAAO;CAET,MAAM,UAAU,MAAM,QAAQ,SAAS,EAAE,CAAC,CAAC,QAAQ,QAAQ,EAAE;CAC7D,IAAI,QAAQ,WAAW,GACrB,OAAO;CACT,OAAO,QAAQ,MAAM,GAAG,CAAC,CAAC,OAAM,YAAW,YAAY,MAAM,YAAY,OAAO,YAAY,QAAQ,CAAC,QAAQ,SAAS,GAAG,CAAC;AAC5H;AAMA,IAAa,YAAb,MAAuB;CACQ;CAA7B,YAAY,SAAmE;EAAlD,KAAA,UAAA;CAAmD;;CAGhF,IAAI,YAAoB;EACtB,OAAO,YAAY,KAAK,QAAQ,QAAQ;CAC1C;;CAGA,IAAI,SAAkB;EACpB,OAAO,kBAAkB,KAAK,QAAQ,QAAQ;CAChD;;CAGA,aAAqB;EACnB,IAAI,KAAK,QACP,OAAO,KAAK;EACd,OAAO,KAAK,QAAQ,YAAY,KAAK;CACvC;CAEA,SAAmB;EACjB,OAAO;GAAE,QAAQ,KAAK;GAAQ,KAAK,KAAK;GAAW,MAAM,KAAK,SAAS;EAAE;CAC3E;CAEA,WAA0B;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T;AAEA,SAAS,aAAa,UAA4B;CAChD,IAAI;EACF,OAAO,GAAG,YAAY,QAAQ;CAChC,QACM;EACJ,OAAO,CAAC;CACV;AACF;AAEA,SAAS,cAAc,OAAwB;CAC7C,OAAO,aAAa,KAAK;AAC3B;;;;;AAMA,SAAS,YAAY,SAAgC;CACnD,IAAI,GAAG,WAAW,KAAK,KAAK,SAAS,YAAY,CAAC,GAChD,OAAO;CAET,MAAM,cAAc,GAAG,YAAY,SAAS,EAAE,eAAe,KAAK,CAAC,CAAC,CAAC,QAAO,UAAS,MAAM,YAAY,CAAC;CACxG,IAAI,YAAY,WAAW,GACzB,OAAO;CAET,MAAM,QAAQ,KAAK,KAAK,SAAS,YAAY,EAAE,CAAE,IAAI;CACrD,OAAO,GAAG,WAAW,KAAK,KAAK,OAAO,YAAY,CAAC,IAAI,QAAQ;AACjE;AAEA,SAAS,aAAa,MAAkD;CACtE,IAAI;EACF,MAAM,SAAS,eAAe,KAAK,MAAM,cAAc,KAAK,KAAK,MAAM,IAAI,CAAC,CAAC,CAAC;EAC9E,OAAO,kBAAkB,KAAK,SAAS,OAAO;CAChD,QACM;EACJ,OAAO;CACT;AACF;AAEA,SAAS,WAAW,MAAsB;CACxC,IAAI,QAAQ;CACZ,KAAK,MAAM,SAAS,GAAG,YAAY,MAAM;EAAE,eAAe;EAAM,WAAW;CAAK,CAAC,GAC/E,IAAI,MAAM,OAAO,KAAK,MAAM,SAAS,MACnC,SAAS;CAEb,OAAO,KAAK,IAAI,GAAG,KAAK;AAC1B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"up-C4H13hBw.js","names":[],"sources":["../../src/cli/up.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process'\nimport type { UpFlags } from '#src/cli/args'\nimport { spawn } from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { buildDaemonArgv } from '#src/cli/args'\nimport { bold, delay, dim, fail, firstRunPassword, green, invocation, paint } from '#src/cli/io'\nimport { rotateLog, tailLog } from '#src/helpers/daemon-log'\nimport { runtimeArgs } from '#src/helpers/runtime'\nimport { versionMismatchNote } from '#src/helpers/version'\n\n/** `up` starts the panel; without `--foreground` it re-spawns itself detached. */\n\nconst DEFAULT_PORT = 3999\n\nexport const upArgs = {\n port: { type: 'string', alias: 'p', description: `control panel port (default: ${DEFAULT_PORT})` },\n host: { type: 'string', description: 'local | lan | an ipv4 address (default: local)' },\n autostart: { type: 'boolean', default: true, negativeDescription: 'do not start the entries marked autostart' },\n open: { type: 'boolean', description: 'open the panel in a browser once it is up' },\n foreground: { type: 'boolean', description: 'run in this process instead of detaching (systemd/docker)' },\n printConfig: { type: 'boolean', description: 'print the effective config and exit' },\n} as const\n\ninterface RawUpArgs {\n port?: string\n host?: string\n autostart?: boolean\n open?: boolean\n foreground?: boolean\n printConfig?: boolean\n}\n\n/** citty only parses; the port's range and the boolean defaults are decided here. */\nexport function toUpFlags(args: RawUpArgs): UpFlags {\n let port: number | undefined\n if (args.port !== undefined) {\n // The whole argument must be a decimal integer. `Number.parseInt` takes a prefix, so a\n // partial parse slipped past the range check as a *valid* port: `--port 1e3` started the\n // panel on port 1 (privileged, and not what anyone typed) and `--port 8000x` on 8000.\n const raw = args.port.trim()\n port = /^\\d+$/.test(raw) ? Number.parseInt(raw, 10) : Number.NaN\n if (!Number.isInteger(port) || port <= 0 || port > 65535)\n fail(`invalid port: ${args.port}`)\n }\n\n return {\n port,\n host: args.host,\n autostart: args.autostart !== false,\n open: args.open === true,\n foreground: args.foreground === true,\n printConfig: args.printConfig === true,\n }\n}\n\n/**\n * A bind value as the address it resolves to.\n *\n * Deliberately local and dependency-free: this module must stay importable without a state graph\n * (`test/cli/isolation`), and `helpers/bind.ts` caches `os.networkInterfaces()`, which a pure\n * comparison has no business triggering.\n */\nfunction bindAddress(bind: string): string {\n return bind === 'local' ? '127.0.0.1' : bind === 'lan' ? '0.0.0.0' : bind\n}\n\n/**\n * Which `up` flags the live panel contradicts, as one sentence — or `null` when it agrees.\n *\n * `up` on a live panel reports \"already running\" and exits 0, which is right: the common use is\n * \"make sure it is running\". But it used to swallow `--port`, `--host` and `--open` on that path,\n * so `up --port 4800` against a panel on 3999 printed a success line and exited 0 having changed\n * nothing — a deploy script reading `$?` concluded the port move worked. AGENTS.md settles the\n * direction: a flag the command cannot honour is refused, and `restart --workspace` without an id\n * already exits 1 for the same reason. `--open` is refused too, because it is not \"make sure it is\n * running\" either — it asks for a browser, and none opens on a panel this command did not start.\n *\n * `--no-autostart` is deliberately **not** here. It is not contradicted by the live panel: it\n * expresses a wish about a boot this command is not performing, and the panel has already booted,\n * so there is nothing to honour or refuse. Refusing it would break `up --no-autostart` in a retry\n * loop, which is the one spelling a script uses to keep its hands off the entries.\n */\nexport function alreadyRunningConflict(flags: UpFlags, runtime: { url: string, port: number, bindHost: string }): string | null {\n const asked: string[] = []\n if (flags.port !== undefined && flags.port !== runtime.port)\n asked.push(`--port ${flags.port}`)\n // Compared through `bindHost`, never as text: the record stores the address that was bound, so a\n // panel started with `--host lan` reads `bindHost: '0.0.0.0'` and the same flag compared raw would\n // always look unhonoured — refusing the idempotent re-run this command exists for. `--host` naming\n // the live bind is the same request as `--port` naming the live port, which is already let through.\n if (flags.host !== undefined && bindAddress(flags.host) !== runtime.bindHost)\n asked.push(`--host ${flags.host}`)\n if (flags.open)\n asked.push('--open')\n\n if (asked.length === 0)\n return null\n\n const what = asked.join(' and ')\n // \"so --port 4800 it was not honoured\" is not English: one flag reads \"was not\", several \"were\n // not\", and the flag names are the subject either way.\n const clause = asked.length === 1 ? `${what} was not honoured` : `${what} were not honoured`\n return `home-hosted is already running at ${runtime.url} — ${clause}. Stop it and start it again with those flags, or use \\`${invocation()} restart\\` to move it.`\n}\n\nexport async function runUp(flags: UpFlags, entry: string): Promise<void> {\n // `--print-config` reports the effective config and returns; it never detaches,\n // because there would be a daemon left with nothing to serve.\n if (flags.foreground || flags.printConfig) {\n // Imported here rather than at the top of the function: detaching does not need the daemon's\n // graph at all, and loading it costs ~1s of the parent's ~2.5s before the child even spawns.\n const { runControlPlane } = await import('#src/index')\n await runControlPlane({\n port: flags.port,\n host: flags.host,\n autostart: flags.autostart,\n open: flags.open,\n printConfig: flags.printConfig,\n })\n return\n }\n\n const { clearRuntime, readRuntime, runtimeIsAlive, runtimeIsGone } = await import('#src/helpers/daemon')\n const { daemonLogPath, dataRoot, projectDir } = await import('#src/helpers/paths')\n\n const existing = readRuntime()\n if (existing !== null && await runtimeIsAlive(existing)) {\n // A flag this path cannot honour is refused, and a refusal is one message on one stream: the\n // whole thing — where the panel is, which flag was dropped, what to run — goes to stderr, so\n // stdout stays empty and a script reading it does not see a success line for a move that did\n // not happen.\n const conflict = alreadyRunningConflict(flags, existing)\n if (conflict !== null)\n fail(conflict)\n\n process.stdout.write(`${green('already running')} home-hosted ${existing.version} (pid ${existing.pid}) at ${existing.url}\\n`)\n const note = versionMismatchNote(existing.version)\n if (note !== null)\n process.stdout.write(`${dim(note)}\\n`)\n // The user may have arrived via `npx`, which leaves no `home-hosted` on their PATH.\n process.stdout.write(`${dim(`stop it with \\`${invocation()} down\\``)}\\n`)\n return\n }\n // Only a record with *nothing* behind its pid is deleted. A pid that merely looks recycled is left\n // for the panel this starts to overwrite, because the birth time is wall-clock-derived on Linux and\n // a clock step can make a live panel look recycled — deleting its record would orphan it.\n if (existing !== null && await runtimeIsGone(existing))\n clearRuntime()\n\n fs.mkdirSync(path.dirname(daemonLogPath), { recursive: true })\n rotateLog(daemonLogPath)\n // `0600`: the daemon's stderr lands here, and on a first boot that carries the generated password.\n // Without a mode the file is `0644` under the usual umask, so any local account could read a\n // credential the panel otherwise keeps in a 0600 file.\n const log = fs.openSync(daemonLogPath, 'a', 0o600)\n\n const child = spawn(process.execPath, [...runtimeArgs(), entry, ...buildDaemonArgv(flags)], {\n detached: true,\n cwd: projectDir,\n env: { ...process.env, HHOSTED_HOME: dataRoot, HHOSTED_PROJECT: projectDir },\n stdio: ['ignore', log, log],\n windowsHide: true,\n })\n child.unref()\n fs.closeSync(log)\n\n const runtime = await waitForStartup(child)\n if (runtime === null) {\n const output = tailLog(daemonLogPath)\n process.stderr.write(`${paint('31', 'error')} the control panel did not start\\n`)\n if (output.length > 0)\n process.stderr.write(`${dim(`${daemonLogPath}:`)}\\n${output}\\n`)\n process.exit(1)\n }\n\n process.stdout.write(`${green(`home-hosted ${runtime.version} is up`)} (pid ${runtime.pid})\\n`)\n process.stdout.write(` ${bold(runtime.url)}\\n`)\n process.stdout.write(` ${dim(`project ${runtime.projectDir}`)}\\n`)\n process.stdout.write(` ${dim(`state ${runtime.dataRoot}`)}\\n`)\n process.stdout.write(` ${dim(`log ${runtime.logFile}`)}\\n`)\n const initial = await firstRunPassword()\n if (initial !== null)\n process.stdout.write(`${paint('33', 'password')} ${bold(initial)} ${dim('— the first-run password; change it in Global settings → Authentication')}\\n`)\n await warnIfWslTemperatureMissing()\n}\n\n/**\n * Say once, on `up`, that this box cannot read its own temperature and that it can be fixed.\n *\n * A WSL2 guest has no sensor the kernel exposes, so the Host vitals tile reads `n/a` and looks\n * broken. Nothing tells a person why — the settings page has the button, but only if they go\n * looking. This is the one line that turns \"the panel is broken\" into \"run one command\".\n *\n * Silent when a command is already configured, and on any platform that is not WSL.\n */\nasync function warnIfWslTemperatureMissing(): Promise<void> {\n const { isWsl } = await import('#src/providers/wsl-temperature')\n if (!isWsl())\n return\n const { GlobalSettingsStore } = await import('#src/config/settings')\n const { globalSettingsPath } = await import('#src/helpers/paths')\n const store = new GlobalSettingsStore(globalSettingsPath)\n store.load()\n if (store.host.tempCommand.trim().length > 0)\n return\n process.stdout.write(\n `${paint('33', 'note')} WSL2 detected: the guest exposes no CPU temperature, so Host vitals shows n/a\\n`\n + ` ${dim(`set it up with ${invocation()} setup-temp --wsl`)}\\n`,\n )\n}\n\nasync function waitForStartup(child: ChildProcess, timeoutMs = 20000) {\n const { readRuntime } = await import('#src/helpers/daemon')\n const deadline = Date.now() + timeoutMs\n\n for (;;) {\n if (child.exitCode !== null || child.signalCode !== null)\n return null\n\n const runtime = readRuntime()\n if (runtime !== null && runtime.pid === child.pid)\n return runtime\n\n if (Date.now() > deadline)\n return null\n await delay(150)\n }\n}\n\nexport function upCommand(entry: string) {\n return defineCommand({\n meta: { name: 'up' },\n args: upArgs,\n run: async ({ args }) => {\n await runUp(toUpFlags(args), entry)\n },\n })\n}\n"],"mappings":";;;;;;;AAiBA,IAAa,SAAS;CACpB,MAAM;EAAE,MAAM;EAAU,OAAO;EAAK,aAAa;CAAgD;CACjG,MAAM;EAAE,MAAM;EAAU,aAAa;CAAiD;CACtF,WAAW;EAAE,MAAM;EAAW,SAAS;EAAM,qBAAqB;CAA4C;CAC9G,MAAM;EAAE,MAAM;EAAW,aAAa;CAA4C;CAClF,YAAY;EAAE,MAAM;EAAW,aAAa;CAA4D;CACxG,aAAa;EAAE,MAAM;EAAW,aAAa;CAAsC;AACrF;;AAYA,SAAgB,UAAU,MAA0B;CAClD,IAAI;CACJ,IAAI,KAAK,SAAS,KAAA,GAAW;EAI3B,MAAM,MAAM,KAAK,KAAK,KAAK;EAC3B,OAAO,QAAQ,KAAK,GAAG,IAAI,OAAO,SAAS,KAAK,EAAE,IAAI;EACtD,IAAI,CAAC,OAAO,UAAU,IAAI,KAAK,QAAQ,KAAK,OAAO,OACjD,KAAK,iBAAiB,KAAK,MAAM;CACrC;CAEA,OAAO;EACL;EACA,MAAM,KAAK;EACX,WAAW,KAAK,cAAc;EAC9B,MAAM,KAAK,SAAS;EACpB,YAAY,KAAK,eAAe;EAChC,aAAa,KAAK,gBAAgB;CACpC;AACF;;;;;;;;AASA,SAAS,YAAY,MAAsB;CACzC,OAAO,SAAS,UAAU,cAAc,SAAS,QAAQ,YAAY;AACvE;;;;;;;;;;;;;;;;;AAkBA,SAAgB,uBAAuB,OAAgB,SAAyE;CAC9H,MAAM,QAAkB,CAAC;CACzB,IAAI,MAAM,SAAS,KAAA,KAAa,MAAM,SAAS,QAAQ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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,KA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EAG5C,KAAK,MAAM,UAAS,UAAU,UAAU,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,OAAO,KAAK,CAAC,CAAE;EAClF,KAAK,MAAM,cAAa,UAAS,GAAG,KAAK,MAAM,QAAQ,GAAG,EAAE,EAAE;CAChE,CAAC;CAED,MAAM,UAAU;EAAC;EAAU;EAAU;EAAO;EAAU;EAAS;EAAS;CAAI;CAC5E,MAAM,SAAS,QAAQ,KAAK,QAAQ,UAClC,KAAK,IAAI,OAAO,QAAQ,GAAG,KAAK,KAAI,SAAQ,IAAI,UAAU,GAAA,CAAI,MAAM,CAAC,CAAC;CACxE,MAAM,QAAQ,YACZ,QAAQ,KAAK,QAAQ,UAAU,OAAO,OAAO,OAAO,MAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ;CAEnF,QAAQ,OAAO,MAAM,GAAG,KAAK,KAAK,OAAO,CAAC,EAAE,GAAG;CAC/C,KAAK,MAAM,OAAO,MAChB,QAAQ,OAAO,MAAM,GAAG,KAAK,GAAG,EAAE,GAAG;CAEvC,IAAI,KAAK,cAAc,KAAA,GACrB,QAAQ,OAAO,MAAM,GAAG,IAAI,iEAAiE,EAAE,GAAG;AACtG;AAEA,IAAa,eAAe,cAAc;CACxC,MAAM,EAAE,MAAM,QAAQ;CACtB,MAAM;CACN,MAAM,IAAI,EAAE,QAAQ;EAClB,IAAI;GACF,MAAM,SAAS,EAAE,MAAM,KAAK,KAAK,CAAC;EACpC,SACO,OAAO;GACZ,KAAK,aAAa,KAAK,CAAC;EAC1B;CACF;AACF,CAAC"}
@@ -1 +0,0 @@
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,qBAAqB,KAAK,MAAM,cAAc,IAAI,CAAC,CAAY;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0B;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"}
@@ -1,306 +0,0 @@
1
- # Blank-host restore, with a database
2
-
3
- A worked example: one home stack backed up on one machine, restored onto a machine that starts with
4
- nothing, and the database read back afterwards.
5
-
6
- Every command below is real. The whole thing is a script you can run:
7
- [`blank-host-restore.sh`](./demo/blank-host-restore.sh). It uses throwaway directories under `$TMPDIR` and
8
- docker containers it removes on exit, so it touches nothing of yours.
9
-
10
- ```sh
11
- docs/demo/blank-host-restore.sh
12
- ```
13
-
14
- ## The stack
15
-
16
- One entry: a MongoDB container, with a database dump declared as its data.
17
-
18
- ```json
19
- {
20
- "id": "blog-db",
21
- "command": "docker",
22
- "args": ["run", "--rm", "--name", "hh-demo-blog", "-p", "27017:27017", "mongo:7"],
23
- "port": 27017,
24
- "backupPaths": ["/srv/blog/dump"]
25
- }
26
- ```
27
-
28
- `backupPaths` is the important field. It names what belongs to this entry **beyond** its config, and
29
- that is what the archive carries.
30
-
31
- ## Backing it up
32
-
33
- `create` plans first. That listing is what the archive *would* contain, and nothing has been written
34
- yet:
35
-
36
- ```console
37
- $ home-hosted backup create --all
38
- Plan — what a backup would capture; nothing has been written yet
39
- settings global:settings
40
- secrets global:secrets
41
- - global:secrets:password
42
- - global:secrets:apiToken
43
- tls global:tls (does not exist yet)
44
- workspace workspace:default
45
- - workspace:default:settings
46
- - workspace:default:servers
47
- - workspace:default:data:/srv/blog/dump
48
-
49
- Take this backup? [y/N] y
50
-
51
- $ home-hosted backup list
52
- 1 archive in /home/you/.home-hosted/.hh/.backups
53
- backup-2026-10-21-04-15-49-881.zip 4 KB 2026-10-21 04:15
54
- ```
55
-
56
- `--all` is required: a scope is never assumed, so `backup create` with neither flag refuses and
57
- lists what could be picked. `--confirm` skips the prompt, which is what a cron job wants. `--json` prints the same plan as JSON
58
- and never applies, so a script or an agent can read it and decide.
59
-
60
- ### Databases dump themselves
61
-
62
- A database file copied while the engine runs is a torn copy. Declare `dump` and `load` on the entry
63
- and the backup runs `mongodump` for you, into a `{dumpDir}` the archive carries; the restore runs
64
- `mongorestore` from the same place. A failed dump **refuses the backup**, so an archive is never
65
- half-done. See the engine table in [SERVERS.md](./SERVERS.md).
66
-
67
- ```console
68
- $ home-hosted backup create --all --confirm
69
- backup created backup-2026-10-21-06-55-40-147.zip (3 KB)
70
-
71
- $ home-hosted backup restore backup-2026-10-21-06-55-40-147.zip --all --confirm
72
- restored 3 items from backup-2026-10-21-06-55-40-147.zip
73
- load blog-db: ran
74
- ```
75
-
76
- ### Working while the panel is stopped
77
-
78
- `backup` does not need the panel. It drives the same service either way, so a stopped panel is fine —
79
- which is the point, since stopping the services is what someone does before a careful backup or a
80
- migration:
81
-
82
- ```console
83
- $ home-hosted down
84
- $ home-hosted backup create --all --confirm
85
- backup created backup-2026-10-21-06-55-40-147.zip (3 KB)
86
- ```
87
-
88
- A **persistent** entry keeps running when the panel stops, so "panel off" is not "services off". Those
89
- are named before the backup is taken, and it proceeds anyway — refusing would block the migration this
90
- exists for:
91
-
92
- ```console
93
- $ home-hosted backup create --all
94
- Plan — what a backup would capture; nothing has been written yet
95
- ...
96
- ! 1 entry is still running (gitea) — its data may be captured mid-write
97
-
98
- Take this backup? [y/N]
99
- ```
100
-
101
- A restore writes a **lock** (`<state>/.hh/restore.lock`), taken by the service itself — so the panel's
102
- own restore and this one exclude each other, and neither two shells nor a shell and the page can write
103
- the same host at once. A lock left by a process that died is taken over; one held by a live process
104
- names it and stops. A dry run takes none, because it writes nothing.
105
-
106
- ### Narrowing what an archive carries
107
-
108
- `--include` takes the ids from the plan, comma-separated:
109
-
110
- ```console
111
- $ home-hosted backup create --include workspace:default:servers,global:settings
112
- ```
113
-
114
- `--exclude` is the other direction, and the usual one: naming the one thing to leave out beats listing
115
- everything else. It applies after `--include`, and an excluded id covers what is under it. Both verbs
116
- take it — `create` and `restore` — and so does the HTTP body (`{ include, exclude }`), so a script, a
117
- UI and a shell can say the same thing.
118
-
119
- ```console
120
- $ home-hosted backup create --all --exclude global:secrets --confirm
121
- ```
122
-
123
- That is the command to reach for. `global:secrets` is the panel's password hash and API token hash, so
124
- leaving it out keeps the archive from carrying the machine's credentials and keeps a restore from
125
- replacing the target panel's with the source's. A per-field form works too —
126
- `--exclude global:secrets:password` keeps the token and drops only the password.
127
-
128
- `--all` is the only way to say "everything" — giving **neither** flag is refused, not assumed, so the
129
- destructive default cannot be reached by silence:
130
-
131
- ```console
132
- $ home-hosted backup create --confirm
133
- error name what to act on — pass --include <ids> or --all
134
-
135
- available (or narrow it):
136
- global:settings
137
- global:secrets
138
- global:tls
139
- workspace:default
140
-
141
- --exclude <ids> leaves those out: --all --exclude global:secrets
142
- ```
143
-
144
- An empty `--include` is refused too, rather than treated as "nothing selected" — a script passing an
145
- unset `$LIST` gets an error instead of quietly backing up (or restoring) the whole machine:
146
-
147
- ```console
148
- $ home-hosted backup create --include "$UNSET"
149
- error --include is empty — name the ids to act on, or pass --all for everything
150
- ```
151
-
152
- `--include` and `--all` together is also refused, since one of them would silently win.
153
-
154
- The archive is a plain zip. Its contents, in full:
155
-
156
- ```text
157
- dumps/
158
- dumps/default/blog-db/
159
- dumps/default/blog-db/blog.archive <- what the entry's `dump` hook wrote
160
- global/
161
- global/secrets.json <- password hash, API token hash
162
- global/settings.json <- listener, TLS policy, host vitals, proxy
163
- global/workspaces.json <- the registry: what workspaces exist
164
- manifest.json <- what release wrote it, and the schema it understood
165
- workspaces/
166
- workspaces/default/
167
- workspaces/default/servers.config.json
168
- workspaces/default/settings.json
169
- ```
170
-
171
- **The dump is the data.** `backupPaths` pointed at a directory holding `mongodump` output, not at
172
- MongoDB's live data directory. That distinction matters: copying a running database's files can
173
- capture it torn, which [`README.md`](./BACKUPS.md) warns about. A dump is consistent by
174
- construction.
175
-
176
- ## Restoring onto a blank host
177
-
178
- `restore` reads an archive **by name** from the backups directory, or **by path** with `--from`.
179
- The name is the default: it is an allowlist entry, so a typo cannot point a restore at an unrelated
180
- file. `--from` is for the blank host whose archive is on a USB stick — it names the one file to read,
181
- and it passes the very same gates the panel's upload route does (a zip, at least one entry, every
182
- entry inside the backup layout). Symlinks inside it are still never recreated, in either path.
183
-
184
- ```console
185
- $ home-hosted backup restore --from /media/usb/backup-2026-10-21-04-15-49-881.zip --all --confirm
186
- restored 7 items from backup-2026-10-21-04-15-49-881.zip
187
- ```
188
-
189
- A path and a name are refused together, because they name two different archives — copy the file in
190
- first if that is what you want:
191
-
192
- ```console
193
- $ home-hosted backup restore backup-2026-10-21-04-15-49-881.zip --from /media/usb/other.zip --all
194
- error pass an archive name or --from <path>, not both — they name two different archives
195
- ```
196
-
197
- A name that is not in the backups directory still says so, and now also says which flag takes a path:
198
-
199
- ```console
200
- $ home-hosted backup restore /media/usb/backup-2026-10-21-04-15-49-881.zip --all --confirm
201
- error no backup named "/media/usb/..." in /home/you/.home-hosted/.hh/.backups — a restore takes the archive's file name, not a path; pass --from <path> to read the file where it is, or copy it into that directory
202
- ```
203
-
204
- ```console
205
- $ home-hosted backup restore backup-2026-10-21-04-15-49-881.zip --all
206
- Plan for backup-2026-10-21-04-15-49-881.zip — nothing has been written yet
207
- global
208
- - global:settings
209
- - global:secrets
210
- - global:secrets:password
211
- - global:secrets:apiToken
212
- workspace
213
- - workspace:default
214
- - workspace:default:settings
215
- - workspace:default:servers
216
- - workspace:default:data
217
- - workspace:default:data:/srv/blog/dump
218
-
219
- not applied — this session cannot ask. Re-run with `--confirm` to apply.
220
- ```
221
-
222
- The plan comes first, always. A restore writes over live data, so the default is to say what it
223
- *would* do — and like `create`, it needs a scope: `--all`, or `--include <ids>`. Neither flag is
224
- refused, and that refusal lists the ids the archive actually holds.
225
-
226
- ```console
227
- $ home-hosted backup restore backup-2026-10-21-04-15-49-881.zip --all --confirm
228
- restored 7 items from backup-2026-10-21-04-15-49-881.zip
229
- ```
230
-
231
- The workspace did not exist on this host. It was created, not skipped: an archive is a whole machine's
232
- setup, and refusing it because the id is new would make a blank-host restore impossible.
233
-
234
- ### When a restore cannot do what you asked
235
-
236
- A restore that writes nothing **exits 1 and says why** — never *"restored 0 items"* with a success
237
- status. The same is true of a wrong or missing password on an encrypted archive, and of an archive
238
- from a newer config schema:
239
-
240
- ```console
241
- $ home-hosted backup restore backup-2026-10-21-04-15-49-881.zip --all --confirm
242
- error this backup is password-protected — add `--password <text>` to unlock it
243
-
244
- $ home-hosted backup restore old.zip --all --confirm
245
- error written by home-hosted 0.8.0 (config schema 1); this release understands schema 2
246
- ```
247
-
248
- A restore that applies **some** of an archive carries on and names every piece it had to leave
249
- behind, marked `!`, so a partial result never reads as a complete one — including a dump staged for
250
- an entry with no `load` hook, which only the apply can discover and `--json` lists in `skipped`. A
251
- mistyped `--include` or `--exclude` is refused before anything is written, naming the id — the
252
- dangerous direction being `--exclude`, where a typo would exclude nothing and apply the credentials
253
- you meant to drop.
254
-
255
- Then the entry starts, and the database is read back:
256
-
257
- ```console
258
- $ home-hosted start blog-db
259
- started blog-db
260
-
261
- $ docker exec hh-demo-blog mongosh --quiet --eval 'db.getSiblingDB("blog").posts.countDocuments()'
262
- 3
263
- ```
264
-
265
- Nothing applies the dump by hand: `start` ran the entry's `load` hook, which replays it. The hook
266
- runs in the background once the port answers, so `start` returns before it finishes — the read above
267
- is simply taken after it has. A fresh container holds `0` documents, and this number is what the dump
268
- put there.
269
-
270
- Three documents, on a host that started with nothing.
271
-
272
- > [!WARNING]
273
- > `global:secrets` holds the **panel password hash and API token hash**. A backup that carries it
274
- > carries the machine's credentials, and a restore that applies it **replaces** the target panel's
275
- > password and token with the old machine's. Leave it out unless that is what you want:
276
- >
277
- > ```sh
278
- > home-hosted backup create --all --exclude global:secrets --confirm
279
- > home-hosted backup restore <name> --all --exclude global:secrets --confirm
280
- > ```
281
- >
282
- > That is the recommended default for a shared or moved archive. After restoring one that did carry
283
- > it, rotate with `home-hosted set-token --generate` and `set-password`.
284
-
285
- ## What is recovered, and what is not
286
-
287
- | | |
288
- | --- | --- |
289
- | ✅ **Recovered** | Every workspace and its label. Every entry, with its command, args, env, port and policies. Workspace settings: notifications, DDNS, log retention, server defaults. Panel settings: listener, TLS policy, host vitals, backup schedule, proxy routes. Secrets, if you kept them ticked. Declared data paths, including the database dump. |
290
- | ✅ **Recovered** | Secrets, if you kept them selected. |
291
- | ✅ **Recovered, and the database loads itself** | With `dump`/`load` hooks on the entry, the backup runs the engine's own dump and the restore replays it. The load runs on the entry's **next start**, because `mongorestore` needs a server that is answering. Without hooks, the panel restores files only and applying the dump is your step. |
292
- | ❌ **Not recovered** | `HHOSTED_DDNS_SECRET`, the key DDNS credentials are sealed under. It is never archived, so a restored host cannot decrypt them until you set it again. |
293
- | ❌ **Not recovered** | Anything not in a `backupPaths` directory or the panel's own state: files your entries wrote elsewhere, host packages, `/etc` changes, a reverse proxy outside the panel, cron jobs, the docker images themselves. |
294
- | ❌ **Not recovered** | `$HHOSTED_HOME/.ui` is not archived, so the panel keeps whatever UI it already has on that host. It is not replaced by the UI of the panel that took the backup. |
295
-
296
- ## Re-running it
297
-
298
- The script is the reproducible form of everything above:
299
-
300
- ```sh
301
- docs/demo/blank-host-restore.sh
302
- ```
303
-
304
- It creates two state directories, seeds a real MongoDB, dumps it, backs it up, restores onto the
305
- blank second host, starts the entry there and asserts the documents came back. It exits non-zero if
306
- they do not.