home-hosted 0.13.0 → 0.20.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 (485) hide show
  1. package/README.md +117 -322
  2. package/bin/home-hosted.mjs +41 -0
  3. package/dist/chunks/account-DiLrSyww.js +359 -0
  4. package/dist/chunks/account-DiLrSyww.js.map +1 -0
  5. package/dist/chunks/add-DEIYVkNK.js +183 -0
  6. package/dist/chunks/add-DEIYVkNK.js.map +1 -0
  7. package/dist/chunks/{archive-DP-XQR8X.js → archive-DFi3qK1c.js} +25 -73
  8. package/dist/chunks/archive-DFi3qK1c.js.map +1 -0
  9. package/dist/chunks/{atomic-C1PfJpE7.js → atomic-SZUwDtGD.js} +3 -6
  10. package/dist/chunks/atomic-SZUwDtGD.js.map +1 -0
  11. package/dist/chunks/{backup-CZcVca2a.js → backup-DnyxIzw0.js} +110 -190
  12. package/dist/chunks/backup-DnyxIzw0.js.map +1 -0
  13. package/dist/chunks/backups-BrrN6cwW.js +2203 -0
  14. package/dist/chunks/backups-BrrN6cwW.js.map +1 -0
  15. package/dist/chunks/bind-DIxrnUst.js +43 -0
  16. package/dist/chunks/bind-DIxrnUst.js.map +1 -0
  17. package/dist/chunks/config-text-DxMOQQnk.js +34 -0
  18. package/dist/chunks/config-text-DxMOQQnk.js.map +1 -0
  19. package/dist/chunks/{contracts-CMBD1TF9.js → contracts-CxZ7u1L3.js} +1239 -1454
  20. package/dist/chunks/contracts-CxZ7u1L3.js.map +1 -0
  21. package/dist/chunks/daemon-BAAYUYQC.js +211 -0
  22. package/dist/chunks/daemon-BAAYUYQC.js.map +1 -0
  23. package/dist/chunks/daemon-log-Ccu-69vB.js +179 -0
  24. package/dist/chunks/daemon-log-Ccu-69vB.js.map +1 -0
  25. package/dist/chunks/deploy-CggSOEkq.js +144 -0
  26. package/dist/chunks/deploy-CggSOEkq.js.map +1 -0
  27. package/dist/chunks/{docker-Cy9Lyvda.js → docker--Un0uLfF.js} +32 -68
  28. package/dist/chunks/docker--Un0uLfF.js.map +1 -0
  29. package/dist/chunks/{down-pKbGCW9d.js → down-CpIN7LEQ.js} +34 -94
  30. package/dist/chunks/down-CpIN7LEQ.js.map +1 -0
  31. package/dist/chunks/exposure-CDJNvOCK.js +229 -0
  32. package/dist/chunks/exposure-CDJNvOCK.js.map +1 -0
  33. package/dist/chunks/import-Bd4VZH0f.js +205 -0
  34. package/dist/chunks/import-Bd4VZH0f.js.map +1 -0
  35. package/dist/chunks/import-plan--fDS_l5r.js +147 -0
  36. package/dist/chunks/import-plan--fDS_l5r.js.map +1 -0
  37. package/dist/chunks/import-write-BTfbeV26.js +42 -0
  38. package/dist/chunks/import-write-BTfbeV26.js.map +1 -0
  39. package/dist/chunks/{init-BZ7hK9Vf.js → init-Bv3oH65x.js} +14 -50
  40. package/dist/chunks/init-Bv3oH65x.js.map +1 -0
  41. package/dist/chunks/job-CYOdN6Ub.js +341 -0
  42. package/dist/chunks/job-CYOdN6Ub.js.map +1 -0
  43. package/dist/chunks/jobs-BX4ahcfh.js +489 -0
  44. package/dist/chunks/jobs-BX4ahcfh.js.map +1 -0
  45. package/dist/chunks/last-stop-DD3lHwo_.js +42 -0
  46. package/dist/chunks/last-stop-DD3lHwo_.js.map +1 -0
  47. package/dist/chunks/layout-D0ysDNav.js +18 -0
  48. package/dist/chunks/layout-D0ysDNav.js.map +1 -0
  49. package/dist/chunks/lazy-kfcBNeqj.js +48 -0
  50. package/dist/chunks/lazy-kfcBNeqj.js.map +1 -0
  51. package/dist/chunks/log-buffer-B7jmn7ts.js +110 -0
  52. package/dist/chunks/log-buffer-B7jmn7ts.js.map +1 -0
  53. package/dist/chunks/log-files-CZL2UhuE.js +488 -0
  54. package/dist/chunks/log-files-CZL2UhuE.js.map +1 -0
  55. package/dist/chunks/{logger-B5U4GD3j.js → logger-BnrKTBHQ.js} +2 -6
  56. package/dist/chunks/logger-BnrKTBHQ.js.map +1 -0
  57. package/dist/chunks/{logs---TI_bxM.js → logs-DxKI6OW2.js} +23 -73
  58. package/dist/chunks/logs-DxKI6OW2.js.map +1 -0
  59. package/dist/chunks/ls-BseUHy_m.js +128 -0
  60. package/dist/chunks/ls-BseUHy_m.js.map +1 -0
  61. package/dist/chunks/migrate-D4w_dXDm.js +268 -0
  62. package/dist/chunks/migrate-D4w_dXDm.js.map +1 -0
  63. package/dist/chunks/{nanny-B-Eu0sFW.js → nanny-BWh7nuvv.js} +21 -14
  64. package/dist/chunks/nanny-BWh7nuvv.js.map +1 -0
  65. package/dist/chunks/{nanny-ChMtq1Zl.js → nanny-BjF2-1pv.js} +3 -3
  66. package/dist/chunks/{nanny-ChMtq1Zl.js.map → nanny-BjF2-1pv.js.map} +1 -1
  67. package/dist/chunks/nanny-DGTXVq5d.js +806 -0
  68. package/dist/chunks/nanny-DGTXVq5d.js.map +1 -0
  69. package/dist/chunks/{nanny-sweep-DErnlPY1.js → nanny-sweep-hjmZ_p7S.js} +14 -24
  70. package/dist/chunks/nanny-sweep-hjmZ_p7S.js.map +1 -0
  71. package/dist/chunks/{nearest-6KgQEDUe.js → nearest-DOx4jySJ.js} +2 -10
  72. package/dist/chunks/nearest-DOx4jySJ.js.map +1 -0
  73. package/dist/chunks/{parse-DhmG26fI.js → parse-DVMPLUDe.js} +47 -72
  74. package/dist/chunks/parse-DVMPLUDe.js.map +1 -0
  75. package/dist/chunks/password-policy-Clq6PGE-.js +9 -0
  76. package/dist/chunks/password-policy-Clq6PGE-.js.map +1 -0
  77. package/dist/chunks/{paths-CGlGDrOU.js → paths-C34-TJLh.js} +32 -56
  78. package/dist/chunks/paths-C34-TJLh.js.map +1 -0
  79. package/dist/chunks/{port-B8WBTRMk.js → port-CnsrxKNR.js} +27 -71
  80. package/dist/chunks/port-CnsrxKNR.js.map +1 -0
  81. package/dist/chunks/process-CboOFPU_.js +192 -0
  82. package/dist/chunks/process-CboOFPU_.js.map +1 -0
  83. package/dist/chunks/{restart-Des4DrAN.js → restart-C0J8dZ2L.js} +11 -29
  84. package/dist/chunks/restart-C0J8dZ2L.js.map +1 -0
  85. package/dist/chunks/run-deploy-DoNDvwT4.js +91 -0
  86. package/dist/chunks/run-deploy-DoNDvwT4.js.map +1 -0
  87. package/dist/chunks/{schema-B240VXcV.js → schema-CZ6f-PHD.js} +7 -20
  88. package/dist/chunks/schema-CZ6f-PHD.js.map +1 -0
  89. package/dist/chunks/secret-MY397r90.js +219 -0
  90. package/dist/chunks/secret-MY397r90.js.map +1 -0
  91. package/dist/chunks/secrets-CG5N4lwY.js +1061 -0
  92. package/dist/chunks/secrets-CG5N4lwY.js.map +1 -0
  93. package/dist/chunks/server-Dm_dXfTW.js +255 -0
  94. package/dist/chunks/server-Dm_dXfTW.js.map +1 -0
  95. package/dist/chunks/server-attention-UQwYXqKe.js +10 -0
  96. package/dist/chunks/server-attention-UQwYXqKe.js.map +1 -0
  97. package/dist/chunks/server-create-D7nvhgBd.js +96 -0
  98. package/dist/chunks/server-create-D7nvhgBd.js.map +1 -0
  99. package/dist/chunks/server-ids-BEQD2rFz.js +23 -0
  100. package/dist/chunks/server-ids-BEQD2rFz.js.map +1 -0
  101. package/dist/chunks/server-vars-DMYmHutL.js +27 -0
  102. package/dist/chunks/server-vars-DMYmHutL.js.map +1 -0
  103. package/dist/chunks/service-C8l-ewNA.js +585 -0
  104. package/dist/chunks/service-C8l-ewNA.js.map +1 -0
  105. package/dist/chunks/{settings-xu-XTfWg.js → settings-CtYDs5PX.js} +62 -78
  106. package/dist/chunks/settings-CtYDs5PX.js.map +1 -0
  107. package/dist/chunks/{setup-temp-CAN4_bA-.js → setup-temp-TAtDmMMU.js} +43 -37
  108. package/dist/chunks/setup-temp-TAtDmMMU.js.map +1 -0
  109. package/dist/chunks/shape-CDGeYl_J.js +9 -0
  110. package/dist/chunks/shape-CDGeYl_J.js.map +1 -0
  111. package/dist/chunks/{src-BtWMFmzZ.js → src-BnzkVy_M.js} +12548 -10576
  112. package/dist/chunks/src-BnzkVy_M.js.map +1 -0
  113. package/dist/chunks/{status-DT1EsA-B.js → status-efbbfYZQ.js} +53 -26
  114. package/dist/chunks/status-efbbfYZQ.js.map +1 -0
  115. package/dist/chunks/store-Bs_Lljjm.js +2082 -0
  116. package/dist/chunks/store-Bs_Lljjm.js.map +1 -0
  117. package/dist/chunks/template-xan58bJh.js +28 -0
  118. package/dist/chunks/template-xan58bJh.js.map +1 -0
  119. package/dist/chunks/token-DDeWfZA4.js +142 -0
  120. package/dist/chunks/token-DDeWfZA4.js.map +1 -0
  121. package/dist/chunks/{ui-D562aqw5.js → ui-BcIAtyxE.js} +68 -79
  122. package/dist/chunks/ui-BcIAtyxE.js.map +1 -0
  123. package/dist/chunks/{ui-dir-CsU3uLNV.js → ui-dir-ClCzVRc3.js} +3 -7
  124. package/dist/chunks/ui-dir-ClCzVRc3.js.map +1 -0
  125. package/dist/chunks/ui-format-CDvvqOoi.js +53 -0
  126. package/dist/chunks/ui-format-CDvvqOoi.js.map +1 -0
  127. package/dist/chunks/{ui-release-DKzVvlLd.js → ui-release-XbJ85pYI.js} +36 -38
  128. package/dist/chunks/ui-release-XbJ85pYI.js.map +1 -0
  129. package/dist/chunks/{ui-revert-EkBBwRTt.js → ui-revert-Dgawq7ze.js} +4 -4
  130. package/dist/chunks/ui-revert-Dgawq7ze.js.map +1 -0
  131. package/dist/chunks/{ui-switch-BnZTdMDd.js → ui-switch-CfQMbZ0g.js} +31 -38
  132. package/dist/chunks/ui-switch-CfQMbZ0g.js.map +1 -0
  133. package/dist/chunks/{ui-update-_xryLYxw.js → ui-update-B3PPivUm.js} +30 -48
  134. package/dist/chunks/ui-update-B3PPivUm.js.map +1 -0
  135. package/dist/chunks/ui-update-CAiH2tFb.js +109 -0
  136. package/dist/chunks/ui-update-CAiH2tFb.js.map +1 -0
  137. package/dist/chunks/{up-Pdz-l6IH.js → up-BQSnYxYd.js} +47 -53
  138. package/dist/chunks/up-BQSnYxYd.js.map +1 -0
  139. package/dist/chunks/{usage-DFrCVXpT.js → usage-KG8TeOio.js} +7 -20
  140. package/dist/chunks/usage-KG8TeOio.js.map +1 -0
  141. package/dist/chunks/{workspaces-DYcfvKV_.js → workspaces-D9akpzU8.js} +80 -68
  142. package/dist/chunks/workspaces-D9akpzU8.js.map +1 -0
  143. package/dist/chunks/{wsl-temperature-BiCI4iK6.js → wsl-temperature-D-_d4Yk1.js} +47 -42
  144. package/dist/chunks/wsl-temperature-D-_d4Yk1.js.map +1 -0
  145. package/dist/cli.js +306 -238
  146. package/dist/cli.js.map +1 -1
  147. package/dist/client.js +76 -29
  148. package/dist/client.js.map +1 -1
  149. package/dist/types/api/acme.d.ts +3 -7
  150. package/dist/types/api/auth/$.routes.d.ts +107 -16
  151. package/dist/types/api/backups.d.ts +5 -5
  152. package/dist/types/api/control.d.ts +747 -38
  153. package/dist/types/api/ddns.d.ts +13 -18
  154. package/dist/types/api/events.d.ts +9 -3
  155. package/dist/types/api/health.d.ts +2 -4
  156. package/dist/types/api/jobs.d.ts +438 -0
  157. package/dist/types/api/logs.d.ts +20 -0
  158. package/dist/types/api/metrics.d.ts +2 -5
  159. package/dist/types/api/notifications.d.ts +3 -6
  160. package/dist/types/api/proxy.d.ts +63 -23
  161. package/dist/types/api/server-ops.d.ts +17 -0
  162. package/dist/types/api/servers/$.routes.d.ts +418 -186
  163. package/dist/types/api/session-required.d.ts +16 -0
  164. package/dist/types/api/settings.d.ts +7 -7
  165. package/dist/types/api/state.d.ts +100 -10
  166. package/dist/types/api/static.d.ts +2 -2
  167. package/dist/types/api/tls.d.ts +2 -5
  168. package/dist/types/api/workspaces/$.routes.d.ts +186 -12
  169. package/dist/types/api/wsl-temperature.d.ts +4 -10
  170. package/dist/types/app.d.ts +4511 -2778
  171. package/dist/types/cli/account.d.ts +23 -0
  172. package/dist/types/cli/add.d.ts +96 -0
  173. package/dist/types/cli/args.d.ts +24 -35
  174. package/dist/types/cli/backup-offline.d.ts +2 -8
  175. package/dist/types/cli/backup.d.ts +12 -21
  176. package/dist/types/cli/down.d.ts +15 -41
  177. package/dist/types/cli/import-plan.d.ts +55 -0
  178. package/dist/types/cli/import-write.d.ts +5 -0
  179. package/dist/types/cli/import.d.ts +86 -0
  180. package/dist/types/cli/io.d.ts +26 -35
  181. package/dist/types/cli/job.d.ts +99 -0
  182. package/dist/types/cli/logs.d.ts +1 -10
  183. package/dist/types/cli/ls.d.ts +57 -0
  184. package/dist/types/cli/migrate.d.ts +31 -8
  185. package/dist/types/cli/nearest.d.ts +1 -9
  186. package/dist/types/cli/run-deploy.d.ts +36 -0
  187. package/dist/types/cli/secret.d.ts +90 -0
  188. package/dist/types/cli/server.d.ts +6 -15
  189. package/dist/types/cli/service.d.ts +135 -0
  190. package/dist/types/cli/setup-temp.d.ts +17 -13
  191. package/dist/types/cli/status.d.ts +7 -1
  192. package/dist/types/cli/token.d.ts +6 -0
  193. package/dist/types/cli/ui-switch.d.ts +3 -14
  194. package/dist/types/cli/ui-update.d.ts +3 -16
  195. package/dist/types/cli/up.d.ts +9 -22
  196. package/dist/types/cli/usage.d.ts +2 -6
  197. package/dist/types/cli.d.ts +1 -10
  198. package/dist/types/client.d.ts +4099 -1142
  199. package/dist/types/config/accounts.d.ts +16 -0
  200. package/dist/types/config/jobs.d.ts +68 -0
  201. package/dist/types/config/layout.d.ts +2 -8
  202. package/dist/types/config/migrations.d.ts +9 -41
  203. package/dist/types/config/parse.d.ts +8 -13
  204. package/dist/types/config/patch.d.ts +1 -6
  205. package/dist/types/config/schema.d.ts +16 -18
  206. package/dist/types/config/secret-parts.d.ts +6 -27
  207. package/dist/types/config/secrets.d.ts +167 -88
  208. package/dist/types/config/seed.d.ts +1 -6
  209. package/dist/types/config/server-ids.d.ts +2 -11
  210. package/dist/types/config/settings.d.ts +13 -49
  211. package/dist/types/config/store.d.ts +17 -54
  212. package/dist/types/config/workspaces.d.ts +24 -56
  213. package/dist/types/helpers/action-result.d.ts +18 -32
  214. package/dist/types/helpers/atomic.d.ts +1 -4
  215. package/dist/types/helpers/backoff.d.ts +0 -1
  216. package/dist/types/helpers/bind.d.ts +3 -11
  217. package/dist/types/helpers/config-text.d.ts +4 -19
  218. package/dist/types/helpers/cookies.d.ts +2 -7
  219. package/dist/types/helpers/copy-tree.d.ts +4 -12
  220. package/dist/types/helpers/daemon-log.d.ts +8 -33
  221. package/dist/types/helpers/daemon.d.ts +20 -70
  222. package/dist/types/helpers/deferred.d.ts +2 -4
  223. package/dist/types/helpers/env-file.d.ts +2 -7
  224. package/dist/types/helpers/error.d.ts +3 -14
  225. package/dist/types/helpers/event-stream.d.ts +18 -10
  226. package/dist/types/helpers/factory.d.ts +2 -3
  227. package/dist/types/helpers/last-stop.d.ts +5 -12
  228. package/dist/types/helpers/logger.d.ts +1 -5
  229. package/dist/types/helpers/open.d.ts +0 -1
  230. package/dist/types/helpers/openapi.d.ts +19 -5
  231. package/dist/types/helpers/paths.d.ts +18 -53
  232. package/dist/types/helpers/restore-lock.d.ts +2 -17
  233. package/dist/types/helpers/runtime.d.ts +3 -13
  234. package/dist/types/helpers/secret-compare.d.ts +2 -10
  235. package/dist/types/helpers/server-create.d.ts +15 -0
  236. package/dist/types/helpers/shell.d.ts +2 -16
  237. package/dist/types/helpers/sse.d.ts +8 -6
  238. package/dist/types/helpers/ui-dir.d.ts +1 -5
  239. package/dist/types/helpers/utf8-chunks.d.ts +2 -8
  240. package/dist/types/helpers/validate.d.ts +2 -4
  241. package/dist/types/helpers/validator.d.ts +8 -4
  242. package/dist/types/helpers/version.d.ts +1 -6
  243. package/dist/types/helpers/workspace.d.ts +24 -16
  244. package/dist/types/index.d.ts +2 -3
  245. package/dist/types/middleware/auth.d.ts +8 -27
  246. package/dist/types/middleware/body-limit.d.ts +10 -0
  247. package/dist/types/middleware/host.d.ts +4 -23
  248. package/dist/types/middleware/loopback.d.ts +1 -8
  249. package/dist/types/middleware/token-scope.d.ts +34 -0
  250. package/dist/types/node-compat.d.ts +43 -0
  251. package/dist/types/openapi-reference.d.ts +4 -19
  252. package/dist/types/openapi.d.ts +5 -8
  253. package/dist/types/providers/archive.d.ts +8 -25
  254. package/dist/types/providers/backup-hook.d.ts +4 -19
  255. package/dist/types/providers/ddns/dyndns2.d.ts +0 -3
  256. package/dist/types/providers/ddns/index.d.ts +2 -3
  257. package/dist/types/providers/ddns/ip.d.ts +2 -12
  258. package/dist/types/providers/ddns/namecheap-api.d.ts +3 -2
  259. package/dist/types/providers/ddns/types.d.ts +6 -32
  260. package/dist/types/providers/ddns/zone.d.ts +1 -4
  261. package/dist/types/providers/docker.d.ts +18 -45
  262. package/dist/types/providers/entry-state.d.ts +4 -9
  263. package/dist/types/providers/health-check.d.ts +1 -5
  264. package/dist/types/providers/host.d.ts +33 -108
  265. package/dist/types/providers/identity.d.ts +9 -34
  266. package/dist/types/providers/log-tail.d.ts +14 -24
  267. package/dist/types/providers/nanny-sweep.d.ts +8 -25
  268. package/dist/types/providers/nanny.d.ts +16 -58
  269. package/dist/types/providers/port.d.ts +28 -83
  270. package/dist/types/providers/proc.d.ts +22 -80
  271. package/dist/types/providers/process.d.ts +12 -36
  272. package/dist/types/providers/proxy/admin.d.ts +11 -0
  273. package/dist/types/providers/proxy/types.d.ts +4 -16
  274. package/dist/types/providers/telegram.d.ts +1 -17
  275. package/dist/types/providers/ui-release.d.ts +15 -25
  276. package/dist/types/providers/webhook.d.ts +8 -29
  277. package/dist/types/providers/wsl-temperature.d.ts +13 -22
  278. package/dist/types/services/acme-challenge.d.ts +2 -16
  279. package/dist/types/services/auth.d.ts +65 -80
  280. package/dist/types/services/backups/archive-safety.d.ts +30 -0
  281. package/dist/types/services/backups/paths.d.ts +31 -0
  282. package/dist/types/services/backups.d.ts +61 -271
  283. package/dist/types/services/config-watch.d.ts +3 -15
  284. package/dist/types/services/control-server.d.ts +6 -10
  285. package/dist/types/services/ddns.d.ts +12 -13
  286. package/dist/types/services/dependencies.d.ts +3 -14
  287. package/dist/types/services/deploy.d.ts +34 -0
  288. package/dist/types/services/events.d.ts +15 -9
  289. package/dist/types/services/exposure.d.ts +13 -63
  290. package/dist/types/services/history.d.ts +5 -14
  291. package/dist/types/services/host-monitor.d.ts +6 -11
  292. package/dist/types/services/init.d.ts +5 -35
  293. package/dist/types/services/job-ledger.d.ts +27 -0
  294. package/dist/types/services/jobs.d.ts +113 -0
  295. package/dist/types/services/log-buffer.d.ts +7 -8
  296. package/dist/types/services/log-files.d.ts +12 -42
  297. package/dist/types/services/log-relay.d.ts +3 -13
  298. package/dist/types/services/nanny.d.ts +3 -10
  299. package/dist/types/services/notifications.d.ts +31 -61
  300. package/dist/types/services/panel.d.ts +32 -78
  301. package/dist/types/services/proxy-certificates/certificates.d.ts +31 -69
  302. package/dist/types/services/proxy-config.d.ts +15 -36
  303. package/dist/types/services/proxy-dns01.d.ts +14 -0
  304. package/dist/types/services/proxy.d.ts +73 -254
  305. package/dist/types/services/scheduler.d.ts +46 -0
  306. package/dist/types/services/state.d.ts +17 -8
  307. package/dist/types/services/supervisor/compose.d.ts +2 -6
  308. package/dist/types/services/supervisor/entry.d.ts +29 -32
  309. package/dist/types/services/supervisor/health.d.ts +8 -31
  310. package/dist/types/services/supervisor/job-run.d.ts +36 -0
  311. package/dist/types/services/supervisor/output.d.ts +13 -77
  312. package/dist/types/services/supervisor/persistent.d.ts +5 -11
  313. package/dist/types/services/supervisor/port-preflight.d.ts +4 -10
  314. package/dist/types/services/supervisor/records.d.ts +27 -60
  315. package/dist/types/services/supervisor/restart-required.d.ts +13 -0
  316. package/dist/types/services/supervisor/spawn.d.ts +3 -5
  317. package/dist/types/services/supervisor/view.d.ts +3 -1
  318. package/dist/types/services/supervisor.d.ts +31 -43
  319. package/dist/types/services/tls.d.ts +6 -17
  320. package/dist/types/services/ui-update.d.ts +19 -17
  321. package/dist/types/services/ui.d.ts +10 -19
  322. package/dist/types/shared/action-outcome.d.ts +2 -7
  323. package/dist/types/shared/api-client.d.ts +133 -177
  324. package/dist/types/shared/api-scopes.d.ts +17 -0
  325. package/dist/types/shared/backup-scope.d.ts +16 -90
  326. package/dist/types/shared/clone.d.ts +2 -11
  327. package/dist/types/shared/contracts/accounts.d.ts +99 -0
  328. package/dist/types/shared/contracts/backups.d.ts +219 -0
  329. package/dist/types/shared/contracts/ddns.d.ts +208 -0
  330. package/dist/types/shared/contracts/frames.d.ts +1395 -0
  331. package/dist/types/shared/contracts/index.d.ts +3 -0
  332. package/dist/types/shared/contracts/logs.d.ts +107 -0
  333. package/dist/types/shared/contracts/proxy.d.ts +303 -0
  334. package/dist/types/shared/contracts.d.ts +852 -1982
  335. package/dist/types/shared/cpu-scale.d.ts +3 -19
  336. package/dist/types/shared/crash-cause.d.ts +8 -0
  337. package/dist/types/shared/cron.d.ts +70 -0
  338. package/dist/types/shared/ddns-form.d.ts +9 -43
  339. package/dist/types/shared/endpoint.d.ts +1 -7
  340. package/dist/types/shared/error-codes.d.ts +438 -0
  341. package/dist/types/shared/error-message.d.ts +1 -7
  342. package/dist/types/shared/fields.d.ts +7 -17
  343. package/dist/types/shared/form-repair.d.ts +1 -5
  344. package/dist/types/shared/generated.d.ts +3 -19
  345. package/dist/types/shared/host-readings.d.ts +25 -128
  346. package/dist/types/shared/lazy.d.ts +1 -1
  347. package/dist/types/shared/live-frames.d.ts +2 -8
  348. package/dist/types/shared/live-series.d.ts +2 -8
  349. package/dist/types/shared/live-store.d.ts +4 -8
  350. package/dist/types/shared/log-download.d.ts +6 -0
  351. package/dist/types/shared/meta.d.ts +6 -0
  352. package/dist/types/shared/password-policy.d.ts +10 -0
  353. package/dist/types/shared/patch-diff.d.ts +13 -72
  354. package/dist/types/shared/port-reading.d.ts +18 -0
  355. package/dist/types/shared/probe-latency.d.ts +3 -21
  356. package/dist/types/shared/proxy-form.d.ts +33 -74
  357. package/dist/types/shared/proxy-validate.d.ts +11 -0
  358. package/dist/types/shared/query-params.d.ts +8 -0
  359. package/dist/types/shared/server-attention.d.ts +2 -27
  360. package/dist/types/shared/server-form.d.ts +15 -54
  361. package/dist/types/shared/server-key.d.ts +1 -12
  362. package/dist/types/shared/server-readings.d.ts +7 -32
  363. package/dist/types/shared/server-url.d.ts +9 -31
  364. package/dist/types/shared/shape.d.ts +1 -16
  365. package/dist/types/shared/stream-access.d.ts +2 -8
  366. package/dist/types/shared/ui-format.d.ts +25 -65
  367. package/docs/API.md +315 -107
  368. package/docs/BACKUPS.md +61 -56
  369. package/docs/CLI.md +255 -49
  370. package/docs/DDNS.md +35 -49
  371. package/docs/JOBS.md +129 -0
  372. package/docs/NOTIFICATIONS.md +58 -90
  373. package/docs/REVERSE_PROXY.md +116 -188
  374. package/docs/SECURITY.md +126 -44
  375. package/docs/SERVERS.md +282 -409
  376. package/docs/UI_CREATION.md +90 -47
  377. package/docs/demo/blank-host-restore.sh +31 -7
  378. package/package.json +15 -6
  379. package/scripts/prepare.mjs +47 -0
  380. package/uis/stock/dist/assets/CopyButton-8mliL0xi.js +1 -0
  381. package/uis/stock/dist/assets/GlobalSettingsView-BINXY77E.js +1 -0
  382. package/uis/stock/dist/assets/LogViewer-kiSnTwdY.js +1 -0
  383. package/uis/stock/dist/assets/LogsView-DDXf_ONs.js +1 -0
  384. package/uis/stock/dist/assets/Modal-lrUuViF2.js +39 -0
  385. package/uis/stock/dist/assets/ProxyView-uXMaJdSQ.js +1 -0
  386. package/uis/stock/dist/assets/ServerDetailView-CW0Vb_c0.js +4 -0
  387. package/uis/stock/dist/assets/SettingsShell-B135xWjJ.js +1 -0
  388. package/uis/stock/dist/assets/SettingsView-BLtWxVkl.js +2 -0
  389. package/uis/stock/dist/assets/de-BIoTrHBQ.js +1 -0
  390. package/uis/stock/dist/assets/es-x4-ih8lH.js +1 -0
  391. package/uis/stock/dist/assets/fr-DatqBBkO.js +1 -0
  392. package/uis/stock/dist/assets/index-CnojaKcA.css +2 -0
  393. package/uis/stock/dist/assets/index-D-CiZReu.js +16 -0
  394. package/uis/stock/dist/assets/ja-CW1703Gw.js +1 -0
  395. package/uis/stock/dist/assets/ko-wFbT4XtK.js +1 -0
  396. package/uis/stock/dist/assets/ru-C1p5C4VN.js +1 -0
  397. package/uis/stock/dist/assets/useUnsavedGuard-BcsXsfCC.js +9 -0
  398. package/uis/stock/dist/assets/vi-CDqr0uie.js +1 -0
  399. package/uis/stock/dist/assets/zh-CN-BJ7iit-X.js +1 -0
  400. package/uis/stock/dist/index.html +4 -3
  401. package/uis/stock/dist/ui.json +3 -3
  402. package/dist/chunks/archive-DP-XQR8X.js.map +0 -1
  403. package/dist/chunks/atomic-C1PfJpE7.js.map +0 -1
  404. package/dist/chunks/backup-CZcVca2a.js.map +0 -1
  405. package/dist/chunks/backups-CFRaWe_m.js +0 -4691
  406. package/dist/chunks/backups-CFRaWe_m.js.map +0 -1
  407. package/dist/chunks/config-text-DifCHhnz.js +0 -50
  408. package/dist/chunks/config-text-DifCHhnz.js.map +0 -1
  409. package/dist/chunks/contracts-CMBD1TF9.js.map +0 -1
  410. package/dist/chunks/daemon-log-BVj8cDEo.js +0 -241
  411. package/dist/chunks/daemon-log-BVj8cDEo.js.map +0 -1
  412. package/dist/chunks/daemon-qKVECISl.js +0 -247
  413. package/dist/chunks/daemon-qKVECISl.js.map +0 -1
  414. package/dist/chunks/docker-Cy9Lyvda.js.map +0 -1
  415. package/dist/chunks/down-pKbGCW9d.js.map +0 -1
  416. package/dist/chunks/init-BZ7hK9Vf.js.map +0 -1
  417. package/dist/chunks/last-stop-C-BXz_XI.js +0 -53
  418. package/dist/chunks/last-stop-C-BXz_XI.js.map +0 -1
  419. package/dist/chunks/layout-DwTtmund.js +0 -24
  420. package/dist/chunks/layout-DwTtmund.js.map +0 -1
  421. package/dist/chunks/lazy-Ce5zEAq1.js +0 -66
  422. package/dist/chunks/lazy-Ce5zEAq1.js.map +0 -1
  423. package/dist/chunks/log-buffer-Dy9HHDMD.js +0 -414
  424. package/dist/chunks/log-buffer-Dy9HHDMD.js.map +0 -1
  425. package/dist/chunks/logger-B5U4GD3j.js.map +0 -1
  426. package/dist/chunks/logs---TI_bxM.js.map +0 -1
  427. package/dist/chunks/migrate-Cfoq-Vgh.js +0 -155
  428. package/dist/chunks/migrate-Cfoq-Vgh.js.map +0 -1
  429. package/dist/chunks/nanny-B-Eu0sFW.js.map +0 -1
  430. package/dist/chunks/nanny-BtWfy0QH.js +0 -1167
  431. package/dist/chunks/nanny-BtWfy0QH.js.map +0 -1
  432. package/dist/chunks/nanny-sweep-DErnlPY1.js.map +0 -1
  433. package/dist/chunks/nearest-6KgQEDUe.js.map +0 -1
  434. package/dist/chunks/parse-DhmG26fI.js.map +0 -1
  435. package/dist/chunks/paths-CGlGDrOU.js.map +0 -1
  436. package/dist/chunks/port-B8WBTRMk.js.map +0 -1
  437. package/dist/chunks/restart-Des4DrAN.js.map +0 -1
  438. package/dist/chunks/schema-B240VXcV.js.map +0 -1
  439. package/dist/chunks/secrets-BieELnZh.js +0 -562
  440. package/dist/chunks/secrets-BieELnZh.js.map +0 -1
  441. package/dist/chunks/server-Bge2r2qQ.js +0 -169
  442. package/dist/chunks/server-Bge2r2qQ.js.map +0 -1
  443. package/dist/chunks/server-ids-DRuNLVCV.js +0 -32
  444. package/dist/chunks/server-ids-DRuNLVCV.js.map +0 -1
  445. package/dist/chunks/set-password-D5vZqqSX.js +0 -43
  446. package/dist/chunks/set-password-D5vZqqSX.js.map +0 -1
  447. package/dist/chunks/set-token-obPiEJYk.js +0 -78
  448. package/dist/chunks/set-token-obPiEJYk.js.map +0 -1
  449. package/dist/chunks/settings-xu-XTfWg.js.map +0 -1
  450. package/dist/chunks/setup-temp-CAN4_bA-.js.map +0 -1
  451. package/dist/chunks/shape-DnTKzjQ2.js +0 -24
  452. package/dist/chunks/shape-DnTKzjQ2.js.map +0 -1
  453. package/dist/chunks/src-BtWMFmzZ.js.map +0 -1
  454. package/dist/chunks/status-DT1EsA-B.js.map +0 -1
  455. package/dist/chunks/ui-D562aqw5.js.map +0 -1
  456. package/dist/chunks/ui-dir-CsU3uLNV.js.map +0 -1
  457. package/dist/chunks/ui-release-DKzVvlLd.js.map +0 -1
  458. package/dist/chunks/ui-revert-EkBBwRTt.js.map +0 -1
  459. package/dist/chunks/ui-switch-BnZTdMDd.js.map +0 -1
  460. package/dist/chunks/ui-update-_xryLYxw.js.map +0 -1
  461. package/dist/chunks/up-Pdz-l6IH.js.map +0 -1
  462. package/dist/chunks/usage-DFrCVXpT.js.map +0 -1
  463. package/dist/chunks/workspaces-DYcfvKV_.js.map +0 -1
  464. package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +0 -1
  465. package/dist/types/cli/set-password.d.ts +0 -14
  466. package/dist/types/cli/set-token.d.ts +0 -21
  467. package/uis/stock/dist/assets/CopyButton-BUBKRJyY.js +0 -1
  468. package/uis/stock/dist/assets/GlobalSettingsView-yYMcRWvt.js +0 -1
  469. package/uis/stock/dist/assets/LogViewer-DIliXy62.js +0 -1
  470. package/uis/stock/dist/assets/LogsView-B7Z-7RNg.js +0 -1
  471. package/uis/stock/dist/assets/Modal-DmKa5Qpp.js +0 -39
  472. package/uis/stock/dist/assets/ProxyView-DvZiNkwb.js +0 -1
  473. package/uis/stock/dist/assets/ServerDetailView-6idGT_EX.js +0 -2
  474. package/uis/stock/dist/assets/SettingsShell-CeGtleYI.js +0 -1
  475. package/uis/stock/dist/assets/SettingsView-BrhJIrmk.js +0 -2
  476. package/uis/stock/dist/assets/de-BRITeb0H.js +0 -1
  477. package/uis/stock/dist/assets/es-B2zIEssV.js +0 -1
  478. package/uis/stock/dist/assets/fr-s0ZOBEqh.js +0 -1
  479. package/uis/stock/dist/assets/index-C1MehbKy.css +0 -2
  480. package/uis/stock/dist/assets/index-CnBN54wF.js +0 -15
  481. package/uis/stock/dist/assets/ja-CU7MR85V.js +0 -1
  482. package/uis/stock/dist/assets/ko-tL5Me6d-.js +0 -1
  483. package/uis/stock/dist/assets/ru-92yrvkNJ.js +0 -1
  484. package/uis/stock/dist/assets/vi-CzvY16k2.js +0 -1
  485. package/uis/stock/dist/assets/zh-CN-DDwFW_uW.js +0 -1
@@ -1,241 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import process from "node:process";
3
- import path from "node:path";
4
- import fs from "node:fs";
5
- import { Buffer } from "node:buffer";
6
- //#region src/helpers/daemon-log.ts
7
- var daemon_log_exports = /* @__PURE__ */ __exportAll({
8
- followLog: () => followLog,
9
- logExists: () => logExists,
10
- readLog: () => readLog,
11
- rotateLog: () => rotateLog,
12
- tailLog: () => tailLog
13
- });
14
- /**
15
- * The panel's own console log — the file `up` redirects the daemon's stdout/stderr into.
16
- *
17
- * It is the only record of a panel that is running but misbehaving, and nothing could reach
18
- * it: `up` prints it when the panel *fails to start*, and after that a person had to know the
19
- * path (which `status` does print) and read the bytes themselves.
20
- *
21
- * These live here rather than in `up.ts` so `up` and `logs` share one rotation rule and one
22
- * idea of what a "tail" is.
23
- */
24
- /** One rotation is enough for a console log. */
25
- var LOG_ROTATE_BYTES = 5242880;
26
- function rotateLog(file) {
27
- try {
28
- if (fs.statSync(file).size < LOG_ROTATE_BYTES) return;
29
- fs.rmSync(`${file}.1`, { force: true });
30
- fs.renameSync(file, `${file}.1`);
31
- } catch {}
32
- }
33
- /**
34
- * The last `lines` lines, or `''` when there is no log to read.
35
- *
36
- * Split on the trailing newline rather than after it: a log file ends with one, so a plain
37
- * `split('\n').slice(-lines)` counts that empty last element as a line and quietly returns
38
- * one fewer than asked for.
39
- */
40
- function tailLog(file, lines = 15) {
41
- return withoutTrailingBlank(readLogLines(file)).slice(-lines).join("\n");
42
- }
43
- function readLogLines(file) {
44
- try {
45
- return fs.readFileSync(file, "utf8").split("\n");
46
- } catch {
47
- return [];
48
- }
49
- }
50
- /** A file ending in a newline splits into a final empty element; it is not a line. */
51
- function withoutTrailingBlank(lines) {
52
- return lines.at(-1) === "" ? lines.slice(0, -1) : lines;
53
- }
54
- /**
55
- * The last `lines` lines across the whole rotation, oldest first.
56
- *
57
- * A panel console log keeps one rotation (`.1`), so this reads the current file and `.1` — but a
58
- * **server's** log is rotated by the panel to `.log.<keep>`, three deep by default, and the two
59
- * used to share this one implementation. `readLog` therefore printed the newest third of a
60
- * server's log while the Logs page served all of it. `readRotated` walks the directory instead,
61
- * which covers one file, two, or eleven.
62
- *
63
- * Reads only the tail it needs when it can. The log is capped at 5 MB per file *by rotation*, so a
64
- * panel that has been up a while keeps a large current file — and the old version read it in full,
65
- * split every line and threw all but the last fifty away: 24 ms and 28 MB of heap to print fifty
66
- * lines, on the *default* invocation of a diagnostic command. Most of a tail is not looked at, so
67
- * it is not read.
68
- */
69
- function readLog(file, lines) {
70
- return readRotated(file, lines);
71
- }
72
- /**
73
- * Does this log exist at all — the current file or any rotation of it?
74
- *
75
- * Distinct from "has it lines", which is what `readLog` answers: a log the panel opened and has
76
- * not yet written to is a real log, and a caller deciding "this entry has never run" must not read
77
- * an empty file as absence. Rotations count on their own because `rotateLog` renames the current
78
- * file away, so a log that has just rotated has no current file until the next write.
79
- */
80
- function logExists(file) {
81
- return rotationFiles(file).length > 0;
82
- }
83
- /**
84
- * The last `lines` lines of one file, as text — read backwards in blocks, stopping as soon as
85
- * enough line separators have been seen. `''` when there is nothing to contribute, `null` when
86
- * the file cannot be read at all (which the caller answers by reading everything).
87
- *
88
- * The first element may be a fragment: a block boundary lands mid-line. It is deliberately
89
- * left in place. The loop only exits once `lines + 1` separators are present, so at least
90
- * `lines` complete lines follow the fragment and the caller's `slice(-lines)` can never reach
91
- * it — trimming it would be code no test could make fail, and a randomised comparison against
92
- * the previous implementation confirmed removing it changes nothing.
93
- */
94
- function readTail(file, lines) {
95
- let handle;
96
- try {
97
- handle = fs.openSync(file, "r");
98
- } catch {
99
- return "";
100
- }
101
- try {
102
- const size = fs.fstatSync(handle).size;
103
- if (size === 0) return "";
104
- const block = 65536;
105
- let end = size;
106
- let text = "";
107
- while (end > 0 && countNewlines(text) < lines + 1) {
108
- const start = Math.max(0, end - block);
109
- const length = end - start;
110
- const buffer = Buffer.alloc(length);
111
- fs.readSync(handle, buffer, 0, length, start);
112
- text = buffer.toString("utf8") + text;
113
- end = start;
114
- }
115
- return text;
116
- } catch {
117
- return null;
118
- } finally {
119
- fs.closeSync(handle);
120
- }
121
- }
122
- /**
123
- * The last `lines` lines across a server's rotation, or nothing when there is nothing to read.
124
- *
125
- * A server's log is rotated by the panel into `<id>.log`, `<id>.log.1` … `<id>.log.<keep>`
126
- * (`LogFiles.ownedFiles`), and `keep` defaults to **three**. This reader walked the current
127
- * file and `.1` only, so `logs <id> --lines all` on a panel that had rotated printed the newest
128
- * third of a log the same panel's Logs page serves whole. Measured on a live panel with a chatty
129
- * entry: **114 of 258 lines** on disk were printed, and the first line shown was not the first
130
- * line the log held.
131
- *
132
- * The list comes from the directory rather than from arithmetic on `keep`: a rotation numbered
133
- * above a lowered ceiling still exists until the next prune, and it is still this entry's output.
134
- */
135
- function readRotated(file, lines) {
136
- const files = rotationFiles(file);
137
- if (files.length === 0) return [];
138
- if (lines <= 0) return readRotatedAll(files);
139
- let text = "";
140
- for (const candidate of files) {
141
- const chunk = readTail(candidate, lines + 1);
142
- if (chunk === null) return readRotatedAll(files);
143
- text = `${chunk}${text}`;
144
- if (countNewlines(text) >= lines + 1) break;
145
- }
146
- return withoutTrailingBlank(text.split("\n")).slice(-lines);
147
- }
148
- /**
149
- * The whole of every rotation, oldest first, used for `--lines all` and as the fallback when a
150
- * bounded read cannot reach the tail.
151
- */
152
- function readRotatedAll(files) {
153
- const parts = [];
154
- for (const candidate of [...files].reverse()) try {
155
- parts.push(fs.readFileSync(candidate, "utf8"));
156
- } catch {}
157
- return withoutTrailingBlank(parts.join("").split("\n"));
158
- }
159
- /**
160
- * The files one log is spread across, newest first.
161
- *
162
- * `<id>.log` plus every `<id>.log.<n>` in the directory, numerically ordered — a plain string
163
- * sort puts `.10` before `.2`, and `keep` allows up to ten rotations. A directory that cannot be
164
- * listed falls back to the current file, which is what this reader did before.
165
- */
166
- function rotationFiles(file) {
167
- const dir = path.dirname(file);
168
- const prefix = `${path.basename(file)}.`;
169
- let names;
170
- try {
171
- names = fs.readdirSync(dir);
172
- } catch {
173
- return fs.existsSync(file) ? [file] : [];
174
- }
175
- const rotated = names.filter((name) => name.startsWith(prefix)).map((name) => ({
176
- name,
177
- index: Number(name.slice(prefix.length))
178
- })).filter((entry) => Number.isInteger(entry.index) && entry.index >= 1).sort((left, right) => left.index - right.index).map((entry) => path.join(dir, entry.name));
179
- return fs.existsSync(file) ? [file, ...rotated] : rotated;
180
- }
181
- function countNewlines(text) {
182
- let count = 0;
183
- for (let index = 0; index < text.length; index += 1) if (text.charCodeAt(index) === 10) count += 1;
184
- return count;
185
- }
186
- /**
187
- * Prints the last `lines` of the log, then keeps printing whatever is appended.
188
- *
189
- * Polled rather than watched on purpose. `config-watch` documents why: an editor's save
190
- * replaces the inode, and `fs.watch` is undependable on some filesystems. A foreground
191
- * command also has to notice the rotation `up` performs, which shows up simply as the file
192
- * getting *smaller* — and a poll sees that without any special case.
193
- *
194
- * Resolves when the caller's signal arrives, so the command exits the way a pager would.
195
- */
196
- async function followLog(file, lines, write, pollMs = 250) {
197
- const initial = readLog(file, lines);
198
- if (initial.length > 0) write(`${initial.join("\n")}\n`);
199
- let offset = sizeOf(file);
200
- let stopped = false;
201
- const stop = () => {
202
- stopped = true;
203
- };
204
- process.once("SIGINT", stop);
205
- process.once("SIGTERM", stop);
206
- try {
207
- for (;;) {
208
- await new Promise((resolve) => setTimeout(resolve, pollMs));
209
- if (stopped) break;
210
- const size = sizeOf(file);
211
- if (size < offset) offset = 0;
212
- if (size === offset) continue;
213
- try {
214
- const handle = fs.openSync(file, "r");
215
- try {
216
- const length = size - offset;
217
- const buffer = Buffer.alloc(length);
218
- fs.readSync(handle, buffer, 0, length, offset);
219
- write(buffer.toString("utf8"));
220
- } finally {
221
- fs.closeSync(handle);
222
- }
223
- offset = size;
224
- } catch {}
225
- }
226
- } finally {
227
- process.removeListener("SIGINT", stop);
228
- process.removeListener("SIGTERM", stop);
229
- }
230
- }
231
- function sizeOf(file) {
232
- try {
233
- return fs.statSync(file).size;
234
- } catch {
235
- return 0;
236
- }
237
- }
238
- //#endregion
239
- export { rotateLog as n, tailLog as r, daemon_log_exports as t };
240
-
241
- //# sourceMappingURL=daemon-log-BVj8cDEo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"daemon-log-BVj8cDEo.js","names":[],"sources":["../../src/helpers/daemon-log.ts"],"sourcesContent":["import { Buffer } from 'node:buffer'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\n\n/**\n * The panel's own console log — the file `up` redirects the daemon's stdout/stderr into.\n *\n * It is the only record of a panel that is running but misbehaving, and nothing could reach\n * it: `up` prints it when the panel *fails to start*, and after that a person had to know the\n * path (which `status` does print) and read the bytes themselves.\n *\n * These live here rather than in `up.ts` so `up` and `logs` share one rotation rule and one\n * idea of what a \"tail\" is.\n */\n\n/** One rotation is enough for a console log. */\nconst LOG_ROTATE_BYTES = 5 * 1024 * 1024\n\nexport function rotateLog(file: string): void {\n try {\n if (fs.statSync(file).size < LOG_ROTATE_BYTES)\n return\n fs.rmSync(`${file}.1`, { force: true })\n fs.renameSync(file, `${file}.1`)\n }\n catch {\n // no log yet\n }\n}\n\n/**\n * The last `lines` lines, or `''` when there is no log to read.\n *\n * Split on the trailing newline rather than after it: a log file ends with one, so a plain\n * `split('\\n').slice(-lines)` counts that empty last element as a line and quietly returns\n * one fewer than asked for.\n */\nexport function tailLog(file: string, lines = 15): string {\n return withoutTrailingBlank(readLogLines(file)).slice(-lines).join('\\n')\n}\n\nfunction readLogLines(file: string): string[] {\n try {\n return fs.readFileSync(file, 'utf8').split('\\n')\n }\n catch {\n return []\n }\n}\n\n/** A file ending in a newline splits into a final empty element; it is not a line. */\nfunction withoutTrailingBlank(lines: string[]): string[] {\n return lines.at(-1) === '' ? lines.slice(0, -1) : lines\n}\n\n/**\n * The last `lines` lines across the whole rotation, oldest first.\n *\n * A panel console log keeps one rotation (`.1`), so this reads the current file and `.1` — but a\n * **server's** log is rotated by the panel to `.log.<keep>`, three deep by default, and the two\n * used to share this one implementation. `readLog` therefore printed the newest third of a\n * server's log while the Logs page served all of it. `readRotated` walks the directory instead,\n * which covers one file, two, or eleven.\n *\n * Reads only the tail it needs when it can. The log is capped at 5 MB per file *by rotation*, so a\n * panel that has been up a while keeps a large current file — and the old version read it in full,\n * split every line and threw all but the last fifty away: 24 ms and 28 MB of heap to print fifty\n * lines, on the *default* invocation of a diagnostic command. Most of a tail is not looked at, so\n * it is not read.\n */\nexport function readLog(file: string, lines: number): string[] {\n return readRotated(file, lines)\n}\n\n/**\n * Does this log exist at all — the current file or any rotation of it?\n *\n * Distinct from \"has it lines\", which is what `readLog` answers: a log the panel opened and has\n * not yet written to is a real log, and a caller deciding \"this entry has never run\" must not read\n * an empty file as absence. Rotations count on their own because `rotateLog` renames the current\n * file away, so a log that has just rotated has no current file until the next write.\n */\nexport function logExists(file: string): boolean {\n return rotationFiles(file).length > 0\n}\n\n/**\n * The last `lines` lines of one file, as text — read backwards in blocks, stopping as soon as\n * enough line separators have been seen. `''` when there is nothing to contribute, `null` when\n * the file cannot be read at all (which the caller answers by reading everything).\n *\n * The first element may be a fragment: a block boundary lands mid-line. It is deliberately\n * left in place. The loop only exits once `lines + 1` separators are present, so at least\n * `lines` complete lines follow the fragment and the caller's `slice(-lines)` can never reach\n * it — trimming it would be code no test could make fail, and a randomised comparison against\n * the previous implementation confirmed removing it changes nothing.\n */\nfunction readTail(file: string, lines: number): string | null {\n let handle: number\n try {\n handle = fs.openSync(file, 'r')\n }\n catch {\n // Not there is not the same as empty, but both mean \"nothing to contribute\".\n return ''\n }\n\n try {\n const size = fs.fstatSync(handle).size\n if (size === 0)\n return ''\n const block = 64 * 1024\n let end = size\n let text = ''\n\n // `lines + 1` separators, because a file's own trailing newline terminates no line.\n while (end > 0 && countNewlines(text) < lines + 1) {\n const start = Math.max(0, end - block)\n const length = end - start\n const buffer = Buffer.alloc(length)\n fs.readSync(handle, buffer, 0, length, start)\n text = buffer.toString('utf8') + text\n end = start\n }\n\n return text\n }\n catch {\n return null\n }\n finally {\n fs.closeSync(handle)\n }\n}\n\n/**\n * The last `lines` lines across a server's rotation, or nothing when there is nothing to read.\n *\n * A server's log is rotated by the panel into `<id>.log`, `<id>.log.1` … `<id>.log.<keep>`\n * (`LogFiles.ownedFiles`), and `keep` defaults to **three**. This reader walked the current\n * file and `.1` only, so `logs <id> --lines all` on a panel that had rotated printed the newest\n * third of a log the same panel's Logs page serves whole. Measured on a live panel with a chatty\n * entry: **114 of 258 lines** on disk were printed, and the first line shown was not the first\n * line the log held.\n *\n * The list comes from the directory rather than from arithmetic on `keep`: a rotation numbered\n * above a lowered ceiling still exists until the next prune, and it is still this entry's output.\n */\nfunction readRotated(file: string, lines: number): string[] {\n // Newest first, which is the order the panel lists them in and the order a tail walks.\n const files = rotationFiles(file)\n if (files.length === 0)\n return []\n\n // Everything, asked for as everything: only `--lines all` pays for this, and it asked to.\n if (lines <= 0)\n return readRotatedAll(files)\n\n // The whole tail has to come from one window, so the newest files are read until they hold\n // enough lines. Concatenating their *text* is what makes a rotation's unterminated last line\n // and the next file's first line one line, exactly as appending the bytes would — splicing the\n // arrays instead would drop it.\n let text = ''\n for (const candidate of files) {\n const chunk = readTail(candidate, lines + 1)\n // `null` is a file that exists but could not be read, which is answered by reading everything\n // — the same fallback a single unreadable file always had.\n if (chunk === null)\n return readRotatedAll(files)\n text = `${chunk}${text}`\n if (countNewlines(text) >= lines + 1)\n break\n }\n return withoutTrailingBlank(text.split('\\n')).slice(-lines)\n}\n\n/**\n * The whole of every rotation, oldest first, used for `--lines all` and as the fallback when a\n * bounded read cannot reach the tail.\n */\nfunction readRotatedAll(files: readonly string[]): string[] {\n const parts: string[] = []\n // `files` is newest first; the log reads oldest first.\n for (const candidate of [...files].reverse()) {\n try {\n parts.push(fs.readFileSync(candidate, 'utf8'))\n }\n catch {\n // A missing file is normal: neither the log nor its rotations need exist.\n }\n }\n return withoutTrailingBlank(parts.join('').split('\\n'))\n}\n\n/**\n * The files one log is spread across, newest first.\n *\n * `<id>.log` plus every `<id>.log.<n>` in the directory, numerically ordered — a plain string\n * sort puts `.10` before `.2`, and `keep` allows up to ten rotations. A directory that cannot be\n * listed falls back to the current file, which is what this reader did before.\n */\nfunction rotationFiles(file: string): string[] {\n const dir = path.dirname(file)\n const base = path.basename(file)\n const prefix = `${base}.`\n\n let names: string[]\n try {\n names = fs.readdirSync(dir)\n }\n catch {\n return fs.existsSync(file) ? [file] : []\n }\n\n // `.log.1`, `.log.2`, … ascending — that is newest to oldest.\n const rotated = names\n .filter(name => name.startsWith(prefix))\n .map(name => ({ name, index: Number(name.slice(prefix.length)) }))\n .filter(entry => Number.isInteger(entry.index) && entry.index >= 1)\n .sort((left, right) => left.index - right.index)\n .map(entry => path.join(dir, entry.name))\n\n return fs.existsSync(file) ? [file, ...rotated] : rotated\n}\n\nfunction countNewlines(text: string): number {\n let count = 0\n for (let index = 0; index < text.length; index += 1) {\n if (text.charCodeAt(index) === 10)\n count += 1\n }\n return count\n}\n\n/**\n * Prints the last `lines` of the log, then keeps printing whatever is appended.\n *\n * Polled rather than watched on purpose. `config-watch` documents why: an editor's save\n * replaces the inode, and `fs.watch` is undependable on some filesystems. A foreground\n * command also has to notice the rotation `up` performs, which shows up simply as the file\n * getting *smaller* — and a poll sees that without any special case.\n *\n * Resolves when the caller's signal arrives, so the command exits the way a pager would.\n */\nexport async function followLog(\n file: string,\n lines: number,\n write: (chunk: string) => void,\n pollMs = 250,\n): Promise<void> {\n const initial = readLog(file, lines)\n if (initial.length > 0)\n write(`${initial.join('\\n')}\\n`)\n\n let offset = sizeOf(file)\n let stopped = false\n const stop = (): void => {\n stopped = true\n }\n process.once('SIGINT', stop)\n process.once('SIGTERM', stop)\n\n try {\n for (;;) {\n await new Promise(resolve => setTimeout(resolve, pollMs))\n if (stopped)\n break\n\n const size = sizeOf(file)\n // Truncated or rotated away: start again from the top of what is there now.\n if (size < offset)\n offset = 0\n if (size === offset)\n continue\n\n try {\n const handle = fs.openSync(file, 'r')\n try {\n const length = size - offset\n const buffer = Buffer.alloc(length)\n fs.readSync(handle, buffer, 0, length, offset)\n // Written exactly as read. A poll can land mid-line, and printing the fragment is\n // what `tail -f` does — the rest arrives on the next poll and concatenates. What\n // must NOT happen is rewriting the bytes: collapsing a trailing run of newlines\n // (`replace(/\\n+$/, '\\n')`) silently ate blank lines, because the offset had already\n // advanced past them. A blank line the panel wrote is output the person asked for.\n write(buffer.toString('utf8'))\n }\n finally {\n fs.closeSync(handle)\n }\n offset = size\n }\n catch {\n // The file went away between the stat and the read; the next poll re-checks.\n }\n }\n }\n finally {\n process.removeListener('SIGINT', stop)\n process.removeListener('SIGTERM', stop)\n }\n}\n\nfunction sizeOf(file: string): number {\n try {\n return fs.statSync(file).size\n }\n catch {\n return 0\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAM,mBAAmB;AAEzB,SAAgB,UAAU,MAAoB;CAC5C,IAAI;EACF,IAAI,GAAG,SAAS,IAAI,CAAC,CAAC,OAAO,kBAC3B;EACF,GAAG,OAAO,GAAG,KAAK,KAAK,EAAE,OAAO,KAAK,CAAC;EACtC,GAAG,WAAW,MAAM,GAAG,KAAK,GAAG;CACjC,QACM,CAEN;AACF;;;;;;;;AASA,SAAgB,QAAQ,MAAc,QAAQ,IAAY;CACxD,OAAO,qBAAqB,aAAa,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;AACzE;AAEA,SAAS,aAAa,MAAwB;CAC5C,IAAI;EACF,OAAO,GAAG,aAAa,MAAM,MAAM,CAAC,CAAC,MAAM,IAAI;CACjD,QACM;EACJ,OAAO,CAAC;CACV;AACF;;AAGA,SAAS,qBAAqB,OAA2B;CACvD,OAAO,MAAM,GAAG,EAAE,MAAM,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI;AACpD;;;;;;;;;;;;;;;;AAiBA,SAAgB,QAAQ,MAAc,OAAyB;CAC7D,OAAO,YAAY,MAAM,KAAK;AAChC;;;;;;;;;AAUA,SAAgB,UAAU,MAAuB;CAC/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vB,UAAU;CACZ;CACA,QAAQ,KAAK,UAAU,IAAI;CAC3B,QAAQ,KAAK,WAAW,IAAI;CAE5B,IAAI;EACF,SAAS;GACP,MAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,MAAM,CAAC;GACxD,IAAI,SACF;GAEF,MAAM,OAAO,OAAO,IAAI;GAExB,IAAI,OAAO,QACT,SAAS;GACX,IAAI,SAAS,QACX;GAEF,IAAI;IACF,MAAM,SAAS,GAAG,SAAS,MAAM,GAAG;IACpC,IAAI;KACF,MAAM,SAAS,OAAO;KACtB,MAAM,SAAS,OAAO,MAAM,MAAM;KAClC,GAAG,SAAS,QAAQ,QAAQ,GAAG,QAAQ,MAAM;KAM7C,MAAM,OAAO,SAAS,MAAM,CAAC;IAC/B,UACQ;KACN,GAAG,UAAU,MAAM;IACrB;IACA,SAAS;GACX,QACM,CAEN;EACF;CACF,UACQ;EACN,QAAQ,eAAe,UAAU,IAAI;EACrC,QAAQ,eAAe,WAAW,IAAI;CACxC;AACF;AAEA,SAAS,OAAO,MAAsB;CACpC,IAAI;EACF,OAAO,GAAG,SAAS,IAAI,CAAC,CAAC;CAC3B,QACM;EACJ,OAAO;CACT;AACF"}
@@ -1,247 +0,0 @@
1
- import { S as runtimePath } from "./paths-CGlGDrOU.js";
2
- import { t as writeFileAtomic } from "./atomic-C1PfJpE7.js";
3
- import { t as lazy } from "./lazy-Ce5zEAq1.js";
4
- import { c as processLiveness, r as isProcessAlive } from "./port-B8WBTRMk.js";
5
- import fs from "node:fs";
6
- import { type } from "arktype";
7
- import { randomBytes } from "node:crypto";
8
- import http from "node:http";
9
- import https from "node:https";
10
- //#region src/helpers/daemon.ts
11
- /**
12
- * `run.json` is how `status`/`down` find the live control plane and how they are
13
- * allowed to stop it without a password: the file is mode 0600, and the token in
14
- * it is what `POST /_hh/shutdown` checks.
15
- */
16
- var runtimeSchema = lazy(() => type({
17
- version: "string",
18
- pid: "number.integer >= 1",
19
- /** The address that was actually bound, for humans. */
20
- url: "string",
21
- /** Always a reachable loopback address, for probes (`lan` binds to 0.0.0.0). */
22
- probeUrl: "string",
23
- protocol: "string",
24
- port: "1 <= number.integer <= 65535",
25
- bindHost: "string",
26
- startedAt: "number",
27
- projectDir: "string",
28
- dataRoot: "string",
29
- configPath: "string",
30
- logFile: "string",
31
- token: "string >= 1"
32
- }).onUndeclaredKey("reject"));
33
- function readRuntime() {
34
- try {
35
- const parsed = runtimeSchema(JSON.parse(fs.readFileSync(runtimePath, "utf8")));
36
- return parsed instanceof type.errors ? null : parsed;
37
- } catch {
38
- return null;
39
- }
40
- }
41
- function writeRuntime(runtime) {
42
- writeFileAtomic(runtimePath, `${JSON.stringify(runtime, null, 2)}\n`, { mode: 384 });
43
- }
44
- function clearRuntime() {
45
- fs.rmSync(runtimePath, { force: true });
46
- }
47
- function newToken() {
48
- return randomBytes(32).toString("base64url");
49
- }
50
- /**
51
- * What became of the daemon this record describes: the verdict `run.json`'s pid cannot give on
52
- * its own. See `processLiveness` in `providers/port.ts` for why the pid is not an identity.
53
- */
54
- async function runtimeLiveness(runtime) {
55
- return await processLiveness(runtime.pid, runtime.startedAt);
56
- }
57
- /**
58
- * Is the daemon this record describes still the one running?
59
- *
60
- * `readRuntime()` answers "does a record exist", never "is the panel behind it alive" — and a pid
61
- * alone cannot answer that either. The OS reuses pids, and a zombie still answers signal 0, so a
62
- * bare `isProcessAlive(runtime.pid)` reported a stale `run.json` as a live panel: `up` refused with
63
- * "already running", `status` said "running, but not answering", and `down` signalled whatever
64
- * unrelated process had since inherited the pid.
65
- *
66
- * Every caller must read this one predicate, because a caller that re-derives it slightly differently
67
- * is how a `down` comes to signal a stranger.
68
- */
69
- async function runtimeIsAlive(runtime) {
70
- return isLiveLiveness(await runtimeLiveness(runtime));
71
- }
72
- /**
73
- * Only `'live'` and `'unknown'` count as alive. `'unknown'` means the platform could not read a start
74
- * time, so the live pid is all there is — dismissing it would clear a record the running panel still
75
- * owns. `'recycled'` is emphatically **not** alive: the pid belongs to somebody else now.
76
- */
77
- function isLiveLiveness(liveness) {
78
- return liveness === "live" || liveness === "unknown";
79
- }
80
- /**
81
- * Is the record positively pointing at nothing at all — no process behind the pid?
82
- *
83
- * This is the **only** condition under which deleting `run.json` is safe, so it is deliberately
84
- * narrower than `!runtimeIsAlive`. The start-time check can be wrong in one direction: Linux derives
85
- * a process's birth epoch from `btime`, which the kernel computes from the wall clock
86
- * (`getboottime64`: "calls to settimeofday will affect the value returned"), so a forward clock step
87
- * — common when a laptop or a WSL host wakes from sleep — makes a *live* panel look recycled. Deleting
88
- * its record over that would orphan a running panel: still supervising servers, no longer stoppable by
89
- * `down`. A record that some process may still own is left alone and simply overwritten when a new
90
- * panel finishes booting.
91
- */
92
- async function runtimeIsGone(runtime) {
93
- return await runtimeLiveness(runtime) === "gone";
94
- }
95
- /** A degraded panel is still answering: a 503 must not read as "not running". */
96
- async function probeRuntime(runtime, timeoutMs = 2500) {
97
- const answer = await localCall(runtime.probeUrl, "/healthz", "GET", runtime.token, timeoutMs);
98
- return {
99
- reachable: answer !== null,
100
- degraded: answer?.status === 503,
101
- servers: readServerCounts(answer?.body)
102
- };
103
- }
104
- /** The `servers` block of a `/healthz` answer, or `null` when it did not carry one. */
105
- function readServerCounts(body) {
106
- if (body === void 0) return null;
107
- try {
108
- const { total, running } = JSON.parse(body).servers ?? {};
109
- return typeof total === "number" && typeof running === "number" ? {
110
- total,
111
- running
112
- } : null;
113
- } catch {
114
- return null;
115
- }
116
- }
117
- /**
118
- * What is listening on this home's configured port, when no `run.json` says a panel should be — or
119
- * `null` when nothing is.
120
- *
121
- * Every command that answers "is it running" has to consult this, not the record alone: with
122
- * `run.json` deleted, `status` printed "home-hosted is not running" while `GET /healthz` on the
123
- * same port answered `200`, and `down` refuses instead of letting `down && up` start a second panel
124
- * over a live one. The port comes from the state root's own `settings.json`, because that is the
125
- * only record left once `run.json` is gone.
126
- *
127
- * **A listener is only this home's panel when it says so.** Two homes may share a port (one stopped,
128
- * one running), and treating any listener as "ours" broke `status` and `down` in the stopped one —
129
- * `down` refused over another home's panel. `/healthz` tells a loopback caller which home it serves
130
- * (`homeFingerprint`), so anything else — another home, an older panel, a stranger — is `other`.
131
- *
132
- * It **probes, and never signals**: without a record there is no pid this process can prove it
133
- * owns. A settings file that is missing or does not parse is not evidence either way, so this
134
- * reports nothing rather than inventing a port to test.
135
- */
136
- async function configuredPanelAddress() {
137
- const { readStateFile } = await import("./config-text-DifCHhnz.js").then((n) => n.t);
138
- const { globalSettingsPath, homeFingerprint } = await import("./paths-CGlGDrOU.js").then((n) => n.d);
139
- const { probePort } = await import("./port-B8WBTRMk.js").then((n) => n.o);
140
- const { globalSettingsSchema } = await import("./schema-B240VXcV.js").then((n) => n.s);
141
- let port;
142
- try {
143
- const parsed = globalSettingsSchema(JSON.parse(readStateFile(globalSettingsPath)));
144
- if (parsed instanceof type.errors) return null;
145
- port = parsed.control.port;
146
- } catch {
147
- return null;
148
- }
149
- if (!await probePort("127.0.0.1", port)) return null;
150
- for (const protocol of ["http", "https"]) {
151
- const base = `${protocol}://127.0.0.1:${port}`;
152
- const answer = await localCall(base, "/healthz", "GET", void 0, 2500);
153
- if (answer === null) continue;
154
- return answeredHome(answer.body) === homeFingerprint() ? {
155
- kind: "panel",
156
- url: base
157
- } : {
158
- kind: "other",
159
- port
160
- };
161
- }
162
- return {
163
- kind: "other",
164
- port
165
- };
166
- }
167
- /** The `home` a `/healthz` answer names, or `null`. */
168
- function answeredHome(body) {
169
- try {
170
- const home = JSON.parse(body).home;
171
- return typeof home === "string" ? home : null;
172
- } catch {
173
- return null;
174
- }
175
- }
176
- /**
177
- * Asks the daemon to stop through its own endpoint, so supervised servers are
178
- * shut down cleanly on every platform (a bare signal is not graceful on Windows).
179
- */
180
- async function requestShutdown(runtime, timeoutMs = 4e3, options = {}) {
181
- const query = options.withPersistent === true ? "?withPersistent=true" : "";
182
- const answer = await localCall(runtime.probeUrl, `/_hh/shutdown${query}`, "POST", runtime.token, timeoutMs);
183
- return answer !== null && answer.status >= 200 && answer.status < 300;
184
- }
185
- /**
186
- * Drives a supervised server from this machine (`home-hosted start`/`stop`). The
187
- * token comes from run.json, so it needs no session, no password and no API token —
188
- * only the owner of that 0600 file, talking over loopback.
189
- *
190
- * The wait is generous on purpose: a start may have to run a bootstrap, which has a
191
- * 120s default timeout of its own. Past this it is a wedged panel, not a slow one.
192
- */
193
- async function requestControl(runtime, path, timeoutMs = 15e4, method = "POST") {
194
- const answer = await localCall(runtime.probeUrl, path, method, runtime.token, timeoutMs);
195
- if (answer === null) return null;
196
- let body = null;
197
- try {
198
- body = JSON.parse(answer.body);
199
- } catch {}
200
- return {
201
- status: answer.status,
202
- body
203
- };
204
- }
205
- /**
206
- * Talks to the panel over loopback. Node's `fetch` cannot be told to accept the
207
- * self-signed certificate an uploaded TLS pair usually is, which would break
208
- * `status`, the graceful `down` and the local start/stop — so this speaks
209
- * http/https directly.
210
- */
211
- function localCall(base, path, method, token, timeoutMs) {
212
- return new Promise((resolve) => {
213
- const url = new URL(`${base}${path}`);
214
- const secure = url.protocol === "https:";
215
- const request = (secure ? https : http).request({
216
- hostname: url.hostname,
217
- port: url.port,
218
- path: `${url.pathname}${url.search}`,
219
- method,
220
- ...secure ? { rejectUnauthorized: false } : {},
221
- headers: token === void 0 ? {} : { "x-home-hosted-token": token },
222
- timeout: timeoutMs
223
- }, (response) => {
224
- let body = "";
225
- response.setEncoding("utf8");
226
- response.on("data", (chunk) => {
227
- body += chunk;
228
- });
229
- response.once("end", () => resolve({
230
- status: response.statusCode ?? 0,
231
- body
232
- }));
233
- response.once("aborted", () => resolve(null));
234
- response.once("error", () => resolve(null));
235
- });
236
- request.once("error", () => resolve(null));
237
- request.once("timeout", () => {
238
- request.destroy();
239
- resolve(null);
240
- });
241
- request.end();
242
- });
243
- }
244
- //#endregion
245
- export { clearRuntime, configuredPanelAddress, isLiveLiveness, isProcessAlive, newToken, probeRuntime, readRuntime, requestControl, requestShutdown, runtimeIsAlive, runtimeIsGone, runtimeLiveness, writeRuntime };
246
-
247
- //# sourceMappingURL=daemon-qKVECISl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"daemon-qKVECISl.js","names":[],"sources":["../../src/helpers/daemon.ts"],"sourcesContent":["import type { ProcessLiveness } from '#src/providers/port'\nimport { randomBytes } from 'node:crypto'\nimport fs from 'node:fs'\nimport http from 'node:http'\nimport https from 'node:https'\nimport { type } from 'arktype'\nimport { writeFileAtomic } from '#src/helpers/atomic'\nimport { runtimePath } from '#src/helpers/paths'\nimport { processLiveness } from '#src/providers/port'\nimport { lazy } from '#src/shared/lazy'\n\n/**\n * `run.json` is how `status`/`down` find the live control plane and how they are\n * allowed to stop it without a password: the file is mode 0600, and the token in\n * it is what `POST /_hh/shutdown` checks.\n */\nexport const runtimeSchema = lazy(() => type({\n version: 'string',\n pid: 'number.integer >= 1',\n /** The address that was actually bound, for humans. */\n url: 'string',\n /** Always a reachable loopback address, for probes (`lan` binds to 0.0.0.0). */\n probeUrl: 'string',\n protocol: 'string',\n port: '1 <= number.integer <= 65535',\n bindHost: 'string',\n startedAt: 'number',\n projectDir: 'string',\n dataRoot: 'string',\n configPath: 'string',\n logFile: 'string',\n token: 'string >= 1',\n}).onUndeclaredKey('reject'))\nexport type Runtime = typeof runtimeSchema.infer\n\nexport function readRuntime(): Runtime | null {\n try {\n const parsed = runtimeSchema(JSON.parse(fs.readFileSync(runtimePath, 'utf8')))\n return parsed instanceof type.errors ? null : parsed\n }\n catch {\n return null\n }\n}\n\nexport function writeRuntime(runtime: Runtime): void {\n writeFileAtomic(runtimePath, `${JSON.stringify(runtime, null, 2)}\\n`, { mode: 0o600 })\n}\n\nexport function clearRuntime(): void {\n fs.rmSync(runtimePath, { force: true })\n}\n\nexport function newToken(): string {\n return randomBytes(32).toString('base64url')\n}\n\n/**\n * Re-exported from `providers/port.ts` so the two cannot drift on `EPERM` again.\n *\n * They already had: this copy treated a process owned by another user as alive (correct) while the\n * port one treated it as gone, which made a live nanny look absent. One definition, one answer.\n */\nexport { isProcessAlive } from '#src/providers/port'\n\n/**\n * What became of the daemon this record describes: the verdict `run.json`'s pid cannot give on\n * its own. See `processLiveness` in `providers/port.ts` for why the pid is not an identity.\n */\nexport async function runtimeLiveness(runtime: Runtime): Promise<ProcessLiveness> {\n return await processLiveness(runtime.pid, runtime.startedAt)\n}\n\n/**\n * Is the daemon this record describes still the one running?\n *\n * `readRuntime()` answers \"does a record exist\", never \"is the panel behind it alive\" — and a pid\n * alone cannot answer that either. The OS reuses pids, and a zombie still answers signal 0, so a\n * bare `isProcessAlive(runtime.pid)` reported a stale `run.json` as a live panel: `up` refused with\n * \"already running\", `status` said \"running, but not answering\", and `down` signalled whatever\n * unrelated process had since inherited the pid.\n *\n * Every caller must read this one predicate, because a caller that re-derives it slightly differently\n * is how a `down` comes to signal a stranger.\n */\nexport async function runtimeIsAlive(runtime: Runtime): Promise<boolean> {\n return isLiveLiveness(await runtimeLiveness(runtime))\n}\n\n/**\n * Only `'live'` and `'unknown'` count as alive. `'unknown'` means the platform could not read a start\n * time, so the live pid is all there is — dismissing it would clear a record the running panel still\n * owns. `'recycled'` is emphatically **not** alive: the pid belongs to somebody else now.\n */\nexport function isLiveLiveness(liveness: ProcessLiveness): boolean {\n return liveness === 'live' || liveness === 'unknown'\n}\n\n/**\n * Is the record positively pointing at nothing at all — no process behind the pid?\n *\n * This is the **only** condition under which deleting `run.json` is safe, so it is deliberately\n * narrower than `!runtimeIsAlive`. The start-time check can be wrong in one direction: Linux derives\n * a process's birth epoch from `btime`, which the kernel computes from the wall clock\n * (`getboottime64`: \"calls to settimeofday will affect the value returned\"), so a forward clock step\n * — common when a laptop or a WSL host wakes from sleep — makes a *live* panel look recycled. Deleting\n * its record over that would orphan a running panel: still supervising servers, no longer stoppable by\n * `down`. A record that some process may still own is left alone and simply overwritten when a new\n * panel finishes booting.\n */\nexport async function runtimeIsGone(runtime: Runtime): Promise<boolean> {\n return await runtimeLiveness(runtime) === 'gone'\n}\n\nexport interface RuntimeProbe {\n /** The panel answered on its own port — stronger than \"the pid exists\". */\n reachable: boolean\n /** It answered, but reports a crashed autostart server (`/healthz` is 503). */\n degraded: boolean\n /**\n * How many entries it supervises, and how many are up — `null` when the panel answered without\n * a count (an older panel, or one that did not accept the token).\n */\n servers: { total: number, running: number } | null\n}\n\n/** A degraded panel is still answering: a 503 must not read as \"not running\". */\nexport async function probeRuntime(runtime: Runtime, timeoutMs = 2500): Promise<RuntimeProbe> {\n // The token is what makes `/healthz` include the per-server counts instead of only the public\n // status line. `usage` was already reading the same numbers over `/_hh`; `status` not doing so was\n // this call passing no token, not the data being unavailable.\n const answer = await localCall(runtime.probeUrl, '/healthz', 'GET', runtime.token, timeoutMs)\n return { reachable: answer !== null, degraded: answer?.status === 503, servers: readServerCounts(answer?.body) }\n}\n\n/** The `servers` block of a `/healthz` answer, or `null` when it did not carry one. */\nfunction readServerCounts(body: string | undefined): RuntimeProbe['servers'] {\n if (body === undefined)\n return null\n try {\n const parsed = JSON.parse(body) as { servers?: { total?: unknown, running?: unknown } }\n const { total, running } = parsed.servers ?? {}\n return typeof total === 'number' && typeof running === 'number' ? { total, running } : null\n }\n catch {\n return null\n }\n}\n\n/** What holds the configured control port when no `run.json` names a panel. */\nexport type ConfiguredListener\n = | { kind: 'panel', url: string }\n | { kind: 'other', port: number }\n\n/**\n * What is listening on this home's configured port, when no `run.json` says a panel should be — or\n * `null` when nothing is.\n *\n * Every command that answers \"is it running\" has to consult this, not the record alone: with\n * `run.json` deleted, `status` printed \"home-hosted is not running\" while `GET /healthz` on the\n * same port answered `200`, and `down` refuses instead of letting `down && up` start a second panel\n * over a live one. The port comes from the state root's own `settings.json`, because that is the\n * only record left once `run.json` is gone.\n *\n * **A listener is only this home's panel when it says so.** Two homes may share a port (one stopped,\n * one running), and treating any listener as \"ours\" broke `status` and `down` in the stopped one —\n * `down` refused over another home's panel. `/healthz` tells a loopback caller which home it serves\n * (`homeFingerprint`), so anything else — another home, an older panel, a stranger — is `other`.\n *\n * It **probes, and never signals**: without a record there is no pid this process can prove it\n * owns. A settings file that is missing or does not parse is not evidence either way, so this\n * reports nothing rather than inventing a port to test.\n */\nexport async function configuredPanelAddress(): Promise<ConfiguredListener | null> {\n const { readStateFile } = await import('#src/helpers/config-text')\n const { globalSettingsPath, homeFingerprint } = await import('#src/helpers/paths')\n const { probePort } = await import('#src/providers/port')\n const { globalSettingsSchema } = await import('#src/config/schema')\n\n let port: number\n try {\n const parsed = globalSettingsSchema(JSON.parse(readStateFile(globalSettingsPath)) as unknown)\n // `instanceof type.errors` is the only honest test — ArkType's errors are not `Error`s, so\n // `instanceof Error` is false for a valid *and* an invalid payload.\n if (parsed instanceof type.errors)\n return null\n port = parsed.control.port\n }\n catch {\n // No settings file, or one that does not parse: there is nothing to probe.\n return null\n }\n\n if (!await probePort('127.0.0.1', port))\n return null\n // https only when plain http got no answer at all: the panel may serve TLS on its own port.\n for (const protocol of ['http', 'https']) {\n const base = `${protocol}://127.0.0.1:${port}`\n const answer = await localCall(base, '/healthz', 'GET', undefined, 2500)\n if (answer === null)\n continue\n return answeredHome(answer.body) === homeFingerprint() ? { kind: 'panel', url: base } : { kind: 'other', port }\n }\n return { kind: 'other', port }\n}\n\n/** The `home` a `/healthz` answer names, or `null`. */\nfunction answeredHome(body: string): string | null {\n try {\n const home = (JSON.parse(body) as { home?: unknown }).home\n return typeof home === 'string' ? home : null\n }\n catch {\n return null\n }\n}\n\n/**\n * Asks the daemon to stop through its own endpoint, so supervised servers are\n * shut down cleanly on every platform (a bare signal is not graceful on Windows).\n */\nexport async function requestShutdown(runtime: Runtime, timeoutMs = 4000, options: { withPersistent?: boolean } = {}): Promise<boolean> {\n // `withPersistent` rides the same query channel `workspace` already uses: the request helper\n // sends no body, and this is what lets `down --with-persistent` have the panel end the entries\n // while it is still alive to record the stop.\n const query = options.withPersistent === true ? '?withPersistent=true' : ''\n const answer = await localCall(runtime.probeUrl, `/_hh/shutdown${query}`, 'POST', runtime.token, timeoutMs)\n return answer !== null && answer.status >= 200 && answer.status < 300\n}\n\n/** A `/_hh` answer: the status, plus the body when it was JSON. */\nexport interface ControlAnswer {\n status: number\n body: unknown\n}\n\n/**\n * Drives a supervised server from this machine (`home-hosted start`/`stop`). The\n * token comes from run.json, so it needs no session, no password and no API token —\n * only the owner of that 0600 file, talking over loopback.\n *\n * The wait is generous on purpose: a start may have to run a bootstrap, which has a\n * 120s default timeout of its own. Past this it is a wedged panel, not a slow one.\n */\nexport async function requestControl(runtime: Runtime, path: string, timeoutMs = 150000, method: 'GET' | 'POST' = 'POST'): Promise<ControlAnswer | null> {\n const answer = await localCall(runtime.probeUrl, path, method, runtime.token, timeoutMs)\n if (answer === null)\n return null\n\n let body: unknown = null\n try {\n body = JSON.parse(answer.body)\n }\n catch {\n // Not JSON: an empty body or a proxy's error page. The status still means something.\n }\n return { status: answer.status, body }\n}\n\n/**\n * Talks to the panel over loopback. Node's `fetch` cannot be told to accept the\n * self-signed certificate an uploaded TLS pair usually is, which would break\n * `status`, the graceful `down` and the local start/stop — so this speaks\n * http/https directly.\n */\nfunction localCall(base: string, path: string, method: 'GET' | 'POST', token: string | undefined, timeoutMs: number): Promise<{ status: number, body: string } | null> {\n return new Promise((resolve) => {\n const url = new URL(`${base}${path}`)\n const secure = url.protocol === 'https:'\n const request = (secure ? https : http).request({\n hostname: url.hostname,\n port: url.port,\n // The query travels too: a workspace-scoped local call names its workspace there.\n path: `${url.pathname}${url.search}`,\n method,\n // Only ever pointed at our own listener on this machine.\n ...(secure ? { rejectUnauthorized: false } : {}),\n headers: token === undefined ? {} : { 'x-home-hosted-token': token },\n timeout: timeoutMs,\n }, (response) => {\n let body = ''\n response.setEncoding('utf8')\n response.on('data', (chunk: string) => {\n body += chunk\n })\n response.once('end', () => resolve({ status: response.statusCode ?? 0, body }))\n // The `timeout` below is on the *request*, so it stops covering the call once the\n // headers are in. A socket that dies mid-body — the panel rebinding its listener is\n // the documented case — otherwise leaves this promise unsettled for ever, and\n // `down`/`start`/`stop` hang with it.\n response.once('aborted', () => resolve(null))\n response.once('error', () => resolve(null))\n })\n\n request.once('error', () => resolve(null))\n request.once('timeout', () => {\n request.destroy()\n resolve(null)\n })\n request.end()\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,IAAa,gBAAgB,WAAW,KAAK;CAC3C,SAAS;CACT,KAAK;;CAEL,KAAK;;CAEL,UAAU;CACV,UAAU;CACV,MAAM;CACN,UAAU;CACV,WAAW;CACX,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,SAAS;CACT,OAAO;AACT,CAAC,CAAC,CAAC,gBAAgB,QAAQ,CAAC;AAG5B,SAAgB,cAA8B;CAC5C,IAAI;EACF,MAAM,SAAS,cAAc,KAAK,MAAM,GAAG,aAAa,aAAa,MAAM,CAAC,CAAC;EAC7E,OAAO,kBAAkB,KAAK,SAAS,OAAO;CAChD,QACM;EACJ,OAAO;CACT;AACF;AAEA,SAAgB,aAAa,SAAwB;CACnD,gBAAgB,aAAa,GAAG,KAAK,UAAU,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,IAAM,CAAC;AACvF;AAEA,SAAgB,eAAqB;CACnC,GAAG,OAAO,aAAa,EAAE,OAAO,KAAK,CAAC;AACxC;AAEA,SAAgB,WAAmB;CACjC,OAAO,YAAY,EAAE,CAAC,CAAC,SAAS,WAAW;AAC7C;;;;;AAcA,eAAsB,gBAAgB,SAA4C;CAChF,OAAO,MAAM,gBAAgB,QAAQ,KAAK,QAAQ,SAAS;AAC7D;;;;;;;;;;;;;AAcA,eAAsB,eAAe,SAAoC;CACvE,OAAO,eAAe,MAAM,gBAAgB,OAAO,CAAC;AACtD;;;;;;AAOA,SAAgB,eAAe,UAAoC;CACjE,OAAO,aAAa,UAAU,aAAa;AAC7C;;;;;;;;;;;;;AAcA,eAAsB,cAAc,SAAoC;CACtE,OAAO,MAAM,gBAAgB,OAAO,MAAM;AAC5C;;AAeA,eAAsB,aAAa,SAAkB,YAAY,MAA6B;CAI5F,MAAM,SAAS,MAAM,UA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AM;GACnE,SAAS;EACX,IAAI,aAAa;GACf,IAAI,OAAO;GACX,SAAS,YAAY,MAAM;GAC3B,SAAS,GAAG,SAAS,UAAkB;IACrC,QAAQ;GACV,CAAC;GACD,SAAS,KAAK,aAAa,QAAQ;IAAE,QAAQ,SAAS,cAAc;IAAG;GAAK,CAAC,CAAC;GAK9E,SAAS,KAAK,iBAAiB,QAAQ,IAAI,CAAC;GAC5C,SAAS,KAAK,eAAe,QAAQ,IAAI,CAAC;EAC5C,CAAC;EAED,QAAQ,KAAK,eAAe,QAAQ,IAAI,CAAC;EACzC,QAAQ,KAAK,iBAAiB;GAC5B,QAAQ,QAAQ;GAChB,QAAQ,IAAI;EACd,CAAC;EACD,QAAQ,IAAI;CACd,CAAC;AACH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"docker-Cy9Lyvda.js","names":[],"sources":["../../src/providers/docker.ts"],"sourcesContent":["import { execFile } from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { promisify } from 'node:util'\nimport { type } from 'arktype'\nimport { lazy } from '#src/shared/lazy'\n\nconst execFileAsync = promisify(execFile)\n\n/**\n * CPU and memory of a compose project's **containers**, which the process-tree sampler cannot see.\n *\n * A compose stack is not a process tree: `docker compose up` is a wrapper, and its containers live\n * in another namespace. A stack burning 99% CPU reported `cpuPercent: 0` — the wrapper — so\n * `resources.maxRssBytes` could never fire for a leaking container.\n *\n * Detection is deliberately narrow: `command` must be `docker` (with `compose`) or `docker-compose`.\n * A shell that runs docker and a `docker run` are not recognized and keep the process-tree sample,\n * because a wrong guess attributes a stranger's containers to an entry. An entry's own `env` and\n * `envFile` **are** read; the panel's own environment is not. Attribution is by compose's own\n * labels, never \"every container on this machine\".\n *\n * See `.agentDocs/GOTCHAS.md` (\"Metrics\") for the measured failure and the deliberate limits.\n */\n\n/** How long a completed reading is reused. */\nconst DOCKER_CACHE_MS = 10_000\n\n/**\n * `docker stats --no-stream` samples for about a second before printing (measured 2.0–2.2 s per\n * call here), so it is not a read to perform inside the 1 s supervisor tick: it would delay the\n * whole state frame. Nor one per entry per 5 s sample, which is why one call names every container\n * of every docker-backed entry.\n *\n * Reusing a reading for ten seconds keeps the frame responsive and cuts the spawns from roughly\n * 17 000 a day per entry to about 8 600 for the whole workspace; a memory ceiling that acts up to\n * ~12 s late is still a ceiling. The same discipline, and for the same reason, as `SWAP_CACHE_MS`\n * in `src/providers/host.ts`.\n */\n\n/** The file names compose itself tries, in order, in the directory it runs from (or a parent of it). */\nconst COMPOSE_FILES = ['compose.yaml', 'compose.yml', 'docker-compose.yaml', 'docker-compose.yml']\n\n/** A compose global option before the subcommand, whose value is the next word. */\nconst COMPOSE_VALUE_FLAGS = new Set(['-p', '--project-name', '-f', '--file', '--project-directory', '--env-file', '--profile', '--ansi', '--progress', '--parallel'])\n\n/** A compose global option before the subcommand that takes no value. */\nconst COMPOSE_VALUELESS_FLAGS = new Set(['--compatibility', '--dry-run', '--no-ansi', '--verbose', '-h', '--help'])\n\n/** `docker`'s own options before `compose`, whose value is the next word. */\nconst DOCKER_VALUE_FLAGS = new Set(['-c', '--context', '-H', '--host', '-l', '--log-level', '--config'])\n\nconst PS_FORMAT = '{{.ID}}\\t{{.Names}}\\t{{.Label \"com.docker.compose.project\"}}\\t{{.Label \"com.docker.compose.project.config_files\"}}'\n\n/** One container docker reports, with the labels that attribute it to a project. */\nexport interface ContainerRow {\n id: string\n name: string\n project: string | null\n configFiles: string[]\n}\n\n/** What one compose entry's containers add up to. */\nexport interface ComposeReading {\n /** Summed CPU share, so 200 is two saturated cores. */\n cpuPercent: number\n rssBytes: number\n /** Processes inside the containers — the same question the tree sampler answers. */\n processes: number\n /** How many containers the sum covers. */\n containers: number\n}\n\n/** The evidence that an entry runs a compose project, and the key its containers are attributed by. */\nexport interface ComposeTarget {\n /** What the caller looks the reading up by: the project, else the compose files. */\n key: string\n project: string | null\n configFiles: string[]\n}\n\nconst EMPTY: ReadonlyMap<string, ComposeReading> = new Map()\n\n/** One `docker stats --format json` line. Unknown keys are normal — docker adds fields over time. */\nconst statsLineSchema = lazy(() => type({\n 'CPUPerc': 'string',\n 'ID': 'string',\n 'MemUsage': 'string',\n 'PIDs': 'string',\n '+': 'ignore',\n}))\n\nconst BYTE_SCALES: Record<string, number> = {\n b: 1,\n kb: 1000,\n kib: 1024,\n mb: 1000 ** 2,\n mib: 1024 ** 2,\n gb: 1000 ** 3,\n gib: 1024 ** 3,\n tb: 1000 ** 4,\n tib: 1024 ** 4,\n}\n\n/** `816KiB` -> bytes. Docker prints binary units for memory, and `0B` for a container that is not running. */\nexport function parseHumanBytes(value: string): number | null {\n const match = /^([\\d.]+)\\s*([a-z]+)$/i.exec(value.trim())\n if (match === null)\n return null\n const amount = Number.parseFloat(match[1]!)\n const scale = BYTE_SCALES[match[2]!.toLowerCase()]\n if (scale === undefined || !Number.isFinite(amount))\n return null\n return amount * scale\n}\n\n/** `MemUsage` is `used / limit`; only the used part measures this stack. */\nexport function parseMemUsage(value: string): number | null {\n const [used = ''] = value.split('/')\n return parseHumanBytes(used)\n}\n\n/** `99.61%` -> 99.61. `--` is docker's \"no reading\", which must not become a zero. */\nexport function parsePercent(value: string): number | null {\n const match = /^([\\d.]+)%$/.exec(value.trim())\n if (match === null)\n return null\n const parsed = Number.parseFloat(match[1]!)\n return Number.isFinite(parsed) ? parsed : null\n}\n\n/** The containers docker reports, from the tab-separated `--format` above. */\nexport function parseDockerPs(text: string): ContainerRow[] {\n const rows: ContainerRow[] = []\n for (const line of text.split(/\\r?\\n/)) {\n if (line.trim().length === 0)\n continue\n const [id = '', name = '', project = '', files = ''] = line.split('\\t')\n if (id.trim().length === 0)\n continue\n rows.push({\n id: id.trim(),\n name: name.trim(),\n project: project.trim().length > 0 ? project.trim() : null,\n configFiles: files.split(',').map(entry => entry.trim()).filter(entry => entry.length > 0),\n })\n }\n return rows\n}\n\n/** Per-container readings from `docker stats --no-stream --format json`, keyed by container id. */\nexport function parseDockerStats(text: string): Map<string, Omit<ComposeReading, 'containers'>> {\n const readings = new Map<string, Omit<ComposeReading, 'containers'>>()\n for (const line of text.split(/\\r?\\n/)) {\n if (line.trim().length === 0)\n continue\n let raw: unknown\n try {\n raw = JSON.parse(line)\n }\n catch {\n continue\n }\n const parsed = statsLineSchema(raw)\n if (parsed instanceof type.errors)\n continue\n const cpuPercent = parsePercent(parsed.CPUPerc)\n const rssBytes = parseMemUsage(parsed.MemUsage)\n const processes = Number.parseInt(parsed.PIDs, 10)\n // One unreadable field makes the container unmeasured; a zero there would be invented.\n if (cpuPercent === null || rssBytes === null || !Number.isInteger(processes))\n continue\n /*\n * A container with no processes is not idle — it is not running this stack's work.\n *\n * `docker stats` prints `0.00% / 0B / 0 PIDs` for one in `Restarting`, and publishing that is\n * the zero the repo forbids: measured, a flapping entry served `hh_server_rss_bytes 0` and\n * `hh_server_cpu_percent 0`, steady while reported `running`, indistinguishable from a real\n * idle reading and structurally unable to trip `resources.maxRssBytes`. `PIDs 0` is the one\n * field that says so — a live container always has at least one.\n */\n if (processes === 0)\n continue\n // Docker prints a rounded human size (`1.035MiB`), so the byte value is fractional; rounded to\n // a whole byte here, so every reading has the same unit whatever produced it.\n readings.set(parsed.ID, { cpuPercent, rssBytes: Math.round(rssBytes), processes })\n }\n return readings\n}\n\n/** Same file, on a platform whose paths are case-insensitive. */\nfunction samePath(left: string, right: string): boolean {\n const a = path.resolve(left)\n const b = path.resolve(right)\n return process.platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b\n}\n\n/** The argv of the compose command this entry runs, or null when the entry is not docker-backed. */\nfunction composeArgv(command: string, args: string[]): string[] | null {\n const name = path.basename(command).toLowerCase().replace(/\\.exe$/, '')\n if (name === 'docker-compose')\n return args\n if (name !== 'docker')\n return null\n\n for (let index = 0; index < args.length; index++) {\n const arg = args[index]!\n if (arg === 'compose')\n return args.slice(index + 1)\n if (arg.startsWith('-')) {\n // `docker --context box compose up`: the flag's value is not the subcommand.\n if (DOCKER_VALUE_FLAGS.has(arg) && !arg.includes('='))\n index += 1\n continue\n }\n // A different docker subcommand, so there is no compose project behind this entry.\n return null\n }\n return null\n}\n\n/**\n * The compose options before the subcommand, and where the subcommand starts.\n *\n * Compose requires its global options **before** the subcommand — it answers `unknown shorthand\n * flag: 'p'` for `up -p x` — so only this leading run can carry the project name or the file.\n */\nexport function parseComposeHead(args: string[]): {\n subcommandAt: number\n projectName: string | null\n files: string[]\n projectDirectory: string | null\n} {\n const result = { subcommandAt: args.length, projectName: null as string | null, files: [] as string[], projectDirectory: null as string | null }\n\n for (let index = 0; index < args.length; index++) {\n const arg = args[index]!\n if (!arg.startsWith('-')) {\n result.subcommandAt = index\n return result\n }\n // `--file=compose.yml` and the short attached `-fcompose.yml` / `-pblog` forms.\n if (arg.startsWith('--') && arg.includes('=')) {\n const [flag, value = ''] = [arg.slice(0, arg.indexOf('=')), arg.slice(arg.indexOf('=') + 1)]\n if (flag === '--project-name' || flag === '--file' || flag === '--project-directory') {\n if (flag === '--project-name')\n result.projectName = value\n else if (flag === '--file')\n result.files.push(value)\n else result.projectDirectory = value\n }\n continue\n }\n if (!arg.startsWith('--') && arg.length > 2 && COMPOSE_VALUE_FLAGS.has(arg.slice(0, 2))) {\n const value = arg.slice(2)\n if (arg.startsWith('-p'))\n result.projectName = value\n else if (arg.startsWith('-f'))\n result.files.push(value)\n continue\n }\n\n if (COMPOSE_VALUELESS_FLAGS.has(arg))\n continue\n if (!COMPOSE_VALUE_FLAGS.has(arg))\n // An option this does not know: it still takes no *subcommand* position, so keep scanning.\n continue\n\n const value = args[index + 1]\n if (value === undefined)\n return result\n index += 1\n if (arg === '-p' || arg === '--project-name')\n result.projectName = value\n else if (arg === '-f' || arg === '--file')\n result.files.push(value)\n else if (arg === '--project-directory')\n result.projectDirectory = value\n }\n\n return result\n}\n\n/** The compose file compose would pick: the first known name here or in a parent directory. */\nexport function findComposeFile(from: string): string[] {\n let dir = path.resolve(from)\n for (;;) {\n for (const name of COMPOSE_FILES) {\n const candidate = path.join(dir, name)\n try {\n if (fs.statSync(candidate).isFile())\n return [candidate]\n }\n catch {\n // Not this name.\n }\n }\n const parent = path.dirname(dir)\n if (parent === dir)\n return []\n dir = parent\n }\n}\n\n/** Whether this argv runs a compose stack, without resolving anything — a cheap pre-check. */\nexport function isComposeCommand(command: string, args: string[]): boolean {\n return composeArgv(command, args) !== null\n}\n\n/**\n * The compose project an entry runs, from evidence in its own config: the command it spawns, its\n * argv, its cwd and its environment. `null` means \"sample the process tree\", which is the right\n * answer for every entry this cannot attribute honestly — see the module comment for the limits.\n */\nexport function composeTarget(input: {\n command: string\n args: string[]\n cwd: string\n env?: Record<string, string | undefined>\n}): ComposeTarget | null {\n const composeArgs = composeArgv(input.command, input.args)\n if (composeArgs === null)\n return null\n\n const head = parseComposeHead(composeArgs)\n /*\n * The entry's own environment only — **not** `process.env`.\n *\n * The panel itself often runs under compose, and inheriting its `COMPOSE_PROJECT_NAME` made that\n * one name every entry's project: measured with two entries and the panel's env carrying\n * `COMPOSE_PROJECT_NAME=shared-stack`, both reported `cpuPercent: 199.4, rssBytes: 183500800` —\n * each summing both stacks — and a memory ceiling on one fired on the other's containers. The\n * panel's environment is not the entry's.\n */\n const project = head.projectName\n ?? (input.env?.COMPOSE_PROJECT_NAME !== undefined && input.env.COMPOSE_PROJECT_NAME.length > 0\n ? input.env.COMPOSE_PROJECT_NAME\n : null)\n\n const directory = head.projectDirectory === null ? input.cwd : path.resolve(input.cwd, head.projectDirectory)\n const configFiles = head.files.length > 0\n ? head.files.map(file => path.resolve(directory, file))\n : findComposeFile(directory)\n\n if (project === null && configFiles.length === 0)\n // Neither label to attribute by: these containers cannot be told from the rest of the box's.\n return null\n\n return { key: project === null ? `files:${configFiles.join('\\u0000')}` : `project:${project}`, project, configFiles }\n}\n\n/**\n * The containers belonging to one target, or `null` when that cannot be decided.\n *\n * `null` is the ambiguity refusal: two projects sharing a compose file can only be told apart by an\n * explicit project name, so picking one would report another stack's CPU and RSS as this entry's.\n */\nexport function attributeContainers(target: ComposeTarget, rows: ContainerRow[]): ContainerRow[] | null {\n if (target.project !== null)\n return rows.filter(row => row.project === target.project)\n\n const matched = rows.filter(row => row.configFiles.some(file => target.configFiles.some(own => samePath(file, own))))\n const projects = new Set(matched.map(row => row.project))\n return projects.size <= 1 ? matched : null\n}\n\n/**\n * The sum over one project's containers.\n *\n * Exported so the arithmetic is testable against the shapes docker actually prints; the class below\n * only decides when to spawn. `null` for no containers, and for a listed container without a\n * reading — an under-report is the one direction a memory ceiling must not miss.\n */\nexport function sumContainers(rows: ContainerRow[], readings: Map<string, Omit<ComposeReading, 'containers'>>): ComposeReading | null {\n if (rows.length === 0)\n return null\n let cpuPercent = 0\n let rssBytes = 0\n let processes = 0\n for (const row of rows) {\n const reading = readings.get(row.id)\n if (reading === undefined)\n return null\n cpuPercent += reading.cpuPercent\n rssBytes += reading.rssBytes\n processes += reading.processes\n }\n return {\n cpuPercent: Math.round(cpuPercent * 10) / 10,\n rssBytes: Math.round(rssBytes),\n processes,\n containers: rows.length,\n }\n}\n\n/** Whether a container publishing a port belongs to the stack this entry itself declares. */\nexport function isOwnStack(holder: { project: string | null, composeDir: string | null }, target: ComposeTarget | null): boolean {\n if (target === null)\n return false\n // A non-null project on both sides is the exact answer, and `null === null` must not read as one.\n if (holder.project !== null && target.project !== null)\n return holder.project === target.project\n // Otherwise the working directory compose recorded is the one holding this entry's compose file.\n // Most entries never pass `-p`, so the project name is unknown on both sides and the directory is\n // the evidence that remains — measured: without this, an entry's own already-up stack read as a\n // stranger, and the only escape hatch offered was `kill`.\n if (holder.composeDir === null)\n return false\n return target.configFiles.some(file => samePath(path.dirname(file), holder.composeDir!))\n}\n\n/** One target's running containers from a fresh `docker ps`, or `null` when docker cannot answer. */\nexport async function composeContainers(target: ComposeTarget): Promise<ContainerRow[] | null> {\n try {\n const listing = await execFileAsync('docker', [\n 'ps',\n '--filter',\n 'label=com.docker.compose.project',\n '--format',\n PS_FORMAT,\n ], { timeout: 5000, maxBuffer: 4 * 1024 * 1024 })\n return attributeContainers(target, parseDockerPs(listing.stdout))\n }\n catch {\n // Docker absent, down or not permissioned. \"Cannot ask\" is not \"nothing is running\".\n return null\n }\n}\n\n/**\n * Stops every container of one target and reports what is still running afterwards.\n *\n * The answer comes from a **fresh listing**, not from `docker stop`'s exit code: a stop that\n * printed success for a container still listed is the empty success this exists to refuse.\n * `null` means docker could not be asked, which is not the same as \"it stopped\".\n */\nexport async function stopComposeContainers(target: ComposeTarget): Promise<{ stopped: string[], survivors: string[] } | null> {\n const before = await composeContainers(target)\n if (before === null)\n return null\n if (before.length === 0)\n return { stopped: [], survivors: [] }\n\n try {\n await execFileAsync('docker', ['stop', ...before.map(row => row.name)], { timeout: 120_000, maxBuffer: 4 * 1024 * 1024 })\n }\n catch {\n // A non-zero exit only means one name failed; the relisting below is what decides.\n }\n\n const after = await composeContainers(target)\n if (after === null)\n return null\n const remaining = new Set(after.map(row => row.name))\n return {\n stopped: before.map(row => row.name).filter(name => !remaining.has(name)),\n survivors: after.map(row => row.name),\n }\n}\n\n/**\n * Container readings per compose project, refreshed out of band.\n *\n * One `docker ps` and one batched `docker stats` serve every docker-backed entry, however many\n * there are. When docker cannot be reached the cache is emptied rather than filled with zeros: the\n * caller keeps the process-tree sample, which is at least true of the wrapper, and a metric with no\n * reading is never published as an idle one.\n */\nexport class DockerMetrics {\n private cache: { at: number, byKey: Map<string, ComposeReading> } | null = null\n private refreshing: Promise<void> | null = null\n\n /**\n * The last completed readings, and a refresh started when they are stale.\n *\n * Deliberately synchronous: the spawn takes seconds, and awaiting it here would stretch the\n * supervisor tick that publishes the whole state frame. A fresh reading lands on a later tick.\n */\n readings(targets: ComposeTarget[], now = Date.now()): ReadonlyMap<string, ComposeReading> {\n // A stamp in the future (a backwards clock step) counts as stale, so a reading cannot stick.\n const fresh = this.cache !== null && now >= this.cache.at && now - this.cache.at < DOCKER_CACHE_MS\n if (!fresh && targets.length > 0 && this.refreshing === null) {\n this.refreshing = this.refresh(targets, now).finally(() => {\n this.refreshing = null\n })\n }\n return this.cache?.byKey ?? EMPTY\n }\n\n /** Resolves once the refresh in flight, if any, has finished. */\n async settle(): Promise<void> {\n await this.refreshing\n }\n\n /** One listing and one batched stats call; replaces the cache only with a complete answer. */\n async refresh(targets: ComposeTarget[], now = Date.now()): Promise<void> {\n const byKey = new Map<string, ComposeReading>()\n try {\n const listing = await execFileAsync('docker', [\n 'ps',\n // A compose container is the only kind this can attribute, and the filter also keeps a box\n // full of `docker run` containers out of the listing.\n '--filter',\n 'label=com.docker.compose.project',\n '--format',\n PS_FORMAT,\n ], { timeout: 5000, maxBuffer: 4 * 1024 * 1024 })\n\n const rows = parseDockerPs(listing.stdout)\n const perTarget = new Map<string, ContainerRow[]>()\n const ids = new Set<string>()\n for (const target of targets) {\n const matched = attributeContainers(target, rows)\n // No running container of this project: there is nothing of the stack to measure, and the\n // wrapper the entry spawned is the truth of what is running. The caller keeps its sample.\n if (matched === null || matched.length === 0)\n continue\n perTarget.set(target.key, matched)\n for (const row of matched) ids.add(row.id)\n }\n if (ids.size === 0) {\n this.cache = { at: now, byKey }\n return\n }\n\n const stats = await execFileAsync('docker', ['stats', '--no-stream', '--format', 'json', ...ids], {\n timeout: 15_000,\n maxBuffer: 8 * 1024 * 1024,\n })\n const readings = parseDockerStats(stats.stdout)\n for (const [key, matched] of perTarget) {\n // A partial sum is not a smaller reading, it is a wrong one; only complete sums are kept.\n const summed = sumContainers(matched, readings)\n if (summed !== null)\n byKey.set(key, summed)\n }\n }\n catch {\n // docker absent, not running or not permissioned: no reading, never a zero.\n byKey.clear()\n }\n this.cache = { at: now, byKey }\n }\n}\n"],"mappings":";;;;;;;;AAQA,IAAM,gBAAgB,UAAU,QAAQ;;;;;;;;;;;;;;;;;AAmBxC,IAAM,kBAAkB;;;;;;;;;;;;;AAexB,IAAM,gBAAgB;CAAC;CAAgB;CAAe;CAAuB;AAAoB;;AAGjG,IAAM,sCAAsB,IAAI,IAAI;CAAC;CAAM;CAAkB;CAAM;C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