home-hosted 0.9.8 → 0.9.10
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 +44 -1
- package/README.md +32 -5
- package/dist/cli.js +548 -218
- package/dist/cli.js.map +1 -1
- package/docs/RESTORE_DEMO.md +48 -13
- package/docs/SERVERS.md +10 -2
- package/docs/UI_CREATION.md +1 -1
- package/package.json +1 -1
- package/uis/stock/dist/assets/de-BP4HfMC9.js +1 -0
- package/uis/stock/dist/assets/es-Cehmpy7G.js +1 -0
- package/uis/stock/dist/assets/fr-DN3eC8Ey.js +1 -0
- package/uis/stock/dist/assets/{index-CC5-LZ39.js → index-B9Eov7QO.js} +12 -12
- package/uis/stock/dist/assets/index-DGtvgCsU.css +2 -0
- package/uis/stock/dist/assets/ja-CYAuNjfG.js +1 -0
- package/uis/stock/dist/assets/ko-wQEmDRMK.js +1 -0
- package/uis/stock/dist/assets/ru-BtbhojJ0.js +1 -0
- package/uis/stock/dist/assets/vi-BfUCVFk_.js +1 -0
- package/uis/stock/dist/assets/zh-CN-DEhi0m5s.js +1 -0
- package/uis/stock/dist/index.html +2 -2
- package/uis/stock/dist/ui.json +3 -3
- package/uis/stock/dist/assets/de-bpsNMi6m.js +0 -1
- package/uis/stock/dist/assets/es-DDmL2M4L.js +0 -1
- package/uis/stock/dist/assets/fr-Bt_Ada9D.js +0 -1
- package/uis/stock/dist/assets/index-BdB75ugb.css +0 -2
- package/uis/stock/dist/assets/ja-BBk-_Z4Q.js +0 -1
- package/uis/stock/dist/assets/ko-Cd55rvyJ.js +0 -1
- package/uis/stock/dist/assets/ru-Dbon-iuU.js +0 -1
- package/uis/stock/dist/assets/vi-CjeD5IZq.js +0 -1
- package/uis/stock/dist/assets/zh-CN-CAMCsc0B.js +0 -1
package/AGENTS.md
CHANGED
|
@@ -111,6 +111,43 @@ 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 metric with no reading is absent, never zero.** A scrape has no page to qualify a number, so an
|
|
115
|
+
alerted-on gauge published as `0` from an unsampled view is indistinguishable from a healthy one
|
|
116
|
+
and silences the rule that exists to catch it. Omit the series (`src/api/metrics.ts`), and never
|
|
117
|
+
suffix `_total` a value that a user action resets.
|
|
118
|
+
- **Name the cause the fix follows, not the one the code path suggests.** Node reports a missing
|
|
119
|
+
working directory and a missing program with the same `ENOENT`, so `describeSpawnError` checks the
|
|
120
|
+
resolved `cwd` **and** whether the field holds a whole command line before it blames the command —
|
|
121
|
+
otherwise a deploy under systemd reads "`node` is not installed" while `node` is fine and only the
|
|
122
|
+
launch directory is wrong, and a pasted `node server.js` reads the same way while `node` is
|
|
123
|
+
installed. The same rule decides which advice a refused start prints: a config that needs `migrate`
|
|
124
|
+
must say so rather than "install the release", and a file that cannot be parsed must not claim a
|
|
125
|
+
migration `migrate` cannot perform. Ask what the person will *do* with the sentence before choosing
|
|
126
|
+
it — and when a function's own docstring names the misreading it exists to prevent, that is a claim
|
|
127
|
+
to test, not a description of the code.
|
|
128
|
+
- **One envelope per reader.** This API answers `{ message, code, detail }` for a thrown error and
|
|
129
|
+
`{ ok: false, error }` for a refused lifecycle action. A client that reads one field shows
|
|
130
|
+
`request failed with 409` for the other, losing the only sentence that explains the refusal while
|
|
131
|
+
the card beside it prints that sentence in full. Read both in **one** helper
|
|
132
|
+
(`failureMessage`, `src/shared/api-client.ts`) and scan for the hand-rolled fallback — a unit test
|
|
133
|
+
cannot see a call site that has not been written yet.
|
|
134
|
+
- **A list card and its detail page answer the same question; fix both.** The card is a summary of a
|
|
135
|
+
page someone opens *precisely because the summary was not enough* — so a fact the card states and
|
|
136
|
+
the page omits is worse than either alone. A stopped entry's card learned to say "not running"
|
|
137
|
+
where the chart's default promised "collecting…", and the detail page kept the promise on all
|
|
138
|
+
three of its charts, on the one screen a confused person reaches. A disabled entry's card showed a
|
|
139
|
+
`disabled` chip; its detail page greyed out Start and Restart and said nothing, losing the only
|
|
140
|
+
explanation on the way in. When you give a surface an empty state, a reason or a qualifier, grep
|
|
141
|
+
for the other surface that renders the same field and land it there too — and prefer a shared
|
|
142
|
+
component or a scan test over two call sites remembering in parallel.
|
|
143
|
+
- **A refused operation is a failure, never an empty success.** The backup service answers a *plan*
|
|
144
|
+
for every archive, including ones it cannot read: `plan.error` carries the refusal and `items` is
|
|
145
|
+
empty. A caller that reads only `items` reports "restored 0 items" with exit 0, which on a blank
|
|
146
|
+
host — the one situation where nobody can check the result — is indistinguishable from a restore
|
|
147
|
+
that worked. Read `error`/`needsPassword` before anything else, exit non-zero, and print `skipped`
|
|
148
|
+
when an apply leaves pieces behind (`src/cli/backup.ts`). The same shape is why a scoped id is
|
|
149
|
+
checked against the plan in **both** directions: `--exclude` with a typo excludes nothing, and an
|
|
150
|
+
archive restored that way carries exactly the credentials the person meant to drop.
|
|
114
151
|
- **Conventional commits** — changelogen derives the changelog and `scripts/check-release-version.mjs`
|
|
115
152
|
the version bump. Below 1.0 the **minor is the breaking channel**: a fix is a patch, a minor means
|
|
116
153
|
someone has to read the release notes and act — ask what the user has to do, not whether the commit
|
|
@@ -179,7 +216,13 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
|
|
|
179
216
|
through the engine's admin API (atomic, never hand-edited), it runs under the same nanny a
|
|
180
217
|
`persistent: true` entry uses, and its admin endpoint stays panel-side.
|
|
181
218
|
- **Cross-platform is a hard requirement.** Linux/macOS/Windows: `/proc` vs `ps` vs Win32_Process,
|
|
182
|
-
process groups vs `taskkill /T`, graceful fallbacks, no shell utilities assumed.
|
|
219
|
+
process groups vs `taskkill /T`, graceful fallbacks, no shell utilities assumed. Three Windows
|
|
220
|
+
behaviours no other runner here can exercise, so each is decided in **one shared helper** rather
|
|
221
|
+
than at the call site: a state file hand-edited in a Windows editor carries a byte-order mark or is
|
|
222
|
+
UTF-16, so it is read through `readStateFile` (`src/helpers/config-text.ts`) and never
|
|
223
|
+
`readFileSync(file, 'utf8')`; a bare command found in `node_modules/.bin` must resolve to a shim
|
|
224
|
+
Windows can start, never the `#!/bin/sh` script written beside it (`resolveCommand`); and text
|
|
225
|
+
printed **for a person to paste** is quoted for the shell it targets (`cdCommand`).
|
|
183
226
|
- **Writes are atomic** (`writeFileAtomic`) and validated before commit.
|
|
184
227
|
|
|
185
228
|
## How to work here
|
package/README.md
CHANGED
|
@@ -190,6 +190,7 @@ home-hosted up --foreground # stays in the foreground, logs to stderr
|
|
|
190
190
|
Description=home-hosted
|
|
191
191
|
[Service]
|
|
192
192
|
User=$YOUR_USER
|
|
193
|
+
WorkingDirectory=/srv/home-hosted
|
|
193
194
|
ExecStart=/usr/local/bin/home-hosted up --foreground
|
|
194
195
|
Environment=HHOSTED_HOME=/srv/home-hosted
|
|
195
196
|
Restart=always
|
|
@@ -197,6 +198,13 @@ Restart=always
|
|
|
197
198
|
WantedBy=multi-user.target
|
|
198
199
|
```
|
|
199
200
|
> [!CAUTION]
|
|
201
|
+
> **`WorkingDirectory` is not optional.** Relative entry paths — a server's `cwd`, a
|
|
202
|
+
> `{projectDir}` placeholder, a relative `dataEnvs` — resolve against the directory the panel is
|
|
203
|
+
> started from. systemd starts a unit in `/` unless told otherwise, so without it every relative
|
|
204
|
+
> path in your `servers.config.json` points somewhere under `/` and the entries fail to start.
|
|
205
|
+
> Docker does the same unless you pass `-w`. Set it to the directory holding the config you run
|
|
206
|
+
> from, or pin it explicitly with `Environment=HHOSTED_PROJECT=/srv/home-hosted`.
|
|
207
|
+
>
|
|
200
208
|
> Note: change `$YOUR_USER` to your actual user account, or remove for `root`.
|
|
201
209
|
> You could also change `/srv/home-hosted` to change where the data stores.
|
|
202
210
|
|
|
@@ -241,13 +249,24 @@ default workspace.
|
|
|
241
249
|
| `PUT`/`DELETE /api/notifications/destinations/:id/token`, `POST /api/notifications/destinations/:id/{test,detect-chats}`, `POST /api/notifications/test-webhook` | one destination's bot credential, and a test send | ✅ |
|
|
242
250
|
| `GET`/`PATCH /api/settings/workspace` | server defaults, logs, notifications | ✅ |
|
|
243
251
|
| `GET`/`PATCH /api/settings` | panel-wide: listener, authentication, TLS, host vitals, backups | ❌ |
|
|
244
|
-
| `GET`/`POST /api/backups`, restore | archives | ❌ |
|
|
252
|
+
| `GET`/`POST /api/backups`, restore | archives; a create or restore body selects with `include` and/or `exclude` | ❌ |
|
|
245
253
|
| `GET`/`PATCH /api/proxy`, `POST /api/proxy/{engine,start,stop,apply,revert}`, `PUT`/`DELETE /api/proxy/certificates/:id` | the reverse proxy: its engine, its route table, and its uploaded certificates | ❌ |
|
|
246
254
|
| `GET /healthz` | no session needed — the one an external monitor wants (its per-server detail needs a credential) | ❌ |
|
|
247
|
-
| `GET /api/metrics` | Prometheus text (needs a token or session, like every `/api` route) | ❌ |
|
|
255
|
+
| `GET /api/metrics` | Prometheus text (needs a token or session, like every `/api` route) — scrape it with a bearer token | ❌ |
|
|
248
256
|
|
|
249
257
|
✅ takes `?workspace=<id>`; ❌ is panel-wide. Omitting `?workspace` means `default` workspace is used.
|
|
250
258
|
|
|
259
|
+
**Scraping it.** Point your scraper at `/api/metrics` with the token from `home-hosted set-token
|
|
260
|
+
--generate` as `Authorization: Bearer …`, because it lives under `/api` like every other route.
|
|
261
|
+
`hh_host_cpu_used_percent` is the machine's own CPU share (0–100) — the figure to alert on.
|
|
262
|
+
`hh_host_load1_per_cpu` beside it is a **count of runnable tasks per core**, not a percentage:
|
|
263
|
+
`1.0` means one core's worth of work waiting, so it is fine on a busy box and not comparable with the
|
|
264
|
+
percentage above. A host gauge appears only once the host has been sampled, so a series that is
|
|
265
|
+
*absent* means "no reading", never "zero": do not let a dashboard fill that in. `hh_server_restarts_total`
|
|
266
|
+
counts the retry attempts spent on a server's **current** crash sequence and drops back to `0` when
|
|
267
|
+
someone starts it, so it is a state, not a counter to `rate()` — `hh_server_crashes_24h` is the one
|
|
268
|
+
that only grows within its window.
|
|
269
|
+
|
|
251
270
|
`GET /openapi/spec.json` describes all of it, `/openapi/ui` is the browsable version, and every error
|
|
252
271
|
comes back as one envelope (`{ message, code, detail }`) with a stable `code` a tool can branch on. The
|
|
253
272
|
document declares its own `securitySchemes` (`bearerAuth`), every documented 2xx carries a schema, and
|
|
@@ -449,11 +468,14 @@ Everything binds `127.0.0.1` until you say otherwise.
|
|
|
449
468
|
|
|
450
469
|
- **A password is required to expose the panel.** Replace the default, then bind to `lan` — in the
|
|
451
470
|
UI, in the config, or with `--host lan`. The same guard applies in all three places.
|
|
452
|
-
- **Sessions** live in memory only; the cookie is `HttpOnly` and `SameSite=Strict`, and
|
|
453
|
-
|
|
471
|
+
- **Sessions** live in memory only; the cookie is `HttpOnly` and `SameSite=Strict`, and it is an
|
|
472
|
+
**idle** timeout — every request slides both the session and the cookie, so a panel in regular use
|
|
473
|
+
stays signed in and one left alone for the configured lifetime does not. The login route locks out
|
|
474
|
+
repeated failures per IP — see the `trustProxy` note below for when that is advisory.
|
|
454
475
|
- **API tokens** for scripts and agents: `home-hosted set-token --generate` prints one once, and a
|
|
455
476
|
request proves itself with `Authorization: Bearer …` — the same access as a signed-in browser,
|
|
456
|
-
stored as a SHA-256 hash, revoked with `set-token --clear`.
|
|
477
|
+
stored as a SHA-256 hash, revoked with `set-token --clear`. Changing the panel password does
|
|
478
|
+
**not** revoke a token, so rotate it with `set-token --generate` if one may have leaked.
|
|
457
479
|
- **Port conflicts** are named — `port 4010 is already in use (pid 4242)` — and can be resolved from
|
|
458
480
|
a confirmation popover on that banner or card. The process is looked up again at that moment,
|
|
459
481
|
never taken from the message, and anything the panel supervises is refused, not killed. A server
|
|
@@ -751,6 +773,11 @@ expose them to an unprivileged process. Adopting a self-restarted process works
|
|
|
751
773
|
its argv instead of the environment marker; a launcher whose real process is a `.cmd` shim is the one
|
|
752
774
|
case it cannot see through, and `kill` is the answer there.
|
|
753
775
|
|
|
776
|
+
A config edited in Notepad or PowerShell is read as it is: the byte-order mark Notepad's "UTF-8 with
|
|
777
|
+
BOM" adds, and the UTF-16 that `>` and `Out-File` write, are both understood. A `command` naming a
|
|
778
|
+
project dependency resolves to the `.cmd`/`.exe` shim under `node_modules/.bin` rather than the
|
|
779
|
+
`#!/bin/sh` script beside it.
|
|
780
|
+
|
|
754
781
|
</details>
|
|
755
782
|
|
|
756
783
|
---
|