benignswarm 0.12.96 → 0.12.97
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/dist/admin-index.js +0 -0
- package/dist/args.js +39 -3
- package/dist/brief.js +5 -1
- package/dist/client.js +206 -0
- package/dist/commands/admin.js +84 -22
- package/dist/commands/agent.js +15 -2
- package/dist/commands/cloud-admin.js +56 -3
- package/dist/commands/codex-start.js +333 -239
- package/dist/commands/environment-admin.js +130 -0
- package/dist/commands/environment.js +53 -0
- package/dist/commands/evidence.js +6 -3
- package/dist/commands/feedback.js +12 -1
- package/dist/commands/flow.js +153 -0
- package/dist/commands/hook.js +29 -9
- package/dist/commands/image-admin.js +77 -0
- package/dist/commands/install.js +81 -3
- package/dist/commands/lists.js +4 -0
- package/dist/commands/machine-admin.js +444 -111
- package/dist/commands/machine-resize.js +234 -0
- package/dist/commands/machine.js +957 -39
- package/dist/commands/operator.js +5 -8
- package/dist/commands/retire.js +4 -0
- package/dist/commands/templates.js +27 -0
- package/dist/commands/watch.js +43 -10
- package/dist/commands/wu.js +131 -81
- package/dist/container.js +480 -0
- package/dist/environment-checks.js +79 -0
- package/dist/git.js +28 -0
- package/dist/help.js +85 -34
- package/dist/index.js +5 -1
- package/dist/install.js +43 -1
- package/dist/macos-readiness.js +173 -0
- package/dist/output.js +15 -4
- package/dist/templates.js +218 -0
- package/dist/test-workers.js +17 -0
- package/dist/turn.js +6 -0
- package/dist/usage.js +117 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/commands/install.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { accessSync, constants, existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
|
|
3
|
-
import { delimiter, join } from "node:path";
|
|
2
|
+
import { accessSync, constants, existsSync, readFileSync, readdirSync, realpathSync, statfsSync } from "node:fs";
|
|
3
|
+
import { basename, delimiter, join } from "node:path";
|
|
4
|
+
import { homedir, platform } from "node:os";
|
|
4
5
|
import { bool } from "../args.js";
|
|
5
6
|
import { CliError } from "../errors.js";
|
|
6
7
|
import { binVersion, ensureCommandLinks, ensureInstall, latestPublished, lingerEnabled, readInstall, restartInstallServices, watcherServices } from "../install.js";
|
|
7
8
|
import { CLI_VERSION } from "../version.js";
|
|
8
9
|
import { refreshInstalledHooks } from "../harness.js";
|
|
10
|
+
import { configRoot } from "../config.js";
|
|
11
|
+
import { defaultWorkspaceWritableRoots } from "../start-options.js";
|
|
12
|
+
import { machineEnvironmentChecks } from "../environment-checks.js";
|
|
9
13
|
/**
|
|
10
14
|
* b9s install [<version> | --latest] make or upgrade this machine's one b9s install,
|
|
11
15
|
* repair PATH aliases and restart services that run it
|
|
@@ -42,6 +46,79 @@ export async function install(p, out) {
|
|
|
42
46
|
lines.push(`Not restarted:\n ${elsewhere.join("\n ")}`);
|
|
43
47
|
out.print(lines.join("\n"), { install: rec, restarted, not_restarted: elsewhere });
|
|
44
48
|
}
|
|
49
|
+
function diagnosticSpace(path) {
|
|
50
|
+
try {
|
|
51
|
+
const stat = statfsSync(path);
|
|
52
|
+
const total = stat.blocks * stat.bsize, free = stat.bavail * stat.bsize;
|
|
53
|
+
return Number.isSafeInteger(total) && Number.isSafeInteger(free) ? { free, total } : null;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function doctorStateCheck(root = join(configRoot(), "state")) {
|
|
60
|
+
const corrupt = [];
|
|
61
|
+
const unreadable = [];
|
|
62
|
+
const inspect = (dir) => {
|
|
63
|
+
let entries;
|
|
64
|
+
try {
|
|
65
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
unreadable.push(dir);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
for (const entry of entries) {
|
|
72
|
+
const path = join(dir, entry.name);
|
|
73
|
+
if (entry.isDirectory())
|
|
74
|
+
inspect(path);
|
|
75
|
+
else if (entry.isFile() && entry.name.endsWith(".json")) {
|
|
76
|
+
let contents;
|
|
77
|
+
try {
|
|
78
|
+
contents = readFileSync(path, "utf8");
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
unreadable.push(path);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
JSON.parse(contents);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
corrupt.push(path);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
if (existsSync(root))
|
|
94
|
+
inspect(root);
|
|
95
|
+
const status = corrupt.length ? "failed" : unreadable.length ? "unknown" : "healthy";
|
|
96
|
+
return {
|
|
97
|
+
check: "local_state_files", category: "state_file", component: "b9s local state", status,
|
|
98
|
+
observation: corrupt.length
|
|
99
|
+
? `local state JSON file(s) cannot be parsed: ${corrupt.map((path) => basename(path)).slice(0, 5).join(", ")}`
|
|
100
|
+
: unreadable.length ? `local state could not be inspected (${unreadable.map((path) => basename(path)).slice(0, 5).join(", ")})` : "local state JSON files can be read",
|
|
101
|
+
remedy: corrupt.length
|
|
102
|
+
? "Preserve the original file and a redacted parse diagnostic, check free disk space, then use the state owner's documented recovery; doctor does not reset state."
|
|
103
|
+
: unreadable.length ? "Check permissions and storage for the named local state path; preserve its contents and use the state owner's documented recovery." : null,
|
|
104
|
+
recovery_verified: status === "healthy",
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function doctorEnvironmentChecks(pathValue, writableRoots) {
|
|
108
|
+
const codexRun = spawnSync("codex", ["sandbox", "--", "true"], { encoding: "utf8", timeout: 10_000 });
|
|
109
|
+
const codexProbe = codexRun.error?.message.includes("ENOENT") ? undefined : { ok: codexRun.status === 0, error: codexRun.signal === "SIGTERM" ? "sandbox check timed out" : `exit ${codexRun.status ?? "unknown"}` };
|
|
110
|
+
const bwrapRun = platform() === "linux" ? spawnSync("bwrap", ["--ro-bind", "/", "/", "--dev", "/dev", "--proc", "/proc", "--unshare-all", "--die-with-parent", "true"], { encoding: "utf8", timeout: 10_000 }) : null;
|
|
111
|
+
const bwrapProbe = bwrapRun ? (bwrapRun.error?.message.includes("ENOENT") ? undefined : { ok: bwrapRun.status === 0, error: bwrapRun.signal === "SIGTERM" ? "sandbox check timed out" : `exit ${bwrapRun.status ?? "unknown"}${bwrapRun.stderr ? `: ${bwrapRun.stderr.slice(0, 200)}` : ""}` }) : undefined;
|
|
112
|
+
const home = diagnosticSpace(homedir()), work = diagnosticSpace(join(homedir(), "bschat"));
|
|
113
|
+
const facts = {
|
|
114
|
+
daemon_path: pathValue,
|
|
115
|
+
codex: codexProbe ? { sandbox: codexProbe } : null,
|
|
116
|
+
"claude-code": bwrapProbe ? { sandbox: bwrapProbe } : null,
|
|
117
|
+
disk_free_bytes: home?.free ?? null, disk_total_bytes: home?.total ?? null,
|
|
118
|
+
workdir_free_bytes: work?.free ?? null, workdir_total_bytes: work?.total ?? null,
|
|
119
|
+
};
|
|
120
|
+
return [...machineEnvironmentChecks(facts, writableRoots), doctorStateCheck()];
|
|
121
|
+
}
|
|
45
122
|
/**
|
|
46
123
|
* b9s doctor every b9s on this machine and who uses which: the recorded install, copies on
|
|
47
124
|
* PATH, npx caches, this repo's hook and instructions, and each watcher (plist versus
|
|
@@ -150,8 +227,9 @@ export async function doctor(_p, out) {
|
|
|
150
227
|
checks.push({ ok: true, what: `watcher ${short}: running ${args[0]} (${ver ?? "?"})` });
|
|
151
228
|
}
|
|
152
229
|
const problems = checks.filter((c) => !c.ok);
|
|
230
|
+
const environmentChecks = doctorEnvironmentChecks(process.env.PATH ?? "", defaultWorkspaceWritableRoots());
|
|
153
231
|
const text = checks.map((c) => `${c.ok ? "ok " : "PROBLEM "} ${c.what}${c.fix ? `\n fix: ${c.fix}` : ""}`).join("\n") + `\n${problems.length ? `${problems.length} problem${problems.length === 1 ? "" : "s"}.` : "No problems."}`;
|
|
154
|
-
out.print(text, { install: rec, checks, problems: problems.length });
|
|
232
|
+
out.print(text, { install: rec, checks, environment_checks: environmentChecks, problems: problems.length });
|
|
155
233
|
if (problems.length)
|
|
156
234
|
process.exitCode = 1;
|
|
157
235
|
}
|
package/dist/commands/lists.js
CHANGED
|
@@ -106,6 +106,8 @@ export async function list(p, out) {
|
|
|
106
106
|
const l = await resolveList(c, base, p.positionals[2]);
|
|
107
107
|
let body = str(p.flags, "body") ?? "";
|
|
108
108
|
const file = str(p.flags, "body-file");
|
|
109
|
+
if (file && str(p.flags, "body") !== undefined)
|
|
110
|
+
throw new CliError("usage", "list add accepts --body or --body-file, not both");
|
|
109
111
|
if (file)
|
|
110
112
|
body = readFileSync(file, "utf8");
|
|
111
113
|
const req = { title: p.positionals.slice(3).join(" "), body };
|
|
@@ -172,6 +174,8 @@ export async function item(p, out) {
|
|
|
172
174
|
req[key] = v;
|
|
173
175
|
}
|
|
174
176
|
const file = str(p.flags, "body-file");
|
|
177
|
+
if (file && str(p.flags, "body") !== undefined)
|
|
178
|
+
throw new CliError("usage", "item set accepts --body or --body-file, not both");
|
|
175
179
|
if (file)
|
|
176
180
|
req.body = readFileSync(file, "utf8");
|
|
177
181
|
const ev = str(p.flags, "evidence");
|