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,27 @@
1
+ import type { HttpCheckConfig } from '../shared/contracts.js';
2
+ export interface HealthProbeResult {
3
+ healthy: boolean;
4
+ ms: number;
5
+ detail: string;
6
+ }
7
+ /** TCP connect timing, used for the default `port` mode and readiness. */
8
+ export declare function probeTcp(host: string, port: number, timeoutMs: number): Promise<HealthProbeResult>;
9
+ export interface HttpProbeOptions extends Pick<HttpCheckConfig, 'scheme' | 'allowInvalidCert' | 'path' | 'method' | 'expectBody' | 'expectStatusBelow'> {
10
+ /** `null` counts as "not set", so a value saved by the UI can be cleared again. */
11
+ expectStatus?: number | null;
12
+ timeoutMs: number;
13
+ }
14
+ /**
15
+ * Fetches the configured path and asserts the response, so "listening" is not
16
+ * mistaken for "working".
17
+ */
18
+ export declare function probeHttp(host: string, port: number, options: HttpProbeOptions): Promise<HealthProbeResult>;
19
+ export declare function probeHealth(options: {
20
+ mode: 'port' | 'http';
21
+ hosts: string[];
22
+ port: number;
23
+ timeoutMs: number;
24
+ http: Pick<HttpCheckConfig, 'scheme' | 'allowInvalidCert' | 'path' | 'method' | 'expectBody' | 'expectStatusBelow'> & {
25
+ expectStatus?: number | null;
26
+ };
27
+ }): Promise<HealthProbeResult>;
@@ -0,0 +1,147 @@
1
+ import type { HostConfig, HostView } from '../shared/contracts.js';
2
+ import os from 'node:os';
3
+ /**
4
+ * Whether a cached reading may be reused.
5
+ *
6
+ * Separate from the reading itself so the rule can be tested anywhere — the read is
7
+ * `sysctl`/PowerShell, which no CI runner but macOS and Windows can perform, and a bug here
8
+ * would be one that only shows up as either a stale alert or a spawn storm.
9
+ *
10
+ * A stamp in the future (a backwards wall-clock step) counts as stale: with a plain
11
+ * `now - at < ttl` it computes a negative age, which is "fresh", and the reading would stick
12
+ * until wall time caught back up — potentially hours after an NTP correction.
13
+ */
14
+ export declare function isSwapCacheFresh(cache: {
15
+ at: number;
16
+ } | null, now: number, ttlMs?: number): boolean;
17
+ /**
18
+ * `sysctl -n vm.swapusage` as a percentage. Pure, so the arithmetic is testable with the readings
19
+ * the platform can actually produce rather than only the ones a runner happens to have.
20
+ */
21
+ export declare function swapPercentFromSysctl(stdout: string): number;
22
+ /** One `Win32_PageFileUsage` CSV row as a percentage; see `swapPercentFromSysctl` for the clamp. */
23
+ export declare function swapPercentFromPageFile(stdout: string): number;
24
+ export declare function readSwapUsedPercent(): Promise<number>;
25
+ /**
26
+ * Cumulative CPU time across every core, split into the two halves a utilisation reading needs.
27
+ *
28
+ * `os.cpus()` is the only CPU source common to Linux, macOS and Windows, and each entry is a
29
+ * cumulative* counter since boot — so a percentage is the delta between two snapshots, never a
30
+ * single read. One core busy for the whole window is 100%; all 8 cores busy is 800%, which is why
31
+ * the per-core figure and the machine-wide figure are not interchangeable.
32
+ */
33
+ export interface CpuTimes {
34
+ /** Milliseconds of CPU time spent doing anything but idling, every core summed. */
35
+ busyMs: number;
36
+ /** Milliseconds of CPU time across every core, idle included. */
37
+ totalMs: number;
38
+ }
39
+ export declare function cpuTimesSnapshot(cpus?: os.CpuInfo[]): CpuTimes;
40
+ /**
41
+ * Share of the machine's CPU capacity in use between two snapshots, 0–100.
42
+ *
43
+ * `null` when the window is empty or the counters went backwards (a suspended host, a clock
44
+ * resync), because "no reading" is honest while a fabricated 0 reads as "idle". Pure, so the
45
+ * arithmetic is testable against snapshots a runner can construct rather than only the one its
46
+ * own scheduler happens to produce.
47
+ */
48
+ export declare function cpuUsedPercent(previous: CpuTimes, next: CpuTimes): number | null;
49
+ /**
50
+ * Memory used, as a percentage of what the machine actually has.
51
+ *
52
+ * The definition matters more than the arithmetic, and it differs per platform:
53
+ *
54
+ * - Linux: `/proc/meminfo`'s `MemAvailable` already excludes cache, because Linux counts
55
+ * page cache as reclaimable. `os.freemem()` happens to read the same value here.
56
+ * - macOS: **`os.freemem()` is wrong for this.** libuv reports `host_statistics64`'s
57
+ * `free_count` alone, while macOS keeps as much RAM as it can in *inactive* and
58
+ * speculative* pages — file cache it drops on demand. A perfectly healthy Mac therefore
59
+ * reads as 90%+ used, which is the report a user brought back from a 0.7.3 panel. Read
60
+ * `vm_stat` and count what macOS itself counts as available.
61
+ * - Windows: `os.freemem()` is the free physical page count, which is the ordinary reading.
62
+ */
63
+ /**
64
+ * How much of `total` is not `free`, as a percentage clamped into `[0, 100]`; 0 when `total` is
65
+ * meaningless.
66
+ *
67
+ * `MemAvailable` is a kernel *estimate* and can exceed `MemTotal`, and `SwapFree` can exceed
68
+ * `SwapTotal` — both make the raw ratio negative. That matters more than a strange display: the
69
+ * alert is `used >= threshold`, so a negative reading silently **suppresses** the memory alert
70
+ * entirely. The fallback branch already clamped for exactly this reason; the `/proc` branch did not,
71
+ * so the two disagreed on the same quantity.
72
+ */
73
+ export declare function usedPercent(free: number, total: number): number;
74
+ export declare function memoryInfo(): {
75
+ memoryUsedPercent: number;
76
+ swapUsedPercent: number;
77
+ };
78
+ /**
79
+ * Which "available memory" reading a platform's fallback should use.
80
+ *
81
+ * Split out from `memoryInfo` because the branch it decides is otherwise unreachable off
82
+ * macOS: Linux answers from `/proc/meminfo` first, so the fallback never runs there and no
83
+ * Linux test can prove which reader was chosen. Taking the platform and the OS reading as
84
+ * arguments makes the decision testable on any runner, which matters — using the wrong
85
+ * reader here is the whole macOS bug.
86
+ */
87
+ export declare function availableMemoryBytes(platform: NodeJS.Platform, osFree: number, vmStat?: string): number | null;
88
+ /**
89
+ * What macOS counts as available: free + inactive + speculative pages.
90
+ *
91
+ * `vm_stat` reports pages, so the page size is needed — and it is not always 4096 (Apple
92
+ * silicon uses 16384 for the physical page size, and `vm_stat` has printed a `page size of`
93
+ * header since macOS 11). Both are handled: the header when it is there, `getpagesize` when
94
+ * it is not.
95
+ *
96
+ * Returns `null` when the reading cannot be taken, so the caller reports "unknown" rather
97
+ * than inventing a percentage.
98
+ */
99
+ export declare function macAvailableBytes(vmStat?: string): number | null;
100
+ export interface TemperatureSensor {
101
+ /** The chip or zone name, e.g. `coretemp`, `nvme`, `x86_pkg_temp`. */
102
+ name: string;
103
+ celsius: number;
104
+ }
105
+ /**
106
+ * The CPU temperature, or null when this machine names no CPU sensor.
107
+ *
108
+ * One tier is chosen and the maximum is taken only *within* it — a CPU package reports several
109
+ * dies, so the hottest die is the reading, but a disk's temperature is not a second opinion.
110
+ */
111
+ export declare function pickCpuTemperature(sensors: TemperatureSensor[]): number | null;
112
+ /**
113
+ * Best-effort CPU temperature from Linux thermal zones / hwmon. macOS and Windows expose no
114
+ * unprivileged sensor, so those platforms report null and both UIs read "n/a" — a WSL2 guest has
115
+ * none either, and the Windows host's `MSAcpi_ThermalZoneTemperature` answers a constant 20 °C
116
+ * regardless of load, so reaching across for it would be a fabricated number rather than a reading.
117
+ */
118
+ export declare function cpuTemperature(): number | null;
119
+ /**
120
+ * Run the configured temperature command and parse one number out of its stdout.
121
+ *
122
+ * This is the escape hatch for a machine whose kernel exposes no sensor — a WSL2 guest above all,
123
+ * where `/sys/class/hwmon` is empty and the Windows ACPI zone answers a constant 20 °C. The user
124
+ * supplies the command, so it is spawned without a shell and given a timeout: a hung helper must
125
+ * not stall a sample that the whole panel's tick waits on.
126
+ *
127
+ * Only a whole-number or decimal reading in a plausible range is accepted. Anything else answers
128
+ * null, which the UI reads as `n/a` — never a guess, for the same reason a missing sensor is not
129
+ * published as 0.
130
+ */
131
+ export declare function temperatureFromCommand(command: string, timeoutMs: number): Promise<number | null>;
132
+ /** The first plausible °C reading in a command's output, or null. Exported for its own tests. */
133
+ export declare function parseTemperature(output: string): number | null;
134
+ /**
135
+ * The temperature to report: the configured command when there is one, else the built-in probe.
136
+ *
137
+ * The command wins even on a platform whose probe works, because a person who set it did so to
138
+ * override what the panel found.
139
+ */
140
+ export declare function readTemperature(config: HostConfig): Promise<number | null>;
141
+ /**
142
+ * Samples the machine itself: the failures a home server actually dies from are
143
+ * a full disk, exhausted memory or a runaway load — none of which a port probe
144
+ * can see.
145
+ */
146
+ export declare function sampleHost(config: HostConfig, resolvePath: (target: string) => string): Promise<HostView>;
147
+ export declare function emptyHostView(config: HostConfig): HostView;
@@ -0,0 +1,54 @@
1
+ /** What the panel actually spawned for an entry: the argv it has to recognize again. */
2
+ export interface SpawnInfo {
3
+ command: string;
4
+ args: string[];
5
+ cwd: string;
6
+ }
7
+ /**
8
+ * Splits a command line into words, undoing the quoting Windows put there. `CommandLine`
9
+ * is the raw string from the spawn call, so `"C:\a b\x.cmd" /c` is one argv entry plus
10
+ * two words, and a quoted argument that contains spaces has to come back as one word.
11
+ *
12
+ * Windows also *escapes* a quote inside an argument as `\"` (Node does this for any argv
13
+ * containing a quote), so the escape is undone here — otherwise every argument with a
14
+ * quote in it survives as a stray backslash and never matches what the panel spawned.
15
+ */
16
+ export declare function splitCommandLine(line: string): string[];
17
+ /**
18
+ * True when the argv a process is running is the entry's own: the image must match where
19
+ * `spawn` would have looked it up — the image Path, or the first word of the command line
20
+ * — and the words after it must open with the entry's args, compared literally. So
21
+ * `spawn --port 4000` also covers `spawn -p 4000 --extra`, which is what a self-restarting
22
+ * wrapper does, while `/tmp/evil/server.js` never covers `/srv/web/server.js` — two paths that name
23
+ * a directory are different files, and the basename fallback applies only while one spelling is bare
24
+ * (see `sameWord`).
25
+ *
26
+ * `words` must already be the process's own argv. A command-line *string* is only correct
27
+ * on Windows, where the OS hands one out; `/proc/<pid>/cmdline` quotes are literal bytes
28
+ * of an argument, so re-joining that argv into one string corrupts it.
29
+ */
30
+ export declare function matchesSpawn(info: {
31
+ words: string[];
32
+ imagePath?: string | null;
33
+ }, spawn: SpawnInfo): boolean;
34
+ /** The argv of a pid on the platforms whose process table can answer it; null otherwise. */
35
+ export declare function processArgv(pid: number): Promise<string[] | null>;
36
+ /**
37
+ * `Win32_Process` for one pid, or null when it cannot be read.
38
+ *
39
+ * The whole round trip — launching PowerShell, loading the CIM provider, serializing —
40
+ * costs seconds on a cold runner, so the timeout is generous and the result is converted
41
+ * to CSV rather than JSON: CSV survives a value that contains a quote or a newline, which
42
+ * an argv legitimately can.
43
+ */
44
+ export declare function windowsProcessInfo(pid: number): Promise<{
45
+ commandLine: string;
46
+ imagePath: string | null;
47
+ } | null>;
48
+ /**
49
+ * Which of these pids look like this entry's own detached successor. The environment
50
+ * marker is authoritative where the platform can read it; otherwise the answer rests on
51
+ * the entry's own argv, which is the only signal a detached successor is obliged to keep
52
+ * — and the only one Windows exposes at all.
53
+ */
54
+ export declare function identifyHolders(serverId: string, spawn: SpawnInfo, pids: number[]): Promise<number[]>;
@@ -0,0 +1,29 @@
1
+ import type { LogLine } from '../shared/contracts.js';
2
+ export declare class LogTailer {
3
+ private readonly file;
4
+ private offset;
5
+ private identity;
6
+ private carry;
7
+ constructor(file: string);
8
+ /** Bytes consumed so far; equal to the file size once it has been drained. */
9
+ get position(): number;
10
+ /** Start from the beginning again — used when a fresh process takes the entry over. */
11
+ reset(): void;
12
+ /**
13
+ * The last `count` lines, with the read position moved to the end of the file in the
14
+ * same operation.
15
+ *
16
+ * A panel attaching to a running entry wants both a backfill and a live stream, and
17
+ * only one thing may own the offset. Reading the tail through the same tailer is what
18
+ * keeps a line from being replayed as news or skipped as history — and it is why this
19
+ * does not delegate to `LogFiles.readTail()`, which knows nothing of this position.
20
+ */
21
+ readTailLines(count: number): LogLine[];
22
+ /**
23
+ * Ignore what is already in the file and follow it from here.
24
+ */
25
+ skipToEnd(): void;
26
+ /** Every complete line written since the previous call. */
27
+ read(): LogLine[];
28
+ private consume;
29
+ }
@@ -0,0 +1,51 @@
1
+ import type { NannyState, StopConfig } from '../shared/contracts.js';
2
+ import { terminatePid } from './process.js';
3
+ /**
4
+ * Finds and ends the persistent entries a host is running, with no panel in the loop.
5
+ *
6
+ * `down` leaves these alone on purpose, so `--with-persistent` is the one caller that has to
7
+ * act on them — often after the panel is already gone. The nanny state files are the only
8
+ * record that survives that, and they are per workspace, so every workspace is read.
9
+ *
10
+ * The **nanny** is what gets signalled: it traps the signal and forwards the entry's own
11
+ * `stop` policy to the child it owns, which is what the panel's stop does. That is also why
12
+ * this cannot go through `/_hh` — after a crash there is nothing left to ask.
13
+ */
14
+ /** One live persistent entry, as its state file describes it. */
15
+ export interface PersistentHandle {
16
+ workspaceId: string;
17
+ serverId: string;
18
+ state: NannyState;
19
+ /** The workspace's `.state` directory, which owns the state file. */
20
+ dir: string;
21
+ }
22
+ /**
23
+ * The persistent entries whose nanny is running right now.
24
+ *
25
+ * A `<id>.run.json` file is a *non-persistent* child's own record and carries no nanny, so it
26
+ * is skipped by suffix — the same distinction `backup-offline` relies on. `nannyIsAlive` is
27
+ * the identity check: a live pid alone proves nothing, since pids are reused.
28
+ */
29
+ export declare function livePersistentEntries(hhDir: string): Promise<PersistentHandle[]>;
30
+ /** What one stop did, so a survivor is reported rather than dressed up as success. */
31
+ export interface PersistentStop {
32
+ handle: PersistentHandle;
33
+ stopped: boolean;
34
+ error: string | null;
35
+ }
36
+ /**
37
+ * Stops these entries and consumes the record of each one that ended.
38
+ *
39
+ * `stopFor` is the entry's own `stop` config, read by the caller from the workspace that
40
+ * declares it: the grace period here has to be the one the entry asked for, or a stop that
41
+ * was still finishing its shutdown reads as a failure and escalates to `SIGKILL`.
42
+ */
43
+ export declare function stopPersistentEntries(handles: PersistentHandle[], options?: {
44
+ stopFor?: (handle: PersistentHandle) => StopConfig;
45
+ /**
46
+ * The one thing a test cannot supply: `SIGKILL` is not survivable, and a pid this process
47
+ * may not signal (the real survivor) is a second user this host has no way to create. The
48
+ * seam is the terminator, not the decision — everything below still runs.
49
+ */
50
+ terminate?: typeof terminatePid;
51
+ }): Promise<PersistentStop[]>;
@@ -0,0 +1,94 @@
1
+ import type { ProcessBirth } from './port.js';
2
+ import type { TerminateOptions } from './process.js';
3
+ import type { NannyExit, NannySpec, NannyState, StopConfig } from '../shared/contracts.js';
4
+ /** Suffix of a spawn spec, so a sweep and the state reader can tell them apart. */
5
+ export declare const SPEC_SUFFIX = ".spec.json";
6
+ /**
7
+ * The signals a nanny traps and forwards to its child. Any other signal ends the nanny outright,
8
+ * so nothing was forwarded — see `stopPersistentEntries`, which then signals the child directly.
9
+ */
10
+ export declare const NANNY_TRAPPED_SIGNALS: ReadonlySet<NodeJS.Signals>;
11
+ /**
12
+ * How a nanny is stopped. A trapped signal goes to the nanny's pid alone and the nanny signals its
13
+ * own group once (`killGroup` is honoured there): signalling the group from here as well delivered
14
+ * the stop to the child twice. The SIGKILL escalation still covers the whole group. Windows has no
15
+ * signal a nanny can trap, so its stop is unchanged.
16
+ */
17
+ export declare function nannyStopOptions(stop: StopConfig, platform?: NodeJS.Platform): TerminateOptions;
18
+ /** How often a nanny rewrites its state file. */
19
+ export declare const NANNY_HEARTBEAT_MS = 5000;
20
+ /** A heartbeat older than this is not evidence of anything. */
21
+ export declare const HEARTBEAT_STALE_MS = 30000;
22
+ /**
23
+ * The state directory is passed in rather than read from a global: the panel injects
24
+ * `$HHOSTED_HOME/.state`, and a test injects its own temp directory.
25
+ */
26
+ export declare function nannySpecPath(dir: string, id: string): string;
27
+ export declare function nannyStatePath(dir: string, id: string): string;
28
+ /** The file a nanny writes and the panel tails; one derivation, so they cannot drift. */
29
+ export declare function nannyLogFile(logDir: string, id: string): string;
30
+ /**
31
+ * How to run this CLI again as a nanny. The panel was itself launched through this
32
+ * entry point (`up` re-spawns itself with it), so `process.argv[1]` is the one path
33
+ * that works under tsx, from `dist/cli.js` and through the published bin alike.
34
+ */
35
+ export declare function nannyEntryPoint(): string;
36
+ /** Written before the spawn, consumed by the nanny, never left behind. */
37
+ export declare function writeNannySpec(file: string, spec: NannySpec): void;
38
+ export declare function clearNannySpec(file: string): void;
39
+ /**
40
+ * Reads and unlinks in one step: the spec holds expanded secrets, and a spec left
41
+ * behind — a nanny that died before reading it, a panel killed mid-spawn — is a
42
+ * secret file with no owner. It is consumed even when it cannot be parsed.
43
+ */
44
+ export declare function takeNannySpec(file: string): NannySpec;
45
+ /**
46
+ * Nothing can be waiting on a spec before this panel has spawned a nanny, so every
47
+ * one still on disk at boot belongs to a nanny that never read it.
48
+ */
49
+ export declare function sweepNannySpecs(dir: string): number;
50
+ /** A stale or foreign file reads as "no state", never as a throw. */
51
+ export declare function readNannyState(file: string): NannyState | null;
52
+ export declare function writeNannyState(file: string, state: NannyState): void;
53
+ export declare function clearNannyState(file: string): void;
54
+ /**
55
+ * The same wording the supervisor uses for a child's exit, so history reads alike — plus a hint
56
+ * when the code has a conventional meaning, because `code 137` alone tells an operator nothing and
57
+ * that is the one they most want explained (a container limit or the kernel OOM killer).
58
+ *
59
+ * The hint is worded as a possibility, never a claim: 128+N is a shell convention, and a program
60
+ * is free to exit 137 for its own reasons — a JVM reports OOM that way itself. 126 and 127 are
61
+ * firmer, since the shell sets those when it cannot run the command at all.
62
+ */
63
+ export declare function describeNannyExit(exit: NannyExit): string;
64
+ /**
65
+ * A spawn failure in words a person can act on.
66
+ *
67
+ * Node reports a missing program as `spawn <cmd> ENOENT` — the same errno as a missing *file*, and
68
+ * the same wording whichever of the two it is. A user who pasted `java -jar server.jar` into
69
+ * `command` saw exactly that and had nothing to go on: the message names the whole line, so it
70
+ * reads as "the program is missing" even when the program is fine and only the argument is wrong.
71
+ *
72
+ * `command` is the configured program, so the two cases can be told apart: if a bare name has no
73
+ * path separator, the shell would have searched `PATH` and this one did not.
74
+ *
75
+ * A **missing working directory** is the third cause of the same errno, and it is the one a
76
+ * deployment hits: `spawn` resolves `cwd` before it looks for the program, so an entry whose `cwd`
77
+ * does not exist *under this launch directory* fails exactly like an uninstalled program. That read
78
+ * sent a person to `which node` while `node` was fine and only the relative path was wrong (a unit
79
+ * file with no `WorkingDirectory=`, a container started from `/`). `cwd` is therefore checked first:
80
+ * if it is not an existing directory, nothing else about the spawn could have worked.
81
+ */
82
+ export declare function describeSpawnError(error: NodeJS.ErrnoException, command: string, cwd?: string): string;
83
+ /**
84
+ * Is the nanny this state describes still ours? A live pid proves nothing on its
85
+ * own — pids are reused, and the heartbeat is written *into the file*, not by the
86
+ * process the file names, so a recycled pid with a recent write reads as running.
87
+ * `startedAt` settles that first (`processLiveness`), exactly as `run.json` uses it:
88
+ * the nanny stamps its record during its own boot, so its process is always born
89
+ * before the stamp. The environment marker (Linux, macOS) or the argv we spawned it
90
+ * with answers the rest, Windows included.
91
+ */
92
+ export declare function nannyIsAlive(state: NannyState, id: string, options?: {
93
+ readBirth?: (pid: number) => Promise<ProcessBirth | null>;
94
+ }): Promise<boolean>;
@@ -0,0 +1,142 @@
1
+ /** True when something accepts TCP connections on host:port. */
2
+ export declare function probePort(host: string, port: number, timeoutMs?: number): Promise<boolean>;
3
+ /** A port is free when nothing is listening on it (loopback is enough to detect conflicts). */
4
+ export declare function isPortFree(port: number, host?: string, timeoutMs?: number): Promise<boolean>;
5
+ /**
6
+ * Kills whatever holds the port, minus `exclude` (the panel's own process tree).
7
+ * Only used as a last resort for wrappers that spawn their real server detached,
8
+ * where a process-group signal cannot reach it.
9
+ */
10
+ export declare function killPortHolders(port: number, exclude?: ReadonlySet<number>): Promise<number[]>;
11
+ /**
12
+ * Signal 0 asks the OS whether the pid still exists, without touching it.
13
+ *
14
+ * `EPERM` means the process is there but is **not ours to signal** — a port holder owned by another
15
+ * user is exactly that. Returning `false` for it made `nannyIsAlive` report a live nanny as gone, so
16
+ * `resumePersistent` consumed its state file and started a second copy of the entry while the first ran
17
+ * on untracked. `helpers/daemon.ts` already had this right; the two predicates now agree.
18
+ */
19
+ export declare function isProcessAlive(pid: number): boolean;
20
+ /** When a process started, and whether it has exited but is not reaped yet. */
21
+ export interface ProcessBirth {
22
+ /** Epoch ms the process started, as the OS reports it. */
23
+ startMs: number;
24
+ /** A zombie: exited, still answering signal 0, and nobody's to signal. */
25
+ zombie: boolean;
26
+ }
27
+ /**
28
+ * `/proc/<pid>/stat` field 22 is the start time in clock ticks since boot, which only
29
+ * becomes an epoch by adding `btime` from `/proc/stat`. Field 3 is the state.
30
+ *
31
+ * The comm field is parenthesised and may itself hold spaces and parentheses, so the
32
+ * fields are counted from after the **last** `)`. Counting from the first would shift
33
+ * every offset for a process whose name contains a `)`, and this value decides whether a
34
+ * live-looking pid is really the daemon.
35
+ */
36
+ export declare function parseProcBirth(content: string, btimeSeconds: number, hz?: number): ProcessBirth | null;
37
+ /**
38
+ * One `ps -o state=,lstart=` row, e.g. `S Wed Oct 7 19:43:26 2026` (macOS, other POSIX).
39
+ * The leading weekday is stripped before parsing: `Date.parse` is not obliged to accept it
40
+ * and it says nothing the date does not.
41
+ */
42
+ export declare function parsePsBirth(output: string): ProcessBirth | null;
43
+ /**
44
+ * FILETIME ticks (100ns since **1601**, UTC) to a Unix epoch in ms — the shape
45
+ * `DateTime.ToFileTimeUtc()` returns.
46
+ *
47
+ * The epoch matters: `DateTime.Ticks` counts from **0001**, not 1601, and the two differ by
48
+ * 1600 years. Reading the wrong one put every Windows panel ~1600 years in the future, which
49
+ * `processLiveness` then called `recycled` — a live panel that could never signal-stop itself.
50
+ * The PowerShell call below therefore asks for `ToFileTimeUtc()` explicitly, and this is exported
51
+ * so the conversion is pinned by a test.
52
+ */
53
+ export declare function parseFiletime(ticks: number): number | null;
54
+ /**
55
+ * When the pid started, from the platform's own process table. `null` when the platform
56
+ * cannot say — an unreadable `/proc`, no `ps`, or no PowerShell — which the caller must
57
+ * read as "unknown", never as "gone".
58
+ */
59
+ export declare function processBirth(pid: number): Promise<ProcessBirth | null>;
60
+ /** Is the process at `pid` the one a record stamped `startedAt` describes? */
61
+ export type ProcessLiveness = 'live'
62
+ /** Nothing is running behind the pid: absent, or a zombie nobody has reaped. */
63
+ | 'gone'
64
+ /** A live pid, but born *after* the record was written — the OS recycled it. */
65
+ | 'recycled'
66
+ /** The platform would not report a birth time, so the live pid is all there is to go on. */
67
+ | 'unknown';
68
+ /**
69
+ * A pid is **not** an identity. The OS hands a dead process's pid to an unrelated one later, and a
70
+ * zombie — exited but not yet reaped by its parent — still answers signal 0. So `isProcessAlive`
71
+ * alone can report a long-dead daemon as live, which is what let `up` say "already running" and
72
+ * `status` say "running, but not answering" against a stale `run.json`, and what let `down` signal
73
+ * whatever stranger had inherited the pid.
74
+ *
75
+ * `startedAt` settles it in one direction, with no threshold to guess at: the daemon writes its
76
+ * record *during its own boot*, so its process is necessarily born **before** that stamp. A pid born
77
+ * after it is not that process, whoever else it now is. The comparison is deliberately one-sided —
78
+ * the other direction would have to tell a recycled pid from a wall clock that merely moved, and it
79
+ * cannot, so a record is never called stale for being *older* than its process.
80
+ *
81
+ * `'unknown'` is not `'gone'`: a platform that cannot report a birth time must not have its live pid
82
+ * dismissed, or a running panel's record would be cleared out from under it.
83
+ */
84
+ export declare function processLiveness(pid: number, startedAt: number, options?: {
85
+ toleranceMs?: number;
86
+ readBirth?: (pid: number) => Promise<ProcessBirth | null>;
87
+ }): Promise<ProcessLiveness>;
88
+ /**
89
+ * Asks specific pids to leave, politely first: a stray dev server stops on
90
+ * SIGTERM, and only what ignores it is killed. Deciding *which* pids may be
91
+ * touched belongs to the caller — this only does the signalling.
92
+ */
93
+ export declare function terminatePids(pids: number[], options?: {
94
+ graceMs?: number;
95
+ }): Promise<{
96
+ stopped: number[];
97
+ forced: number[];
98
+ }>;
99
+ /**
100
+ * One filtered `netstat` per family. `-p TCP` alone lists IPv4 only, while Node's default `listen()`
101
+ * binds `[::]`; an unfiltered `-ano` lists every connection and UDP socket, which is slow enough on a
102
+ * busy machine to hit the lookup's timeout — and a timeout reads as "nothing holds the port".
103
+ */
104
+ export declare const NETSTAT_LISTENER_ARGS: ReadonlyArray<readonly string[]>;
105
+ /** `netstat -ano` lines: ` TCP 127.0.0.1:4010 0.0.0.0:0 LISTENING 1234`; UDP rows are skipped. */
106
+ export declare function parseNetstatListeners(output: string, port: number): number[];
107
+ /**
108
+ * The container publishing a host port, when docker is holding it.
109
+ *
110
+ * A published port is bound by `docker-proxy`, which runs as **root** — so `lsof`/`fuser` return
111
+ * nothing for it, and `listPortHolders` reports an empty list for a port that is plainly refusing
112
+ * every bind. Docker itself answers the question without privileges, and names the stack too, so
113
+ * the caller can say *whose* stack it is instead of "nothing is listening".
114
+ */
115
+ export interface DockerPortHolder {
116
+ /** `com.docker.compose.project.working_dir` when the container came from compose. */
117
+ composeDir: string | null;
118
+ /** `com.docker.compose.project`, so a caller can tell this entry's own stack from a stranger's. */
119
+ project: string | null;
120
+ container: string;
121
+ port: number;
122
+ }
123
+ export declare function findDockerPortHolder(port: number): Promise<DockerPortHolder | null>;
124
+ /**
125
+ * Stops the container publishing a host port, which is how docker's port is freed.
126
+ *
127
+ * The socket belongs to a root-owned `docker-proxy`, so there is no pid this process may signal —
128
+ * but the container is the panel's to stop through docker itself, which needs no privileges
129
+ * beyond the socket the user already has. `docker stop` releases the published port and leaves the
130
+ * stack's other services alone.
131
+ */
132
+ export declare function releaseDockerPort(holder: DockerPortHolder, timeoutMs?: number): Promise<boolean>;
133
+ export declare function listPortHolders(port: number): Promise<number[]>;
134
+ /**
135
+ * Pids from `lsof -ti` (one per line) or `fuser` (space-separated, on one line, with a leading
136
+ * space) — both shapes arrive here, which is why the split is on `\s+` rather than `\n`.
137
+ *
138
+ * Exported for its test: this feeds `killPortHolders`, which sends SIGKILL, so a parser that
139
+ * picked up the wrong number would kill an unrelated process. The filter is not decorative —
140
+ * `Number.parseInt('')` is NaN for the empty leading cell, and a pid of 0 or our own is dropped.
141
+ */
142
+ export declare function parsePids(stdout: string): number[];