@astrofoundry/pi-astro 0.40.73 → 0.40.74
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/package.json
CHANGED
package/specialists/AGENTS.md
CHANGED
|
@@ -63,7 +63,7 @@ Wrappers ship as TypeScript and run under Node 24 type stripping: erasable synta
|
|
|
63
63
|
- `arcane manager-upgrade <version>` (`lib/arcane-manager.ts`) follows arcane/AGENTS.md "Manager upgrades": the official image's revision label must equal the release tag's commit (GitHub API), `manager-prepare` records `compose.before.yaml` and every container before the pin commit, the pin goes through the `arcane-gitops` checkout (`git` is exported from `lib/repo.ts` for this), the wait polls `gitops list` and the deployed Compose hash every 30 s for up to 30 minutes, then pull, cold backup, `up -d --no-deps --pull never`, and checks. Any failure before the restart reverts the pin (`stopped`); a failed check after it reverts the pin and runs `manager-rollback` (`rolled back`). The answer always exits 0 with `status`, so the bridge and the agent both see it.
|
|
64
64
|
- `research` is a pure forced-command wrapper: every call is one JSON request on stdin to `request` on VM 110 (`10.1.100.10`, user `spc-research`, key `SSH_KEY_SANDBOX`), whose entry hands it to `spc-research-op` as `researcher` (tracked in the homelab repository's `06-space-x-proxmox/research/system/`). The op attaches one playwright-cli session per Discord thread (`t<id>`) to the shared Chrome over CDP on `127.0.0.1:9222` and opens its own tab; cookie, storage, `run-code`, and browser lifecycle commands are refused. `script` runs the agent's code in the thread folder as `researcher` (5 minutes), on a VM that reaches only the internet (Mira's Sandbox zone plus the VM's own nftables). Defaults stay on Cortex in `work/research/defaults.json`, out of the sandbox's reach. `captcha-help` is in `RISKY`, so its owner approval is the moment the owner solved the challenge in the live view (`research-browser.37pla.net`); the bridge renders that ticket with the channel's `liveView` link.
|
|
65
65
|
- `media` runs trendarr unchanged: `trendarrCli` in `media.json` is its `dist/cli.js`, started with `process.execPath` because sudo's PATH has no node. Each call gets `HOME` set to a fresh `0700` directory under `~/.specialists/work/media/` that holds only `.trendarr/config.json` (`0600`, trendarr's own schema, built from the note fields and `media.json`) and is removed in `finally`; trendarr reads no environment variables and has no config flag, and Node's `os.homedir()` follows `$HOME` on POSIX. Every call passes `--json`; `init` is refused. An add prints trendarr's per-ID `results` and exits 0 even when trendarr exits 1 for a failed ID, because the gate shows only stderr on failure; other failures carry trendarr's stderr without its `warning:` lines, which go into the JSON as `warnings`. The bridge's slash commands and Add buttons call the same wrapper through the entry point (`extensions/astro-discord/media.ts`). `queue` and `queue-remove` (since 0.40.66) skip trendarr, which has no queue records: the wrapper calls `/api/v3/queue` of Radarr and Sonarr itself with the note's keys in the `X-Api-Key` header and prints only `stuckRecords` fields (no paths or download ids); `queue-remove` sends `DELETE /api/v3/queue/<id>?removeFromClient=true&blocklist=false`, needs `--confirm`, and is in `RISKY`. The `jellyfin` commands (since 0.40.68, pure parts in `lib/media-dates.ts`) exist because Jellyfin adds a renamed or moved file as a new item: the library rename of 2026-11-10 turned 873 of 875 episodes into "added today". `date-check` reads every movie, episode, season, and series from `/Items` (one request per type without a limit, because pages of an unsorted list can overlap), Radarr's and Sonarr's files, and each app's whole history from `/api/v3/history/since`; files match by their last path segments (`pathKey`: two for a movie, three for an episode), so the mount points may differ. `planDates` follows the arcane repository's `media/AGENTS.md`: a movie or episode gets its earliest successful import (`firstArrival`; without an import record the earliest of the file's own import date and its rename and deletion records, since a file a disk scan found has none), a season and a series their earliest episode, an empty season its series; only a date more than a day late changes, so a date only ever moves back, and an item Radarr or Sonarr has no file for is reported as unmatched and left alone. `date-repair --confirm` applies the plan through Jellyfin's own `POST /Items/<id>`, the call behind its metadata editor: the item as `GET /Items/<id>?userId=<an administrator>` returns it (without a user id an API key gets 400) with only `DateCreated` changed and `People` left out, because Jellyfin rewrites people only when the request carries them; a test on one episode showed only `DateCreated` and `Etag` differing afterwards. Jellyfin keeps running, and five failed updates stop the run. The API key travels as `Authorization: MediaBrowser Token="<key>"`, the scheme of the server's own `/api-docs/openapi.json` (12.4.0). `bazarr status` reads `/api/system/status` and `/api/system/health` with `X-API-KEY` and prints versions and issues only; the Sonarr and Radarr versions Bazarr reports show that it reaches them. Both read their own config shape (`jellyfinUrl`, `bazarrUrl`), so the trendarr commands run without those keys.
|
|
66
|
-
- `home` (since 0.40.70) reaches Home Assistant, VM 112 on SPACE-X at Mira (`homeAssistantUrl` in `home.json`, token `HOMEASSISTANT_TOKEN`), which replaced a Raspberry Pi with a failing SD card on 2026-11-12. `lib/home-assistant.ts` opens the WebSocket API (`/api/websocket`: `auth_required`, `auth` with the token, `auth_ok`), sends commands with ids, and closes; the wrapper runs on the installer's Node, which has a global `WebSocket`. The Supervisor's state (`/supervisor/info`, `/core/info`, `/os/info`, `/host/info`, `/resolution/info`, `/addons`) is reachable only through the `supervisor/api` command, because Core's REST proxy (`/api/hassio/...`) forwards logs and backups and nothing else (`PATHS_ADMIN` in Core's `hassio/http.py`, read at tag 2026.11.1); `logs` uses that proxy with `?lines=`. `status` prints named fields only (`pick`), so add-on options and addresses stay inside. `homeProblems` turns a snapshot into one line per finding: Core not running, safe or recovery mode, an unhealthy or unsupported Supervisor, its resolution issues, integrations that did not load (`setup_error`, `setup_retry`, ...), open repairs, waiting `update.*` entities, a newest backup older than 48 hours or failed for a location, a disk above 85 %; a part that could not be read is a line too (`unread`), never a pass. `update`, `restart`, `action` (any Home Assistant action with `target` and `data`), and `integration-remove` (since 0.40.71: `DELETE /api/config/config_entries/entry/<id>`, for leftovers such as the Pi's Bluetooth adapter after the move to a VM) change things and are in `RISKY`; all but `action` also need `--confirm`. Since 0.40.72 three generic doors reach everything Home Assistant's own interface can do, the model of the community's ha-mcp server without a second server that holds an administrator token: `ws <type> [json]` (any WebSocket command), `rest <get|post|put|delete> <path> [json]` (any route under `/api/`; dot segments, escapes, and `/api/websocket` refused), and `supervisor <get|post|put|delete> <endpoint> [json]` (through `supervisor/api`; logs and downloads refused because they are not JSON). Reads need no approval: `rest get`, `supervisor get`, and `ws-read`, which sends only the types in `READ_COMMANDS` of `lib/home-assistant.ts` (registries, lists, history, traces, dashboards, the helpers' `<domain>/list`; never `backup/config/info`, `application_credentials`, or `auth`, which return credentials). Everything else is in `RISKY` (`/^ws(\s|$)/` so that `ws-read` stays free). Generic answers pass `redactSecrets` and `bounded` (60,000 characters; a list keeps its first items). `restart` treats a connection Core closes as started, because Core often closes the socket before it sends the result. No Home Assistant API reads or writes files (ha-mcp needs its own component inside Home Assistant for that), so the `file-` commands (since 0.40.73, pure parts in `lib/home-files.ts`) go through the Advanced SSH & Web Terminal add-on (`a0d7b954_ssh`, port 22 on the host network): `files-setup` adds one `authorized_keys` line, `restrict,command="sudo -n /usr/local/bin/spc-home-entry \"$SSH_ORIGINAL_COMMAND\""`, and one `init_commands` line that writes the entry script, because the add-on copies `authorized_keys` lines verbatim and evaluates `init_commands` at every start (`init-ssh/run`, `init-user/run` of hassio-addons/app-ssh, read 2026-11-12); the owner's other options go back unchanged and are never printed, and `--no-password` empties the SSH password, which turns password login off. The script (`entry/remote/spc-home-entry.sh`, embedded as `ENTRY_SCRIPT`; a test compares them and runs it) serves YAML paths below `/homeassistant` without hidden folders, dot segments, or `secrets.yaml`, and copies the current file to `.spc-home-backups/<path>.<UTC stamp>` before every write, restore, and removal, under a stamp no copy has yet. The wrapper reads the add-on's port and user name from `/addons/a0d7b954_ssh/info`, masks secret-named values in `file-read` (`redactYaml`; a mask, not a boundary), refuses to write a text that carries `[redacted]`, and wraps every change in two configuration checks (`changeChecked`): a change that turns a valid configuration invalid is restored from the kept copy, one made while it was already invalid stays. The four changing commands and `files-setup` are in `RISKY`. The skill's table of commands was checked against Core 2026.11.1 and the Supervisor's route table. Arguments are checked before config and secret are read. The agent has no `read` tool. The morning run reads `home problems` (`homeStatus` in `daily-run.ts`): each line is an item under Home, and the tagged message posts once per set of problems. Cortex reaches `10.1.70.32` on TCP 8123, 4357, and 22 through the policies `Home Assistant at Mira - from Cortex` on both consoles.
|
|
66
|
+
- `home` (since 0.40.70) reaches Home Assistant, VM 112 on SPACE-X at Mira (`homeAssistantUrl` in `home.json`, token `HOMEASSISTANT_TOKEN`), which replaced a Raspberry Pi with a failing SD card on 2026-11-12. `lib/home-assistant.ts` opens the WebSocket API (`/api/websocket`: `auth_required`, `auth` with the token, `auth_ok`), sends commands with ids, and closes; the wrapper runs on the installer's Node, which has a global `WebSocket`. The Supervisor's state (`/supervisor/info`, `/core/info`, `/os/info`, `/host/info`, `/resolution/info`, `/addons`) is reachable only through the `supervisor/api` command, because Core's REST proxy (`/api/hassio/...`) forwards logs and backups and nothing else (`PATHS_ADMIN` in Core's `hassio/http.py`, read at tag 2026.11.1); `logs` uses that proxy with `?lines=`. `status` prints named fields only (`pick`), so add-on options and addresses stay inside. `homeProblems` turns a snapshot into one line per finding: Core not running, safe or recovery mode, an unhealthy or unsupported Supervisor, its resolution issues, integrations that did not load (`setup_error`, `setup_retry`, ...), open repairs, waiting `update.*` entities, a newest backup older than 48 hours or failed for a location, a disk above 85 %; the Supervisor's `no_current_backup` counts only while no backup is younger than 48 hours, because the Supervisor wants a backup of type full and Home Assistant's own backups are always partial; a part that could not be read is a line too (`unread`), never a pass. `update`, `restart`, `action` (any Home Assistant action with `target` and `data`), and `integration-remove` (since 0.40.71: `DELETE /api/config/config_entries/entry/<id>`, for leftovers such as the Pi's Bluetooth adapter after the move to a VM) change things and are in `RISKY`; all but `action` also need `--confirm`. Since 0.40.72 three generic doors reach everything Home Assistant's own interface can do, the model of the community's ha-mcp server without a second server that holds an administrator token: `ws <type> [json]` (any WebSocket command), `rest <get|post|put|delete> <path> [json]` (any route under `/api/`; dot segments, escapes, and `/api/websocket` refused), and `supervisor <get|post|put|delete> <endpoint> [json]` (through `supervisor/api`; logs and downloads refused because they are not JSON). Reads need no approval: `rest get`, `supervisor get`, and `ws-read`, which sends only the types in `READ_COMMANDS` of `lib/home-assistant.ts` (registries, lists, history, traces, dashboards, the helpers' `<domain>/list`; never `backup/config/info`, `application_credentials`, or `auth`, which return credentials). Everything else is in `RISKY` (`/^ws(\s|$)/` so that `ws-read` stays free). Generic answers pass `redactSecrets` and `bounded` (60,000 characters; a list keeps its first items). `restart` treats a connection Core closes as started, because Core often closes the socket before it sends the result. No Home Assistant API reads or writes files (ha-mcp needs its own component inside Home Assistant for that), so the `file-` commands (since 0.40.73, pure parts in `lib/home-files.ts`) go through the Advanced SSH & Web Terminal add-on (`a0d7b954_ssh`, port 22 on the host network): `files-setup` adds one `authorized_keys` line, `restrict,command="sudo -n /usr/local/bin/spc-home-entry \"$SSH_ORIGINAL_COMMAND\""`, and one `init_commands` line that writes the entry script, because the add-on copies `authorized_keys` lines verbatim and evaluates `init_commands` at every start (`init-ssh/run`, `init-user/run` of hassio-addons/app-ssh, read 2026-11-12); the owner's other options go back unchanged and are never printed, and `--no-password` empties the SSH password, which turns password login off. The script (`entry/remote/spc-home-entry.sh`, embedded as `ENTRY_SCRIPT`; a test compares them and runs it) serves YAML paths below `/homeassistant` without hidden folders, dot segments, or `secrets.yaml`, and copies the current file to `.spc-home-backups/<path>.<UTC stamp>` before every write, restore, and removal, under a stamp no copy has yet. The wrapper reads the add-on's port and user name from `/addons/a0d7b954_ssh/info`, masks secret-named values in `file-read` (`redactYaml`; a mask, not a boundary), refuses to write a text that carries `[redacted]`, and wraps every change in two configuration checks (`changeChecked`): a change that turns a valid configuration invalid is restored from the kept copy, one made while it was already invalid stays. The four changing commands and `files-setup` are in `RISKY`. The skill's table of commands was checked against Core 2026.11.1 and the Supervisor's route table. Arguments are checked before config and secret are read. The agent has no `read` tool. The morning run reads `home problems` (`homeStatus` in `daily-run.ts`): each line is an item under Home, and the tagged message posts once per set of problems. Cortex reaches `10.1.70.32` on TCP 8123, 4357, and 22 through the policies `Home Assistant at Mira - from Cortex` on both consoles.
|
|
67
67
|
- `arcane release-notes <stack>[/<service>]` is `lib/releases.ts`: a single-image check and `resolveRef` give the running and latest versions, `HttpRegistry.labels` reads `org.opencontainers.image.source` from the latest image (index to linux/amd64 manifest to config blob), and the anonymous GitHub releases API (60 requests an hour, up to 3 pages of 100) gives the releases in between, oldest first. `condenseNotes` keeps each release under 12,000 characters by section priority; `capTotal` drops the oldest releases past 40,000 characters in total.
|
|
68
68
|
|
|
69
69
|
## Gate
|
|
@@ -146,6 +146,15 @@ describe("home assistant findings", () => {
|
|
|
146
146
|
expect(homeProblems(snapshot({ backups: null, unread: ["backup list"] }), NOW)).toEqual(["the backup list could not be read"]);
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
+
it("drops the Supervisor's full-backup warning while a recent backup exists", () => {
|
|
150
|
+
const resolution = { issues: [{ type: "no_current_backup", context: "system" }, { type: "free_space", context: "system" }] };
|
|
151
|
+
expect(homeProblems(snapshot({ resolution, backups: { backups: [{ date: "2026-11-11T01:16:00Z", failed_agent_ids: [] }] } }), NOW)).toEqual(["the Supervisor reports free_space (system)"]);
|
|
152
|
+
expect(homeProblems(snapshot({ resolution, backups: { backups: [{ date: "2026-11-01T04:00:00Z", failed_agent_ids: [] }] } }), NOW)).toEqual([
|
|
153
|
+
"the Supervisor reports no_current_backup (system), free_space (system)",
|
|
154
|
+
"the newest backup is 11 days old",
|
|
155
|
+
]);
|
|
156
|
+
});
|
|
157
|
+
|
|
149
158
|
it("lists each kind of problem in one line", () => {
|
|
150
159
|
const problems = homeProblems(
|
|
151
160
|
snapshot({
|
|
@@ -238,6 +238,12 @@ export function diskUse(host: unknown): DiskUse | null {
|
|
|
238
238
|
/** A backup older than this is a problem: Home Assistant makes one every night by default. */
|
|
239
239
|
const BACKUP_MAX_AGE_HOURS = 48;
|
|
240
240
|
const DISK_MAX_USED_PERCENT = 85;
|
|
241
|
+
/**
|
|
242
|
+
* The Supervisor raises this until a backup of type "full" exists, but Home Assistant's own backups are always
|
|
243
|
+
* "partial" (`partial_backup` in Core's hassio/backup.py, 2026.11.1), so it never clears; the backup age check
|
|
244
|
+
* below covers the same risk.
|
|
245
|
+
*/
|
|
246
|
+
const COVERED_SUPERVISOR_ISSUES = ["no_current_backup"];
|
|
241
247
|
const NAMED = 4;
|
|
242
248
|
|
|
243
249
|
function named(items: string[]): string {
|
|
@@ -253,7 +259,10 @@ export function homeProblems(s: HomeSnapshot, now: number): string[] {
|
|
|
253
259
|
if (field(s.config, "recovery_mode") === true) out.push("Home Assistant runs in recovery mode");
|
|
254
260
|
if (s.supervisor !== null && field(s.supervisor, "healthy") === false) out.push(`the Supervisor is unhealthy${strings(field(s.resolution, "unhealthy")).length > 0 ? `: ${strings(field(s.resolution, "unhealthy")).join(", ")}` : ""}`);
|
|
255
261
|
if (s.supervisor !== null && field(s.supervisor, "supported") === false) out.push(`the installation is unsupported${strings(field(s.resolution, "unsupported")).length > 0 ? `: ${strings(field(s.resolution, "unsupported")).join(", ")}` : ""}`);
|
|
256
|
-
const
|
|
262
|
+
const covered = s.backups !== null && (backupSummary(s.backups, now).ageHours ?? Number.POSITIVE_INFINITY) <= BACKUP_MAX_AGE_HOURS;
|
|
263
|
+
const issues = rows(field(s.resolution, "issues"))
|
|
264
|
+
.filter((i) => !(covered && COVERED_SUPERVISOR_ISSUES.includes(text(i.type) ?? "")))
|
|
265
|
+
.map((i) => `${text(i.type) ?? "?"}${text(i.context) ? ` (${text(i.context)})` : ""}`);
|
|
257
266
|
if (issues.length > 0) out.push(`the Supervisor reports ${named(issues)}`);
|
|
258
267
|
for (const f of failedIntegrations(s.entries)) out.push(`the ${f.title} integration (${f.domain}) did not load: ${f.state}${f.reason ? `, ${f.reason.slice(0, 160)}` : ""}`);
|
|
259
268
|
const repairs = openRepairs(s.repairs);
|