@astrofoundry/pi-astro 0.40.27 → 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.
@@ -43,6 +43,9 @@ describe("approvals", () => {
43
43
  expect(isRisky("arcane", ["host", "container-logs", "sonarr", "2026-09-06T12:00:00Z", "2026-09-06T12:15:00Z"])).toBe(false);
44
44
  expect(isRisky("edge", ["vps", "reboot", "--confirm", "--help"])).toBe(false);
45
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);
46
49
  expect(isRisky("proxmox", ["set", "107", "memory=768"])).toBe(true);
47
50
  expect(isRisky("proxmox", ["space-x", "set", "105", "memory=768"])).toBe(true);
48
51
  expect(isRisky("proxmox", ["space-x", "guests"])).toBe(false);
@@ -39,6 +39,7 @@ export const RISKY: Readonly<Record<string, readonly RegExp[]>> = {
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.27",
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>`
@@ -36,7 +36,7 @@ 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`.
@@ -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 },
@@ -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);
@@ -4,7 +4,7 @@ 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";
@@ -241,6 +241,16 @@ describe("dns wrapper", () => {
241
241
  expect(() => technitiumTarget(["node", "technitium2", "zones"])).toThrow(/domain name/);
242
242
  });
243
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
+
244
254
  it("validates join arguments", () => {
245
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" });
246
256
  expect(() => parseJoinArgs(["http://evil.example:5380", "10.1.40.53"])).toThrow(UsageError);