home-hosted 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -111,11 +111,61 @@ workspace config guard, so a busy default port turns config tests red for the wr
111
111
  - **A bounded read stays bounded.** `logs --lines 1e3` falls back to the default and `0x10` is not the
112
112
  "whole log" sentinel (`src/cli/logs.ts`); `--lines N` reads a tail, never the whole file
113
113
  (`test/cli/logs.test.ts`).
114
+ - **A reader that hangs up is a finished conversation, not a crash.** `treatClosedReaderAsDone()`
115
+ (`src/cli/io.ts`) is installed **once** at the entry; only `EPIPE` is the reader leaving
116
+ (`test/cli/epipe.test.ts`). Why not `SIGPIPE`: [`.agentDocs/GOTCHAS.md`](.agentDocs/GOTCHAS.md).
117
+ - **One refusal is one message on one stream.** A refusal's whole text goes to stderr, including any
118
+ list it exists to explain; stdout carries only an answer (`test/cli/backup-args.test.ts`).
119
+ - **A browser API that needs a secure context is absent on the origin the docs promise.** Guard the
120
+ feature, not the call: `copyText` (`uis/stock/src/lib/clipboard.ts`) falls back to `execCommand` and
121
+ returns a verdict, or a button is dead on a LAN page; `uis/stock/test/clipboard-source.test.ts`
122
+ fails any other file that names `navigator.clipboard`.
123
+ - **A row of chrome is measured at 320 px with the tap floor counted.** No mount can measure a
124
+ layout, so `uis/stock/test/topbar-width.test.ts` pins the declarations that keep the title from
125
+ collapsing to 0 px.
126
+ - **A retention knob bounds the directory, not a loop.** Derive the set from the directory once
127
+ (`ownedFiles`/`retained`, `src/services/log-files.ts`) so the list, the size and the tail agree with
128
+ `readdir`, and prune inside `rotate` (`test/services/log-files.test.ts`).
129
+ - **A file a route hands back is streamed, and the bound decides how much it matters.** `logs.maxBytes`
130
+ allows 100 MB per rotation, so `createReadStream` + `stat` for `Content-Length`, in both routes. A
131
+ schema ceiling is not a reason to buffer: it is the size a person downloads at.
132
+ - **A page the panel serves must not be blank without a CDN.** Render real content from
133
+ `spec.json` first (`src/openapi-reference.ts`), then load any richer browser as optional
134
+ enhancement, **pinned** — an unpinned `import` from a CDN is a third party that can break the
135
+ panel's page. Before blaming a library for being online-only, drive its self-hosted build offline:
136
+ the claim is usually about the integration, not the library.
137
+ - **An entry's server is not always the process the panel spawned.** A compose entry's containers
138
+ outlive their wrapper, so resolve what the entry *declares it runs* (`composeTarget`), stop that,
139
+ and decide from a **fresh listing** — never the signal or `docker stop`'s exit code, which is 0 for
140
+ a container it could not end. A survivor is a `conflict` naming it (`src/providers/docker.ts`).
141
+ - **A per-frame path may not call a syscall per server.** The frame is built once a second and once
142
+ per request, so anything reading the host, the filesystem or the process table from a view builder
143
+ is cached on its own clock, not merely memoised per call (`lanAddress`, `src/helpers/bind.ts`).
144
+ - **A generated config says what it means for every branch, not just the one it names.** A name no
145
+ policy names gets the engine's **default** (the public CA), not "no automation" — so every local
146
+ name must be named in the internal policy too. A state describing something that has not happened
147
+ is a promise: decide `local` from the leaf in the store, not the hostname's shape.
114
148
  - **A metric with no reading is absent, never zero.** A scrape has no page to qualify a number, so an
115
149
  alerted-on gauge published as `0` from an unsampled view is indistinguishable from a healthy one
116
150
  and silences the rule that exists to catch it. Omit the series (`src/api/metrics.ts`), and never
117
151
  suffix `_total` a value that a user action resets — no series here is a counter, and
118
152
  `test/api/panel.test.ts` enumerates the scrape and fails on a `_total` name or a `counter` type.
153
+ - **A reading is labelled with what it measured, and a fallback must measure the same thing.** The
154
+ "CPU temp" tile took `Math.max` over every hwmon chip, so a box with an NVMe reported the **disk's**
155
+ temperature as the CPU's — and fired the temperature alert on it. Pick the sensor *by name*
156
+ (`coretemp`/`k10temp`/`x86_pkg_temp`/`cpu-thermal`, then `acpitz`), and take the max only inside that
157
+ tier, because a CPU package honestly has several dies. `pickCpuTemperature` (`src/providers/host.ts`)
158
+ is the one place that decides, so it is testable without a sensor. **A platform with no sensor
159
+ reports `null` and the UI says `n/a`** — WSL2 exposes no thermal zone at all, and the Windows host's
160
+ `MSAcpi_ThermalZoneTemperature` returns a constant 20 °C whatever the load, so reaching for it
161
+ would publish a fabricated number in the tile that exists to warn about heat.
162
+ - **A throttle window belongs to a message that arrived.** A send that failed must give its window
163
+ back (`releaseCooldown`), or the alert that would have reached a recovering receiver is the one the
164
+ outage took. Undo only the deadline *this* send armed; `notify()` is fire-and-forget.
165
+ - **A header is a byte string, and a stub does not make it one.** HTTP headers are Latin-1, so
166
+ validate at the door (`headerProblem`/`parseHeaders`) rather than let a `ByteString` engine message
167
+ land on a person's row, and treat a header name as case-insensitive
168
+ (`test/services/notifications.test.ts`).
119
169
  - **Name the cause the fix follows, not the one the code path suggests.** Node reports a missing
120
170
  working directory and a missing program with the same `ENOENT`, so `describeSpawnError` checks the
121
171
  resolved `cwd` **and** whether the field holds a whole command line before it blames the command —
@@ -177,6 +227,11 @@ workspace config guard, so a busy default port turns config tests red for the wr
177
227
  when an apply leaves pieces behind (`src/cli/backup.ts`). The same shape is why a scoped id is
178
228
  checked against the plan in **both** directions: `--exclude` with a typo excludes nothing, and an
179
229
  archive restored that way carries exactly the credentials the person meant to drop.
230
+ - **An archive outlives the release that wrote it.** Read a snapshot through the migrations `migrate`
231
+ would run (`liftArchived`, `src/services/backups.ts`), write the **lifted** file, and stamp it with
232
+ the release that wrote it; the newer direction stays a refusal from the manifest.
233
+ - **A summary line that disagrees with the lines above it is a bug.** Count every outcome a command
234
+ can have.
180
235
  - **Conventional commits** — changelogen derives the changelog and `scripts/check-release-version.mjs`
181
236
  the version bump. Below 1.0 the **minor is the breaking channel**: a fix is a patch, a minor means
182
237
  someone has to read the release notes and act — ask what the user has to do, not whether the commit
@@ -233,6 +288,16 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
233
288
  per-workspace service through `PanelService.requireWorkspace(id)`, never a module global.
234
289
  - **A restore writes only where a config says** — archive allowlist, `origin` matching first, symlinks
235
290
  never recreated.
291
+ - **A declared path is the capture boundary, and its bytes keep their modes.** *Both* directions of a
292
+ backup obey the declared path: the restore may not write through a link that leaves it, and the
293
+ capture may not read through one — a `media -> /mnt/nas` link inside a declared `data/` put the whole
294
+ share in every archive, and `du` on the declared path still said empty. The allowlist is a *move*
295
+ rule, not a character rule: `My Photos/` and `ünïcode/日本語.txt` are what a real data tree holds, so
296
+ a `\w` allowlist refused the archive the panel had just written. And a mode is part of the data —
297
+ `0600`/`0700`/`0755` travel, a setuid bit does not — because a restore that widens a secret to `0644`
298
+ changes who can read what the backup existed to protect.
299
+ `src/providers/archive.ts` (`walk`, `permissionBits`), `src/services/backups.ts`
300
+ (`isSafeArchiveEntry`), `test/providers/archive.test.ts`.
236
301
  - **A port is only ever freed from a fresh lookup, never a quoted pid.** `free-port` re-lists the
237
302
  listeners and refuses any in `supervisedPids()` instead of killing it; a docker-published port has
238
303
  no pid this user may see, so the container docker reports publishing *that* port is stopped instead.
@@ -251,6 +316,19 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
251
316
  - **The reverse proxy's engine is a process the panel owns, not a server entry.** Its config is applied
252
317
  through the engine's admin API (atomic, never hand-edited), it runs under the same nanny a
253
318
  `persistent: true` entry uses, and its admin endpoint stays panel-side.
319
+ - **A claim that a dependency touches nothing else has to be checked against the dependency.** The
320
+ proxy docs said "nothing else on the machine is touched", and the engine's own log said otherwise on
321
+ the very first start: `pki.ca.local | installing root certificate (you might be prompted for
322
+ password)` then `certificate installed properly in linux trusts` — the local CA's root goes into
323
+ `/etc/ssl/certs`, which is why a `.lan` name is trusted at all, and why that first start needs
324
+ `sudo`. Measured: one new `Caddy_Local_Authority_-_2026_ECC_Root*.pem` per engine data directory, so
325
+ two homes on one box leave two roots, and a root outlives the `.hh` it came from. The knob exists
326
+ (`apps.pki.certificate_authorities.local.install_trust`, verified by `POST /load`: `install_trust`
327
+ under `ca`, under `apps.tls`, and on the issuer are all `unknown field`) and the panel does not set
328
+ it, which is the right default — but the doc has to say what happens. Any run of the engine against
329
+ a scratch home therefore **writes the host's trust store**; say so and clean up the root and its
330
+ `/etc/ssl/certs` hash symlinks, or the next round inherits a machine with a dozen dead CAs.
331
+
254
332
  - **Cross-platform is a hard requirement.** Linux/macOS/Windows: `/proc` vs `ps` vs Win32_Process,
255
333
  process groups vs `taskkill /T`, graceful fallbacks, no shell utilities assumed. Three Windows
256
334
  behaviours no other runner here can exercise, so each is decided in **one shared helper** rather
package/README.md CHANGED
@@ -243,7 +243,7 @@ means the panel's default workspace.
243
243
  | `GET /api/state` | the full snapshot: global settings, every workspace with its servers, host vitals | ❌ |
244
244
  | `GET`/`POST /api/workspaces`, `PATCH`/`DELETE /api/workspaces/:id` | the registry: list, create, rename, remove | ❌ |
245
245
  | `GET /api/events` | SSE: the live state, plus logs (`?logs=0`, `?serverId=…`; a `server` payload carries its `workspaceId`) | ❌ |
246
- | `GET`/`POST /api/servers`, `POST /api/servers/start-all`, `POST /api/servers/stop-all` | that workspace's entries, and its lifecycle for all of them | ✅ |
246
+ | `GET`/`POST /api/servers`, `POST /api/servers/start-all`, `POST /api/servers/stop-all` | that workspace's entries, and its lifecycle for all of them (`?withPersistent=true` ends the entries that outlive the panel) | ✅ |
247
247
  | `GET`/`PATCH`/`DELETE /api/servers/:id`, `PUT /api/servers/:id` | one entry — `PUT` creates or replaces it, so a re-run converges | ✅ |
248
248
  | `POST /api/servers/:id/{start,stop,restart}`, `POST /api/servers/:id/free-port` | one entry's lifecycle, and freeing its port | ✅ |
249
249
  | `GET /api/servers/:id/logs`, `GET /api/servers/:id/stream` | that entry's buffered lines, and its SSE | ✅ |
@@ -283,7 +283,11 @@ stop, a delete or a manual start can lower, so no name ends in `_total`.
283
283
  comes back as one envelope (`{ message, code, detail }`) with a stable `code` a tool can branch on. The
284
284
  document declares its own `securitySchemes` (`bearerAuth`), every documented 2xx carries a schema, and
285
285
  each operation is tagged — so `openapi-typescript`, `openapi-generator` or a docs renderer can generate
286
- a working client without hand-written glue.
286
+ a working client without hand-written glue. `/openapi/ui` builds its route index from the spec itself, so
287
+ it stays readable on a box with no internet; the richer interactive browser it also offers is fetched
288
+ from a **version-pinned** CDN and is optional — the plain index is what you get when that CDN is
289
+ unreachable. Scalar's bundle does render offline when self-hosted, but it is 4.9 MB, so the index is the
290
+ cheaper trade for a panel that ships no other web assets.
287
291
 
288
292
  </details>
289
293
 
@@ -314,15 +318,15 @@ can be told what to be: *"Help me build a UI for home-hosted: nostalgic game the
314
318
  | ♻️ **Auto-restart** | Exponential backoff on crash, with the counter reset once a process stays up. The budget is remembered across a restart of the panel. |
315
319
  | 🩺 **Health that acts** | TCP or HTTP probes per server: warn, then force a restart — bounded by the same retry budget as a crash, so a sick entry stops instead of looping. Ports are checked before starting, and a program that [restarts itself](./docs/SERVERS.md#when-a-program-restarts-itself) can be followed or replaced. |
316
320
  | 🔗 **Ordered startup** | `dependsOn` waits for a dependency to be *healthy* — not merely spawned. `stop-all`/`down` stop dependents before their dependencies; stopping one server names the dependents it leaves running. [SERVERS.md](./docs/SERVERS.md#field-reference) |
317
- | 📜 **Logs** | Live per-server stream, buffer plus rotated files on disk, search, filter to one stream, download, one click to clear. |
318
- | 📈 **Resources** | CPU and RSS per process tree — the summed containers for a compose entry — with an optional memory ceiling that restarts the entry. |
319
- | 🌡️ **Host vitals** | CPU usage, memory, swap, disk and CPU temperature, plus the load average as a per-cpu count, with thresholds that notify once and again on recovery. |
321
+ | 📜 **Logs** | Live per-server stream, buffer plus rotated files on disk, search, filter to one stream, download, one click to clear. `Keep rotated files` in **Workspace Settings** bounds the directory, and the search reads every rotation it keeps — lowering it deletes the extras. |
322
+ | 📈 **Resources** | CPU and RSS per process tree — the summed containers for a compose entry — with an optional memory ceiling that restarts the entry. Stopping a compose entry stops its containers even when the wrapper is gone, and says so if one survives. [SERVERS.md](./docs/SERVERS.md#docker-and-compose) |
323
+ | 🌡️ **Host vitals** | CPU usage, memory, swap, disk and CPU temperature, plus the load average as a per-cpu count, with thresholds that notify once and again on recovery. Where the OS exposes no sensor — a WSL2 guest above all — the tile says `n/a`; [`setup-temp --wsl`](./docs/SERVERS.md#cpu-temperature-where-the-os-exposes-none) bridges to the Windows host. |
320
324
  | 🤖 **Token API** | Scripts and agents drive it with `Authorization: Bearer` — no browser, no session. [↑](#-agents-scripts-and-tools) |
321
325
  | 🔔 **Notifications** | Telegram and webhooks (ntfy, Discord, Slack, anything) on crash, unhealthy, recovery, host thresholds and DNS changes. Toggles and throttle set once; each destination inherits or overrides. [Setup](./docs/NOTIFICATIONS.md). |
322
326
  | 🌐 **Dynamic DNS** | Keep hostnames pointed at your public IP — Cloudflare, Namecheap, Spaceship, Porkbun, GoDaddy, Gandi and more. [DDNS.md](./docs/DDNS.md) |
323
327
  | 🔀 **Reverse proxy** | One Caddy engine in front of everything, with automatic HTTPS: `git.example.com` → a Gitea entry, `panel.example.com` → the panel itself. Installed and supervised by it. [Details](./docs/REVERSE_PROXY.md) |
324
328
  | 💾 **Backups** | One `.zip` of the panel and the workspaces you pick — plain or AES-256, picked per item, from the panel or the CLI. [Details](#-backups). |
325
- | 🌍 **Nine languages** | English, Vietnamese, Chinese, Japanese, Spanish, Korean, Russian, French, German — picked on the login page or in **Global settings → Language**, kept per browser. |
329
+ | 🌍 **Nine languages** | English, Vietnamese, Chinese, Japanese, Spanish, Korean, Russian, French, German — picked on the login page or in **Global settings → Language**, kept per browser. Action toasts included. The NOC console ships English-only on purpose; its density is the point. |
326
330
  | 🎨 **BYOU — Bring Your Own UI** | Upload a static build, `ui-update` to follow its releases, `ui-revert` to go back. [UI_CREATION.md](./docs/UI_CREATION.md) |
327
331
  | 🔐 **Security** | Cookie sessions, API tokens, scrypt hashes, per-IP lockout, optional TLS, and a refusal to expose itself without a password. |
328
332
  | 🧩 **Bring any program** | A server is a `command`, its args and a working directory — plus optional `dataEnvs`, `dependsOn` and `dump`/`load` hooks. Presets fill the form; nothing requires one. [Fields](./docs/SERVERS.md) |
@@ -384,8 +388,8 @@ restarts itself), and how hand-edits are validated: [SERVERS.md](./docs/SERVERS.
384
388
  | command | |
385
389
  | --- | --- |
386
390
  | `home-hosted up` | start the panel detached, and keep it alive in the background |
387
- | `home-hosted down` | stop it cleanly — supervised processes included, persistent entries left running |
388
- | `home-hosted restart` | `down`, then `up` — or `restart <id>` to restart one server, leaving the panel up |
391
+ | `home-hosted down` | stop it cleanly — supervised processes included, [persistent entries](./docs/SERVERS.md#persistent-entries) left running (`--with-persistent` stops those too) |
392
+ | `home-hosted restart` | `down`, then `up` — or `restart <id>` to restart one server, leaving the panel up (`--with-persistent` restarts the persistent entries as well) |
389
393
  | `home-hosted status` | pid, URL, health, uptime, state and log paths (`--json` for scripts). Edge cases are under [what `status` tells you](#-cli). |
390
394
  | `home-hosted start <id>` | start one server in the default workspace — and anything it `dependsOn` (`--workspace <id>`). `--free-port` frees the port first, then starts |
391
395
  | `home-hosted stop <id>` | stop one server, nothing else (`--workspace <id>`) |
@@ -409,12 +413,12 @@ restarts itself), and how hand-edits are validated: [SERVERS.md](./docs/SERVERS.
409
413
  ```text
410
414
  up -p/--port --host --open --no-autostart --foreground --print-config
411
415
 
412
- down (no flags)
416
+ down --with-persistent
413
417
  status --json
414
418
  logs --lines <n> --follow --json
415
419
  backup [list|create|restore] [<name> | --from <path>] (--include <ids> | --all) [--exclude <ids>] --password --confirm --json
416
420
  start, stop <id> [-w/--workspace <id>] (both need the panel up)
417
- restart [<id>] [-w/--workspace <id>] (no id: the panel; with one: that server)
421
+ restart [<id>] [-w/--workspace <id>] [--with-persistent] (no id: the panel; with one: that server)
418
422
  init --dir --name --pm --no-install -y/--yes
419
423
  set-password --clear
420
424
  set-token --generate --clear
@@ -506,6 +510,12 @@ the move on its first run; 0.8.0 then starts against the result.
506
510
  | `gone` | it is not running; the record is stale and may be cleared |
507
511
  | `recycled` | the OS has handed the recorded pid to **another** process. The record is stale, but a signal would hit a stranger, so only the token-authenticated shutdown touches it |
508
512
 
513
+ Piping a command into `head`, `grep -q` or anything that stops reading early is ordinary shell and it
514
+ works: the command exits **0**, not with a broken-pipe error, so `set -o pipefail` stays happy.
515
+
516
+ `--json` writes one document to stdout on success and nothing to stdout on a refusal — the reason, and
517
+ any list it explains, go to stderr, so a script can parse stdout without filtering prose out of it.
518
+
509
519
  </details>
510
520
 
511
521
  ---
@@ -575,6 +585,12 @@ a PEM pair and let home-hosted terminate TLS itself.
575
585
  | `on` | any peer | the proxy is the only way in. **The client address is then the caller's own header**, so the per-IP lockout counts per *forged* address and stops throttling brute force; the panel warns at startup if that panel is exposed |
576
586
  | `off` | nobody | nothing in front, or the proxy sets no header |
577
587
 
588
+ **A plain-`http://` LAN address is not a secure context.** Browsers withhold some APIs from it, and the
589
+ panel works around the one it uses: **Copy** (the archive directory, the logs directory, the TLS
590
+ fingerprint, a server's JSON config) falls back to the legacy clipboard call, so it still works from
591
+ `http://192.168.1.201:3999`. Where even that is refused, the button says *Could not copy* instead of
592
+ doing nothing.
593
+
578
594
  **Port conflicts.** A busy port is named — `port 4010 is already in use (pid 4242)` — and can be
579
595
  resolved from a confirmation popover. The holder is looked up again at that moment, never taken from
580
596
  the message, and anything the panel supervises is refused rather than killed. A server that
@@ -655,8 +671,10 @@ Generated directories (`node_modules`, `dist`, `.next`, framework caches) are sk
655
671
  <details>
656
672
  <summary><b>🔑 Restoring a secret, and what not to restore</b></summary>
657
673
 
658
- An archive records the release and config schema that wrote it; a restore refuses a newer schema
659
- outright rather than restoring the parts it recognizes.
674
+ An archive records the release and config schema that wrote it. A restore refuses a **newer** schema
675
+ outright rather than restoring the parts it recognizes, and **lifts an older one** through the same
676
+ migrations `home-hosted migrate` would run — the archive you take before an upgrade is the one you
677
+ reach for afterwards, so its configs are brought to this release's shape as they are written back.
660
678
 
661
679
  Ticking a **single secret** merges by field — restoring the Telegram token leaves the DDNS
662
680
  credentials alone. Ticking the whole **Secrets** entry replaces that file with the archive's copy.
@@ -687,6 +705,13 @@ literal absolute path is restored to that same path.
687
705
  placed under a workspace the archive says it belongs to — if that workspace's `servers.config.json` is
688
706
  not part of the restore, its data is reported as skipped rather than guessed at.
689
707
 
708
+ **A declared path is the capture boundary.** A symlink *inside* a declared directory that resolves
709
+ outside it is left out of the archive rather than followed, so a `media -> /mnt/nas` link does not
710
+ silently pull a share you never declared into every backup. A link that stays inside is captured once,
711
+ under the first name the walk reaches it by, and a declared path that is *itself* a symlink is
712
+ captured through. File permission bits travel: a `0600` key comes back `0600`, a `0700` directory
713
+ `0700`, a `0755` script executable — a backup must not widen access to what it was taken to protect.
714
+
690
715
  </details>
691
716
 
692
717
  <details>
@@ -801,7 +826,8 @@ the same way: every supervised process tree is stopped before the panel exits.
801
826
 
802
827
  An entry marked `persistent` is the exception, and `down` names it instead of stopping it: it runs
803
828
  under its own nanny process, keeps logging, and is reattached by the next panel
804
- ([SERVERS.md](./docs/SERVERS.md#persistent-entries)).
829
+ ([SERVERS.md](./docs/SERVERS.md#persistent-entries)). Add `--with-persistent` to stop those too —
830
+ with the panel up or after it has already gone, since each nanny's state file is enough.
805
831
 
806
832
  </details>
807
833