@astrofoundry/pi-astro 0.40.26 → 0.40.28

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.
@@ -21,6 +21,7 @@ describe("approvals", () => {
21
21
  expect(isRisky("network", ["unifi", "mira", "--local", "write", "PUT", "/v1/sites/x/networks/y", "{}"])).toBe(true);
22
22
  expect(isRisky("network", ["unifi", "mira", "nat-write", "POST", "{}"])).toBe(true);
23
23
  expect(isRisky("network", ["unifi", "37", "nat"])).toBe(false);
24
+ expect(isRisky("network", ["unifi", "mira", "app-policy-delete", "0123456789abcdef01234567"])).toBe(true);
24
25
  expect(isRisky("network", ["unifi", "mira", "device-network", "0123456789abcdef01234567", "{}"])).toBe(true);
25
26
  expect(isRisky("network", ["unifi", "mira", "app-get", "/api/s/default/stat/device"])).toBe(false);
26
27
  expect(isRisky("arcane", ["projects", "list"])).toBe(false);
@@ -42,6 +43,9 @@ describe("approvals", () => {
42
43
  expect(isRisky("arcane", ["host", "container-logs", "sonarr", "2026-09-06T12:00:00Z", "2026-09-06T12:15:00Z"])).toBe(false);
43
44
  expect(isRisky("edge", ["vps", "reboot", "--confirm", "--help"])).toBe(false);
44
45
  expect(isRisky("proxmox", ["guests"])).toBe(false);
46
+ expect(isRisky("dns", ["technitium", "host", "technitium1", "upgrade"])).toBe(true);
47
+ expect(isRisky("dns", ["technitium", "host", "technitium3", "restart"])).toBe(true);
48
+ expect(isRisky("dns", ["technitium", "host", "technitium2", "status"])).toBe(false);
45
49
  expect(isRisky("proxmox", ["set", "107", "memory=768"])).toBe(true);
46
50
  expect(isRisky("proxmox", ["space-x", "set", "105", "memory=768"])).toBe(true);
47
51
  expect(isRisky("proxmox", ["space-x", "guests"])).toBe(false);
@@ -33,12 +33,13 @@ export const RISKY: Readonly<Record<string, readonly RegExp[]>> = {
33
33
  ],
34
34
  identity: [/^zitadel\s+(DELETE|POST|PUT|PATCH)\b/, /^dmz\s+(deploy-config|pomerium-restart|render|lego-renew)\b/],
35
35
  // Every UniFi write, on either console.
36
- network: [/^unifi\s+\S+\s+(write|nat-write|device-network)\b/],
36
+ network: [/^unifi\s+\S+\s+(write|nat-write|device-network|app-policy-delete)\b/],
37
37
  dns: [
38
38
  /^technitium\s+primary\s+(zone-create|zone-catalog|zone-delete|record-add|record-update|record-delete|cluster-init|cluster-delete|cluster-remove|server-domain)\b/,
39
39
  /^technitium\s+node\s+\S+\s+(server-domain|stale-zone-delete)\b/,
40
40
  /^technitium\s+join\b/,
41
41
  /^cloudflare\s+record-(add|update|delete)\b/,
42
+ /^technitium\s+host\s+\S+\s+(restart|upgrade)\b/,
42
43
  ],
43
44
  edge: [/^vps\s+deploy-nginx\b/],
44
45
  backup: [/^(vzdump-run|host-backup-run|arcane-backup-run|gcs-run|restic-check-run|restic-restore|restore-clean)\b/],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrofoundry/pi-astro",
3
- "version": "0.40.26",
3
+ "version": "0.40.28",
4
4
  "description": "Personal pi customizations (extensions, subagents, skills, prompts, themes) for the pi coding agent.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -54,6 +54,25 @@ API reference: grimoire products `technitium-api` (HTTP API) and `technitium-dns
54
54
  { "args": ["technitium", "join", "http://10.1.40.53:5380", "10.1.40.53"] }
55
55
  ```
56
56
 
57
+ ## `technitium host <technitium1|technitium2|technitium3> <command>`
58
+
59
+ Fixed operations on each node's host through one forced-command SSH key (`spc-dns-node-entry`): technitium1 on Synapse directly, technitium2 through Pulsar (`pct exec 107`), technitium3 through SPACE-X (`pct exec 100`).
60
+
61
+ | Command | Effect |
62
+ |---|---|
63
+ | `status` | `dns` service state, start time, restart count, uptime, memory, root disk |
64
+ | `journal <since>` | the `dns` service journal since, e.g. `2 hours ago` |
65
+ | `updates` | upgradable OS packages |
66
+ | `restart` | restart Technitium and print its state |
67
+ | `upgrade` | run the official installer (`download.technitium.com/dns/install.sh`), which upgrades Technitium and its ASP.NET runtime in place; up to 10 minutes |
68
+
69
+ Upgrade or restart one node at a time and check `cluster-state` and `resolve` on it before the next; the other two nodes keep answering. Upgrade the secondaries first and technitium1 last, and keep all three on the same version.
70
+
71
+ ```json
72
+ { "args": ["technitium", "host", "technitium3", "status"] }
73
+ { "args": ["technitium", "host", "technitium2", "upgrade"] }
74
+ ```
75
+
57
76
  Internal split DNS: public hostnames such as `auth.37pla.net` resolve to the DMZ (`10.0.20.10`) inside the homelab and to the VPS (`35.237.66.101`) outside.
58
77
 
59
78
  ## `cloudflare <command>`
@@ -94,6 +94,8 @@ Behavior learned on the live consoles:
94
94
 
95
95
  `app-get` reads any path of the Network application's own API under `/api/s/default/` or `/v2/api/site/default/`, through the same connector and key. Use it to find the fields a change needs before adding a narrow write command. Useful reads: `/api/s/default/stat/device` (devices with `mgmt_network_id`, `config_network`, `port_table`, `port_overrides`, `uplink`), `/api/s/default/stat/sta` (clients with `ap_mac`, `sw_mac`, `sw_port`), `/api/s/default/rest/networkconf` (networks with their 24-hex ids, VLAN, subnet, DHCP range).
96
96
 
97
+ `app-policy-delete <policyId>` deletes a firewall policy that the official API lists with `id: null`, such as rules converted from the old firewall (Mira's `BLOCK INTERNET` rows on 2026-10-31). Find its 24-hex `_id` with `app-get /v2/api/site/default/firewall-policies`; every other policy change goes through `write`.
98
+
97
99
  `device-network` changes only a device's management network and address: a PUT of `/api/s/default/rest/device/<deviceId>` whose body may hold just `mgmt_network_id` and `config_network`. Both sites use the same layout: the uplink port stays native Default with all VLANs tagged, and each device sits on Management with a static address and the local DNS nodes.
98
100
 
99
101
  ```json
@@ -36,11 +36,11 @@ Host: Cortex (macOS on Apple silicon; Homebrew git; the specialists' Node, trend
36
36
  - `arcane`: `ZITADEL_KEY_JSON`, `GITOPS_DEPLOY_KEY_B64`, `ZITADEL_USER_ID` (plain), `SSH_KEY_ARCANE_HOST_B64` (user `spc-arcane` on VM 100, for `host`, `manager-*`), and optionally `MEALIE_API_KEY` (only `host mealie-api` reads it).
37
37
  - `identity`: `ZITADEL_PAT`, `SSH_KEY_DMZ_B64`, `HOMELAB_DEPLOY_KEY_B64`.
38
38
  - `network`: `UNIFI_API_KEY` (account key: unifi.ui.com, Settings, API Keys), `UNIFI_LOCAL_37_API_KEY` and `UNIFI_LOCAL_MIRA_API_KEY` (each console: Network, Settings, Integrations), `SSH_KEY_PULSAR_B64`.
39
- - `dns`: `TECHNITIUM_TOKEN` (API token of user `spc-dns` on the cluster primary), `CLOUDFLARE_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`.
39
+ - `dns`: `TECHNITIUM_TOKEN` (API token of user `spc-dns` on the cluster primary), `CLOUDFLARE_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`, `SSH_KEY_DNS_NODES_B64` (root on Synapse, Pulsar, and SPACE-X, forced to `spc-dns-node-entry`). `dns.json` also needs `technitium1Host`, `technitium2Host`, `technitium3Host`, and `nodeSshUser` for `technitium host`.
40
40
  - `edge`: `GCP_SA_KEY_JSON` (service account key), `SSH_KEY_FRONTDOOR_B64`, `HOMELAB_DEPLOY_KEY_B64`.
41
41
  - `security`: `SSH_KEY_OBS_B64`.
42
42
  - `backup`: `SSH_KEY_PULSAR_B64`, `SSH_KEY_ARCANE_B64`.
43
- - `proxmox`: `PVE_TOKEN_ID` (plain, `spc-proxmox@pve!cortex`), `PVE_TOKEN_SECRET`, `SSH_KEY_PULSAR_B64`.
43
+ - `proxmox`: `PVE_TOKEN_ID` (plain, `spc-proxmox@pve!cortex`), `PVE_TOKEN_SECRET`, `PVE_SPACEX_TOKEN_ID` and `PVE_SPACEX_TOKEN_SECRET` (the same user on SPACE-X), `SSH_KEY_PULSAR_B64` (trusted by Pulsar and SPACE-X). `proxmox.json` also needs `spacexApiUrl`, `spacexCertSha256`, `spacexNode`, `spacexHost`, `spacexUser`, and `known_hosts` the SPACE-X host key.
44
44
  - `inference`: `SSH_KEY_NEXUS_B64`.
45
45
  - `media`: `TMDB_ACCESS_TOKEN` (TMDB API Read Access Token), `OMDB_API_KEY`, `RADARR_API_KEY`, `SONARR_API_KEY` (Settings, General, Security; each app has one), `SABNZBD_API_KEY` (the API key, not the NZB key, which can only add NZBs and cannot read or pause the queue).
46
46
  2. **Identities.** Zitadel (`https://auth.37pla.net/ui/console`): service user `spc-arcane` with Access Token Type JWT and a JSON key; service user `spc-identity` with a Personal Access Token and the Instance Owner role. Technitium (cluster primary): user `spc-dns` in the Administrators group with an API token; the cluster syncs the user to every node. Cloudflare: an account-owned API token with `Zone:Read` and `DNS:Edit` on both zones. GCP project `frontdoor-1337`: service account `spc-edge` with `roles/iap.tunnelResourceAccessor` and `roles/compute.viewer`, JSON key. Proxmox (`ssh pulsar`): user `spc-proxmox@pve`, role `SpecialistGuest` = `VM.Audit VM.PowerMgmt VM.Snapshot VM.Snapshot.Rollback VM.Config.CPU VM.Config.Memory VM.Config.Options VM.Config.Network VM.Config.CDROM VM.GuestAgent.Audit`, ACLs `PVEAuditor` on `/` and `SpecialistGuest` on `/vms` for both the user and the token `spc-proxmox@pve!cortex` (`-privsep 1`).
@@ -126,7 +126,7 @@ Host: Cortex (macOS on Apple silicon; Homebrew git; the specialists' Node, trend
126
126
  { "agent": "astro.arcane", "tool": "arcane", "service": "arcane", "timeoutMs": 8100000 },
127
127
  { "agent": "astro.identity", "tool": "identity", "service": "identity", "timeoutMs": 120000 },
128
128
  { "agent": "astro.network", "tool": "network", "service": "network", "timeoutMs": 120000 },
129
- { "agent": "astro.dns", "tool": "dns", "service": "dns", "timeoutMs": 60000 },
129
+ { "agent": "astro.dns", "tool": "dns", "service": "dns", "timeoutMs": 660000 },
130
130
  { "agent": "astro.edge", "tool": "edge", "service": "edge", "timeoutMs": 300000 },
131
131
  { "agent": "astro.security", "tool": "security", "service": "security", "timeoutMs": 120000 },
132
132
  { "agent": "astro.backup", "tool": "backup", "service": "backup", "timeoutMs": 3600000 },
@@ -151,6 +151,6 @@ The `astro-discord` extension gives Discord users access to the specialists from
151
151
 
152
152
  ## Rotation and operations
153
153
 
154
- Rotation steps for every field live in the homelab repository, `03-cortex-macmini/ROTATION.md`. After any change in Vaultwarden run `specialist-cli provision`. Host state and the sudo rules are documented in `03-cortex-macmini/README.md`; the forced-command scripts are tracked under `02-pulsar-proxmox/dmz/system/`, `02-pulsar-proxmox/pulsar/system/`, `02-pulsar-proxmox/observability/system/`, `host/` of the `astronaute77/arcane` repository, `04-nexus-macstudio/system/`, and `00-frontdoor-vps/system/`.
154
+ Rotation steps for every field live in the homelab repository, `03-cortex-macmini/ROTATION.md`. After any change in Vaultwarden run `specialist-cli provision`. Host state and the sudo rules are documented in `03-cortex-macmini/README.md`; the forced-command scripts are tracked under `02-pulsar-proxmox/dmz/system/`, `02-pulsar-proxmox/pulsar/system/`, `06-space-x-proxmox/system/`, `02-pulsar-proxmox/observability/system/`, `host/` of the `astronaute77/arcane` repository, `04-nexus-macstudio/system/`, and `00-frontdoor-vps/system/`.
155
155
 
156
156
  All nine planned specialists exist. See `AGENTS.md` for how to add one.
@@ -1,10 +1,13 @@
1
1
  import { randomBytes } from "node:crypto";
2
+ import { join as joinPath } from "node:path";
2
3
  import { readConfig } from "../lib/config.ts";
3
4
  import { ServiceError, UsageError } from "../lib/errors.ts";
4
5
  import { main } from "../lib/main.ts";
5
6
  import { printJson, printRaw } from "../lib/output.ts";
6
7
  import { redactSecrets } from "../lib/sanitize.ts";
7
- import { readSecret } from "../lib/secrets.ts";
8
+ import { specialistsHome } from "../lib/paths.ts";
9
+ import { readSecret, secretPath } from "../lib/secrets.ts";
10
+ import { sshFixed } from "../lib/ssh.ts";
8
11
 
9
12
  const SERVICE = "dns";
10
13
 
@@ -15,6 +18,31 @@ interface DnsConfig extends Record<string, string> {
15
18
 
16
19
  const SHAPE = { technitiumPrimaryUrl: "string" } as const;
17
20
 
21
+ /** SSH targets of the node key: Synapse itself, and the Proxmox hosts that run technitium2 and technitium3 as containers. */
22
+ interface NodeHostConfig extends Record<string, string> {
23
+ technitium1Host: string;
24
+ technitium2Host: string;
25
+ technitium3Host: string;
26
+ nodeSshUser: string;
27
+ }
28
+
29
+ const NODE_HOST_SHAPE = { technitium1Host: "string", technitium2Host: "string", technitium3Host: "string", nodeSshUser: "string" } as const;
30
+
31
+ export const DNS_NODES = ["technitium1", "technitium2", "technitium3"] as const;
32
+ type DnsNode = (typeof DNS_NODES)[number];
33
+
34
+ /** Fixed commands of the forced-command entry `spc-dns-node-entry` on each node. */
35
+ export const NODE_COMMANDS: Readonly<Record<string, { args: number; help: string }>> = {
36
+ status: { args: 0, help: "dns service state, restarts, uptime, memory, root disk" },
37
+ journal: { args: 1, help: "journal <since> dns service journal since, e.g. '2 hours ago'" },
38
+ updates: { args: 0, help: "upgradable OS packages" },
39
+ restart: { args: 0, help: "restart the Technitium service" },
40
+ upgrade: { args: 0, help: "run the official Technitium installer, which upgrades in place" },
41
+ };
42
+ const SINCE = /^[A-Za-z0-9 :+-]{1,40}$/;
43
+ /** The installer downloads Technitium and the ASP.NET runtime; the gate allows the dns tool 11 minutes. */
44
+ const UPGRADE_TIMEOUT_MS = 600_000;
45
+
18
46
  /** Commands that need the cluster catalog, which the primary's cluster state names. */
19
47
  const CATALOG_COMMANDS = new Set(["zone-create", "zone-catalog"]);
20
48
 
@@ -35,6 +63,30 @@ const HEX_ID = /^[0-9a-f]{32}$/;
35
63
  const NODE_ID = /^[0-9]{1,10}$/;
36
64
  const IP_LIST = /^[0-9A-Fa-f:.]+(,[0-9A-Fa-f:.]+)*$/;
37
65
 
66
+ export function buildNodeRemote(args: string[]): { node: DnsNode; remote: string } {
67
+ const [node, name, ...rest] = args;
68
+ if (!(DNS_NODES as readonly string[]).includes(node)) throw new UsageError(`technitium host <${DNS_NODES.join("|")}> <command>`);
69
+ const spec = name === undefined ? undefined : NODE_COMMANDS[name];
70
+ if (!spec) throw new UsageError(`unknown host command: ${name ?? "(none)"}; one of ${Object.keys(NODE_COMMANDS).join(", ")}`);
71
+ if (rest.length !== spec.args) throw new UsageError(`${name} takes ${spec.args} argument(s)`);
72
+ if (name === "journal" && !SINCE.test(rest[0])) throw new UsageError("since: letters, digits, spaces, colon, plus, minus only");
73
+ return { node: node as DnsNode, remote: [name, ...rest].join(" ") };
74
+ }
75
+
76
+ async function nodeHost(args: string[]): Promise<number> {
77
+ const { node, remote } = buildNodeRemote(args);
78
+ const hosts = readConfig<NodeHostConfig>(SERVICE, NODE_HOST_SHAPE);
79
+ const host = { technitium1: hosts.technitium1Host, technitium2: hosts.technitium2Host, technitium3: hosts.technitium3Host }[node];
80
+ const result = await sshFixed(
81
+ { host, user: hosts.nodeSshUser, keyFile: secretPath(SERVICE, "SSH_KEY_DNS_NODES"), knownHostsFile: joinPath(specialistsHome(), "config", "known_hosts") },
82
+ remote,
83
+ remote === "upgrade" ? UPGRADE_TIMEOUT_MS : 120_000,
84
+ );
85
+ if (result.stdout.length > 0) printRaw(result.stdout);
86
+ if (result.code !== 0) throw new ServiceError(result.stderr.trim() || `${remote} exited ${result.code}`);
87
+ return 0;
88
+ }
89
+
38
90
  /** Technitium HTTP API reads, valid on both nodes. */
39
91
  export const TECHNITIUM_READS: Readonly<Record<string, { args: [number, number]; help: string }>> = {
40
92
  zones: { args: [0, 1], help: "zones [filter] list authoritative zones (filter: * and ? wildcards)" },
@@ -67,6 +119,11 @@ const HELP = `dns specialist
67
119
  technitium primary <command> [args] the cluster primary
68
120
  technitium node <fqdn> <command> [args] another cluster node, through the primary (reads and server-domain)
69
121
  technitium join <nodeUrl> <nodeIp> join a fresh node (default login) as a Secondary node, e.g. http://10.1.40.53:5380 10.1.40.53
122
+ technitium host <technitium1|technitium2|technitium3> <command>
123
+ the node's host through a forced-command key:
124
+ ${Object.entries(NODE_COMMANDS)
125
+ .map(([name, c]) => ` ${name.padEnd(10)} ${c.help}`)
126
+ .join("\n")}
70
127
  reads:
71
128
  ${Object.values(TECHNITIUM_READS)
72
129
  .map((r) => ` ${r.help}`)
@@ -286,6 +343,7 @@ export function technitiumTarget(args: string[]): { node: string | undefined; re
286
343
 
287
344
  async function technitium(config: DnsConfig, args: string[]): Promise<number> {
288
345
  if (args[0] === "join") return join(config, args.slice(1));
346
+ if (args[0] === "host") return nodeHost(args.slice(1));
289
347
  const { node, rest } = technitiumTarget(args);
290
348
  const catalog = CATALOG_COMMANDS.has(rest[0] ?? "") ? await clusterCatalog(config) : "";
291
349
  const request = technitiumRequest(catalog, rest);
@@ -80,6 +80,8 @@ ${Object.values(UNIFI_READS)
80
80
  unifi <37|mira> app-get <path> [--local] any GET of the Network application under /api/s/default/ or /v2/api/site/default/
81
81
  unifi <37|mira> device-network <deviceId> <json> [--local]
82
82
  set a device's management network and IP (keys mgmt_network_id, config_network)
83
+ unifi <37|mira> app-policy-delete <policyId> [--local]
84
+ delete a firewall policy the official API lists without an id
83
85
  unifi <37|mira> nat [--local] the console's NAT rules (Policy Table; not in the official API)
84
86
  unifi <37|mira> nat-write POST <json> | PUT <ruleId> <json> | DELETE <ruleId> [--local]
85
87
  unifi <37|mira> fingerprint the local console's certificate fingerprint (for the pin)
@@ -223,6 +225,13 @@ export function deviceNetworkWrite(args: string[]): UnifiWrite {
223
225
  return { method: "PUT", path: `/api/s/default/rest/device/${id}`, body };
224
226
  }
225
227
 
228
+ /** `app-policy-delete <policyId>`: a firewall policy that the official API returns with `id: null` (rules converted from the old firewall). */
229
+ export function appPolicyDelete(args: string[]): UnifiWrite {
230
+ const [id, ...extra] = args;
231
+ if (id === undefined || !NAT_ID.test(id) || extra.length > 0) throw new UsageError("app-policy-delete <24-hex policyId from app-get /v2/api/site/default/firewall-policies>");
232
+ return { method: "DELETE", path: `/v2/api/site/default/firewall-policies/${id}` };
233
+ }
234
+
226
235
  /** `nat-write POST <json>`, `nat-write PUT <ruleId> <json>`, or `nat-write DELETE <ruleId>`. */
227
236
  export function natWrite(args: string[]): UnifiWrite {
228
237
  const [method, first, second, ...extra] = args;
@@ -330,6 +339,10 @@ async function unifi(args: string[]): Promise<number> {
330
339
  return 0;
331
340
  }
332
341
  if (rest[0] === "app-get") return printAnswer(await siteRequest(site, readSite(site), local, appGetPath(rest.slice(1)), "GET", undefined, "app"), `UniFi ${site} application`);
342
+ if (rest[0] === "app-policy-delete") {
343
+ const call = appPolicyDelete(rest.slice(1));
344
+ return printAnswer(await siteRequest(site, readSite(site), local, call.path, call.method, undefined, "app"), `UniFi ${site} policy`);
345
+ }
333
346
  if (rest[0] === "device-network") {
334
347
  const call = deviceNetworkWrite(rest.slice(1));
335
348
  return printAnswer(await siteRequest(site, readSite(site), local, call.path, call.method, call.body, "app"), `UniFi ${site} device`);
@@ -4,14 +4,14 @@ import { join } from "node:path";
4
4
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
5
  import { refusedPrefix, command as arcaneCommand } from "./arcane/run.ts";
6
6
  import { buildBackupRemote, command as backupCommand } from "./backup/run.ts";
7
- import { parseJoinArgs, parseParams, parseRecordFilters, technitiumRequest, technitiumTarget, command as dnsCommand } from "./dns/run.ts";
7
+ import { buildNodeRemote, parseJoinArgs, parseParams, parseRecordFilters, technitiumRequest, technitiumTarget, command as dnsCommand } from "./dns/run.ts";
8
8
  import { buildVpsRemote, command as edgeCommand, isTransientSshFailure, PUBLIC_ROUTES, routeProbe } from "./edge/run.ts";
9
9
  import { API_PREFIXES, buildDmzRemote, validateApiPath, command as identityCommand } from "./identity/run.ts";
10
10
  import { buildInferenceRemote, command as inferenceCommand } from "./inference/run.ts";
11
11
  import { MAX_ADD_IDS, MAX_EXCLUDE_IDS, buildTrendarrCall, interpretRun, parseImdbIds, trendarrConfig, trendarrError, trendarrWarnings, command as mediaCommand } from "./media/run.ts";
12
12
  import { ServiceError, UsageError } from "./lib/errors.ts";
13
13
  import { safeRepoPath, safeWritePath } from "./lib/repo.ts";
14
- import { appGetPath, buildPulsarRemote, cloudPath, deviceNetworkWrite, NAT_PATH, natWrite, parseQuery, parseSiteArgs, unifiPath, unifiWrite, command as networkCommand } from "./network/run.ts";
14
+ import { appGetPath, appPolicyDelete, buildPulsarRemote, cloudPath, deviceNetworkWrite, NAT_PATH, natWrite, parseQuery, parseSiteArgs, unifiPath, unifiWrite, command as networkCommand } from "./network/run.ts";
15
15
  import { buildHostRemote, splitHost, needsConfirm, parseSetPairs, parseVmid, validateApiPath as validatePvePath, command as proxmoxCommand } from "./proxmox/run.ts";
16
16
  import { banLength, buildObsRemote, compactDecisions, parseGoDuration, summariseAlerts, summariseVulns, summariseWazuh, vulnEvents, wazuhEvents, command as securityCommand } from "./security/run.ts";
17
17
 
@@ -118,6 +118,8 @@ describe("network wrapper", () => {
118
118
  it("limits application reads and device network writes", () => {
119
119
  const id = "0123456789abcdef01234567";
120
120
  expect(appGetPath(["/api/s/default/stat/device"])).toBe("/api/s/default/stat/device");
121
+ expect(appPolicyDelete(["0123456789abcdef01234567"])).toEqual({ method: "DELETE", path: "/v2/api/site/default/firewall-policies/0123456789abcdef01234567" });
122
+ expect(() => appPolicyDelete(["611cef69-df2e-4498-9845-8685daee84f3"])).toThrow(UsageError);
121
123
  expect(appGetPath(["/v2/api/site/default/nat"])).toBe("/v2/api/site/default/nat");
122
124
  expect(() => appGetPath(["/api/s/other/stat/device"])).toThrow(UsageError);
123
125
  expect(() => appGetPath(["/api/s/default/../../x"])).toThrow(UsageError);
@@ -239,6 +241,16 @@ describe("dns wrapper", () => {
239
241
  expect(() => technitiumTarget(["node", "technitium2", "zones"])).toThrow(/domain name/);
240
242
  });
241
243
 
244
+ it("maps node host commands to the forced-command entry", () => {
245
+ expect(buildNodeRemote(["technitium1", "status"])).toEqual({ node: "technitium1", remote: "status" });
246
+ expect(buildNodeRemote(["technitium3", "journal", "2 hours ago"])).toEqual({ node: "technitium3", remote: "journal 2 hours ago" });
247
+ expect(buildNodeRemote(["technitium2", "upgrade"]).remote).toBe("upgrade");
248
+ expect(() => buildNodeRemote(["synapse", "status"])).toThrow(UsageError);
249
+ expect(() => buildNodeRemote(["technitium1", "reboot"])).toThrow(/unknown host command/);
250
+ expect(() => buildNodeRemote(["technitium1", "journal", "1h; rm -rf /"])).toThrow(/since/);
251
+ expect(() => buildNodeRemote(["technitium1", "status", "extra"])).toThrow(/argument/);
252
+ });
253
+
242
254
  it("validates join arguments", () => {
243
255
  expect(parseJoinArgs(["http://10.1.40.53:5380", "10.1.40.53"])).toEqual({ nodeUrl: "http://10.1.40.53:5380", nodeIp: "10.1.40.53" });
244
256
  expect(() => parseJoinArgs(["http://evil.example:5380", "10.1.40.53"])).toThrow(UsageError);