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.
Files changed (317) hide show
  1. package/README.md +273 -628
  2. package/dist/chunks/archive-DpCwA8Nf.js +339 -0
  3. package/dist/chunks/archive-DpCwA8Nf.js.map +1 -0
  4. package/dist/chunks/atomic-CEfCUfkQ.js +25 -0
  5. package/dist/chunks/atomic-CEfCUfkQ.js.map +1 -0
  6. package/dist/chunks/backup-CPrJVPJI.js +797 -0
  7. package/dist/chunks/backup-CPrJVPJI.js.map +1 -0
  8. package/dist/chunks/backups-Bd2SF2qd.js +4346 -0
  9. package/dist/chunks/backups-Bd2SF2qd.js.map +1 -0
  10. package/dist/chunks/config-text-DifCHhnz.js +50 -0
  11. package/dist/chunks/config-text-DifCHhnz.js.map +1 -0
  12. package/dist/chunks/contracts-ku5ypHXJ.js +2256 -0
  13. package/dist/chunks/contracts-ku5ypHXJ.js.map +1 -0
  14. package/dist/chunks/daemon-TwXk5vb8.js +215 -0
  15. package/dist/chunks/daemon-TwXk5vb8.js.map +1 -0
  16. package/dist/chunks/daemon-log-BVj8cDEo.js +241 -0
  17. package/dist/chunks/daemon-log-BVj8cDEo.js.map +1 -0
  18. package/dist/chunks/docker-CGv4Uv7w.js +436 -0
  19. package/dist/chunks/docker-CGv4Uv7w.js.map +1 -0
  20. package/dist/chunks/down-BlX5X3bm.js +378 -0
  21. package/dist/chunks/down-BlX5X3bm.js.map +1 -0
  22. package/dist/chunks/init-DdmqHVra.js +263 -0
  23. package/dist/chunks/init-DdmqHVra.js.map +1 -0
  24. package/dist/chunks/last-stop-BZ08Z89-.js +52 -0
  25. package/dist/chunks/last-stop-BZ08Z89-.js.map +1 -0
  26. package/dist/chunks/layout-D74TGUnr.js +24 -0
  27. package/dist/chunks/layout-D74TGUnr.js.map +1 -0
  28. package/dist/chunks/log-buffer-HnP0jKhZ.js +350 -0
  29. package/dist/chunks/log-buffer-HnP0jKhZ.js.map +1 -0
  30. package/dist/chunks/logger-B5U4GD3j.js +13 -0
  31. package/dist/chunks/logger-B5U4GD3j.js.map +1 -0
  32. package/dist/chunks/logs-gI_69Q1P.js +265 -0
  33. package/dist/chunks/logs-gI_69Q1P.js.map +1 -0
  34. package/dist/chunks/migrate-BTlsibvF.js +155 -0
  35. package/dist/chunks/migrate-BTlsibvF.js.map +1 -0
  36. package/dist/chunks/nanny-20aBXL1o.js +1069 -0
  37. package/dist/chunks/nanny-20aBXL1o.js.map +1 -0
  38. package/dist/chunks/nanny-CjnnrIpm.js +132 -0
  39. package/dist/chunks/nanny-CjnnrIpm.js.map +1 -0
  40. package/dist/chunks/nanny-DUaAfCV-.js +39 -0
  41. package/dist/chunks/nanny-DUaAfCV-.js.map +1 -0
  42. package/dist/chunks/nanny-sweep-Ca9kPAVi.js +104 -0
  43. package/dist/chunks/nanny-sweep-Ca9kPAVi.js.map +1 -0
  44. package/dist/chunks/nearest-6KgQEDUe.js +41 -0
  45. package/dist/chunks/nearest-6KgQEDUe.js.map +1 -0
  46. package/dist/chunks/parse-B9owE47G.js +383 -0
  47. package/dist/chunks/parse-B9owE47G.js.map +1 -0
  48. package/dist/chunks/paths-BT94q6-w.js +172 -0
  49. package/dist/chunks/paths-BT94q6-w.js.map +1 -0
  50. package/dist/chunks/port-B8WBTRMk.js +333 -0
  51. package/dist/chunks/port-B8WBTRMk.js.map +1 -0
  52. package/dist/chunks/restart-UZgeDukG.js +126 -0
  53. package/dist/chunks/restart-UZgeDukG.js.map +1 -0
  54. package/dist/chunks/rolldown-runtime-D7D4PA-g.js +13 -0
  55. package/dist/chunks/schema-o7Lgk0V1.js +102 -0
  56. package/dist/chunks/schema-o7Lgk0V1.js.map +1 -0
  57. package/dist/chunks/secrets-D7PdYh71.js +544 -0
  58. package/dist/chunks/secrets-D7PdYh71.js.map +1 -0
  59. package/dist/chunks/server-BuIeSsRu.js +169 -0
  60. package/dist/chunks/server-BuIeSsRu.js.map +1 -0
  61. package/dist/chunks/server-ids-DRuNLVCV.js +32 -0
  62. package/dist/chunks/server-ids-DRuNLVCV.js.map +1 -0
  63. package/dist/chunks/set-password-DegMumPh.js +43 -0
  64. package/dist/chunks/set-password-DegMumPh.js.map +1 -0
  65. package/dist/chunks/set-token-21d1FTDC.js +78 -0
  66. package/dist/chunks/set-token-21d1FTDC.js.map +1 -0
  67. package/dist/chunks/settings-BVSBnIwJ.js +332 -0
  68. package/dist/chunks/settings-BVSBnIwJ.js.map +1 -0
  69. package/dist/chunks/setup-temp-XiuAtiW2.js +150 -0
  70. package/dist/chunks/setup-temp-XiuAtiW2.js.map +1 -0
  71. package/dist/chunks/shape-DnTKzjQ2.js +24 -0
  72. package/dist/chunks/shape-DnTKzjQ2.js.map +1 -0
  73. package/dist/chunks/src-BL97vLVb.js +11153 -0
  74. package/dist/chunks/src-BL97vLVb.js.map +1 -0
  75. package/dist/chunks/status-EuWdRq8Q.js +119 -0
  76. package/dist/chunks/status-EuWdRq8Q.js.map +1 -0
  77. package/dist/chunks/ui-DbPuwddJ.js +323 -0
  78. package/dist/chunks/ui-DbPuwddJ.js.map +1 -0
  79. package/dist/chunks/ui-dir-CsU3uLNV.js +39 -0
  80. package/dist/chunks/ui-dir-CsU3uLNV.js.map +1 -0
  81. package/dist/chunks/ui-release-DKzVvlLd.js +312 -0
  82. package/dist/chunks/ui-release-DKzVvlLd.js.map +1 -0
  83. package/dist/chunks/ui-revert-BhqOAhmM.js +27 -0
  84. package/dist/chunks/ui-revert-BhqOAhmM.js.map +1 -0
  85. package/dist/chunks/ui-switch-CMoslPO2.js +150 -0
  86. package/dist/chunks/ui-switch-CMoslPO2.js.map +1 -0
  87. package/dist/chunks/ui-update-TTBBoDik.js +272 -0
  88. package/dist/chunks/ui-update-TTBBoDik.js.map +1 -0
  89. package/dist/chunks/up-C4H13hBw.js +196 -0
  90. package/dist/chunks/up-C4H13hBw.js.map +1 -0
  91. package/dist/chunks/usage-CSBgLRN5.js +85 -0
  92. package/dist/chunks/usage-CSBgLRN5.js.map +1 -0
  93. package/dist/chunks/workspaces-CAln2sQ7.js +221 -0
  94. package/dist/chunks/workspaces-CAln2sQ7.js.map +1 -0
  95. package/dist/chunks/wsl-temperature-BiCI4iK6.js +322 -0
  96. package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +1 -0
  97. package/dist/cli.js +229 -24861
  98. package/dist/cli.js.map +1 -1
  99. package/dist/client.js +120 -0
  100. package/dist/client.js.map +1 -0
  101. package/dist/types/api/acme.d.ts +24 -0
  102. package/dist/types/api/auth/$.routes.d.ts +103 -0
  103. package/dist/types/api/backups.d.ts +179 -0
  104. package/dist/types/api/control.d.ts +469 -0
  105. package/dist/types/api/ddns.d.ts +432 -0
  106. package/dist/types/api/events.d.ts +21 -0
  107. package/dist/types/api/health.d.ts +27 -0
  108. package/dist/types/api/logs.d.ts +95 -0
  109. package/dist/types/api/metrics.d.ts +19 -0
  110. package/dist/types/api/notifications.d.ts +141 -0
  111. package/dist/types/api/proxy.d.ts +1128 -0
  112. package/dist/types/api/servers/$.routes.d.ts +1318 -0
  113. package/dist/types/api/settings.d.ts +642 -0
  114. package/dist/types/api/state.d.ts +492 -0
  115. package/dist/types/api/static.d.ts +11 -0
  116. package/dist/types/api/tls.d.ts +112 -0
  117. package/dist/types/api/workspaces/$.routes.d.ts +797 -0
  118. package/dist/types/api/wsl-temperature.d.ts +113 -0
  119. package/dist/types/app.d.ts +6080 -0
  120. package/dist/types/cli/args.d.ts +75 -0
  121. package/dist/types/cli/backup-offline.d.ts +23 -0
  122. package/dist/types/cli/backup.d.ts +79 -0
  123. package/dist/types/cli/down.d.ts +75 -0
  124. package/dist/types/cli/init.d.ts +60 -0
  125. package/dist/types/cli/io.d.ts +65 -0
  126. package/dist/types/cli/logs.d.ts +64 -0
  127. package/dist/types/cli/migrate.d.ts +33 -0
  128. package/dist/types/cli/nanny.d.ts +19 -0
  129. package/dist/types/cli/nearest.d.ts +10 -0
  130. package/dist/types/cli/restart.d.ts +42 -0
  131. package/dist/types/cli/server.d.ts +68 -0
  132. package/dist/types/cli/set-password.d.ts +14 -0
  133. package/dist/types/cli/set-token.d.ts +21 -0
  134. package/dist/types/cli/setup-temp.d.ts +65 -0
  135. package/dist/types/cli/status.d.ts +14 -0
  136. package/dist/types/cli/ui-revert.d.ts +3 -0
  137. package/dist/types/cli/ui-switch.d.ts +27 -0
  138. package/dist/types/cli/ui-update.d.ts +72 -0
  139. package/dist/types/cli/up.d.ts +90 -0
  140. package/dist/types/cli/usage.d.ts +23 -0
  141. package/dist/types/cli.d.ts +12 -0
  142. package/dist/types/client.d.ts +6284 -0
  143. package/dist/types/config/layout.d.ts +11 -0
  144. package/dist/types/config/migrations.d.ts +69 -0
  145. package/dist/types/config/parse.d.ts +54 -0
  146. package/dist/types/config/patch.d.ts +20 -0
  147. package/dist/types/config/schema.d.ts +318 -0
  148. package/dist/types/config/secret-parts.d.ts +48 -0
  149. package/dist/types/config/secrets.d.ts +206 -0
  150. package/dist/types/config/seed.d.ts +30 -0
  151. package/dist/types/config/server-ids.d.ts +14 -0
  152. package/dist/types/config/settings.d.ts +74 -0
  153. package/dist/types/config/store.d.ts +132 -0
  154. package/dist/types/config/workspaces.d.ts +96 -0
  155. package/dist/types/helpers/action-result.d.ts +46 -0
  156. package/dist/types/helpers/atomic.d.ts +9 -0
  157. package/dist/types/helpers/backoff.d.ts +7 -0
  158. package/dist/types/helpers/bind.d.ts +16 -0
  159. package/dist/types/helpers/config-text.d.ts +23 -0
  160. package/dist/types/helpers/cookies.d.ts +19 -0
  161. package/dist/types/helpers/copy-tree.d.ts +15 -0
  162. package/dist/types/helpers/daemon-log.d.ts +45 -0
  163. package/dist/types/helpers/daemon.d.ts +122 -0
  164. package/dist/types/helpers/deferred.d.ts +7 -0
  165. package/dist/types/helpers/env-file.d.ts +20 -0
  166. package/dist/types/helpers/error.d.ts +18 -0
  167. package/dist/types/helpers/factory.d.ts +6 -0
  168. package/dist/types/helpers/last-stop.d.ts +20 -0
  169. package/dist/types/helpers/logger.d.ts +7 -0
  170. package/dist/types/helpers/open.d.ts +2 -0
  171. package/dist/types/helpers/openapi.d.ts +46 -0
  172. package/dist/types/helpers/paths.d.ts +94 -0
  173. package/dist/types/helpers/restore-lock.d.ts +32 -0
  174. package/dist/types/helpers/runtime.d.ts +18 -0
  175. package/dist/types/helpers/secret-compare.d.ts +13 -0
  176. package/dist/types/helpers/shell.d.ts +19 -0
  177. package/dist/types/helpers/sse.d.ts +23 -0
  178. package/dist/types/helpers/template.d.ts +8 -0
  179. package/dist/types/helpers/ui-dir.d.ts +11 -0
  180. package/dist/types/helpers/validate.d.ts +7 -0
  181. package/dist/types/helpers/validator.d.ts +12 -0
  182. package/dist/types/helpers/version.d.ts +10 -0
  183. package/dist/types/helpers/workspace.d.ts +25 -0
  184. package/dist/types/index.d.ts +17 -0
  185. package/dist/types/middleware/auth.d.ts +37 -0
  186. package/dist/types/middleware/host.d.ts +29 -0
  187. package/dist/types/middleware/loopback.d.ts +18 -0
  188. package/dist/types/openapi-reference.d.ts +22 -0
  189. package/dist/types/openapi.d.ts +34 -0
  190. package/dist/types/providers/archive.d.ts +54 -0
  191. package/dist/types/providers/backup-hook.d.ts +34 -0
  192. package/dist/types/providers/ddns/cloudflare.d.ts +2 -0
  193. package/dist/types/providers/ddns/desec.d.ts +2 -0
  194. package/dist/types/providers/ddns/digitalocean.d.ts +2 -0
  195. package/dist/types/providers/ddns/duckdns.d.ts +2 -0
  196. package/dist/types/providers/ddns/dyndns2.d.ts +15 -0
  197. package/dist/types/providers/ddns/dynu.d.ts +2 -0
  198. package/dist/types/providers/ddns/freedns.d.ts +2 -0
  199. package/dist/types/providers/ddns/gandi.d.ts +2 -0
  200. package/dist/types/providers/ddns/godaddy.d.ts +2 -0
  201. package/dist/types/providers/ddns/henet.d.ts +3 -0
  202. package/dist/types/providers/ddns/index.d.ts +12 -0
  203. package/dist/types/providers/ddns/ip.d.ts +27 -0
  204. package/dist/types/providers/ddns/namecheap-api.d.ts +13 -0
  205. package/dist/types/providers/ddns/namecheap.d.ts +6 -0
  206. package/dist/types/providers/ddns/noip.d.ts +2 -0
  207. package/dist/types/providers/ddns/porkbun.d.ts +2 -0
  208. package/dist/types/providers/ddns/spaceship.d.ts +7 -0
  209. package/dist/types/providers/ddns/types.d.ts +98 -0
  210. package/dist/types/providers/ddns/zone.d.ts +11 -0
  211. package/dist/types/providers/docker.d.ts +117 -0
  212. package/dist/types/providers/entry-state.d.ts +15 -0
  213. package/dist/types/providers/health-check.d.ts +27 -0
  214. package/dist/types/providers/host.d.ts +147 -0
  215. package/dist/types/providers/identity.d.ts +54 -0
  216. package/dist/types/providers/log-tail.d.ts +29 -0
  217. package/dist/types/providers/nanny-sweep.d.ts +51 -0
  218. package/dist/types/providers/nanny.d.ts +94 -0
  219. package/dist/types/providers/port.d.ts +142 -0
  220. package/dist/types/providers/proc.d.ts +116 -0
  221. package/dist/types/providers/process.d.ts +61 -0
  222. package/dist/types/providers/proxy/caddy.d.ts +2 -0
  223. package/dist/types/providers/proxy/index.d.ts +7 -0
  224. package/dist/types/providers/proxy/types.d.ts +54 -0
  225. package/dist/types/providers/server-vars.d.ts +4 -0
  226. package/dist/types/providers/telegram.d.ts +32 -0
  227. package/dist/types/providers/ui-release.d.ts +113 -0
  228. package/dist/types/providers/webhook.d.ts +64 -0
  229. package/dist/types/providers/wsl-temperature.d.ts +69 -0
  230. package/dist/types/services/acme-challenge.d.ts +44 -0
  231. package/dist/types/services/auth.d.ts +145 -0
  232. package/dist/types/services/backups.d.ts +352 -0
  233. package/dist/types/services/config-watch.d.ts +40 -0
  234. package/dist/types/services/control-server.d.ts +58 -0
  235. package/dist/types/services/ddns.d.ts +67 -0
  236. package/dist/types/services/dependencies.d.ts +21 -0
  237. package/dist/types/services/events.d.ts +17 -0
  238. package/dist/types/services/exposure.d.ts +33 -0
  239. package/dist/types/services/history.d.ts +36 -0
  240. package/dist/types/services/host-monitor.d.ts +32 -0
  241. package/dist/types/services/init.d.ts +71 -0
  242. package/dist/types/services/log-buffer.d.ts +28 -0
  243. package/dist/types/services/log-files.d.ts +87 -0
  244. package/dist/types/services/log-relay.d.ts +36 -0
  245. package/dist/types/services/nanny.d.ts +14 -0
  246. package/dist/types/services/notifications.d.ts +124 -0
  247. package/dist/types/services/panel.d.ts +194 -0
  248. package/dist/types/services/proxy-config.d.ts +83 -0
  249. package/dist/types/services/proxy.d.ts +454 -0
  250. package/dist/types/services/state.d.ts +41 -0
  251. package/dist/types/services/supervisor/compose.d.ts +17 -0
  252. package/dist/types/services/supervisor/entry.d.ts +139 -0
  253. package/dist/types/services/supervisor/health.d.ts +55 -0
  254. package/dist/types/services/supervisor/pending-load.d.ts +6 -0
  255. package/dist/types/services/supervisor/persistent.d.ts +55 -0
  256. package/dist/types/services/supervisor/port-preflight.d.ts +45 -0
  257. package/dist/types/services/supervisor/records.d.ts +38 -0
  258. package/dist/types/services/supervisor/spawn.d.ts +15 -0
  259. package/dist/types/services/supervisor/view.d.ts +4 -0
  260. package/dist/types/services/supervisor.d.ts +113 -0
  261. package/dist/types/services/tls.d.ts +48 -0
  262. package/dist/types/services/ui-update.d.ts +44 -0
  263. package/dist/types/services/ui.d.ts +50 -0
  264. package/dist/types/shared/api-client.d.ts +137 -0
  265. package/dist/types/shared/backup-scope.d.ts +109 -0
  266. package/dist/types/shared/clone.d.ts +14 -0
  267. package/dist/types/shared/contracts.d.ts +4233 -0
  268. package/dist/types/shared/cpu-scale.d.ts +25 -0
  269. package/dist/types/shared/ddns-form.d.ts +62 -0
  270. package/dist/types/shared/endpoint.d.ts +8 -0
  271. package/dist/types/shared/error-message.d.ts +8 -0
  272. package/dist/types/shared/fields.d.ts +21 -0
  273. package/dist/types/shared/generated.d.ts +26 -0
  274. package/dist/types/shared/host-readings.d.ts +185 -0
  275. package/dist/types/shared/patch-diff.d.ts +94 -0
  276. package/dist/types/shared/probe-latency.d.ts +25 -0
  277. package/dist/types/shared/proxy-form.d.ts +182 -0
  278. package/dist/types/shared/server-attention.d.ts +37 -0
  279. package/dist/types/shared/server-key.d.ts +13 -0
  280. package/dist/types/shared/server-readings.d.ts +55 -0
  281. package/dist/types/shared/server-url.d.ts +43 -0
  282. package/dist/types/shared/shape.d.ts +17 -0
  283. package/dist/types/shared/ui-format.d.ts +89 -0
  284. package/docs/API.md +180 -0
  285. package/docs/BACKUPS.md +97 -0
  286. package/docs/CLI.md +122 -0
  287. package/docs/DDNS.md +12 -3
  288. package/docs/NOTIFICATIONS.md +3 -1
  289. package/docs/RESTORE_DEMO.md +6 -4
  290. package/docs/REVERSE_PROXY.md +2 -2
  291. package/docs/SECURITY.md +82 -0
  292. package/docs/SERVERS.md +47 -15
  293. package/docs/UI_CREATION.md +82 -286
  294. package/package.json +18 -9
  295. package/uis/stock/dist/assets/de-DyGrM1KK.js +1 -0
  296. package/uis/stock/dist/assets/es-BebHdc0E.js +1 -0
  297. package/uis/stock/dist/assets/fr-DsDTrxhI.js +1 -0
  298. package/uis/stock/dist/assets/index-6LANO2Ua.css +2 -0
  299. package/uis/stock/dist/assets/index-D06cUZbM.js +56 -0
  300. package/uis/stock/dist/assets/ja-D3RARJjW.js +1 -0
  301. package/uis/stock/dist/assets/ko-CKI3dFoD.js +1 -0
  302. package/uis/stock/dist/assets/ru-DEU5ujXt.js +1 -0
  303. package/uis/stock/dist/assets/vi-ULKPnasj.js +1 -0
  304. package/uis/stock/dist/assets/zh-CN-tCvnOxWy.js +1 -0
  305. package/uis/stock/dist/index.html +2 -2
  306. package/uis/stock/dist/ui.json +3 -3
  307. package/AGENTS.md +0 -403
  308. package/uis/stock/dist/assets/de-CiSKBON6.js +0 -1
  309. package/uis/stock/dist/assets/es-BgNQbboq.js +0 -1
  310. package/uis/stock/dist/assets/fr-WzBF8AXI.js +0 -1
  311. package/uis/stock/dist/assets/index-CXDl25BP.js +0 -53
  312. package/uis/stock/dist/assets/index-Cok5msAO.css +0 -2
  313. package/uis/stock/dist/assets/ja-DMQqF4ip.js +0 -1
  314. package/uis/stock/dist/assets/ko-DgfSg9v_.js +0 -1
  315. package/uis/stock/dist/assets/ru-DjIByX61.js +0 -1
  316. package/uis/stock/dist/assets/vi-DOB8nYFC.js +0 -1
  317. package/uis/stock/dist/assets/zh-CN-DZ3WlUgy.js +0 -1
@@ -0,0 +1,2256 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { type } from "arktype";
3
+ /**
4
+ * The alert thresholds a percentage reading is banded against, when the frame carries none.
5
+ *
6
+ * One home, the same rule as `LOAD_ALERT_PER_CPU_DEFAULT`: `hostSchema` defaults to these, and a
7
+ * surface reading a frame from a panel that predates the fields bands against the numbers that
8
+ * panel alerted on.
9
+ */
10
+ var HOST_ALERT_DEFAULTS = {
11
+ diskUsedPercent: 90,
12
+ memoryUsedPercent: 90,
13
+ swapUsedPercent: 50,
14
+ tempCelsius: 85
15
+ };
16
+ var NOTHING_SAMPLED = {
17
+ sampled: false,
18
+ cpuUsedPercent: null,
19
+ memoryUsedPercent: null,
20
+ swapUsedPercent: null,
21
+ load1m: null,
22
+ load5m: null,
23
+ load15m: null,
24
+ loadPerCpu: null,
25
+ tempCelsius: null,
26
+ disks: [],
27
+ loadBand: null,
28
+ memoryBand: null,
29
+ swapBand: null,
30
+ tempBand: null
31
+ };
32
+ /** A number the frame carries, or null when it carries none. */
33
+ function present(value) {
34
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
35
+ }
36
+ /**
37
+ * How a per-cpu load sits against the threshold the panel notifies on.
38
+ *
39
+ * The ratio is what a person configures: `host.loadPerCpu` is the count the alert fires at, so
40
+ * `danger` is that number itself and `warn` is the approach to it. `0` disables the alert in
41
+ * `sampleHost`, so nothing can breach it and the band is `ok` — painting a box red for a
42
+ * notification that will never arrive is the same defect as inventing a reading. It lives here
43
+ * rather than in a component so both UIs share one band, the mistake that produced two hardcoded
44
+ * copies of the default.
45
+ */
46
+ function loadBand(loadPerCpu, alertPerCpu) {
47
+ return thresholdBand(loadPerCpu, alertPerCpu, 2);
48
+ }
49
+ /**
50
+ * How a reading sits against the threshold the panel notifies on.
51
+ *
52
+ * `danger` at the threshold is the whole point: the alert fires there, so a bar that stays `warn`
53
+ * while a notification goes out disagrees with the panel's own verdict. `0` disables that alert in
54
+ * `sampleHost`, so nothing can breach it and the band is `ok`. One rule for the per-cpu load, the
55
+ * three percentages and each disk — they differ only in what the number means, and the mistake this
56
+ * replaced was four surfaces each deciding a band for itself.
57
+ */
58
+ function percentageBand(value, alertAt, fallback) {
59
+ return thresholdBand(value, alertAt, fallback);
60
+ }
61
+ function thresholdBand(value, alertAt, fallback) {
62
+ if (value === null || !Number.isFinite(value)) return null;
63
+ const threshold = alertAt === void 0 || !Number.isFinite(alertAt) ? fallback : alertAt;
64
+ if (threshold <= 0) return "ok";
65
+ if (value >= threshold) return "danger";
66
+ if (value >= threshold * .7) return "warn";
67
+ return "ok";
68
+ }
69
+ /** The readings of one host frame; a missing frame is the same as an unsampled one. */
70
+ function hostReadings(host) {
71
+ if (host === null || host === void 0) return NOTHING_SAMPLED;
72
+ if (!(host.sampledAt !== null)) return {
73
+ ...NOTHING_SAMPLED,
74
+ disks: []
75
+ };
76
+ const load1m = present(host.loadAvg[0]);
77
+ const cpus = present(host.cpus);
78
+ const loadPerCpu = load1m === null ? null : load1m / Math.max(1, cpus ?? 1);
79
+ return {
80
+ sampled: true,
81
+ cpuUsedPercent: present(host.cpuUsedPercent),
82
+ memoryUsedPercent: present(host.memoryUsedPercent),
83
+ swapUsedPercent: present(host.swapUsedPercent),
84
+ load1m,
85
+ load5m: present(host.loadAvg[1]),
86
+ load15m: present(host.loadAvg[2]),
87
+ loadPerCpu,
88
+ loadBand: loadBand(loadPerCpu, host.loadAlertPerCpu),
89
+ memoryBand: percentageBand(present(host.memoryUsedPercent), host.memoryUsedPercentAlert, HOST_ALERT_DEFAULTS.memoryUsedPercent),
90
+ swapBand: percentageBand(present(host.swapUsedPercent), host.swapUsedPercentAlert, HOST_ALERT_DEFAULTS.swapUsedPercent),
91
+ tempBand: percentageBand(present(host.tempCelsius), host.tempCelsiusAlert, HOST_ALERT_DEFAULTS.tempCelsius),
92
+ tempCelsius: present(host.tempCelsius),
93
+ disks: host.disks.map((disk) => ({
94
+ ...disk,
95
+ band: percentageBand(present(disk.usedPercent), host.diskUsedPercentAlert, HOST_ALERT_DEFAULTS.diskUsedPercent)
96
+ }))
97
+ };
98
+ }
99
+ //#endregion
100
+ //#region src/shared/contracts.ts
101
+ var contracts_exports = /* @__PURE__ */ __exportAll({
102
+ actionResultSchema: () => actionResultSchema,
103
+ apiErrorSchema: () => apiErrorSchema,
104
+ apiTokenCreatedSchema: () => apiTokenCreatedSchema,
105
+ appStateSchema: () => appStateSchema,
106
+ authSchema: () => authSchema,
107
+ authStatusSchema: () => authStatusSchema,
108
+ backupCreateSchema: () => backupCreateSchema,
109
+ backupCreatedResponseSchema: () => backupCreatedResponseSchema,
110
+ backupEntrySchema: () => backupEntrySchema,
111
+ backupFileSchema: () => backupFileSchema,
112
+ backupFilesResponseSchema: () => backupFilesResponseSchema,
113
+ backupHookOrNullSchema: () => backupHookOrNullSchema,
114
+ backupHookPatchOrNullSchema: () => backupHookPatchOrNullSchema,
115
+ backupHookPatchSchema: () => backupHookPatchSchema,
116
+ backupHookSchema: () => backupHookSchema,
117
+ backupScheduleSchema: () => backupScheduleSchema,
118
+ backupScheduleViewSchema: () => backupScheduleViewSchema,
119
+ backupScopeSchema: () => backupScopeSchema,
120
+ backupSelectionSchema: () => backupSelectionSchema,
121
+ backupsSchema: () => backupsSchema,
122
+ backupsViewSchema: () => backupsViewSchema,
123
+ bindSchema: () => bindSchema,
124
+ bootstrapOrNullSchema: () => bootstrapOrNullSchema,
125
+ bootstrapPatchOrNullSchema: () => bootstrapPatchOrNullSchema,
126
+ bootstrapPatchSchema: () => bootstrapPatchSchema,
127
+ bootstrapSchema: () => bootstrapSchema,
128
+ bufferedLogsResponseSchema: () => bufferedLogsResponseSchema,
129
+ controlSchema: () => controlSchema,
130
+ controlViewSchema: () => controlViewSchema,
131
+ ddnsAccountSchema: () => ddnsAccountSchema,
132
+ ddnsConfigSchema: () => ddnsConfigSchema,
133
+ ddnsCredentialsSchema: () => ddnsCredentialsSchema,
134
+ ddnsDomainSchema: () => ddnsDomainSchema,
135
+ ddnsIpv4Schema: () => ddnsIpv4Schema,
136
+ ddnsIpv6Schema: () => ddnsIpv6Schema,
137
+ ddnsProviderFieldSchema: () => ddnsProviderFieldSchema,
138
+ ddnsProviderInfoSchema: () => ddnsProviderInfoSchema,
139
+ ddnsRecordStateSchema: () => ddnsRecordStateSchema,
140
+ ddnsRecordTypeSchema: () => ddnsRecordTypeSchema,
141
+ ddnsRecordViewSchema: () => ddnsRecordViewSchema,
142
+ ddnsStatusSchema: () => ddnsStatusSchema,
143
+ ddnsViewSchema: () => ddnsViewSchema,
144
+ defaultsSchema: () => defaultsSchema,
145
+ deliveryResultSchema: () => deliveryResultSchema,
146
+ destinationIdParamSchema: () => destinationIdParamSchema,
147
+ destinationStatusSchema: () => destinationStatusSchema,
148
+ destinationTestSchema: () => destinationTestSchema,
149
+ duplicateWebhookIds: () => duplicateWebhookIds,
150
+ entryStateSchema: () => entryStateSchema,
151
+ freePortResultSchema: () => freePortResultSchema,
152
+ healthResponseSchema: () => healthResponseSchema,
153
+ healthSchema: () => healthSchema,
154
+ healthStateSchema: () => healthStateSchema,
155
+ historyActorSchema: () => historyActorSchema,
156
+ historyEventSchema: () => historyEventSchema,
157
+ hostDiskSchema: () => hostDiskSchema,
158
+ hostSchema: () => hostSchema,
159
+ hostViewSchema: () => hostViewSchema,
160
+ httpCheckSchema: () => httpCheckSchema,
161
+ labelOrNullSchema: () => labelOrNullSchema,
162
+ logBufferLinesSchema: () => logBufferLinesSchema,
163
+ logFileInfoSchema: () => logFileInfoSchema,
164
+ logHistoryQuerySchema: () => logHistoryQuerySchema,
165
+ logLineSchema: () => logLineSchema,
166
+ logLinesResponseSchema: () => logLinesResponseSchema,
167
+ logQuerySchema: () => logQuerySchema,
168
+ logServerViewSchema: () => logServerViewSchema,
169
+ logServersViewSchema: () => logServersViewSchema,
170
+ logStreamSchema: () => logStreamSchema,
171
+ loginSchema: () => loginSchema,
172
+ logsSchema: () => logsSchema,
173
+ nannyExitSchema: () => nannyExitSchema,
174
+ nannySpecSchema: () => nannySpecSchema,
175
+ nannyStateSchema: () => nannyStateSchema,
176
+ notificationActionSchema: () => notificationActionSchema,
177
+ notificationDefaultsSchema: () => notificationDefaultsSchema,
178
+ notificationDefaultsViewSchema: () => notificationDefaultsViewSchema,
179
+ notificationTargetSchema: () => notificationTargetSchema,
180
+ notificationViewSchema: () => notificationViewSchema,
181
+ notificationsSchema: () => notificationsSchema,
182
+ okResponseSchema: () => okResponseSchema,
183
+ onPortConflictDefaultSchema: () => onPortConflictDefaultSchema,
184
+ onPortConflictSchema: () => onPortConflictSchema,
185
+ parseBind: () => parseBind,
186
+ passwordSchema: () => passwordSchema,
187
+ passwordSetResponseSchema: () => passwordSetResponseSchema,
188
+ passwordValueSchema: () => passwordValueSchema,
189
+ portSchema: () => portSchema,
190
+ portStateSchema: () => portStateSchema,
191
+ processResourcesSchema: () => processResourcesSchema,
192
+ proxyCertificateSchema: () => proxyCertificateSchema,
193
+ proxyCertificateStateSchema: () => proxyCertificateStateSchema,
194
+ proxyCertificateUploadSchema: () => proxyCertificateUploadSchema,
195
+ proxyCertificateViewSchema: () => proxyCertificateViewSchema,
196
+ proxyConfigSchema: () => proxyConfigSchema,
197
+ proxyDns01Schema: () => proxyDns01Schema,
198
+ proxyDnsAccountViewSchema: () => proxyDnsAccountViewSchema,
199
+ proxyEngineInfoSchema: () => proxyEngineInfoSchema,
200
+ proxyEngineInstallSchema: () => proxyEngineInstallSchema,
201
+ proxyEngineSchema: () => proxyEngineSchema,
202
+ proxyEngineSourceSchema: () => proxyEngineSourceSchema,
203
+ proxyEngineStatusSchema: () => proxyEngineStatusSchema,
204
+ proxyPatchSchema: () => proxyPatchSchema,
205
+ proxyRoutePatchSchema: () => proxyRoutePatchSchema,
206
+ proxyRouteSchema: () => proxyRouteSchema,
207
+ proxyRouteStatusSchema: () => proxyRouteStatusSchema,
208
+ proxyRouteViewSchema: () => proxyRouteViewSchema,
209
+ proxyRunStateSchema: () => proxyRunStateSchema,
210
+ proxyStatusSchema: () => proxyStatusSchema,
211
+ proxyTargetSchema: () => proxyTargetSchema,
212
+ proxyTlsModeSchema: () => proxyTlsModeSchema,
213
+ proxyViewSchema: () => proxyViewSchema,
214
+ resourcesSchema: () => resourcesSchema,
215
+ restartSchema: () => restartSchema,
216
+ restoreItemSchema: () => restoreItemSchema,
217
+ restorePlanSchema: () => restorePlanSchema,
218
+ restoreRequestSchema: () => restoreRequestSchema,
219
+ restoreSkipSchema: () => restoreSkipSchema,
220
+ serverCreateSchema: () => serverCreateSchema,
221
+ serverHistorySchema: () => serverHistorySchema,
222
+ serverOrphanSchema: () => serverOrphanSchema,
223
+ serverPatchSchema: () => serverPatchSchema,
224
+ serverSchema: () => serverSchema,
225
+ serverStatusSchema: () => serverStatusSchema,
226
+ serverViewSchema: () => serverViewSchema,
227
+ sessionViewSchema: () => sessionViewSchema,
228
+ settingsPatchSchema: () => settingsPatchSchema,
229
+ settingsSavedSchema: () => settingsSavedSchema,
230
+ settingsViewSchema: () => settingsViewSchema,
231
+ stopSchema: () => stopSchema,
232
+ telegramChatsSchema: () => telegramChatsSchema,
233
+ telegramTokenSchema: () => telegramTokenSchema,
234
+ tlsReviewResponseSchema: () => tlsReviewResponseSchema,
235
+ tlsSchema: () => tlsSchema,
236
+ tlsStatusSchema: () => tlsStatusSchema,
237
+ tlsUploadSchema: () => tlsUploadSchema,
238
+ uiInstallResponseSchema: () => uiInstallResponseSchema,
239
+ uiMetaSchema: () => uiMetaSchema,
240
+ uiStatusSchema: () => uiStatusSchema,
241
+ usageEntrySchema: () => usageEntrySchema,
242
+ usageViewSchema: () => usageViewSchema,
243
+ webhookTargetSchema: () => webhookTargetSchema,
244
+ workspaceCreateSchema: () => workspaceCreateSchema,
245
+ workspaceIdSchema: () => workspaceIdSchema,
246
+ workspaceRenameSchema: () => workspaceRenameSchema,
247
+ workspaceSchema: () => workspaceSchema,
248
+ workspaceSettingsPatchSchema: () => workspaceSettingsPatchSchema,
249
+ workspaceSettingsSavedSchema: () => workspaceSettingsSavedSchema,
250
+ workspaceSettingsViewSchema: () => workspaceSettingsViewSchema,
251
+ workspaceViewSchema: () => workspaceViewSchema,
252
+ wslTemperatureSchema: () => wslTemperatureSchema
253
+ });
254
+ /**
255
+ * Schemas shared by the control plane and the SPA: the server entry shape, the
256
+ * control panel's own settings, API DTOs and SSE frames. Nothing here knows
257
+ * about a particular server — an entry carries its own command, args, env and
258
+ * bootstrap.
259
+ */
260
+ /** `local` -> 127.0.0.1, `lan` -> 0.0.0.0, or an explicit IPv4 to bind. */
261
+ var bindSchema = type("\"local\" | \"lan\" | /^\\d{1,3}(?:\\.\\d{1,3}){3}$/");
262
+ /**
263
+ * A top-level unit: its own settings, servers, secrets, logs and nanny state
264
+ * under `$HHOSTED_HOME/.hh/<id>/`. The id is the directory name and never
265
+ * changes; the label is what a person reads and may rename at will.
266
+ */
267
+ var workspaceIdSchema = type("/^[a-z0-9][a-z0-9_-]*$/");
268
+ var workspaceSchema = type({
269
+ id: workspaceIdSchema,
270
+ label: "1 <= string <= 60"
271
+ }).onUndeclaredKey("reject");
272
+ /** `id` is optional; when omitted it is derived from the label. */
273
+ var workspaceCreateSchema = type({
274
+ "id?": workspaceIdSchema,
275
+ "label?": "1 <= string <= 60"
276
+ }).onUndeclaredKey("reject");
277
+ var workspaceRenameSchema = type({ label: "1 <= string <= 60" }).onUndeclaredKey("reject");
278
+ /** Parses a bind value (`local` | `lan` | ipv4); null when it is not one. */
279
+ function parseBind(value) {
280
+ const parsed = bindSchema(value);
281
+ return parsed instanceof type.errors ? null : parsed;
282
+ }
283
+ /** `null` means "no port": no readiness probe, no health supervision, no preflight. */
284
+ var portSchema = type("1 <= number.integer <= 65535 | null");
285
+ /**
286
+ * What to do when something already listens on the entry's port. `follow` and
287
+ * `reclaim` only ever act on a holder proven to be this entry's own detached
288
+ * successor (the `HHOSTED_SERVER_ID` marker, POSIX only); `kill` is the blunt one:
289
+ * it stops any holder except the panel's own process tree.
290
+ */
291
+ var onPortConflictSchema = type.enumerated("block", "warn", "follow", "reclaim", "kill");
292
+ /** The stored forms carry the default; a patch must not (see the patch schemas below). */
293
+ var onPortConflictDefaultSchema = onPortConflictSchema.default("block");
294
+ var restartSchema = type({
295
+ enabled: "boolean = true",
296
+ maxRetries: "number.integer >= 0 = 3",
297
+ baseDelayMs: "number >= 0 = 1000",
298
+ factor: "number >= 1 = 2",
299
+ maxDelayMs: "number >= 0 = 30000",
300
+ /** A process alive this long is considered healthy again and the retry counter resets. */
301
+ resetAfterMs: "number >= 0 = 60000"
302
+ }).onUndeclaredKey("reject");
303
+ var httpCheckSchema = type({
304
+ /** `https` is for a backend that serves TLS itself; pair it with `allowInvalidCert` when it is self-signed. */
305
+ scheme: "\"http\" | \"https\" = \"http\"",
306
+ /** Accept any certificate. A self-signed pair is the normal case here, and the probe is local. */
307
+ allowInvalidCert: "boolean = false",
308
+ /** Path on the server's own port, e.g. `/healthz`. */
309
+ path: "string = \"/\"",
310
+ method: "\"GET\" | \"HEAD\" = \"GET\"",
311
+ /** Exact status to accept; `null` (or omitted) means any status below `expectStatusBelow`. */
312
+ expectStatus: "number.integer | null?",
313
+ expectStatusBelow: "number.integer = 400",
314
+ /** Substring that must appear in the response body. */
315
+ expectBody: "string = \"\""
316
+ }).onUndeclaredKey("reject");
317
+ /** Restart guards for the process tree. */
318
+ var resourcesSchema = type({
319
+ /** Restart when the tree's RSS exceeds this; 0 disables. */
320
+ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
321
+ var healthSchema = type({
322
+ enabled: "boolean = true",
323
+ /** `port` = TCP connect only; `http` = fetch `http.path` and assert the response. */
324
+ mode: "\"port\" | \"http\" = \"port\"",
325
+ http: httpCheckSchema.default(() => ({})),
326
+ intervalMs: "number >= 500 = 5000",
327
+ timeoutMs: "number >= 100 = 1500",
328
+ /** Consecutive failed probes before the warning state is shown. */
329
+ unhealthyThreshold: "number.integer >= 1 = 3",
330
+ /** 0 disables it; otherwise a port stuck unhealthy this long forces a restart. */
331
+ forceRestartAfterMs: "number >= 0 = 0",
332
+ /** How long to wait for the port to accept connections after spawn. */
333
+ startTimeoutMs: "number >= 0 = 20000"
334
+ }).onUndeclaredKey("reject");
335
+ var stopSchema = type({
336
+ signal: "\"SIGTERM\" | \"SIGINT\" | \"SIGKILL\" = \"SIGTERM\"",
337
+ killGroup: "boolean = true",
338
+ graceMs: "number >= 0 = 5000",
339
+ /** Last resort for wrappers that detach their real server. */
340
+ killPortHolders: "boolean = false"
341
+ }).onUndeclaredKey("reject");
342
+ var bootstrapSchema = type({
343
+ command: "string",
344
+ args: type("string[]").default(() => []),
345
+ env: type("Record<string, string>").default(() => ({})),
346
+ timeoutMs: "number >= 1000 = 120000",
347
+ /** Run once per `up` session; whatever it installs persists on disk. */
348
+ runOnce: "boolean = true"
349
+ }).onUndeclaredKey("reject");
350
+ var bootstrapOrNullSchema = bootstrapSchema.or(type("null"));
351
+ /**
352
+ * The `bootstrap` group as a patch carries it: every field optional, and **no defaults**.
353
+ *
354
+ * A patch must not fill a default in (`AGENTS.md`), and it could not here for a second reason.
355
+ * `bootstrap` is not in `SERVER_MERGE_KEYS`, so `applyPatch` **replaces** the whole group; the
356
+ * defaults on `bootstrapSchema` used to arrive with the patch, so sending one changed field
357
+ * wrote a group with the other four reset. Measured on `PATCH /api/servers/db` with
358
+ * `{"bootstrap":{"command":"next.sh"}}`: stored `args: ["--ci"]` became `[]`, `runOnce: false`
359
+ * became `true` — re-arming a one-shot bootstrap to run on every `up` — and `timeoutMs: 5000`
360
+ * became `120000`. The group is still replaced, so a caller sends the fields it means to keep;
361
+ * what changes is that the panel no longer invents the ones it did not send.
362
+ */
363
+ var bootstrapPatchSchema = type({
364
+ command: "string >= 1?",
365
+ args: "string[]?",
366
+ env: "Record<string, string>?",
367
+ timeoutMs: "number >= 1000?",
368
+ runOnce: "boolean?"
369
+ }).onUndeclaredKey("reject");
370
+ var bootstrapPatchOrNullSchema = bootstrapPatchSchema.or(type("null"));
371
+ /**
372
+ * A command run around a backup, for engines that need one to produce a consistent copy.
373
+ *
374
+ * `mongodump` is the reason this exists: copying `dbPath` while the server writes gives a torn copy,
375
+ * and a dump taken by the engine is the only supported way. Same shape as `bootstrap` — one program
376
+ * and its args, never a command line — and the same rule that the panel never guesses what an engine
377
+ * needs.
378
+ *
379
+ * `{dumpDir}` is created before `dump` runs and captured by the archive; on restore the same
380
+ * directory is filled again before `load` runs, so the two hooks see the same path.
381
+ */
382
+ var backupHookSchema = type({
383
+ command: "string >= 1",
384
+ args: type("string[]").default(() => []),
385
+ env: type("Record<string, string>").default(() => ({})),
386
+ timeoutMs: "number >= 1000 = 600000",
387
+ /**
388
+ * How long to wait for the entry to answer before running a `load`.
389
+ *
390
+ * Only matters for `load`, and only for an entry with no `port`: the wait is normally "the port
391
+ * accepts a connection", which an entry that declares no port cannot offer. Two seconds by
392
+ * default, because a portless entry usually starts fast and a fixed wait is pure delay; a slow
393
+ * database reached over a socket should raise it.
394
+ */
395
+ waitMs: "number >= 0 = 2000"
396
+ }).onUndeclaredKey("reject");
397
+ var backupHookOrNullSchema = backupHookSchema.or(type("null"));
398
+ /**
399
+ * The `dump`/`load` group as a patch carries it: every field optional, and **no defaults**.
400
+ *
401
+ * The same defect `bootstrapPatchSchema` exists for, in the same `editableFields`: both hooks are
402
+ * replaced rather than merged, so the group's defaults used to arrive with a one-field edit and
403
+ * reset `args`, `env`, `timeoutMs` and `waitMs` to values nobody sent. `waitMs` is the one that
404
+ * bites hardest — a `load` waiting on a slow database would silently drop back to 2 s.
405
+ */
406
+ var backupHookPatchSchema = type({
407
+ command: "string >= 1?",
408
+ args: "string[]?",
409
+ env: "Record<string, string>?",
410
+ timeoutMs: "number >= 1000?",
411
+ waitMs: "number >= 0?"
412
+ }).onUndeclaredKey("reject");
413
+ var backupHookPatchOrNullSchema = backupHookPatchSchema.or(type("null"));
414
+ /**
415
+ * A label that may be written as `null`, which means "no label" — the same spelling `port` and
416
+ * `bootstrap` already accept in a file.
417
+ *
418
+ * `serverSchema.label` was `'string?'`, so a hand-edited `"label": null` refused the **whole config** with
419
+ * `servers[0] ("web"): label must be a string (was null)`. The write side already tolerates `null`, and every
420
+ * display falls back with `label ?? id` — which `null` satisfies and `''` does not.
421
+ */
422
+ var labelOrNullSchema = type("string | null");
423
+ var logBufferLinesSchema = type("50 <= number.integer <= 100000");
424
+ var serverSchema = type({
425
+ id: "/^[a-z0-9][a-z0-9_-]*$/",
426
+ label: labelOrNullSchema.optional(),
427
+ enabled: "boolean = true",
428
+ autostart: "boolean = false",
429
+ /**
430
+ * Handed to a nanny process that owns the pipes, so the entry keeps running when
431
+ * this panel stops, restarts or is killed. `down`/`stop-all` leave it alone and
432
+ * report it; only an explicit stop or restart stops it.
433
+ */
434
+ persistent: "boolean = false",
435
+ command: "string >= 1",
436
+ args: type("string[]").default(() => []),
437
+ cwd: "string = \".\"",
438
+ env: type("Record<string, string>").default(() => ({})),
439
+ /**
440
+ * `ENV=path` pairs: exported to the process (overriding `env`) *and* the path
441
+ * is backed up automatically — one declaration for data directories.
442
+ */
443
+ dataEnvs: type("Record<string, string>").default(() => ({})),
444
+ bootstrap: bootstrapOrNullSchema.optional(),
445
+ /**
446
+ * Run before this entry's data is captured, writing into `{dumpDir}`.
447
+ *
448
+ * For a database: `mongodump --archive={dumpDir}/db.archive`. A failed dump **refuses the backup**
449
+ * rather than archiving a stale directory next to it — the whole point is that the dump is the
450
+ * authoritative copy.
451
+ */
452
+ dump: backupHookOrNullSchema.optional(),
453
+ /** Run after this entry's data is restored, reading from `{dumpDir}`. Its server is stopped first. */
454
+ load: backupHookOrNullSchema.optional(),
455
+ port: portSchema.optional(),
456
+ bind: bindSchema.default(() => "local"),
457
+ onPortConflict: onPortConflictDefaultSchema,
458
+ restart: restartSchema.default(() => ({})),
459
+ health: healthSchema.default(() => ({})),
460
+ stop: stopSchema.default(() => ({})),
461
+ logBufferLines: logBufferLinesSchema.default(() => 500),
462
+ /** Ids this server needs running first (and healthy); `stop-all` stops dependents before it. */
463
+ dependsOn: type("string[]").default(() => []),
464
+ /** Optional KEY=value file loaded at spawn; its values override `env`. */
465
+ envFile: "string = \"\"",
466
+ resources: resourcesSchema.default(() => ({})),
467
+ /** Paths included in backups for this server (templates allowed). */
468
+ backupPaths: type("string[]").default(() => []),
469
+ /**
470
+ * Skip well-known build output and dependency directories (`node_modules`,
471
+ * `dist`, `.next`, caches, …) inside the paths this entry declares.
472
+ */
473
+ backupIgnoreGenerated: "boolean = true"
474
+ }).onUndeclaredKey("reject");
475
+ /**
476
+ * Authentication for the control panel itself. The password never lives here —
477
+ * only the policy does; its scrypt hash sits in a git-ignored secrets file.
478
+ */
479
+ var authSchema = type({
480
+ enabled: "boolean = true",
481
+ /** Idle timeout: a session dies this long after its **last** request, not after login. */
482
+ sessionTtlMs: "number >= 60000 = 604800000",
483
+ /** `auto` adds `Secure` when the request arrived over https (proxy-aware). */
484
+ cookieSecure: "\"auto\" | \"always\" | \"never\" = \"auto\"",
485
+ /** Trust `x-forwarded-*` from a reverse proxy; also drives the client IP. */
486
+ trustProxy: "boolean | \"loopback\" = \"loopback\"",
487
+ maxLoginAttempts: "number.integer >= 1 = 5",
488
+ lockoutMs: "number >= 1000 = 60000"
489
+ }).onUndeclaredKey("reject");
490
+ /**
491
+ * The event toggles and the throttle — the part a target may **inherit** instead of setting.
492
+ *
493
+ * `enabled` is deliberately not here: "send to this one" is a property of the target, never
494
+ * something to inherit. Everything else answers the same question for every transport, and one
495
+ * definition means a fourth cannot quietly spell `onRecovered` differently.
496
+ */
497
+ var notificationPolicyShape = {
498
+ onCrash: "boolean = true",
499
+ onUnhealthy: "boolean = true",
500
+ onForcedRestart: "boolean = true",
501
+ onRecovered: "boolean = false",
502
+ /** Host vitals breaches (disk, memory, swap, load, temperature). */
503
+ onHost: "boolean = true",
504
+ /** Dynamic DNS changes and failures. */
505
+ onDdns: "boolean = true",
506
+ /** Per server *and* reason, so a flapping server cannot spam the chat. */
507
+ cooldownMs: "number >= 0 = 120000"
508
+ };
509
+ /**
510
+ * The general settings: what applies to every target that does not override it.
511
+ *
512
+ * The point of the block is that the common case — "tell me about crashes and host thresholds,
513
+ * throttled every two minutes" — is set **once**, instead of once per transport and again per
514
+ * destination.
515
+ */
516
+ var notificationDefaultsSchema = type({ ...notificationPolicyShape }).onUndeclaredKey("reject");
517
+ /**
518
+ * The same block **as a response**: tolerant of a key this release does not know.
519
+ *
520
+ * A request schema rejects undeclared keys, a response schema must not — an upgrade writes a new UI
521
+ * while an old panel keeps serving, and a newer panel adding one field here must not blank this
522
+ * build's whole app. Reusing the strict schema in the view did exactly that: one additive key in
523
+ * `defaults` rejected the state frame and the page went blank.
524
+ */
525
+ var notificationDefaultsViewSchema = type({ ...notificationPolicyShape });
526
+ /**
527
+ * Whether a target follows the general block or carries its own.
528
+ *
529
+ * **Defaults to `true`**, which is what an existing config means: before this block existed every
530
+ * target carried its own toggles, and reading one as "inherit" would silently change which events
531
+ * it delivers on upgrade. A target the page creates opts *in* to inheritance explicitly, so the
532
+ * new default applies to new targets without rewriting anybody's config.
533
+ */
534
+ var useOwnSettingsSchema = "boolean = true";
535
+ /**
536
+ * One Telegram destination.
537
+ *
538
+ * `chatId` is config; the bot token is a **secret**, keyed by this target's `id` in the workspace's
539
+ * `.secrets.json`. More than one is allowed, which is why the token cannot be a singleton any more.
540
+ */
541
+ var telegramDestinationSchema = type({
542
+ kind: "\"telegram\"",
543
+ id: "/^[a-z0-9][a-z0-9_-]*$/",
544
+ /** Off until configured: a bare `enabled: true` with no chat would fail every send. */
545
+ enabled: "boolean = false",
546
+ chatId: "string = \"\"",
547
+ useOwnSettings: useOwnSettingsSchema,
548
+ ...notificationPolicyShape
549
+ }).onUndeclaredKey("reject");
550
+ /**
551
+ * One webhook target: a URL, a method, and the headers to send with it.
552
+ *
553
+ * This is the general transport, and it is a *list* because a home panel alerts more than one
554
+ * place — a phone, a chat channel, a dashboard. The headers are what make it general rather
555
+ * than JSON-only: ntfy wants `Title`/`Priority` headers with a plain-text body, a bearer-token
556
+ * receiver wants `Authorization`, and a JSON receiver wants `content-type`. One shape covers
557
+ * all three; a per-service adapter would be a code change per service.
558
+ */
559
+ /** One webhook destination. */
560
+ var webhookTargetSchema = type({
561
+ kind: "\"webhook\"",
562
+ id: "/^[a-z0-9][a-z0-9_-]*$/",
563
+ /** Empty only while the target is a draft; the page will not save one without it. */
564
+ url: "string = \"\"",
565
+ enabled: "boolean = true",
566
+ method: "\"POST\" | \"PUT\" = \"POST\"",
567
+ /** Payload format: `json` sends the event as JSON, `text` sends the plain message. */
568
+ format: "\"json\" | \"text\" = \"json\"",
569
+ /**
570
+ * Extra headers, `Name: value` per line. The one field that lets this transport talk to
571
+ * ntfy (`Title`, `Priority`), a bearer-token endpoint (`Authorization`) or anything else
572
+ * with a header-shaped contract.
573
+ */
574
+ headers: "string = \"\"",
575
+ useOwnSettings: useOwnSettingsSchema,
576
+ ...notificationPolicyShape
577
+ }).onUndeclaredKey("reject");
578
+ /** A destination is one of the kinds this build can deliver to. */
579
+ var notificationTargetSchema = telegramDestinationSchema.or(webhookTargetSchema);
580
+ /**
581
+ * The destination list.
582
+ *
583
+ * `id` is the list key — the cooldown, the last-result record and a Telegram target's token are all
584
+ * keyed by it — so it must be unique across kinds, not just within one. Enforced by
585
+ * `duplicateWebhookIds` at the write; a schema `narrow` cannot be rendered to JSON Schema and every
586
+ * route's `toJsonSchema()` would throw.
587
+ */
588
+ var destinationListSchema = notificationTargetSchema.array();
589
+ var notificationsSchema = type({
590
+ /** What every destination inherits unless it carries its own settings. */
591
+ defaults: notificationDefaultsSchema.default(() => ({})),
592
+ /** Replaced by a patch, the same way `ddns.accounts` is: a merge cannot express removing one. */
593
+ destinations: destinationListSchema.default(() => [])
594
+ }).onUndeclaredKey("reject");
595
+ /**
596
+ * The ids that appear more than once, so a write can refuse them.
597
+ *
598
+ * A schema-level check is not available here (see above), and this is the one shape that has to
599
+ * be told apart from a plain validation error: the list is valid, but its identity is not.
600
+ */
601
+ function duplicateWebhookIds(targets) {
602
+ const seen = /* @__PURE__ */ new Set();
603
+ const duplicates = /* @__PURE__ */ new Set();
604
+ for (const target of targets) {
605
+ if (seen.has(target.id)) duplicates.add(target.id);
606
+ seen.add(target.id);
607
+ }
608
+ return [...duplicates];
609
+ }
610
+ /** On-disk log retention for the Logs page. */
611
+ var logsSchema = type({
612
+ persist: "boolean = true",
613
+ /** Per server, before rotating to `.1`, `.2`, ... */
614
+ maxBytes: "10000 <= number <= 100000000 = 2000000",
615
+ keep: "1 <= number.integer <= 10 = 3"
616
+ }).onUndeclaredKey("reject");
617
+ var tlsSchema = type({ enabled: "boolean = false" }).onUndeclaredKey("reject");
618
+ /** Host-level vitals and their alert thresholds. */
619
+ var hostSchema = type({
620
+ enabled: "boolean = true",
621
+ intervalMs: "number >= 5000 = 15000",
622
+ /** Filesystems reported and alerted on; templates and `~` are expanded. */
623
+ diskPaths: type("string[]").default(() => ["."]),
624
+ /**
625
+ * 0 disables an individual alert. Each default is written from `HOST_ALERT_DEFAULTS`, so the
626
+ * number a fresh config gets and the number a surface bands against when a frame carries no
627
+ * threshold are one value — the same one-home rule `loadPerCpu` follows below.
628
+ */
629
+ diskUsedPercent: `number >= 0 = ${HOST_ALERT_DEFAULTS.diskUsedPercent}`,
630
+ memoryUsedPercent: `number >= 0 = ${HOST_ALERT_DEFAULTS.memoryUsedPercent}`,
631
+ swapUsedPercent: `number >= 0 = ${HOST_ALERT_DEFAULTS.swapUsedPercent}`,
632
+ /**
633
+ * The per-cpu load the panel notifies on. One home: the frame's `loadAlertPerCpu` is this value,
634
+ * and `loadBand` reads it, so a surface cannot band the load against a number nobody configured.
635
+ */
636
+ loadPerCpu: type("number >= 0").default(2),
637
+ tempCelsius: `number >= 0 = ${HOST_ALERT_DEFAULTS.tempCelsius}`,
638
+ /**
639
+ * How to read the CPU temperature when the kernel exposes no sensor.
640
+ *
641
+ * A command whose stdout is a number in °C — the escape hatch for a machine this panel cannot read
642
+ * for itself (a WSL2 guest, a VM, a board whose hwmon chip is unsupported). Empty means "use the
643
+ * built-in probe". It runs on the sampling interval, so it must be cheap; `docs/SERVERS.md` carries
644
+ * the WSL2 setup.
645
+ */
646
+ tempCommand: "string <= 512 = \"\"",
647
+ /** How long that command may run before it is killed, so a hung helper cannot stall a sample. */
648
+ tempCommandTimeoutMs: "100 <= number <= 30000 = 5000"
649
+ }).onUndeclaredKey("reject");
650
+ /** A record family the DDNS engine can point at this host. */
651
+ var ddnsRecordTypeSchema = type.enumerated("A", "AAAA");
652
+ /**
653
+ * One DNS provider account. Its credentials are secrets and live in the secrets
654
+ * file keyed by this `id`, never in the config.
655
+ */
656
+ var ddnsAccountSchema = type({
657
+ id: "/^[a-z0-9][a-z0-9_-]*$/",
658
+ provider: "string >= 1",
659
+ label: "string = \"\""
660
+ }).onUndeclaredKey("reject");
661
+ /**
662
+ * A hostname to keep pointed at this machine. That list is the whole user-facing
663
+ * setup: the provider account it belongs to, and (optionally) which families.
664
+ */
665
+ var ddnsDomainSchema = type({
666
+ host: "/^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/",
667
+ account: "string >= 1",
668
+ /** Records to keep current; `A` unless the host needs IPv6 too. */
669
+ types: ddnsRecordTypeSchema.array().default(() => ["A"]),
670
+ /**
671
+ * The registered domain (apex) this host sits in. Only needed where a
672
+ * provider cannot look it up and the guess is wrong (three-label suffixes).
673
+ */
674
+ zone: "string?",
675
+ /** Seconds; `1` means "automatic" where the provider supports it. */
676
+ ttl: "number.integer >= 1?",
677
+ /** Proxying is a property of the record, not the panel: Cloudflare only. */
678
+ proxied: "boolean = false",
679
+ enabled: "boolean = true"
680
+ }).onUndeclaredKey("reject");
681
+ /** Which public IP families to detect; a provider is only called for the ones declared. */
682
+ var ddnsIpv4Schema = type({
683
+ enabled: "boolean = true",
684
+ /** Override the public-IP endpoint; empty uses the built-in list. */
685
+ url: "string = \"\""
686
+ }).onUndeclaredKey("reject");
687
+ var ddnsIpv6Schema = type({
688
+ enabled: "boolean = false",
689
+ url: "string = \"\""
690
+ }).onUndeclaredKey("reject");
691
+ /**
692
+ * Dynamic DNS: keep a list of hostnames pointed at this machine's public IP.
693
+ * Probing is cheap and constant; a provider is only called when the address it
694
+ * last confirmed differs, which is what keeps simple endpoints (FreeDNS, No-IP)
695
+ * inside their rate limits.
696
+ */
697
+ var ddnsConfigSchema = type({
698
+ enabled: "boolean = false",
699
+ /** How often the public address is re-checked. */
700
+ intervalMs: "number >= 60000 = 300000",
701
+ ipv4: ddnsIpv4Schema.default(() => ({})),
702
+ ipv6: ddnsIpv6Schema.default(() => ({})),
703
+ /** Default TTL for the records that accept one. */
704
+ ttl: "number.integer >= 1 = 1",
705
+ accounts: ddnsAccountSchema.array().default(() => []),
706
+ domains: ddnsDomainSchema.array().default(() => [])
707
+ }).onUndeclaredKey("reject");
708
+ var ddnsRecordStateSchema = type("\"pending\" | \"ok\" | \"unchanged\" | \"error\" | \"skipped\"");
709
+ /** What happened to one hostname on the last pass. */
710
+ var ddnsRecordViewSchema = type({
711
+ "host": "string",
712
+ "account": "string",
713
+ "provider": "string",
714
+ "type": ddnsRecordTypeSchema,
715
+ "ip": "string | null",
716
+ "state": ddnsRecordStateSchema,
717
+ "message": "string | null",
718
+ "updatedAt": "number | null",
719
+ /** The provider refused permanently; no retry until the hostname, account or credentials change, or a check. */
720
+ "stopped?": "boolean"
721
+ });
722
+ /** Live DDNS state, as the state frame and the settings page read it. */
723
+ var ddnsStatusSchema = type({
724
+ enabled: "boolean",
725
+ running: "boolean",
726
+ lastRunAt: "number | null",
727
+ lastResult: "string | null",
728
+ ipv4: "string | null",
729
+ ipv6: "string | null",
730
+ records: ddnsRecordViewSchema.array()
731
+ });
732
+ /** What a provider needs from the person configuring it. */
733
+ var ddnsProviderFieldSchema = type({
734
+ key: "string",
735
+ label: "string",
736
+ hint: "string = \"\"",
737
+ optional: "boolean = false"
738
+ });
739
+ /** Provider capabilities, so the UI knows which options to show. */
740
+ var ddnsProviderInfoSchema = type({
741
+ id: "string",
742
+ label: "string",
743
+ docsUrl: "string",
744
+ families: ddnsRecordTypeSchema.array(),
745
+ fields: ddnsProviderFieldSchema.array(),
746
+ ttl: "boolean",
747
+ proxied: "boolean",
748
+ /** These credentials can also answer an ACME DNS-01 challenge (a TXT record). */
749
+ txt: "boolean"
750
+ });
751
+ /** `GET /api/ddns`: the policy, the live state, and the providers this build knows. */
752
+ var ddnsViewSchema = type({
753
+ config: ddnsConfigSchema,
754
+ status: ddnsStatusSchema,
755
+ providers: ddnsProviderInfoSchema.array(),
756
+ /** Account ids whose credentials are stored. */
757
+ credentials: type("string[]")
758
+ }).onDeepUndeclaredKey("ignore");
759
+ /**
760
+ * `PUT /api/ddns/credentials/:id`: the secret fields that provider declares.
761
+ *
762
+ * The provider travels with the request because the account may still be an
763
+ * unsaved draft — the server needs its field list, not a config entry.
764
+ */
765
+ var ddnsCredentialsSchema = type({
766
+ provider: "string >= 1",
767
+ credentials: type("Record<string, string>")
768
+ }).onUndeclaredKey("reject");
769
+ type({
770
+ enabled: "boolean?",
771
+ intervalMs: "number >= 60000?",
772
+ ipv4: type({
773
+ enabled: "boolean?",
774
+ url: "string?"
775
+ }).onUndeclaredKey("reject").optional(),
776
+ ipv6: type({
777
+ enabled: "boolean?",
778
+ url: "string?"
779
+ }).onUndeclaredKey("reject").optional(),
780
+ ttl: "number.integer >= 1?",
781
+ accounts: ddnsAccountSchema.array().optional(),
782
+ domains: ddnsDomainSchema.array().optional()
783
+ }).onUndeclaredKey("reject");
784
+ /** Tar archives of config, secrets, TLS and declared data paths. */
785
+ /**
786
+ * What an automatic backup captures, in the vocabulary the manual dialog and the CLI already use.
787
+ *
788
+ * `only` is `--include`, `except` is `--all --exclude`, and both name the same ids: a coarse id
789
+ * (`workspace:default`) covers every leaf under it. Omitted means the full default scope, which is
790
+ * what a schedule written before this field existed must keep meaning.
791
+ *
792
+ * An empty `ids` is refused rather than read as either "nothing" or "everything": those are the two
793
+ * readings a person cannot tell apart from the file, and one of them captures nothing at all.
794
+ */
795
+ var backupScopeSchema = type({
796
+ mode: "\"only\" | \"except\"",
797
+ ids: type("string >= 1").array().atLeastLength(1)
798
+ }).onUndeclaredKey("reject");
799
+ /** The scheduled half: an interval, a retention of its own, and what it captures. */
800
+ var backupScheduleSchema = type({
801
+ /** 0 turns the schedule off; otherwise the gap between automatic archives. */
802
+ intervalMs: "number.integer >= 0 = 0",
803
+ /** How many automatic archives to keep. Manual ones are never pruned by it. */
804
+ keep: "number.integer >= 1 = 7",
805
+ /**
806
+ * Absent means the whole default scope — every workspace and `includePaths`. Deliberately not
807
+ * defaulted to an explicit value: a reader cannot tell an untouched file from one that chose
808
+ * "everything", and a default here would rewrite every existing schedule on its first save.
809
+ */
810
+ scope: backupScopeSchema.optional()
811
+ }).onUndeclaredKey("reject");
812
+ var backupsSchema = type({
813
+ enabled: "boolean = true",
814
+ dir: "string = \".backups\"",
815
+ /** How many archives to keep in total, newest first. */
816
+ keep: "number.integer >= 1 = 5",
817
+ /** Extra paths in every backup, in addition to each server's `backupPaths`. */
818
+ includePaths: type("string[]").default(() => []),
819
+ schedule: backupScheduleSchema.default(() => ({}))
820
+ }).onUndeclaredKey("reject");
821
+ var allowedHostsSchema = type(/^(?:\*\.)?[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i).array().atMostLength(64);
822
+ var controlSchema = type({
823
+ /** What the panel calls itself; the stock UI shows it in the sidebar. */
824
+ label: "1 <= string <= 60 = \"home-hosted\"",
825
+ port: "1 <= number.integer <= 65535 = 3999",
826
+ /** Where the control panel itself listens; keep it `local` unless you mean it. */
827
+ host: bindSchema.default(() => "local"),
828
+ openBrowser: "boolean = false",
829
+ /**
830
+ * Public hostnames the panel answers to, besides IPs, local names and its own proxy routes —
831
+ * a name an external reverse proxy or tunnel forwards. `*.example.com` matches subdomains.
832
+ */
833
+ allowedHosts: allowedHostsSchema.default(() => []),
834
+ auth: authSchema.default(() => ({})),
835
+ tls: tlsSchema.default(() => ({}))
836
+ }).onUndeclaredKey("reject");
837
+ /** Applied to every server entry; whatever an entry sets wins. */
838
+ var defaultsSchema = type({
839
+ enabled: "boolean = true",
840
+ autostart: "boolean = false",
841
+ bind: bindSchema.default(() => "local"),
842
+ onPortConflict: onPortConflictDefaultSchema,
843
+ restart: restartSchema.default(() => ({})),
844
+ health: healthSchema.default(() => ({})),
845
+ stop: stopSchema.default(() => ({})),
846
+ logBufferLines: logBufferLinesSchema.default(() => 500)
847
+ }).onUndeclaredKey("reject");
848
+ var restartPatchSchema = type({
849
+ enabled: "boolean?",
850
+ maxRetries: "number.integer >= 0?",
851
+ baseDelayMs: "number >= 0?",
852
+ factor: "number >= 1?",
853
+ maxDelayMs: "number >= 0?",
854
+ resetAfterMs: "number >= 0?"
855
+ }).onUndeclaredKey("reject");
856
+ var httpCheckPatchSchema = type({
857
+ scheme: "\"http\" | \"https\"?",
858
+ allowInvalidCert: "boolean?",
859
+ path: "string?",
860
+ method: "\"GET\" | \"HEAD\"?",
861
+ expectStatus: "number.integer | null?",
862
+ expectStatusBelow: "number.integer?",
863
+ expectBody: "string?"
864
+ }).onUndeclaredKey("reject");
865
+ var resourcesPatchSchema = type({ maxRssBytes: "number.integer >= 0?" }).onUndeclaredKey("reject");
866
+ var healthPatchSchema = type({
867
+ enabled: "boolean?",
868
+ mode: "\"port\" | \"http\"?",
869
+ http: httpCheckPatchSchema.optional(),
870
+ intervalMs: "number >= 500?",
871
+ timeoutMs: "number >= 100?",
872
+ unhealthyThreshold: "number.integer >= 1?",
873
+ forceRestartAfterMs: "number >= 0?",
874
+ startTimeoutMs: "number >= 0?"
875
+ }).onUndeclaredKey("reject");
876
+ var stopPatchSchema = type({
877
+ signal: "\"SIGTERM\" | \"SIGINT\" | \"SIGKILL\"?",
878
+ killGroup: "boolean?",
879
+ graceMs: "number >= 0?",
880
+ killPortHolders: "boolean?"
881
+ }).onUndeclaredKey("reject");
882
+ var authPatchSchema = type({
883
+ enabled: "boolean?",
884
+ sessionTtlMs: "number >= 60000?",
885
+ cookieSecure: "\"auto\" | \"always\" | \"never\"?",
886
+ trustProxy: "boolean | \"loopback\"?",
887
+ maxLoginAttempts: "number.integer >= 1?",
888
+ lockoutMs: "number >= 1000?"
889
+ }).onUndeclaredKey("reject");
890
+ var notificationPolicyPatchShape = {
891
+ onCrash: "boolean?",
892
+ onUnhealthy: "boolean?",
893
+ onForcedRestart: "boolean?",
894
+ onRecovered: "boolean?",
895
+ onHost: "boolean?",
896
+ onDdns: "boolean?",
897
+ cooldownMs: "number >= 0?"
898
+ };
899
+ /**
900
+ * The patch shape for one destination.
901
+ *
902
+ * `kind` is required: a patch cannot change a destination's kind (that would silently drop its
903
+ * credential), so it names the kind it is addressing. The list is **replaced**, not merged — a merge
904
+ * cannot express removing a destination, the same reason `ddns.accounts` is replaced.
905
+ */
906
+ var destinationPatchSchema = type({
907
+ kind: "\"telegram\" | \"webhook\"",
908
+ id: "/^[a-z0-9][a-z0-9_-]*$/",
909
+ enabled: "boolean?",
910
+ useOwnSettings: "boolean?",
911
+ /** Telegram only. */
912
+ chatId: "string?",
913
+ /** Webhook only. */
914
+ url: "string?",
915
+ method: "\"POST\" | \"PUT\"?",
916
+ format: "\"json\" | \"text\"?",
917
+ headers: "string?",
918
+ ...notificationPolicyPatchShape
919
+ }).onUndeclaredKey("reject");
920
+ var notificationsPatchSchema = type({
921
+ /** Merged key by key, like the other nested groups. */
922
+ /**
923
+ * A merge key-by-key, and **every field optional** — `notificationPolicyPatchShape`, not a
924
+ * `.partial()` of the defaults schema.
925
+ *
926
+ * ArkType's `.partial()` leaves a field's `= false` / `= 120000` default in place, so a body of
927
+ * `{ onHost: false }` validated into all seven keys and one toggle overwrote the rest. A patch
928
+ * schema here carries no defaults (the rule for every patch), and the store merges it over the
929
+ * stored block.
930
+ */
931
+ defaults: type({ ...notificationPolicyPatchShape }).onUndeclaredKey("reject").optional(),
932
+ /** Replaced whole, so a removed destination stays removed. */
933
+ destinations: destinationPatchSchema.array().optional()
934
+ }).onUndeclaredKey("reject");
935
+ var hostPatchSchema = type({
936
+ enabled: "boolean?",
937
+ intervalMs: "number >= 5000?",
938
+ diskPaths: type("string[]").optional(),
939
+ diskUsedPercent: "number >= 0?",
940
+ memoryUsedPercent: "number >= 0?",
941
+ swapUsedPercent: "number >= 0?",
942
+ loadPerCpu: "number >= 0?",
943
+ tempCelsius: "number >= 0?",
944
+ tempCommand: "string <= 512?",
945
+ tempCommandTimeoutMs: "100 <= number <= 30000?"
946
+ }).onUndeclaredKey("reject");
947
+ var backupSchedulePatchSchema = type({
948
+ intervalMs: "number.integer >= 0?",
949
+ keep: "number.integer >= 1?",
950
+ /**
951
+ * No defaults, like every patch: `null` clears it back to the full default scope, which is the
952
+ * only way to spell "forget the choice I made" — an omitted key means "leave it as it is".
953
+ */
954
+ scope: backupScopeSchema.or(type("null")).optional()
955
+ }).onUndeclaredKey("reject");
956
+ var backupsPatchSchema = type({
957
+ enabled: "boolean?",
958
+ dir: "string?",
959
+ keep: "number.integer >= 1?",
960
+ includePaths: type("string[]").optional(),
961
+ schedule: backupSchedulePatchSchema.optional()
962
+ }).onUndeclaredKey("reject");
963
+ var logsPatchSchema = type({
964
+ persist: "boolean?",
965
+ maxBytes: "10000 <= number <= 100000000?",
966
+ keep: "1 <= number.integer <= 10?"
967
+ }).onUndeclaredKey("reject");
968
+ var tlsPatchSchema = type({ enabled: "boolean?" }).onUndeclaredKey("reject");
969
+ var controlPatchSchema = type({
970
+ label: "1 <= string <= 60 | null?",
971
+ port: "1 <= number.integer <= 65535?",
972
+ host: bindSchema.optional(),
973
+ openBrowser: "boolean?",
974
+ allowedHosts: allowedHostsSchema.optional(),
975
+ auth: authPatchSchema.optional(),
976
+ tls: tlsPatchSchema.optional()
977
+ }).onUndeclaredKey("reject");
978
+ var defaultsPatchSchema = type({
979
+ enabled: "boolean?",
980
+ autostart: "boolean?",
981
+ bind: bindSchema.optional(),
982
+ onPortConflict: onPortConflictSchema.optional(),
983
+ restart: restartPatchSchema.optional(),
984
+ health: healthPatchSchema.optional(),
985
+ stop: stopPatchSchema.optional(),
986
+ logBufferLines: logBufferLinesSchema.optional()
987
+ }).onUndeclaredKey("reject");
988
+ var editableFields = {
989
+ /**
990
+ * `null` clears it, the same spelling `serverSchema` accepts and every display's `label ?? id`
991
+ * fallback needs — an empty string satisfies neither. `serverPatchSchema` is what the editor
992
+ * validates its payload against and what `PATCH /api/servers/:id` checks, so without this a
993
+ * cleared Label was refused with "label must be a string (was null)" and could not be saved at all
994
+ * (`1f58a5d` fixed `applyPatch` and the *control* patch schema, and cited that one in its message).
995
+ */
996
+ label: labelOrNullSchema.optional(),
997
+ enabled: "boolean?",
998
+ autostart: "boolean?",
999
+ persistent: "boolean?",
1000
+ command: "string?",
1001
+ args: "string[]?",
1002
+ cwd: "string?",
1003
+ env: "Record<string, string>?",
1004
+ dataEnvs: "Record<string, string>?",
1005
+ bootstrap: bootstrapPatchOrNullSchema.optional(),
1006
+ dump: backupHookPatchOrNullSchema.optional(),
1007
+ load: backupHookPatchOrNullSchema.optional(),
1008
+ port: portSchema.optional(),
1009
+ bind: bindSchema.optional(),
1010
+ onPortConflict: onPortConflictSchema.optional(),
1011
+ restart: restartPatchSchema.optional(),
1012
+ health: healthPatchSchema.optional(),
1013
+ stop: stopPatchSchema.optional(),
1014
+ logBufferLines: logBufferLinesSchema.optional(),
1015
+ dependsOn: type("string[]").optional(),
1016
+ envFile: "string?",
1017
+ resources: resourcesPatchSchema.optional(),
1018
+ backupPaths: type("string[]").optional(),
1019
+ backupIgnoreGenerated: "boolean?"
1020
+ };
1021
+ var serverPatchSchema = type(editableFields).onUndeclaredKey("reject");
1022
+ var serverCreateSchema = type({
1023
+ id: "/^[a-z0-9][a-z0-9_-]*$/",
1024
+ ...editableFields,
1025
+ command: "string"
1026
+ }).onUndeclaredKey("reject");
1027
+ /**
1028
+ * What the panel hands a persistent entry's nanny, written 0600 and unlinked by the
1029
+ * nanny as it reads it. Everything is already resolved and expanded, because
1030
+ * `Supervisor.resolveSpawn()` must stay the only resolver.
1031
+ */
1032
+ var nannySpecSchema = type({
1033
+ serverId: "string",
1034
+ command: "string",
1035
+ args: "string[]",
1036
+ cwd: "string",
1037
+ env: "Record<string, string>",
1038
+ /** Directory of the JSONL the nanny writes; `<dir>/<id>.log`, exactly as the panel names it. */
1039
+ logDir: "string",
1040
+ /** The same retention the panel applies, so the nanny rotates identically. */
1041
+ logs: logsSchema,
1042
+ /** How the nanny stops the child it owns. */
1043
+ stop: stopSchema
1044
+ }).onUndeclaredKey("reject");
1045
+ /** How the child of a nanny ended, recorded for a panel that may not have been there. */
1046
+ var nannyExitSchema = type({
1047
+ code: "number | null",
1048
+ signal: "string | null",
1049
+ at: "number",
1050
+ runtimeMs: "number"
1051
+ }).onUndeclaredKey("reject");
1052
+ /**
1053
+ * A persistent entry's process state, written by its nanny (heartbeat included) and
1054
+ * read by the panel to re-adopt a survivor and to learn how a child it never saw
1055
+ * exit actually ended.
1056
+ */
1057
+ var nannyStateSchema = type({
1058
+ "serverId": "string",
1059
+ "nannyPid": "number",
1060
+ "childPid": "number | null",
1061
+ "startedAt": "number",
1062
+ "logFile": "string",
1063
+ "heartbeatAt": "number",
1064
+ "lastExit?": nannyExitSchema
1065
+ }).onUndeclaredKey("reject");
1066
+ /**
1067
+ * The part of an entry's supervision the panel must remember across its own restarts.
1068
+ *
1069
+ * In memory alone, a crash loop was handed a fresh `maxRetries` by every panel start
1070
+ * (`restarts` counted "since the control plane started"), and a `runOnce` bootstrap
1071
+ * re-ran for the same reason. Both are decisions whose whole point is to outlast the
1072
+ * process that made them.
1073
+ */
1074
+ var entryStateSchema = type({
1075
+ /** Attempts spent on the current crash sequence; reset once the process stays up. */
1076
+ "restarts": "number.integer >= 0",
1077
+ /**
1078
+ * Force restarts spent on the current unhealthy sequence.
1079
+ *
1080
+ * Separate from `restarts` because the two are different failures — a process that keeps dying
1081
+ * and a process that stays up but cannot serve. Persisted for the same reason the crash counter
1082
+ * is: a budget that lives only in memory is handed back fresh by every panel restart, so a
1083
+ * health-storm that is restarted often enough never exhausts it.
1084
+ */
1085
+ "healthRestarts?": "number.integer >= 0",
1086
+ /** The `runOnce` bootstrap already ran for this entry. */
1087
+ "bootstrapDone": "boolean",
1088
+ /**
1089
+ * A restored dump this entry still has to load, and where it is.
1090
+ *
1091
+ * The restore cannot run the load hook itself: `mongorestore` needs a server that is answering, and
1092
+ * the entry is stopped at that moment. So the restore stages the dump and records it here, and the
1093
+ * next `start` runs the hook once the process is up. Persisted, because a restore followed by a
1094
+ * panel restart must not lose the load.
1095
+ */
1096
+ "pendingLoad?": "string | null",
1097
+ /**
1098
+ * The last child this panel spawned for a non-persistent entry. A detached child
1099
+ * outlives the panel, so this is the only way a later boot recognizes its own
1100
+ * survivor instead of spawning a second copy beside it.
1101
+ */
1102
+ "lastPid?": "number | null",
1103
+ "lastStartedAt?": "number | null"
1104
+ });
1105
+ /** Edits to the panel-wide settings: listener, auth, TLS policy, host vitals, backups. */
1106
+ var settingsPatchSchema = type({
1107
+ control: controlPatchSchema.optional(),
1108
+ host: hostPatchSchema.optional(),
1109
+ backups: backupsPatchSchema.optional()
1110
+ }).onUndeclaredKey("reject");
1111
+ /** Edits to one workspace's settings: server defaults, log retention, notifications. */
1112
+ var workspaceSettingsPatchSchema = type({
1113
+ defaults: defaultsPatchSchema.optional(),
1114
+ logs: logsPatchSchema.optional(),
1115
+ notifications: notificationsPatchSchema.optional()
1116
+ }).onUndeclaredKey("reject");
1117
+ var authStatusSchema = type({
1118
+ enabled: "boolean",
1119
+ passwordSet: "boolean",
1120
+ passwordUpdatedAt: "number | null",
1121
+ /**
1122
+ * An API token is set; it is shown here as a flag, never as a value. Optional so
1123
+ * a freshly built UI still parses the state of a panel process that predates it:
1124
+ * an upgrade replaces `uis/stock/dist` on disk while the old process keeps
1125
+ * serving, and a missing key must not blank the whole app.
1126
+ */
1127
+ apiTokenSet: "boolean?",
1128
+ /** Still the boot-time default; the login page says so and exposure stays blocked. */
1129
+ usingDefaultPassword: "boolean",
1130
+ /** The panel currently listens beyond loopback. */
1131
+ exposed: "boolean",
1132
+ /** Non-null when that exposure is not backed by a password. */
1133
+ blockedReason: "string | null",
1134
+ sessionTtlMs: "number",
1135
+ cookieSecure: "string",
1136
+ trustProxy: "boolean | \"loopback\"",
1137
+ maxLoginAttempts: "number",
1138
+ lockoutMs: "number"
1139
+ });
1140
+ var tlsStatusSchema = type({
1141
+ enabled: "boolean",
1142
+ certPresent: "boolean",
1143
+ subject: "string | null",
1144
+ issuer: "string | null",
1145
+ validFrom: "string | null",
1146
+ validTo: "string | null",
1147
+ daysRemaining: "number | null",
1148
+ fingerprint: "string | null",
1149
+ keyMatches: "boolean | null",
1150
+ error: "string | null"
1151
+ });
1152
+ /**
1153
+ * The reverse-proxy engine this panel can drive. One engine ships today; the
1154
+ * field exists so a config written now keeps working if a second one lands.
1155
+ */
1156
+ var proxyEngineSchema = type.enumerated("caddy");
1157
+ /** What a route forwards to: a supervised entry, the panel itself, or a literal upstream. */
1158
+ var proxyTargetSchema = type.enumerated("server", "panel", "external");
1159
+ /** `auto` lets the engine decide: a public name gets ACME, a local one its own CA. */
1160
+ var proxyTlsModeSchema = type.enumerated("auto", "off", "manual");
1161
+ /**
1162
+ * One public hostname, and where it goes. A route is panel-wide on purpose — the
1163
+ * point is one domain per service across every workspace — so a target that
1164
+ * names an entry names its workspace too.
1165
+ */
1166
+ var proxyRouteSchema = type({
1167
+ id: "/^[a-z0-9][a-z0-9_-]*$/",
1168
+ /** The public hostname this route answers for. */
1169
+ host: "/^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/",
1170
+ enabled: "boolean = true",
1171
+ target: proxyTargetSchema.default(() => "server"),
1172
+ /** `target: "server"` — an id is only unique inside its workspace. */
1173
+ workspace: "string = \"\"",
1174
+ server: "string = \"\"",
1175
+ /** `target: "external"` — a literal upstream such as `http://10.0.0.5:8080`. */
1176
+ url: "string = \"\"",
1177
+ /** Optional path prefix; empty serves the whole host. */
1178
+ path: "string = \"\"",
1179
+ tls: proxyTlsModeSchema.default(() => "auto"),
1180
+ /**
1181
+ * Which DNS account answers a DNS-01 challenge for this hostname, as
1182
+ * `<workspace>/<account>` — the account belongs to a workspace, so the proxy
1183
+ * references it rather than owning it. Empty picks the workspace's only
1184
+ * account that can write TXT records.
1185
+ */
1186
+ dnsAccount: "string = \"\""
1187
+ }).onUndeclaredKey("reject");
1188
+ /**
1189
+ * One uploaded PEM pair. The pair itself lives on disk (0600) beside the panel's
1190
+ * own; this is the entry that names it, so a route can be checked against it.
1191
+ */
1192
+ var proxyCertificateSchema = type({
1193
+ id: "/^[a-z0-9][a-z0-9_-]*$/",
1194
+ label: "string = \"\""
1195
+ }).onUndeclaredKey("reject");
1196
+ /**
1197
+ * What a route's certificate situation is, for the page to show. `fallback` is a
1198
+ * public name the CA would not issue for, so the engine is serving its own CA.
1199
+ */
1200
+ var proxyCertificateStateSchema = type.enumerated("off", "local", "uploaded", "issued", "pending", "failed", "fallback");
1201
+ /**
1202
+ * DNS-01, answered by the panel instead of the engine.
1203
+ *
1204
+ * The engine never holds DNS credentials: it asks the panel over the ACMEProxy
1205
+ * protocol, and the panel writes the challenge record through the workspace
1206
+ * account a route names. `resolvers` overrides the nameservers Caddy uses to see
1207
+ * the record, which is what split-horizon DNS needs.
1208
+ */
1209
+ var proxyDns01Schema = type({
1210
+ /** Off means the engine uses HTTP-01/TLS-ALPN-01, exactly as before. */
1211
+ enabled: "boolean = false",
1212
+ /** Nameservers Caddy checks the TXT record against; empty uses its own defaults. */
1213
+ resolvers: type("string[]").default(() => [])
1214
+ }).onUndeclaredKey("reject");
1215
+ /** Reverse proxy: expose the stack through one engine, with automatic HTTPS. */
1216
+ var proxyConfigSchema = type({
1217
+ enabled: "boolean = false",
1218
+ engine: proxyEngineSchema.default(() => "caddy"),
1219
+ /** Cleartext side: ACME HTTP-01 challenges and the redirect to HTTPS. */
1220
+ httpPort: "1 <= number.integer <= 65535 = 80",
1221
+ httpsPort: "1 <= number.integer <= 65535 = 443",
1222
+ /** ACME account address; a public certificate needs one. */
1223
+ email: "string = \"\"",
1224
+ /** The ACME staging endpoint: untrusted certificates, no rate-limit burn. */
1225
+ staging: "boolean = false",
1226
+ dns01: proxyDns01Schema.default(() => ({})),
1227
+ /** PEM pairs a route with `tls: "manual"` may serve; the engine picks by SNI. */
1228
+ certificates: proxyCertificateSchema.array().default(() => []),
1229
+ routes: proxyRouteSchema.array().default(() => [])
1230
+ }).onUndeclaredKey("reject");
1231
+ /** Where the binary came from: the release we downloaded, or a path a person set. */
1232
+ var proxyEngineSourceSchema = type.enumerated("downloaded", "custom");
1233
+ /** What the panel knows about the installed engine. */
1234
+ var proxyEngineStatusSchema = type({
1235
+ id: proxyEngineSchema,
1236
+ installed: "boolean",
1237
+ /** The version the binary reports; `null` until it has been probed. */
1238
+ version: "string | null",
1239
+ source: proxyEngineSourceSchema.or(type("null")),
1240
+ path: "string | null",
1241
+ bytes: "number | null",
1242
+ error: "string | null"
1243
+ });
1244
+ /** Engine capabilities, so the page knows which options to offer. */
1245
+ var proxyEngineInfoSchema = type({
1246
+ id: proxyEngineSchema,
1247
+ label: "string",
1248
+ docsUrl: "string",
1249
+ releaseUrl: "string",
1250
+ acme: "boolean",
1251
+ internalCa: "boolean",
1252
+ dns01: "boolean",
1253
+ tcp: "boolean"
1254
+ });
1255
+ var proxyRouteStatusSchema = type.enumerated("ok", "disabled", "no-upstream", "error");
1256
+ /** A route as the page reads it: the config, plus the upstream resolved live. */
1257
+ var proxyRouteViewSchema = type({
1258
+ "route": proxyRouteSchema,
1259
+ "status": proxyRouteStatusSchema,
1260
+ "upstream": "string | null",
1261
+ "message": "string | null",
1262
+ /** Where this hostname's certificate stands. Optional: an older panel omits it. */
1263
+ "certificate?": type({
1264
+ "state": proxyCertificateStateSchema,
1265
+ "message": "string | null",
1266
+ /**
1267
+ * For `fallback`: minutes until the engine tries the CA again by itself, read
1268
+ * from the certificate it fell back to. Optional, so an older client ignores it.
1269
+ */
1270
+ "retryInMinutes?": "number"
1271
+ })
1272
+ }).onDeepUndeclaredKey("ignore");
1273
+ var proxyRunStateSchema = type.enumerated("off", "stopped", "starting", "running", "error", "unsupported");
1274
+ /** Live engine state. */
1275
+ var proxyStatusSchema = type({
1276
+ state: proxyRunStateSchema,
1277
+ pid: "number | null",
1278
+ /** The addresses the engine serves on, for the page to show. */
1279
+ urls: type("string[]"),
1280
+ /** Days until the soonest publicly-issued certificate expires; `null` when none. */
1281
+ certExpiryDays: "number | null",
1282
+ since: "number | null",
1283
+ lastError: "string | null"
1284
+ });
1285
+ /** One uploaded pair, described: what it is for, and whether it is usable. */
1286
+ var proxyCertificateViewSchema = type({
1287
+ id: "string",
1288
+ label: "string",
1289
+ /** Both halves are on disk. */
1290
+ present: "boolean",
1291
+ /** The engine would serve this pair for at least one manual route. */
1292
+ used: "boolean",
1293
+ subject: "string | null",
1294
+ issuer: "string | null",
1295
+ validTo: "string | null",
1296
+ daysRemaining: "number | null",
1297
+ /** Hostnames the pair covers, read from its SANs. */
1298
+ hosts: type("string[]"),
1299
+ error: "string | null"
1300
+ });
1301
+ /**
1302
+ * A DNS account the route table may name, flattened across workspaces so the proxy
1303
+ * page can offer one list. The account itself stays in its workspace.
1304
+ */
1305
+ var proxyDnsAccountViewSchema = type({
1306
+ workspace: "string",
1307
+ account: "string",
1308
+ provider: "string",
1309
+ label: "string",
1310
+ /** The credentials can write a TXT record, so this account can answer a challenge. */
1311
+ writesTxt: "boolean",
1312
+ /** Credentials are stored; an account without them cannot answer yet. */
1313
+ hasCredentials: "boolean"
1314
+ });
1315
+ /** `GET /api/proxy`: the policy, the engine, the live state and the resolved routes. */
1316
+ var proxyViewSchema = type({
1317
+ "config": proxyConfigSchema,
1318
+ "engine": proxyEngineStatusSchema,
1319
+ "engines": proxyEngineInfoSchema.array(),
1320
+ "status": proxyStatusSchema,
1321
+ "routes": proxyRouteViewSchema.array(),
1322
+ /** Every uploaded pair, with what it covers and when it expires. */
1323
+ "certificates": proxyCertificateViewSchema.array(),
1324
+ /** Every DNS account a route may name. Optional: an older panel omits it. */
1325
+ "dnsAccounts?": proxyDnsAccountViewSchema.array()
1326
+ }).onDeepUndeclaredKey("ignore");
1327
+ /**
1328
+ * A route as a patch sends it: every field optional, so a client may change one
1329
+ * member of a route — or add a route with only the two fields that matter.
1330
+ */
1331
+ var proxyRoutePatchSchema = type({
1332
+ id: "string",
1333
+ host: "string",
1334
+ enabled: "boolean?",
1335
+ target: proxyTargetSchema.optional(),
1336
+ workspace: "string?",
1337
+ server: "string?",
1338
+ url: "string?",
1339
+ path: "string?",
1340
+ tls: proxyTlsModeSchema.optional(),
1341
+ dnsAccount: "string?"
1342
+ }).onUndeclaredKey("reject");
1343
+ /**
1344
+ * The proxy block as a patch: no defaults, and `routes` is a list a patch
1345
+ * **replaces** — a key-by-key merge cannot express removing a route.
1346
+ */
1347
+ var proxyPatchSchema = type({
1348
+ enabled: "boolean?",
1349
+ engine: proxyEngineSchema.optional(),
1350
+ httpPort: "1 <= number.integer <= 65535?",
1351
+ httpsPort: "1 <= number.integer <= 65535?",
1352
+ email: "string?",
1353
+ staging: "boolean?",
1354
+ /**
1355
+ * A patch shape, not the config's: both keys are optional and merge, so a client
1356
+ * may send one without resetting the other, and an explicit `null` clears a key.
1357
+ */
1358
+ dns01: type({
1359
+ enabled: "boolean | null?",
1360
+ resolvers: "string[] | null?"
1361
+ }).onUndeclaredKey("reject").optional(),
1362
+ certificates: proxyCertificateSchema.array().optional(),
1363
+ routes: proxyRoutePatchSchema.array().optional()
1364
+ }).onUndeclaredKey("reject");
1365
+ /** `PUT /api/proxy/certificates/:id`: the pair itself, plus what to call it. */
1366
+ var proxyCertificateUploadSchema = type({
1367
+ label: "string = \"\"",
1368
+ certificate: "string >= 1",
1369
+ privateKey: "string >= 1"
1370
+ }).onUndeclaredKey("reject");
1371
+ /** `POST /api/proxy/engine`: which release to install; empty means the current one. */
1372
+ var proxyEngineInstallSchema = type({ version: "string = \"\"" }).onUndeclaredKey("reject");
1373
+ /**
1374
+ * One destination as the page reads it: the fields it owns, the policy it will use, and the outcome
1375
+ * of the last send to it.
1376
+ *
1377
+ * The policy here is the **effective** one — inherited from the general block when
1378
+ * `useOwnSettings` is false — so the page shows what will happen, not what is stored.
1379
+ */
1380
+ var destinationStatusSchema = type({
1381
+ "id": "string",
1382
+ "kind": "\"telegram\" | \"webhook\"",
1383
+ "enabled": "boolean",
1384
+ "useOwnSettings": "boolean",
1385
+ onCrash: "boolean",
1386
+ onUnhealthy: "boolean",
1387
+ onForcedRestart: "boolean",
1388
+ onRecovered: "boolean",
1389
+ /** Host vitals breaches (disk, memory, swap, load, temperature). */
1390
+ onHost: "boolean",
1391
+ /** Dynamic DNS, when this panel knows about it (optional for an older panel). */
1392
+ onDdns: "boolean?",
1393
+ cooldownMs: "number",
1394
+ /** Telegram only, null on a webhook. */
1395
+ "chatId": "string | null",
1396
+ /** Telegram only: whether a bot token is stored for this destination. */
1397
+ "tokenSet": "boolean",
1398
+ /** Webhook only, null on a Telegram destination. */
1399
+ "url": "string | null",
1400
+ "method": "\"POST\" | \"PUT\" | null",
1401
+ "format": "\"json\" | \"text\" | null",
1402
+ "headers": "string | null",
1403
+ /** Last delivery outcome, for the page. Optional: a newer panel may not have sent one yet. */
1404
+ "lastResult?": "string | null",
1405
+ "lastResultAt?": "number | null"
1406
+ });
1407
+ /**
1408
+ * The chats a bot can see, as `POST /notifications/destinations/:id/detect-chats` answers them.
1409
+ *
1410
+ * This was declared inline in the route while `TelegramChat` in `providers/telegram.ts` described the
1411
+ * same two fields — one shape written twice, which is the drift this file exists to prevent.
1412
+ */
1413
+ var telegramChatsSchema = type({ chats: type({
1414
+ id: "string | number",
1415
+ title: "string"
1416
+ }).array() });
1417
+ var notificationViewSchema = type({
1418
+ /** The general block: what a destination inherits unless it overrides it. Optional for an older panel. */
1419
+ "defaults?": notificationDefaultsViewSchema,
1420
+ /** Every destination, in config order. Optional for an older panel. */
1421
+ "destinations?": destinationStatusSchema.array()
1422
+ });
1423
+ var sessionViewSchema = type({
1424
+ authenticated: "boolean",
1425
+ authRequired: "boolean",
1426
+ passwordSet: "boolean",
1427
+ /** A long-lived API token is configured; optional for the same reason as above. */
1428
+ apiTokenSet: "boolean?",
1429
+ usingDefaultPassword: "boolean",
1430
+ /** The boot-time password, exposed only while it is still in use. */
1431
+ defaultPassword: "string | null",
1432
+ sessionTtlMs: "number"
1433
+ });
1434
+ /** `POST /api/auth/token`: the new token, returned once, and the readable head the panel keeps. */
1435
+ var apiTokenCreatedSchema = type({
1436
+ token: "string",
1437
+ hint: "string"
1438
+ });
1439
+ var loginSchema = type({ password: "string <= 512" }).onUndeclaredKey("reject");
1440
+ /** Any non-empty password is allowed; only a sanity cap on the length. */
1441
+ var passwordValueSchema = type("1 <= string <= 512");
1442
+ var passwordSchema = type({
1443
+ currentPassword: "string?",
1444
+ newPassword: passwordValueSchema
1445
+ }).onUndeclaredKey("reject");
1446
+ var serverStatusSchema = type("\"stopped\" | \"starting\" | \"running\" | \"stopping\" | \"backoff\" | \"crashed\" | \"conflict\"");
1447
+ var healthStateSchema = type("\"disabled\" | \"unknown\" | \"healthy\" | \"unhealthy\"");
1448
+ var portStateSchema = type("\"unknown\" | \"free\" | \"in-use\"");
1449
+ var logStreamSchema = type("\"stdout\" | \"stderr\" | \"system\"");
1450
+ var logLineSchema = type({
1451
+ ts: "number",
1452
+ stream: logStreamSchema,
1453
+ text: "string"
1454
+ });
1455
+ /**
1456
+ * Who asked for something, so a restart can be attributed.
1457
+ *
1458
+ * `policy` is the panel acting on its own (a health-forced restart, a memory ceiling);
1459
+ * `user` is a signed-in browser; `agent` is a request carrying an API token; `boot` is
1460
+ * the autostart pass. Optional: events written before this field existed carry none.
1461
+ */
1462
+ var historyActorSchema = type.enumerated("policy", "user", "agent", "boot");
1463
+ var historyEventSchema = type({
1464
+ "serverId": "string",
1465
+ "ts": "number",
1466
+ "type": "\"start\" | \"exit\" | \"crash\" | \"forced-restart\" | \"unhealthy\" | \"recovered\"",
1467
+ "detail": "string",
1468
+ /** How long the process had been up, recorded on exit and crash. */
1469
+ "runtimeMs": "number?",
1470
+ /** Who caused it; absent on events from before this field existed. */
1471
+ "actor?": historyActorSchema
1472
+ });
1473
+ /** Rolling window stats derived from the persisted event log. */
1474
+ var serverHistorySchema = type({
1475
+ windowMs: "number",
1476
+ /** Share of the window the process was up (null when nothing is known yet). */
1477
+ uptimeRatio: "number | null",
1478
+ restarts: "number",
1479
+ crashes: "number",
1480
+ forcedRestarts: "number",
1481
+ lastCrashAt: "number | null",
1482
+ lastExitAt: "number | null",
1483
+ lastRuntimeMs: "number | null",
1484
+ events: historyEventSchema.array()
1485
+ });
1486
+ var processResourcesSchema = type({
1487
+ cpuPercent: "number | null",
1488
+ /** RSS of the process and its descendants. */
1489
+ rssBytes: "number | null",
1490
+ processes: "number",
1491
+ sampledAt: "number"
1492
+ });
1493
+ var hostDiskSchema = type({
1494
+ path: "string",
1495
+ totalBytes: "number",
1496
+ freeBytes: "number",
1497
+ usedPercent: "number"
1498
+ });
1499
+ var hostViewSchema = type({
1500
+ "enabled": "boolean",
1501
+ "cpus": "number",
1502
+ "loadAvg": type("number[]"),
1503
+ /**
1504
+ * Share of this machine's CPU capacity in use over the last sampling interval, 0–100.
1505
+ *
1506
+ * Optional: an older panel sends no such field, and a required one rejects the whole frame and
1507
+ * blanks the UI that panel is serving. `null` on the first sample, which has no window to
1508
+ * measure yet — a number there would be invented.
1509
+ */
1510
+ "cpuUsedPercent?": "number | null",
1511
+ "uptimeMs": "number",
1512
+ "memoryUsedPercent": "number",
1513
+ "swapUsedPercent": "number",
1514
+ "tempCelsius": "number | null",
1515
+ "disks": hostDiskSchema.array(),
1516
+ /** Human readable threshold breaches, for the banner and notifications. */
1517
+ "alerts": type("string[]"),
1518
+ "sampledAt": "number | null",
1519
+ /**
1520
+ * The per-cpu load this panel notifies on — `host.loadPerCpu`, the number the alert fires at.
1521
+ *
1522
+ * Optional: a panel that predates this field alerts on the default, which is what the UI's band
1523
+ * assumes when the field is absent. It travels here because the frame is the only thing a host
1524
+ * surface reads, and a surface that cannot see the threshold hardcoded `2`/`1.4` — so raising
1525
+ * the threshold in Settings left the tile painting a healthy box `danger` while the alert the
1526
+ * threshold governs stayed silent. `0` disables the alert, so nothing can breach it.
1527
+ */
1528
+ "loadAlertPerCpu?": "number",
1529
+ /**
1530
+ * The percentage alert thresholds — `host.diskUsedPercent`, `host.memoryUsedPercent`,
1531
+ * `host.swapUsedPercent` and `host.tempCelsius` — the numbers the panel notifies at.
1532
+ *
1533
+ * Optional for the same reason as `loadAlertPerCpu`, and carried for the same reason: a surface
1534
+ * that cannot see the threshold has to invent one, and the invented ones disagreed with the
1535
+ * panel's verdict. The swap bar called 50% `warn` while the alert fired there; raising
1536
+ * `host.tempCelsius` to 95 left a 90 °C box painted `danger` for a notification that never
1537
+ * arrives; and a disk threshold lowered to 80 notified at 82% while every disk bar called it
1538
+ * `warn`. `0` disables that alert, so nothing can breach it.
1539
+ */
1540
+ "memoryUsedPercentAlert?": "number",
1541
+ "swapUsedPercentAlert?": "number",
1542
+ "tempCelsiusAlert?": "number",
1543
+ /**
1544
+ * `host.diskUsedPercent`, the threshold a filesystem is banded against.
1545
+ *
1546
+ * It travels once for the frame rather than per disk: the threshold is one config value that
1547
+ * applies to every configured path, which is why `hostReadings` copies it onto each disk's `band`.
1548
+ */
1549
+ "diskUsedPercentAlert?": "number"
1550
+ });
1551
+ /**
1552
+ * The WSL2 temperature bridge, as the settings page reports it.
1553
+ *
1554
+ * A WSL2 guest cannot read a CPU temperature at all, so the panel offers to install a Windows-side
1555
+ * helper and point `host.tempCommand` at it. `supported` is false on any other platform, which is
1556
+ * how the UI hides the whole block rather than offering a button that cannot work.
1557
+ */
1558
+ var wslTemperatureSchema = type({
1559
+ /** This process runs under WSL. */
1560
+ "wsl": "boolean",
1561
+ /** The setup can work here — the same as `wsl` today, separate so a future bridge can differ. */
1562
+ "supported": "boolean",
1563
+ /** `host.tempCommand` already names a command. */
1564
+ "configured": "boolean",
1565
+ /** The helper script exists on disk. */
1566
+ "scriptWritten": "boolean",
1567
+ /** LibreHardwareMonitor was found on the Windows side. */
1568
+ "libraryPresent": "boolean",
1569
+ /** Where the helper was written, for the sentence that tells a person what to delete. */
1570
+ "scriptPath": "string | null",
1571
+ /** The command the panel would run, absent until it is configured. */
1572
+ "tempCommand?": "string | null",
1573
+ /** The last probe's reading, so the page can say "this works" without running it again. */
1574
+ "lastReadingCelsius?": "number | null",
1575
+ /** Why the last probe failed, if it did — a missing library and no sensor read differently. */
1576
+ "lastError?": "string | null",
1577
+ /**
1578
+ * The library is missing and installing it needs consent.
1579
+ *
1580
+ * The panel will not download a third-party binary on a click that did not mention one, so the
1581
+ * first press answers `needsDownload` and the page asks. Absent on an older panel.
1582
+ */
1583
+ "needsDownload?": "boolean"
1584
+ });
1585
+ var backupFileSchema = type({
1586
+ name: "string",
1587
+ sizeBytes: "number",
1588
+ createdAt: "number",
1589
+ /** The archive carries a password-protected payload. */
1590
+ encrypted: "boolean"
1591
+ });
1592
+ /**
1593
+ * One selectable entry in a backup: a global item (`global:settings`,
1594
+ * `global:secrets`, `global:tls`) or a workspace, whose `items` are the
1595
+ * sub-choices a per-workspace dialog offers.
1596
+ */
1597
+ var backupEntrySchema = type({
1598
+ /** `global:settings` | `global:secrets` | `global:tls` | `workspace:<id>`. */
1599
+ "id": "string",
1600
+ /**
1601
+ * The panel's own English wording. Kept because it is what an older UI reads, and what a
1602
+ * single-language UI wants; a translated UI prefers the `*Key` beside it.
1603
+ */
1604
+ "label": "string",
1605
+ /** A catalog key for `label`, with its placeholder values, so a UI can render its own language. */
1606
+ "labelKey?": "string",
1607
+ "labelParams?": "Record<string, string>",
1608
+ "kind": "\"settings\" | \"secrets\" | \"tls\" | \"workspace\"",
1609
+ "workspaceId?": "string",
1610
+ "note": "string | null",
1611
+ /** The same pair for `note`: the panel knows which reason it is, the UI knows the wording. */
1612
+ "noteKey?": "string",
1613
+ "noteParams?": "Record<string, string>",
1614
+ /** What this entry would capture; a workspace carries several leaves. */
1615
+ "items": type({
1616
+ "id": "string",
1617
+ "label": "string",
1618
+ "labelKey?": "string",
1619
+ "labelParams?": "Record<string, string>",
1620
+ /** `settings`/`servers`/`secrets` for a workspace, `data` for a declared path. */
1621
+ "kind": "\"settings\" | \"servers\" | \"secrets\" | \"data\"",
1622
+ /** Which secret a `secrets` leaf carries (`password`, `apiToken`, `telegram`, `ddns`, …). */
1623
+ "secret?": "string",
1624
+ "path?": "string",
1625
+ /** Who declared a data path: `global`, `<serverId>:backupPaths` or `<serverId>:<ENV>`. */
1626
+ "origin?": "string",
1627
+ "included": "boolean",
1628
+ "note": "string | null",
1629
+ "noteKey?": "string",
1630
+ "noteParams?": "Record<string, string>",
1631
+ "ignoreGenerated?": "boolean"
1632
+ }).array()
1633
+ });
1634
+ /**
1635
+ * The schedule as a *response* carries it: undeclared keys are accepted, at both levels.
1636
+ *
1637
+ * A response schema may not reject (a newer panel may add a field an older client still reads), and
1638
+ * `scope` is one level deep — so the outer `.onUndeclaredKey` on the config schema is not enough:
1639
+ * a frame carrying `schedule.scope` rejected outright while this was the config shape.
1640
+ */
1641
+ var backupScheduleViewSchema = backupScheduleSchema.onDeepUndeclaredKey("ignore");
1642
+ var backupsViewSchema = type({
1643
+ "enabled": "boolean",
1644
+ "dir": "string",
1645
+ "keep": "number",
1646
+ /**
1647
+ * The scheduled half, so the page can show and edit it.
1648
+ *
1649
+ * Optional because the panel and the UI upgrade separately: an older panel does not send it,
1650
+ * and a required field would blank the settings page for that panel. The page reads it as
1651
+ * "off, keep 7" when absent — the schema defaults — so nothing changes for it.
1652
+ */
1653
+ "schedule?": backupScheduleViewSchema,
1654
+ /** When the last automatic archive was written; null until one has run. Optional for the same reason. */
1655
+ "lastAutomaticAt?": "number | null",
1656
+ /**
1657
+ * Why the last scheduled pass failed, and when it tried.
1658
+ *
1659
+ * A failed pass wrote only a panel-console warning, so "enabled, zero archives" looked the same
1660
+ * as "failing every interval since the day it was enabled" — indistinguishable from the page,
1661
+ * which is the only place a person looks. Null once a pass succeeds.
1662
+ */
1663
+ "scheduleError?": type({
1664
+ message: "string",
1665
+ at: "number"
1666
+ }),
1667
+ /** Extra paths from the global config, in addition to each server's own. */
1668
+ "includePaths": type("string[]"),
1669
+ /**
1670
+ * The selection model, carried here only by a panel older than this release.
1671
+ *
1672
+ * Reading it costs a `readFileSync` of the global and every workspace's `.secrets.json` plus a
1673
+ * `statSync` per archive, and the state frame is rebuilt ~13×/s — so it moved to
1674
+ * `GET /api/backups` (`backupSelectionSchema`), which a dialog fetches when it opens. Optional on
1675
+ * purpose: a newer UI reads a panel that still sends it, and a UI must never reject a payload for
1676
+ * a field it does not use. Absent means "ask the endpoint".
1677
+ */
1678
+ "entries?": backupEntrySchema.array(),
1679
+ "files?": backupFileSchema.array()
1680
+ });
1681
+ /**
1682
+ * The backup *selection model*: what a capture could include, and what is already on disk.
1683
+ *
1684
+ * Its own route rather than a field of the state frame, because building it reads every workspace's
1685
+ * secrets file and stats every archive — work proportional to workspaces × archives, on a path that
1686
+ * runs per frame. A dialog needs it when it opens and not otherwise.
1687
+ */
1688
+ var backupSelectionSchema = type({
1689
+ /** The archive directory, so a dialog can print the path without a second read. */
1690
+ dir: "string",
1691
+ /** Every selectable entry, global first, then each workspace. */
1692
+ entries: backupEntrySchema.array(),
1693
+ files: backupFileSchema.array()
1694
+ });
1695
+ /** One restorable slice of an archive: a global item, a workspace item, or a data path. */
1696
+ var restoreItemSchema = type({
1697
+ /** A backup entry or leaf id (`workspace:<id>:servers`, `data:<path>`, ...). */
1698
+ "id": "string",
1699
+ "label": "string",
1700
+ "labelKey?": "string",
1701
+ "labelParams?": "Record<string, string>",
1702
+ "kind": "\"settings\" | \"secrets\" | \"servers\" | \"tls\" | \"data\"",
1703
+ "workspaceId?": "string",
1704
+ /** false when the current instance does not declare it, or it is not in the archive. */
1705
+ "restorable": "boolean",
1706
+ /** Echo of the request's selection, so the checkboxes round-trip. */
1707
+ "selected": "boolean",
1708
+ "note": "string | null",
1709
+ "noteKey?": "string",
1710
+ "noteParams?": "Record<string, string>"
1711
+ });
1712
+ /**
1713
+ * Why one thing was skipped, as a reason the UI can word itself.
1714
+ *
1715
+ * `skipped` stays a list of ready-made English sentences for an older UI and for
1716
+ * `noc-console`; this is the same list in parts, so a translated UI says it in the
1717
+ * reader's language instead of showing the panel's English inside its own sentence.
1718
+ */
1719
+ var restoreSkipSchema = type({
1720
+ "label": "string",
1721
+ "labelKey?": "string",
1722
+ "labelParams?": "Record<string, string>",
1723
+ /** A catalog key for the parenthesis, e.g. `not selected`; absent when there is none. */
1724
+ "reasonKey?": "string",
1725
+ "reasonParams?": "Record<string, string>"
1726
+ });
1727
+ var restorePlanSchema = type({
1728
+ "dryRun": "boolean",
1729
+ "encrypted": "boolean",
1730
+ /** The archive needs a password (none or a wrong one was supplied). */
1731
+ "needsPassword": "boolean",
1732
+ /**
1733
+ * Where the archive says it came from. Optional: an archive written before this
1734
+ * stamp existed carries neither field, and an older panel never sends the row.
1735
+ */
1736
+ "archive?": type({
1737
+ "writtenBy?": "string",
1738
+ "schema?": "number"
1739
+ }),
1740
+ "items": restoreItemSchema.array(),
1741
+ /**
1742
+ * One row per backup hook that ran, so a person can see which entries brought their own dump.
1743
+ *
1744
+ * Optional, like every new response field: an older panel never sends it and an older UI never
1745
+ * reads it. `output` is a bounded tail, not a log — enough to see what `mongorestore` said.
1746
+ */
1747
+ "hooks?": type({
1748
+ "serverId": "string",
1749
+ "workspaceId": "string",
1750
+ "action": "\"dump\" | \"load\"",
1751
+ "ok": "boolean",
1752
+ "output?": "string"
1753
+ }).array(),
1754
+ "applied": type("string[]"),
1755
+ /**
1756
+ * The ids `applied` names, so a UI resolves each through `items` and renders its own label.
1757
+ * `applied` itself stays: it is what a UI with one language reads.
1758
+ */
1759
+ "appliedIds?": type("string[]"),
1760
+ "skipped": type("string[]"),
1761
+ "skippedItems?": restoreSkipSchema.array(),
1762
+ /** Only the panel's own listener needs a restart; its servers are re-read live. */
1763
+ "restartRequired": "boolean",
1764
+ /** The panel re-read the restored config within this same restore. */
1765
+ "reloaded": "boolean",
1766
+ /**
1767
+ * Servers that are **running now** and whose declared data path this restore overwrote.
1768
+ *
1769
+ * A data path is copied over while its owner keeps running, holding open handles to files
1770
+ * that were just replaced — the process keeps its old view and the archive's copy wins on
1771
+ * disk, so anything written since the archive was taken is gone. The plan has to say which
1772
+ * entries that happened to, because nothing else in the result mentions them.
1773
+ *
1774
+ * Optional: an older panel does not send it, and a plan that touched no running entry sends none.
1775
+ */
1776
+ "replacedUnderRunning?": type({
1777
+ workspaceId: "string",
1778
+ serverId: "string",
1779
+ path: "string"
1780
+ }).array(),
1781
+ /**
1782
+ * Workspaces this restore created because the archive named them and the host did not
1783
+ * have them. Optional: an older panel never sends the row, and an archive written
1784
+ * before the registry was captured creates none.
1785
+ */
1786
+ "createdWorkspaces?": type("string[]"),
1787
+ "error": "string?"
1788
+ });
1789
+ var backupCreateSchema = type({
1790
+ /** Optional: encrypts the archive. Never stored. */
1791
+ password: passwordValueSchema.optional(),
1792
+ /** Leaf ids to capture (`global:settings`, `workspace:<id>:servers`, `data:<path>`, ...); omitted means everything. */
1793
+ include: type("string[] >= 1").optional(),
1794
+ /**
1795
+ * Leaf ids to leave out, applied after `include` — the CLI's `--exclude`, and the one thing to
1796
+ * name when the archive should carry everything but the credentials.
1797
+ *
1798
+ * Empty is refused for the same reason `include` refuses it: an empty list reads as "nothing" to
1799
+ * a person and as "everything" to a reader, so it must not be sent at all.
1800
+ */
1801
+ exclude: type("string[] >= 1").optional()
1802
+ }).onUndeclaredKey("reject");
1803
+ var restoreRequestSchema = type({
1804
+ name: "string?",
1805
+ password: passwordValueSchema.optional(),
1806
+ /** Item ids to restore; omitted means every restorable item. */
1807
+ include: type("string[]").optional(),
1808
+ /**
1809
+ * Item ids to leave out, applied after `include` — the CLI's `--exclude` on the same command.
1810
+ *
1811
+ * `BackupService.restore()` has always taken it and the local channel has always sent it, but this
1812
+ * schema declared only `name`/`password`/`include` **and rejects undeclared keys**, so the same
1813
+ * request over `/api` answered `exclude must be removed`: a script or either UI could only say
1814
+ * "these items", never "everything except these", on the one path that overwrites a live host.
1815
+ *
1816
+ * Empty is refused for the same reason it is on a create — it reads as "nothing" to a person and
1817
+ * as "everything" to the reader, so it must not be sent at all.
1818
+ */
1819
+ exclude: type("string[] >= 1").optional()
1820
+ }).onUndeclaredKey("reject");
1821
+ /** Runtime view of a server: its effective config plus everything observed. */
1822
+ var serverViewSchema = type({
1823
+ "id": "string",
1824
+ /** The workspace that owns it; optional so an older panel's frame still parses. */
1825
+ "workspaceId?": "string",
1826
+ "config": serverSchema,
1827
+ "bindHost": "string",
1828
+ "url": "string | null",
1829
+ "status": serverStatusSchema,
1830
+ "health": healthStateSchema,
1831
+ "portState": portStateSchema,
1832
+ "pid": "number | null",
1833
+ /** True when the process serving this entry was adopted, not spawned by the panel. */
1834
+ "adopted": "boolean?",
1835
+ /**
1836
+ * The panel stopped this entry because it could not serve, rather than someone asking.
1837
+ *
1838
+ * Optional, like every new field: an older panel does not send it. `/healthz` needs it because
1839
+ * the status alone cannot tell "the operator switched this off" (never a problem) from "the
1840
+ * panel gave up on it" (a broken service) — both are `stopped`.
1841
+ */
1842
+ "stoppedByPanel?": "boolean",
1843
+ "startedAt": "number | null",
1844
+ "exitCode": "number | null",
1845
+ "exitSignal": "string | null",
1846
+ "restarts": "number",
1847
+ "maxRetries": "number",
1848
+ "lastError": "string | null",
1849
+ "nextRetryAt": "number | null",
1850
+ "unhealthySince": "number | null",
1851
+ "bufferedLines": "number",
1852
+ "history": serverHistorySchema,
1853
+ /** Last health probe latency (TCP connect or HTTP request). */
1854
+ "responseMs": "number | null",
1855
+ "resources": processResourcesSchema.or(type("null"))
1856
+ }).onDeepUndeclaredKey("ignore");
1857
+ /**
1858
+ * What `/healthz` answers, on both statuses — 200 when serving, 503 when a server has crashed,
1859
+ * which shares this response's `content` in the spec. The detail fields are optional because they are
1860
+ * only included for an authenticated caller.
1861
+ */
1862
+ var healthResponseSchema = type({
1863
+ "status": "\"ok\" | \"degraded\"",
1864
+ "uptimeMs": "number",
1865
+ "servers?": type({
1866
+ total: "number",
1867
+ running: "number",
1868
+ crashed: "number",
1869
+ unhealthy: "number"
1870
+ }),
1871
+ "hostAlerts?": "string[]"
1872
+ });
1873
+ var controlViewSchema = type({
1874
+ /** The configured panel name, for the shell to render. */
1875
+ "label": "string",
1876
+ "port": "number",
1877
+ /** The configured bind value (`local` | `lan` | ipv4). */
1878
+ "host": "string",
1879
+ /** The address actually bound. */
1880
+ "bindHost": "string",
1881
+ "url": "string",
1882
+ "openBrowser": "boolean",
1883
+ "allowedHosts?": "string[]",
1884
+ /** The live listener differs from the configured host/port. */
1885
+ "restartRequired": "boolean",
1886
+ "protocol": "string",
1887
+ "auth": authStatusSchema,
1888
+ "tls": tlsStatusSchema
1889
+ });
1890
+ /** Everything one workspace owns, plus the live state of its servers. */
1891
+ /**
1892
+ * A user-supplied UI, as the settings page shows it.
1893
+ *
1894
+ * Every field is optional, and none of them is a fallback: a `ui.json` may be written by
1895
+ * the panel (which adds `uploadedAt`/`files`) **or dropped in by hand** following
1896
+ * `docs/UI_CREATION.md`, which documents only the author-facing fields. Requiring ours
1897
+ * meant a hand-written file parsed to nothing at all, taking `repo`/`tag` with it and
1898
+ * silently disabling `ui-update` for exactly the UI that declared itself.
1899
+ */
1900
+ var uiMetaSchema = type({
1901
+ "name?": "string",
1902
+ "version?": "string | null",
1903
+ /** Set by the panel, not by the author. */
1904
+ "uploadedAt?": "number",
1905
+ /** Counted by the panel, not declared. */
1906
+ "files?": "number.integer >= 1",
1907
+ /** `owner/name` of the UI's own repository, for `ui-update`. */
1908
+ "repo?": "string",
1909
+ /** The release tag this build came from, e.g. `v0.6.0`. Stamped by the build, never committed. */
1910
+ "tag?": "string",
1911
+ /** The release asset name, e.g. `home-hosted-ui-noc-console`. */
1912
+ "asset?": "string",
1913
+ /** When the UI was built, in unix epoch seconds. Stamped by the build, never committed. */
1914
+ "unix?": "number.integer >= 0"
1915
+ });
1916
+ var uiStatusSchema = type({
1917
+ /** A user-supplied UI is being served instead of the stock one. */
1918
+ custom: "boolean",
1919
+ /** Where that UI lives, whether or not it exists yet. */
1920
+ dir: "string",
1921
+ meta: uiMetaSchema.or(type("null"))
1922
+ });
1923
+ /** One process a panel spawned that no configured entry claims any more. */
1924
+ var serverOrphanSchema = type({
1925
+ /** The id it was started as, which is also the key of the state file it was found in. */
1926
+ serverId: "string",
1927
+ pid: "number",
1928
+ /** When the panel spawned it; null when the record predates the stamp. */
1929
+ startedAt: "number | null"
1930
+ });
1931
+ var workspaceViewSchema = type({
1932
+ "id": "string",
1933
+ "label": "string",
1934
+ /** The workspace's servers config; the settings file sits beside it. */
1935
+ "configPath": "string",
1936
+ "settingsPath": "string",
1937
+ "configError": "string | null",
1938
+ /** Keys a newer release wrote that this one ignores. */
1939
+ "configWarnings?": type("string[]"),
1940
+ "logsDir": "string",
1941
+ "defaults": defaultsSchema,
1942
+ "logs": logsSchema,
1943
+ "notifications": notificationViewSchema,
1944
+ /** Dynamic DNS state. Optional so a newer UI still frames an older payload. */
1945
+ "ddns?": ddnsStatusSchema,
1946
+ "serverCount": "number",
1947
+ "runningCount": "number",
1948
+ "crashedCount": "number",
1949
+ /**
1950
+ * Processes this panel started that no current entry owns.
1951
+ *
1952
+ * A detached child outlives a hard panel death, and its handle is the entry-state file keyed by
1953
+ * the *id* it was started under. Rename the entry and nothing ever reads that file again; delete
1954
+ * the entry while the panel is down and the file is reclaimed, destroying the last handle. The
1955
+ * orphan then runs with no card, no `/healthz` line and no CLI action — for a queue consumer,
1956
+ * two consumers of the same queue. This is the view that makes it actionable.
1957
+ *
1958
+ * Optional: an older panel never sends it.
1959
+ */
1960
+ "orphans?": serverOrphanSchema.array(),
1961
+ "servers": serverViewSchema.array()
1962
+ }).onDeepUndeclaredKey("ignore");
1963
+ /**
1964
+ * The whole panel in one frame: global state plus every workspace. Workspace
1965
+ * pages read their own subtree; the global pages read across all of them.
1966
+ */
1967
+ var appStateSchema = type({
1968
+ "control": controlViewSchema,
1969
+ "host": hostViewSchema,
1970
+ "backups": backupsViewSchema,
1971
+ "ui": uiStatusSchema,
1972
+ "workspaces": workspaceViewSchema.array(),
1973
+ /** The reverse proxy, when this panel has one. Optional: an older panel does not send it. */
1974
+ "proxy?": proxyViewSchema,
1975
+ /** The directory the panel was started from; relative entry paths use it. */
1976
+ "projectDir": "string",
1977
+ /** `HHOSTED_HOME`: every file home-hosted owns lives under here. */
1978
+ "dataRoot": "string",
1979
+ /** The release this panel is running. Optional: an older panel does not send one. */
1980
+ "version?": "string"
1981
+ }).onDeepUndeclaredKey("ignore");
1982
+ /** One SSE frame, discriminated by `type`: a client narrowing on it gets the payload that frame carries. */
1983
+ var stateFrameSchema = type({
1984
+ type: "\"hello\" | \"state\"",
1985
+ ts: "number",
1986
+ state: appStateSchema
1987
+ }).onDeepUndeclaredKey("ignore");
1988
+ var serverFrameSchema = type({
1989
+ "type": "\"server\"",
1990
+ "ts": "number",
1991
+ "workspaceId?": "string",
1992
+ "serverId": "string",
1993
+ "server": serverViewSchema
1994
+ }).onDeepUndeclaredKey("ignore");
1995
+ var logFrameSchema = type({
1996
+ "type": "\"log\"",
1997
+ "ts": "number",
1998
+ "workspaceId?": "string",
1999
+ "serverId": "string",
2000
+ "lines": logLineSchema.array()
2001
+ }).onDeepUndeclaredKey("ignore");
2002
+ stateFrameSchema.or(serverFrameSchema).or(logFrameSchema);
2003
+ var logQuerySchema = type({ limit: "string?" });
2004
+ /**
2005
+ * What a per-server lifecycle action answers with.
2006
+ *
2007
+ * `ok`/`error` are what the panel returns and every UI already reads; `code` was added so a
2008
+ * script can branch without matching English, and it is **absent on success** — a code names a
2009
+ * failure.
2010
+ */
2011
+ var actionResultSchema = type({
2012
+ "ok": "boolean",
2013
+ "error?": "string",
2014
+ "message?": "string",
2015
+ "code?": "string"
2016
+ });
2017
+ /** Whether a probe (a test send, a token check) worked, and why not when it did not. */
2018
+ var deliveryResultSchema = type({
2019
+ "ok": "boolean",
2020
+ "error?": "string"
2021
+ });
2022
+ /** A password was set or changed, and what that means for the caller's session. */
2023
+ var passwordSetResponseSchema = type({
2024
+ ok: "boolean",
2025
+ enabled: "boolean",
2026
+ sessionsInvalidated: "boolean"
2027
+ });
2028
+ /**
2029
+ * What both TLS mutation routes answer: the panel's listener and the move that is in flight.
2030
+ *
2031
+ * Declared once because the two routes return the same `review()` body — the DELETE declared
2032
+ * `okResponseSchema` while returning this, so a generated client read `undefined` for every field.
2033
+ */
2034
+ var tlsReviewResponseSchema = type({
2035
+ control: controlViewSchema,
2036
+ rebinding: "boolean",
2037
+ targetUrl: "string"
2038
+ });
2039
+ /**
2040
+ * The plain acknowledgement most mutations answer with.
2041
+ *
2042
+ * Defined once because a dozen routes return it, and each was declaring its own or none at all —
2043
+ * which is why the spec had untyped `200`s where a generated client needs a shape.
2044
+ */
2045
+ var okResponseSchema = type({ ok: "boolean" });
2046
+ /** A backup was removed: the archive list it leaves behind. */
2047
+ var backupFilesResponseSchema = type({
2048
+ ok: "boolean",
2049
+ files: backupFileSchema.array()
2050
+ });
2051
+ /** A UI build was installed (it also reports the build), or reverted. */
2052
+ var uiInstallResponseSchema = type({
2053
+ "ok": "boolean",
2054
+ "meta?": uiStatusSchema.get("meta"),
2055
+ "ui": uiStatusSchema,
2056
+ /** Revert only: whether there was a custom UI to remove. */
2057
+ "removed?": "boolean"
2058
+ });
2059
+ /** A backup was created: the new archive and the list it belongs to. */
2060
+ var backupCreatedResponseSchema = type({
2061
+ file: backupFileSchema,
2062
+ files: backupFileSchema.array()
2063
+ });
2064
+ /** Buffered or persisted log lines, the shape every log-reading route returns. */
2065
+ /**
2066
+ * `GET /api/servers/:id/logs` — the **buffered** lines, straight from memory.
2067
+ *
2068
+ * It is not the disk history below: this route has no window, no rotation and no search, so it
2069
+ * answers `{ lines }` and nothing else. The schema used to be a copy of the disk shape
2070
+ * (`serverId`/`enabled`/`sizeBytes`/`files`/`searched`), so the documented response named five
2071
+ * fields the handler never sent — and `searched` was declared as an array here while the disk route
2072
+ * sends a number. `test/api/panel.test.ts` only walks routes it can reach with a live fixture and
2073
+ * skipped this one, so nothing caught it.
2074
+ */
2075
+ var bufferedLogsResponseSchema = type({ lines: logLineSchema.array() });
2076
+ /**
2077
+ * `GET /api/logs/:id` — one entry's log **from disk**, with its rotation and its search window.
2078
+ *
2079
+ * This is the shape the UIs parse (`logHistoryViewSchema` below is the same thing with its own
2080
+ * name for the client side), and it is what `logLinesResponseSchema` should always have been.
2081
+ */
2082
+ var logLinesResponseSchema = type({
2083
+ serverId: "string",
2084
+ enabled: "boolean",
2085
+ sizeBytes: "number",
2086
+ /** The rotated files this entry has, newest first. */
2087
+ files: "string[]",
2088
+ /** How many lines the search looked at, or null when the request carried no `search`. */
2089
+ searched: "number | null",
2090
+ lines: logLineSchema.array()
2091
+ });
2092
+ /**
2093
+ * One server's live resource reading, for `home-hosted usage`.
2094
+ *
2095
+ * `cpuPercent` and `rssBytes` are `number | null` because a reading can be absent — a process the
2096
+ * sampler has not seen yet, or one that just exited. Absent is **not** zero: a `0` here would read as
2097
+ * "idle" and hide a server that is not being measured at all.
2098
+ */
2099
+ var usageEntrySchema = type({
2100
+ "id": "string",
2101
+ "workspaceId": "string",
2102
+ "label": "string",
2103
+ "status": serverStatusSchema,
2104
+ /** Absent when nothing is running or the sampler has no sample yet. */
2105
+ "cpuPercent?": "number",
2106
+ "rssBytes?": "number",
2107
+ /** Processes in this entry's tree, including an adopted successor's. */
2108
+ "processes?": "number",
2109
+ "sampledAt?": "number",
2110
+ /**
2111
+ * How the entry has behaved over the panel's history window, so `usage` can answer "is this
2112
+ * restarting every few minutes" and not only "what is it using right now". Copied from the same
2113
+ * `ServerView.history` the page reads; absent when nothing is known yet.
2114
+ */
2115
+ "restarts?": "number",
2116
+ "crashes?": "number",
2117
+ "uptimeRatio?": "number",
2118
+ "lastExitAt?": "number"
2119
+ });
2120
+ var usageViewSchema = type({
2121
+ "servers": usageEntrySchema.array(),
2122
+ /** When the host-level sample was taken, so a caller can tell live numbers from a frozen frame. */
2123
+ "sampledAt?": "number"
2124
+ });
2125
+ /**
2126
+ * What a `free-port` attempt did. The pids are reported so the UI can say which
2127
+ * process left, and which listeners were deliberately left alone because this
2128
+ * panel supervises them.
2129
+ */
2130
+ var freePortResultSchema = type({
2131
+ ok: "boolean",
2132
+ port: "number | null",
2133
+ /** Asked to leave with SIGTERM, and the ones that ignored it. */
2134
+ terminated: "number[]",
2135
+ forced: "number[]",
2136
+ /** Listeners this panel supervises; never signalled. */
2137
+ skipped: "number[]",
2138
+ /** The port answers no more after the attempt. */
2139
+ free: "boolean"
2140
+ });
2141
+ var logHistoryQuerySchema = type({
2142
+ tail: "string?",
2143
+ /**
2144
+ * Case-insensitive substring filter. Both this and `stream` are filters, so the route reads a
2145
+ * wider window than `tail` and applies them to that: filtering only the display tail would
2146
+ * report an older match as "no results", and "the last N stderr lines" as whatever happened
2147
+ * to fall in a window sized for all streams. `searched` reports how many lines were read.
2148
+ */
2149
+ search: "string?",
2150
+ stream: "\"stdout\" | \"stderr\" | \"system\"?"
2151
+ });
2152
+ var logFileInfoSchema = type({
2153
+ name: "string",
2154
+ sizeBytes: "number"
2155
+ });
2156
+ var logServerViewSchema = type({
2157
+ serverId: "string",
2158
+ label: "string",
2159
+ status: serverStatusSchema,
2160
+ enabled: "boolean",
2161
+ sizeBytes: "number",
2162
+ files: logFileInfoSchema.array()
2163
+ });
2164
+ var logServersViewSchema = type({ servers: logServerViewSchema.array() });
2165
+ type({
2166
+ serverId: "string",
2167
+ enabled: "boolean",
2168
+ sizeBytes: "number",
2169
+ files: type("string[]"),
2170
+ /** How many lines the search looked at, or null when not searching. */
2171
+ searched: "number | null",
2172
+ lines: logLineSchema.array()
2173
+ });
2174
+ var notificationActionSchema = type({
2175
+ /** Optional override, so the token can be tried before it is saved. */
2176
+ botToken: "string?",
2177
+ chatId: "string?"
2178
+ }).onUndeclaredKey("reject");
2179
+ /**
2180
+ * The `:id` path parameter of a destination route.
2181
+ *
2182
+ * Validated, because the id is not only a lookup key: it also keys a bot token in the secrets file.
2183
+ * Unvalidated, `DELETE /destinations/ghost/token` answered `200`, and an id of `botToken` wrote the
2184
+ * literal secrets key `telegram.botToken`, which the reader then took for the **legacy singleton** —
2185
+ * every real destination's token became unreachable.
2186
+ */
2187
+ var destinationIdParamSchema = type({ id: "/^[a-z0-9][a-z0-9_-]*$/" });
2188
+ /**
2189
+ * `POST /api/notifications/test-webhook`: the webhook to try, as a draft or by id.
2190
+ *
2191
+ * The target travels whole because the page tests what is in its form, which may not be saved yet —
2192
+ * and the request schema rejects undeclared keys, so the webhook shape is reused rather than a
2193
+ * second DTO that could drift from it.
2194
+ */
2195
+ var destinationTestSchema = type({
2196
+ target: webhookTargetSchema.omit("kind", "id").and(type({
2197
+ id: "string?",
2198
+ kind: "\"webhook\"?"
2199
+ })),
2200
+ /** Echoed so the result is recorded against the right row; absent for a draft. */
2201
+ id: "string?"
2202
+ }).onUndeclaredKey("reject");
2203
+ var telegramTokenSchema = type({ botToken: "string >= 1" }).onUndeclaredKey("reject");
2204
+ /**
2205
+ * The single error envelope every route answers failures with.
2206
+ *
2207
+ * `detail` is **optional**: `toErrorBody()` omits the key when the error carries none, which is the
2208
+ * common case — measured, `/api/logs/ghost`, `/api/servers/ghost` and `/api/settings/ui` all answer
2209
+ * `{ message, code }` and nothing else. Requiring it here told every OpenAPI client to expect a field
2210
+ * that is usually absent, and disagreed with `ApiErrorBody` in `helpers/error.ts`, which has it
2211
+ * optional because that is what it actually serialises.
2212
+ */
2213
+ var apiErrorSchema = type({
2214
+ "message": "string",
2215
+ /** Stable, machine-readable; `AUTH_REQUIRED` also drives the login redirect. */
2216
+ "code": "string",
2217
+ /** Structured context when the failure has any — a field list, the routes holding a certificate. */
2218
+ "detail?": "unknown"
2219
+ });
2220
+ var tlsUploadSchema = type({
2221
+ certificate: "string >= 1",
2222
+ privateKey: "string >= 1"
2223
+ }).onUndeclaredKey("reject");
2224
+ /** `GET /api/settings`: the panel-wide configuration, as Global Settings reads it. */
2225
+ var settingsViewSchema = type({
2226
+ control: controlViewSchema,
2227
+ host: hostSchema,
2228
+ backups: backupsViewSchema,
2229
+ ui: uiStatusSchema
2230
+ }).onDeepUndeclaredKey("ignore");
2231
+ /** `PATCH /api/settings` answers with the saved view, plus where the listener lands. */
2232
+ var settingsSavedSchema = settingsViewSchema.and(type({
2233
+ /** The listener is moving; reconnect at `targetUrl` when it stops being null. */
2234
+ rebinding: "boolean",
2235
+ targetUrl: "string | null"
2236
+ }));
2237
+ /**
2238
+ * `GET /api/settings/workspace?workspace=<id>`: what a workspace owns and can
2239
+ * change on its own. Global things (listener, auth, host, backups, TLS) are not
2240
+ * here — they belong to the panel, not to any workspace.
2241
+ */
2242
+ var workspaceSettingsViewSchema = type({
2243
+ id: "string",
2244
+ label: "string",
2245
+ settingsPath: "string",
2246
+ configPath: "string",
2247
+ configError: "string | null",
2248
+ defaults: defaultsSchema,
2249
+ logs: logsSchema,
2250
+ notifications: notificationViewSchema
2251
+ }).onDeepUndeclaredKey("ignore");
2252
+ var workspaceSettingsSavedSchema = workspaceSettingsViewSchema;
2253
+ //#endregion
2254
+ export { settingsViewSchema as $, logsSchema as A, proxyConfigSchema as B, healthResponseSchema as C, logQuerySchema as D, logLinesResponseSchema as E, okResponseSchema as F, restoreRequestSchema as G, proxyPatchSchema as H, parseBind as I, serverSchema as J, serverCreateSchema as K, passwordSchema as L, nannyStateSchema as M, notificationActionSchema as N, logServersViewSchema as O, notificationsSchema as P, settingsSavedSchema as Q, passwordSetResponseSchema as R, freePortResultSchema as S, logHistoryQuerySchema as T, proxyViewSchema as U, proxyEngineInstallSchema as V, restorePlanSchema as W, sessionViewSchema as X, serverViewSchema as Y, settingsPatchSchema as Z, deliveryResultSchema as _, hostReadings as _t, backupCreateSchema as a, uiInstallResponseSchema as at, duplicateWebhookIds as b, backupSelectionSchema as c, workspaceCreateSchema as ct, contracts_exports as d, workspaceSchema as dt, stopSchema as et, controlSchema as f, workspaceSettingsPatchSchema as ft, defaultsSchema as g, wslTemperatureSchema as gt, ddnsViewSchema as h, workspaceViewSchema as ht, appStateSchema as i, tlsUploadSchema as it, nannySpecSchema as j, loginSchema as k, backupsSchema as l, workspaceIdSchema as lt, ddnsCredentialsSchema as m, workspaceSettingsViewSchema as mt, apiErrorSchema as n, telegramTokenSchema as nt, backupCreatedResponseSchema as o, uiMetaSchema as ot, ddnsConfigSchema as p, workspaceSettingsSavedSchema as pt, serverPatchSchema as q, apiTokenCreatedSchema as r, tlsReviewResponseSchema as rt, backupFilesResponseSchema as s, usageViewSchema as st, actionResultSchema as t, telegramChatsSchema as tt, bufferedLogsResponseSchema as u, workspaceRenameSchema as ut, destinationIdParamSchema as v, hostSchema as w, entryStateSchema as x, destinationTestSchema as y, proxyCertificateUploadSchema as z };
2255
+
2256
+ //# sourceMappingURL=contracts-ku5ypHXJ.js.map