@astrofoundry/pi-astro 0.40.18 → 0.40.19

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.
@@ -36,7 +36,7 @@ export const RISKY: Readonly<Record<string, readonly RegExp[]>> = {
36
36
  network: [/^unifi\s+\S+\s+write\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
- /^technitium\s+node\s+\S+\s+server-domain\b/,
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
42
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrofoundry/pi-astro",
3
- "version": "0.40.18",
3
+ "version": "0.40.19",
4
4
  "description": "Personal pi customizations (extensions, subagents, skills, prompts, themes) for the pi coding agent.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -28,6 +28,7 @@ The internal resolvers form one Technitium cluster, `dns.home.arpa`: the Primary
28
28
  | `cluster-delete` (primary) | remove the cluster from the primary; refused while Secondary nodes exist |
29
29
  | `cluster-remove <secondaryNodeId>` (primary) | ask a Secondary node (id from `cluster-state`) to leave |
30
30
  | `server-domain <name>` (primary or node) | set that node's DNS Server Domain |
31
+ | `stale-zone-delete <zone>` (node only) | delete a Secondary zone no catalog manages (checked first), so the cluster catalog recreates it |
31
32
 
32
33
  Record parameters by type (the API's names): `A`/`AAAA` `ipAddress` (update: `newIpAddress`); `CNAME` `cname`; `TXT` `text`; `MX` `exchange`, `preference`; `SRV` `priority`, `weight`, `port`, `target`; `NS` `nameServer`; `PTR` `ptrName`. `ttl=<seconds>` and `comments=<text>` apply to all; `overwrite=true` replaces the record set on add.
33
34
 
@@ -58,6 +58,7 @@ export const TECHNITIUM_WRITES: Readonly<Record<string, { args: [number, number]
58
58
  "cluster-delete": { args: [0, 0], help: "cluster-delete remove the cluster from the primary (only without Secondary nodes)" },
59
59
  "cluster-remove": { args: [1, 1], help: "cluster-remove <secondaryNodeId> ask a Secondary node to leave the cluster" },
60
60
  "server-domain": { args: [1, 1], help: "server-domain <name> DNS Server Domain of the target node (also with node)" },
61
+ "stale-zone-delete": { args: [1, 1], help: "stale-zone-delete <zone> (node only) delete a Secondary zone that no catalog manages, so the cluster catalog recreates it" },
61
62
  };
62
63
 
63
64
  const HELP = `dns specialist
@@ -168,6 +169,8 @@ export function technitiumRequest(catalog: string, args: string[]): TechnitiumRe
168
169
  case "cluster-remove":
169
170
  if (!NODE_ID.test(rest[0])) throw new UsageError("cluster-remove needs the numeric Secondary node id from cluster-state");
170
171
  return { path: "/api/admin/cluster/primary/removeSecondary", params: { secondaryNodeId: rest[0] }, primaryOnly: true };
172
+ case "stale-zone-delete":
173
+ return { path: "/api/zones/delete", params: { zone: assertName(rest[0], "zone") }, primaryOnly: false };
171
174
  case "server-domain":
172
175
  return { path: "/api/settings/set", params: { dnsServerDomain: assertName(rest[0], "server domain") }, primaryOnly: false };
173
176
  default:
@@ -286,7 +289,16 @@ async function technitium(config: DnsConfig, args: string[]): Promise<number> {
286
289
  if (node !== undefined && request.primaryOnly) throw new UsageError("zone and cluster writes go to the primary; the other nodes follow through the catalog zone and the cluster");
287
290
  const params = node === undefined ? request.params : { ...request.params, node };
288
291
  const target = node ?? "primary";
289
- const parsed = await technitiumCall(config.technitiumPrimaryUrl, request.path, params, readSecret(SERVICE, "TECHNITIUM_TOKEN"), target);
292
+ const token = readSecret(SERVICE, "TECHNITIUM_TOKEN");
293
+ if (rest[0] === "stale-zone-delete") {
294
+ if (node === undefined) throw new UsageError("stale-zone-delete needs node <fqdn>; delete a primary zone with zone-delete");
295
+ const options = await technitiumCall(config.technitiumPrimaryUrl, "/api/zones/options/get", { zone: params.zone, node }, token, target);
296
+ const zone = options.response as { type?: string; catalog?: string | null } | undefined;
297
+ if (!["Secondary", "SecondaryCatalog"].includes(zone?.type ?? "") || (zone?.catalog ?? null) !== null) {
298
+ throw new UsageError(`${params.zone} on ${node} is ${zone?.type ?? "unknown"} in catalog ${zone?.catalog ?? "none"}; only a Secondary zone outside any catalog is stale`);
299
+ }
300
+ }
301
+ const parsed = await technitiumCall(config.technitiumPrimaryUrl, request.path, params, token, target);
290
302
  printJson({ node: target, status: parsed.status, response: redactSecrets(parsed.response ?? null) });
291
303
  return 0;
292
304
  }
@@ -195,6 +195,7 @@ describe("dns wrapper", () => {
195
195
  primaryOnly: true,
196
196
  });
197
197
  expect(technitiumRequest("c", ["cluster-delete"]).params).toEqual({ forceDelete: "false" });
198
+ expect(technitiumRequest("c", ["stale-zone-delete", "pdf.37pla.net"])).toEqual({ path: "/api/zones/delete", params: { zone: "pdf.37pla.net" }, primaryOnly: false });
198
199
  expect(technitiumRequest("cluster-catalog.dns.home.arpa", ["zone-catalog", "pdf.37pla.net"])).toEqual({
199
200
  path: "/api/zones/options/set",
200
201
  params: { zone: "pdf.37pla.net", catalog: "cluster-catalog.dns.home.arpa" },