@astrofoundry/pi-astro 0.40.80 → 0.40.82
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.
|
@@ -615,14 +615,15 @@ class Bridge {
|
|
|
615
615
|
const area = monday ? "Security (weekly)" : "Security";
|
|
616
616
|
reports.push(posted ? { area, line: posted.headline, needs: posted.needs, channelId: securitySchedule.channelId, messageId: posted.messageId } : { area, line: done(name) ? "already posted today" : "the report failed; the bridge log has the reason", needs: done(name) ? [] : ["the security report failed; the bridge log has the reason"], channelId: securitySchedule.channelId });
|
|
617
617
|
}
|
|
618
|
-
|
|
619
|
-
if (tools && !this.stopping) {
|
|
620
|
-
if (!done("tools")) await this.toolsReport(tools, date).catch((err) => log(`daily ${date}: tools report failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
621
|
-
}
|
|
618
|
+
// Arcane before the tools: an automatic Homebrew node update removes the binary its release reviewers spawn from until the bridge restarts.
|
|
622
619
|
const arcane = reportSchedule(this.config, "arcane");
|
|
623
620
|
if (arcane && !this.stopping) {
|
|
624
621
|
if (!done("arcane")) await this.arcaneReport(arcane, date).catch((err) => log(`daily ${date}: arcane report failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
625
622
|
}
|
|
623
|
+
const tools = reportSchedule(this.config, "tools");
|
|
624
|
+
if (tools && !this.stopping) {
|
|
625
|
+
if (!done("tools")) await this.toolsReport(tools, date).catch((err) => log(`daily ${date}: tools report failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
626
|
+
}
|
|
626
627
|
if (this.stopping) return;
|
|
627
628
|
const areas = await this.collectAreas();
|
|
628
629
|
// Read only now: a button pressed while the areas were checked has changed what still waits.
|
|
@@ -653,7 +654,10 @@ class Bridge {
|
|
|
653
654
|
// Recorded only now: a run a crash cut short runs again and skips the reports it already posted.
|
|
654
655
|
writeReportState("daily", { date, status: "sending", notified, links });
|
|
655
656
|
let first = "";
|
|
656
|
-
for (const chunk of chunkMessage(text))
|
|
657
|
+
for (const chunk of chunkMessage(text)) {
|
|
658
|
+
const { id } = await this.rest.createMessage(schedule.channelId, { content: chunk });
|
|
659
|
+
first ||= id;
|
|
660
|
+
}
|
|
657
661
|
writeReportState("daily", { date, status: "sent", messageId: first, notified, links });
|
|
658
662
|
log(`daily ${date}: posted`);
|
|
659
663
|
}
|
package/package.json
CHANGED
package/skills/arcane/SKILL.md
CHANGED
|
@@ -7,7 +7,7 @@ description: How the Arcane specialist operates the Arcane container platform an
|
|
|
7
7
|
|
|
8
8
|
Arcane manages the Docker host on VM 100 (`10.0.40.30`). Every app is a Compose project synced from the GitOps repository `astronaute77/arcane`, branch `main`, into `/opt/docker`. The `arcane` tool wraps `arcane-cli` with a fresh short-lived token on every call and adds `git` subcommands for the repository checkout. `arcane-cli gitops ...` (server-side syncs) passes through untouched.
|
|
9
9
|
|
|
10
|
-
Since 2026-11-09 a second environment, `mira`, runs the `media-mira` project on media-mira (`10.1.40.30`, VM 111 on SPACE-X at Mira) through an Edge agent. `stack-update`, `stack-rollback`, `deployment`, and `release-notes` find a stack's environment themselves; `update-report`, `container-watch`, and `project-status` cover every environment and name the remote one in `environment`. A raw arcane-cli call on Mira needs `--env f1968df8-bce3-4a65-966f-72934727ae86
|
|
10
|
+
Since 2026-11-09 a second environment, `mira`, runs the `media-mira` project on media-mira (`10.1.40.30`, VM 111 on SPACE-X at Mira) through an Edge agent. `stack-update`, `stack-rollback`, `deployment`, and `release-notes` find a stack's environment themselves; `update-report`, `container-watch`, and `project-status` cover every environment and name the remote one in `environment`. A raw arcane-cli call on Mira needs `--env f1968df8-bce3-4a65-966f-72934727ae86` (the wrapper turns `--env` into `--agent` for arcane-cli 3, and a call without either goes to the manager's own host). The `host` commands reach VM 100 only.
|
|
11
11
|
|
|
12
12
|
## Calling the tool
|
|
13
13
|
|
package/specialists/AGENTS.md
CHANGED
|
@@ -53,6 +53,7 @@ Wrappers ship as TypeScript and run under Node 24 type stripping: erasable synta
|
|
|
53
53
|
- `inference` reaches Nexus through one forced-command key. The Europa check is HTTP only until Windows OpenSSH forced commands are verified.
|
|
54
54
|
- `REFUSED_PREFIXES` protects only the wrapper itself (`config`, `auth`, `self-update`, `completion`). The GitOps-first rule for managed projects lives in the skill and the agent prompt, not in code, because unmanaged projects and emergencies need the direct CLI.
|
|
55
55
|
- The wrapper's repository commands are the `git` group; `gitops` must stay free because it is an `arcane-cli` command group (server-side syncs).
|
|
56
|
+
- arcane-cli 3 (Arcane 3.0) renamed `--env` to `--agent` and `environments` to `agents`, and without `--agent` runs a command on every agent and wraps each answer in `{success, agents}`. Since 0.40.82 the wrapper writes every call in the 2.x form and `cliArgs` translates it for the installed major (`arcane-cli --version`, read once per invocation): a 3.x call always names its agent (`--agent 0`, the manager's own host, by default), which keeps the 2.x output shapes (`RunScoped` in the CLI's `cmdutil/scope.go` runs a call with an agent like 2.x did, checked at v3.0.1). The same wrapper therefore runs before and after the manager upgrade. `envContent` (v3's Git sync environment values) is in `ARCANE_DENIED_KEYS`.
|
|
56
57
|
- Every passthrough call writes a private per-call copy of `arcanecli.yml` with `jwt_token` set, because some `arcane-cli` commands validate the config file before reading `ARCANE_TOKEN`. The copy is removed after the call. arcane-cli prints a warning on stderr that `jwt_token` and `refresh_token` in the config stop working in v3 (in the bridge log since 2026-10-23); `cliFailure` therefore names the exit code and the filtered stdout as well, because a failure can carry nothing else on stderr (the media update on 2026-11-02).
|
|
57
58
|
- Every wrapper answers `--help` without reading config, so agents can discover subcommands before anything else is set up.
|
|
58
59
|
- `entry/specialist-install.sh` runs as root, so it runs only `/usr/bin`, `/bin`, `/usr/sbin`, `/sbin` and the Node it installed, never Homebrew or anything else the main user can write; it checks that `/usr/local/libexec/specialist-node` (and each `specialist-<tool>` folder) and its parents belong to root and are writable by nobody else. Arguments are checked before the root test (tests exercise that part). Downloads go to a root-only temporary directory and are verified before use: Node against `SHASUMS256.txt` and the LTS flag in `index.json`, npm tarballs against the registry's `sha512` integrity, arcane-cli against the release's checksums file. Inside `/Users/specialist` it works only as `specialist` (`sudo -u specialist -H`), from a staging directory root hands over, so a link the specialist plants cannot redirect a root write. Each component switches by rename after a check (every installed wrapper's `--help`, `--version` of the new binary) and restores the previous copy when the check fails. Older versions are refused; `rollback` swaps current and previous. `python`, `gcloud`, `bw`, and `jq` follow the same rules: version folders under `/usr/local/libexec/specialist-<tool>/` behind the links `current` and `previous`, sealed `root:wheel` and not writable by others, smoke-tested as `specialist` before `current` moves; `python` refuses a switch that breaks the current gcloud. Consumers use the `current` paths: `provision.sh` for `bw` and `jq`, `edge.json` for `gcloud` and `gcloudPython`. Nothing a wrapper runs with secrets may come from Homebrew.
|
|
@@ -58,7 +58,60 @@ const HOST_SHAPE = { hostAddress: "string", hostUser: "string" } as const;
|
|
|
58
58
|
export const REFUSED_PREFIXES: readonly string[] = ["config", "auth", "self-update", "completion"];
|
|
59
59
|
|
|
60
60
|
/** Global arcane-cli flags that take a separate value. */
|
|
61
|
-
const VALUE_FLAGS = ["--env", "--output", "--config", "-c", "--request-timeout", "--log-level", "--limit"];
|
|
61
|
+
const VALUE_FLAGS = ["--env", "--agent", "--output", "--config", "-c", "--request-timeout", "--log-level", "--limit"];
|
|
62
|
+
|
|
63
|
+
/** The manager's own Docker host, which arcane-cli 2 reaches without --env and 3 names `--agent 0`. */
|
|
64
|
+
const LOCAL_ENV = "0";
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* arcane-cli 3 renamed `--env` to `--agent` and `environments` to `agents`, and
|
|
68
|
+
* without `--agent` it runs a command on every agent and wraps each answer.
|
|
69
|
+
* Calls are written in the 2.x form; for a 3.x CLI this names the agent on every
|
|
70
|
+
* call (the manager's own host when none is given), which keeps 2.x output.
|
|
71
|
+
*/
|
|
72
|
+
export function cliArgs(args: readonly string[], major: number): string[] {
|
|
73
|
+
if (major < 3) return [...args];
|
|
74
|
+
const out: string[] = [];
|
|
75
|
+
let positional = false;
|
|
76
|
+
let scoped = false;
|
|
77
|
+
for (let i = 0; i < args.length; i++) {
|
|
78
|
+
const a = args[i];
|
|
79
|
+
if (a === "--env" || a === "--agent") {
|
|
80
|
+
out.push("--agent", args[i + 1] ?? "");
|
|
81
|
+
scoped = true;
|
|
82
|
+
i++;
|
|
83
|
+
} else if (a.startsWith("--env=") || a.startsWith("--agent=")) {
|
|
84
|
+
out.push(`--agent=${a.slice(a.indexOf("=") + 1)}`);
|
|
85
|
+
scoped = true;
|
|
86
|
+
} else if (VALUE_FLAGS.includes(a)) {
|
|
87
|
+
out.push(a, args[i + 1] ?? "");
|
|
88
|
+
i++;
|
|
89
|
+
} else if (!positional && !a.startsWith("-")) {
|
|
90
|
+
positional = true;
|
|
91
|
+
out.push(a === "environments" ? "agents" : a);
|
|
92
|
+
} else {
|
|
93
|
+
out.push(a);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return scoped ? out : ["--agent", LOCAL_ENV, ...out];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The major version of the installed arcane-cli, from its `--version` line. */
|
|
100
|
+
export function cliMajorOf(versionOutput: string): number {
|
|
101
|
+
const m = /(\d+)\.\d+\.\d+/.exec(versionOutput);
|
|
102
|
+
if (!m) throw new ServiceError(`arcane-cli --version printed no version: ${versionOutput.trim().slice(0, 200)}`);
|
|
103
|
+
return Number(m[1]);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let cliMajorCache: number | undefined;
|
|
107
|
+
|
|
108
|
+
async function cliMajor(config: ArcaneConfig): Promise<number> {
|
|
109
|
+
if (cliMajorCache !== undefined) return cliMajorCache;
|
|
110
|
+
const result = await run(config.arcaneCli, ["--version"], { timeoutMs: 30_000 });
|
|
111
|
+
if (result.code !== 0) throw new ServiceError(`arcane-cli --version failed: ${result.stderr.trim()}`);
|
|
112
|
+
cliMajorCache = cliMajorOf(result.stdout);
|
|
113
|
+
return cliMajorCache;
|
|
114
|
+
}
|
|
62
115
|
|
|
63
116
|
/** Positional words of an arcane-cli invocation, with global flags and their values removed. */
|
|
64
117
|
export function positionalWords(args: string[]): string[] {
|
|
@@ -192,11 +245,15 @@ let targetEnv: string | undefined;
|
|
|
192
245
|
|
|
193
246
|
/** One federated token and one private config copy for every arcane-cli call of this invocation. */
|
|
194
247
|
async function withCli<T>(config: ArcaneConfig, fn: (cli: Cli) => Promise<T>, env: string | undefined = targetEnv): Promise<T> {
|
|
248
|
+
const major = await cliMajor(config);
|
|
195
249
|
const token = await federatedToken(config);
|
|
196
250
|
const callConfig = writeCallConfig(config, token);
|
|
197
251
|
const at = env === undefined ? [] : ["--env", env];
|
|
198
252
|
try {
|
|
199
|
-
return await fn((args, timeoutMs = TIMEOUT_MS) =>
|
|
253
|
+
return await fn((args, timeoutMs = TIMEOUT_MS) => {
|
|
254
|
+
const scoped = args.some((a) => a === "--env" || a === "--agent" || a.startsWith("--env=") || a.startsWith("--agent=")) ? args : [...at, ...args];
|
|
255
|
+
return run(config.arcaneCli, ["--config", callConfig, "--no-color", ...cliArgs(scoped, major)], { env: { ARCANE_TOKEN: token }, timeoutMs });
|
|
256
|
+
});
|
|
200
257
|
} finally {
|
|
201
258
|
rmSync(dirname(callConfig), { recursive: true, force: true });
|
|
202
259
|
}
|
|
@@ -232,8 +289,6 @@ async function cliJson(cli: Cli, args: string[]): Promise<unknown> {
|
|
|
232
289
|
}
|
|
233
290
|
}
|
|
234
291
|
|
|
235
|
-
/** The manager's own Docker host, which arcane-cli reaches without --env. */
|
|
236
|
-
const LOCAL_ENV = "0";
|
|
237
292
|
|
|
238
293
|
interface ArcaneEnv {
|
|
239
294
|
id: string;
|
|
@@ -5,7 +5,7 @@ import type { AddressInfo } from "node:net";
|
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
8
|
-
import { cliFailure, refusedPrefix, command as arcaneCommand } from "./arcane/run.ts";
|
|
8
|
+
import { cliArgs, cliFailure, cliMajorOf, refusedPrefix, command as arcaneCommand } from "./arcane/run.ts";
|
|
9
9
|
import { buildBackupRemote, command as backupCommand } from "./backup/run.ts";
|
|
10
10
|
import { buildNodeRemote, parseJoinArgs, parseParams, parseRecordFilters, technitiumRequest, technitiumTarget, command as dnsCommand } from "./dns/run.ts";
|
|
11
11
|
import { buildVpsRemote, command as edgeCommand, isTransientSshFailure, PUBLIC_ROUTES, routeProbe } from "./edge/run.ts";
|
|
@@ -1313,3 +1313,27 @@ describe("research wrapper", () => {
|
|
|
1313
1313
|
out.mockRestore();
|
|
1314
1314
|
});
|
|
1315
1315
|
});
|
|
1316
|
+
|
|
1317
|
+
describe("arcane-cli 3 arguments", () => {
|
|
1318
|
+
it("keeps 2.x arguments unchanged", () => {
|
|
1319
|
+
expect(cliArgs(["--env", "2", "projects", "list", "--all"], 2)).toEqual(["--env", "2", "projects", "list", "--all"]);
|
|
1320
|
+
expect(cliArgs(["environments", "list"], 2)).toEqual(["environments", "list"]);
|
|
1321
|
+
});
|
|
1322
|
+
it("names the agent on every 3.x call, the manager's own host by default", () => {
|
|
1323
|
+
expect(cliArgs(["--output", "json", "projects", "list", "--all"], 3)).toEqual(["--agent", "0", "--output", "json", "projects", "list", "--all"]);
|
|
1324
|
+
expect(cliArgs(["--env", "2", "--output", "json", "gitops", "list", "--all"], 3)).toEqual(["--agent", "2", "--output", "json", "gitops", "list", "--all"]);
|
|
1325
|
+
expect(cliArgs(["--env=2", "containers", "list"], 3)).toEqual(["--agent=2", "containers", "list"]);
|
|
1326
|
+
});
|
|
1327
|
+
it("renames the environments command to agents only as the command word", () => {
|
|
1328
|
+
expect(cliArgs(["--output", "json", "environments", "version", "2"], 3)).toEqual(["--agent", "0", "--output", "json", "agents", "version", "2"]);
|
|
1329
|
+
expect(cliArgs(["projects", "get", "environments"], 3)).toEqual(["--agent", "0", "projects", "get", "environments"]);
|
|
1330
|
+
});
|
|
1331
|
+
it("reads the major version from arcane-cli --version", () => {
|
|
1332
|
+
expect(cliMajorOf("Arcane CLI version: 3.0.1\nGo version: go1.25.4\n")).toBe(3);
|
|
1333
|
+
expect(cliMajorOf("arcane-cli version v2.17.3\n")).toBe(2);
|
|
1334
|
+
expect(() => cliMajorOf("unknown")).toThrow(/printed no version/);
|
|
1335
|
+
});
|
|
1336
|
+
it("treats --agent as a global flag with a value", () => {
|
|
1337
|
+
expect(refusedPrefix(["--agent", "2", "auth", "login"])).toBe("auth");
|
|
1338
|
+
});
|
|
1339
|
+
});
|