@astrofoundry/pi-astro 0.40.73 → 0.40.75
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/extensions/astro-discord/approvals.ts +14 -0
- package/extensions/astro-discord/discord.test.ts +16 -1
- package/extensions/astro-discord/index.ts +15 -5
- package/package.json +1 -1
- package/specialists/AGENTS.md +1 -1
- package/specialists/lib/home-assistant.test.ts +9 -0
- package/specialists/lib/home-assistant.ts +10 -1
|
@@ -3,6 +3,20 @@ import { createServer, type Server } from "node:http";
|
|
|
3
3
|
|
|
4
4
|
export type Decision = "approve" | "deny" | "timeout";
|
|
5
5
|
|
|
6
|
+
/** Longest command an approval message shows inline; Discord refuses messages above 2000 characters. */
|
|
7
|
+
export const APPROVAL_INLINE_CHARS = 1200;
|
|
8
|
+
const APPROVAL_PREVIEW_CHARS = 300;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* How an approval shows the command: whole when it is short, otherwise its start in the message and the whole
|
|
12
|
+
* command as an attached text file, so the owner can still read everything he approves.
|
|
13
|
+
*/
|
|
14
|
+
export function approvalCommand(args: readonly string[]): { inline: string; file?: { name: string; content: string } } {
|
|
15
|
+
const whole = args.join(" ");
|
|
16
|
+
if (whole.length <= APPROVAL_INLINE_CHARS) return { inline: whole };
|
|
17
|
+
return { inline: `${whole.slice(0, APPROVAL_PREVIEW_CHARS)}… (${whole.length} characters, the whole command is attached)`, file: { name: "command.txt", content: `${whole}\n` } };
|
|
18
|
+
}
|
|
19
|
+
|
|
6
20
|
export interface Ticket {
|
|
7
21
|
id: string;
|
|
8
22
|
agent: string;
|
|
@@ -2,7 +2,7 @@ import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import { ApprovalServer, type Ticket } from "./approvals.ts";
|
|
5
|
+
import { APPROVAL_INLINE_CHARS, ApprovalServer, approvalCommand, type Ticket } from "./approvals.ts";
|
|
6
6
|
import { chunkMessage, fenceState } from "./chunk.ts";
|
|
7
7
|
import { applyAdminCommand, describeConfig } from "./admin.ts";
|
|
8
8
|
import { helpText, needsPrefixText, needsYou, parseCommand } from "./commands.ts";
|
|
@@ -70,6 +70,21 @@ describe("config", () => {
|
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
+
describe("approval command", () => {
|
|
74
|
+
it("shows a short command whole and a long one as a preview with the whole command attached", () => {
|
|
75
|
+
expect(approvalCommand(["restart", "--confirm"])).toEqual({ inline: "restart --confirm" });
|
|
76
|
+
const body = JSON.stringify({ alias: "Hallway lights", actions: "x".repeat(3000) });
|
|
77
|
+
const long = approvalCommand(["rest", "post", "/api/config/automation/config/1734267132664", body]);
|
|
78
|
+
const whole = `rest post /api/config/automation/config/1734267132664 ${body}`;
|
|
79
|
+
expect(long.inline.length).toBeLessThan(APPROVAL_INLINE_CHARS);
|
|
80
|
+
expect(long.inline.startsWith("rest post /api/config/automation/config/1734267132664")).toBe(true);
|
|
81
|
+
expect(long.inline).toContain(`(${whole.length} characters, the whole command is attached)`);
|
|
82
|
+
expect(long.file).toEqual({ name: "command.txt", content: `${whole}\n` });
|
|
83
|
+
// The message around the command stays far below Discord's 2000-character limit.
|
|
84
|
+
expect(`🔒 **home** wants to run \`${long.inline}\` for <@123456789012345678>. <@123456789012345678>: approve or deny within 30 min.`.length).toBeLessThan(2000);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
73
88
|
describe("chunk", () => {
|
|
74
89
|
it("splits on paragraphs and keeps fences balanced", () => {
|
|
75
90
|
const text = `${"a".repeat(1500)}\n\n${"b".repeat(1500)}`;
|
|
@@ -7,7 +7,7 @@ import { APPROVAL_TOKEN_ENV, APPROVAL_URL_ENV } from "../specialist-gate/index.t
|
|
|
7
7
|
import { type AgentConfig, defaultDirs, discoverAgents, resolveSkills } from "../astro-subagents/agents.ts";
|
|
8
8
|
import { AGENT_ENV, type ChildSession, type DispatchDefaults, type RunResult, childRemaining, currentDepth, finalOutput, isFailed, resultOutput, runAgent } from "../astro-subagents/child.ts";
|
|
9
9
|
import { pruneSessions, sessionDirFor } from "../astro-subagents/sessions.ts";
|
|
10
|
-
import { ApprovalServer, type Ticket } from "./approvals.ts";
|
|
10
|
+
import { ApprovalServer, approvalCommand, type Ticket } from "./approvals.ts";
|
|
11
11
|
import { chunkMessage } from "./chunk.ts";
|
|
12
12
|
import { applyAdminCommand } from "./admin.ts";
|
|
13
13
|
import { CHANNEL_RULES, helpText, needsPrefixText, needsYou, parseCommand } from "./commands.ts";
|
|
@@ -275,7 +275,7 @@ class Bridge {
|
|
|
275
275
|
this.config = config;
|
|
276
276
|
this.conversations = loadState();
|
|
277
277
|
this.rest = new DiscordRest(token);
|
|
278
|
-
this.approvals = new ApprovalServer({ onTicket: (t) => void this.askApproval(t), onExpired: (t) => void this.expireApproval(t) }, config.approvalTimeoutMinutes * 60_000);
|
|
278
|
+
this.approvals = new ApprovalServer({ onTicket: (t) => void this.askApproval(t).catch((err) => this.approvalFailed(t, err)), onExpired: (t) => void this.expireApproval(t).catch((err) => log(`approval ${t.id} expiry: ${err instanceof Error ? err.message : String(err)}`)) }, config.approvalTimeoutMinutes * 60_000);
|
|
279
279
|
this.security = new SecurityMonitor({
|
|
280
280
|
rest: this.rest,
|
|
281
281
|
runEntry: (service, caller, args, timeoutMs) => this.runEntry(service, caller, args, timeoutMs),
|
|
@@ -1946,12 +1946,14 @@ class Bridge {
|
|
|
1946
1946
|
const owners = this.config.owners.map((id) => `<@${id}>`).join(" ");
|
|
1947
1947
|
const liveView = (await this.settingsFor(task.channelId))?.settings.liveView;
|
|
1948
1948
|
const site = liveView ? captchaSite(ticket.args) : null;
|
|
1949
|
+
const command = approvalCommand(ticket.args);
|
|
1949
1950
|
const content =
|
|
1950
1951
|
site && liveView
|
|
1951
1952
|
? `${captchaText(site, liveView, owners)} Within ${this.config.approvalTimeoutMinutes} min.`
|
|
1952
|
-
: `🔒 **${short}** wants to run ${code(
|
|
1953
|
+
: `🔒 **${short}** wants to run ${code(command.inline)} for <@${task.userId}>. ${owners}: approve or deny within ${this.config.approvalTimeoutMinutes} min.`;
|
|
1953
1954
|
const posted = await this.rest.createMessage(task.channelId, {
|
|
1954
1955
|
content,
|
|
1956
|
+
...(command.file && !site ? { file: command.file } : {}),
|
|
1955
1957
|
replyTo: task.messageId,
|
|
1956
1958
|
components: approvalButtons(ticket.id, false, site ? CAPTCHA_LABELS : undefined),
|
|
1957
1959
|
mentionUsers: this.config.owners,
|
|
@@ -1960,12 +1962,20 @@ class Bridge {
|
|
|
1960
1962
|
this.saveOpenWork();
|
|
1961
1963
|
}
|
|
1962
1964
|
|
|
1965
|
+
/** A ticket that could not be shown is denied, so the specialist stops waiting; the bridge keeps running. */
|
|
1966
|
+
private approvalFailed(ticket: Ticket, err: unknown): void {
|
|
1967
|
+
log(`approval ${ticket.id} for ${ticket.agent} could not be posted; denying: ${err instanceof Error ? err.message : String(err)}`);
|
|
1968
|
+
this.approvals.decide(ticket.id, "deny", "bridge");
|
|
1969
|
+
const task = this.active.get(ticket.agent.replace(/^astro\./, ""));
|
|
1970
|
+
if (task) void this.rest.createMessage(task.channelId, { content: "⚠️ The approval request could not be posted, so the change was not run. Ask again.", replyTo: task.messageId }).catch(() => undefined);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1963
1973
|
private async expireApproval(ticket: Ticket): Promise<void> {
|
|
1964
1974
|
const posted = this.approvalMessages.get(ticket.id);
|
|
1965
1975
|
if (!posted) return;
|
|
1966
1976
|
this.approvalMessages.delete(ticket.id);
|
|
1967
1977
|
this.saveOpenWork();
|
|
1968
|
-
await this.rest.editMessage(posted.channelId, posted.messageId, `⌛ No decision within ${this.config.approvalTimeoutMinutes} min; ${code(ticket.args.
|
|
1978
|
+
await this.rest.editMessage(posted.channelId, posted.messageId, `⌛ No decision within ${this.config.approvalTimeoutMinutes} min; ${code(approvalCommand(ticket.args).inline)} was not run.`).catch(() => undefined);
|
|
1969
1979
|
await this.rest.removeOwnReaction(posted.userMessage.channelId, posted.userMessage.messageId, REACTION.waiting).catch(() => undefined);
|
|
1970
1980
|
}
|
|
1971
1981
|
|
|
@@ -2033,7 +2043,7 @@ class Bridge {
|
|
|
2033
2043
|
this.saveOpenWork();
|
|
2034
2044
|
const site = captchaSite(ticket.args);
|
|
2035
2045
|
const verdict = decision === "approve" ? `✅ Approved by <@${userId}>` : `⛔ Denied by <@${userId}>`;
|
|
2036
|
-
await this.rest.updateInteractionMessage(interaction.id, interaction.token, site ? captchaVerdict(site, decision === "approve", userId) : `${verdict}: ${code(ticket.args.
|
|
2046
|
+
await this.rest.updateInteractionMessage(interaction.id, interaction.token, site ? captchaVerdict(site, decision === "approve", userId) : `${verdict}: ${code(approvalCommand(ticket.args).inline)}`);
|
|
2037
2047
|
if (posted) await this.rest.removeOwnReaction(posted.userMessage.channelId, posted.userMessage.messageId, REACTION.waiting).catch(() => undefined);
|
|
2038
2048
|
log(`approval ${ticket.id} ${decision} by ${userId}: ${ticket.args.join(" ")}`);
|
|
2039
2049
|
}
|
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);
|