benignswarm 0.12.65 → 0.12.68
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/args.js +2 -2
- package/dist/commands/admin.js +3 -1
- package/dist/commands/codex-start.js +110 -48
- package/dist/commands/codex.js +11 -8
- package/dist/commands/machine-admin.js +5 -3
- package/dist/commands/machine.js +57 -21
- package/dist/commands/operator.js +27 -1
- package/dist/commands/watch.js +73 -57
- package/dist/commands/wu.js +41 -6
- package/dist/harness.js +21 -0
- package/dist/harnesses.js +268 -0
- package/dist/help.js +16 -8
- package/dist/index.js +13 -3
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/args.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { CliError } from "./errors.js";
|
|
3
|
-
export const STRING_FLAGS = ["as", "admin", "key", "url", "label", "model", "since", "limit", "after", "topic", "goal", "task", "state", "blocked-on", "tags", "custom", "vendor", "role", "description", "permissions", "cardinality", "machine", "dir", "confirm", "type", "name", "out", "token", "prefix", "uses", "expires-hours", "skill-dir", "harness", "reply-to", "event", "project", "projects", "post", "title", "body", "body-file", "handoff-to", "evidence", "agent", "parent", "parent-item", "channel", "statuses", "assign", "if-status", "status", "exec", "interval", "requeue-after", "unacked-after", "category", "command", "follow-delay", "env", "scope", "pr", "note", "add", "remove", "merged", "tag", "activity", "max-unanswered", "to", "replay-of", "branch", "effort", "by", "target", "milestone", "file", "exit", "depends-on", "source", "by", "on", "question", "ruling", "gaps", "unit", "units", "blocks", "sla", "takeover", "max-open", "max-in-progress", "require-scope", "require-evidence", "default-approver", "merged-by", "integrator-role", "require-rebased", "require-merge-commit", "require-pushed", "quiet", "summary", "meaning", "expert-role", "reviews", "works", "trials", "email", "repeat", "summary-minutes", "churn", "unmet", "require-cited-changes", "checks-every", "propose", "waits-on", "sandbox", "thread", "turn-timeout", "ssh", "variant", "count", "needs", "min-ram", "exclude", "carry", "from", "to-ssh", "wait", "writable"];
|
|
4
|
-
export const BOOL_FLAGS = ["latest", "no-restart", "json", "follow", "account", "help", "version", "broadcast", "create-channels", "read-account-status", "replace-key", "mentions-me", "no-skill", "replace", "unread", "force", "no-hooks", "yes", "open", "bind-here", "peek", "once", "launchd", "full", "no-bind", "all", "here", "keep-worktree", "prune", "abandon", "defer", "hold", "clear", "met", "shared", "archive", "approve", "turn", "service", "print-hooks", "create", "rotate", "codex-userns", "print-apparmor"];
|
|
3
|
+
export const STRING_FLAGS = ["as", "admin", "key", "url", "label", "model", "since", "limit", "after", "topic", "goal", "task", "state", "blocked-on", "tags", "custom", "vendor", "role", "description", "permissions", "cardinality", "machine", "dir", "confirm", "type", "name", "out", "token", "prefix", "uses", "expires-hours", "skill-dir", "harness", "reply-to", "event", "project", "projects", "post", "title", "body", "body-file", "handoff-to", "evidence", "agent", "parent", "parent-item", "channel", "statuses", "assign", "if-status", "status", "exec", "interval", "requeue-after", "unacked-after", "category", "command", "follow-delay", "env", "scope", "pr", "note", "add", "remove", "merged", "tag", "activity", "max-unanswered", "to", "replay-of", "branch", "effort", "by", "target", "milestone", "file", "exit", "depends-on", "source", "by", "on", "question", "ruling", "gaps", "unit", "units", "blocks", "sla", "takeover", "max-open", "max-in-progress", "require-scope", "require-evidence", "default-approver", "merged-by", "integrator-role", "require-rebased", "require-merge-commit", "require-pushed", "quiet", "summary", "meaning", "expert-role", "reviews", "works", "trials", "email", "repeat", "summary-minutes", "churn", "unmet", "require-cited-changes", "checks-every", "propose", "waits-on", "sandbox", "thread", "turn-timeout", "session", "plain", "if-yes", "if-no", "ssh", "variant", "count", "needs", "min-ram", "exclude", "carry", "from", "to-ssh", "wait", "writable"];
|
|
4
|
+
export const BOOL_FLAGS = ["latest", "no-restart", "json", "follow", "account", "help", "version", "broadcast", "create-channels", "read-account-status", "replace-key", "mentions-me", "no-skill", "replace", "unread", "force", "no-hooks", "yes", "open", "bind-here", "peek", "once", "launchd", "full", "no-bind", "all", "here", "keep-worktree", "prune", "abandon", "defer", "hold", "clear", "met", "shared", "archive", "approve", "turn", "service", "print-hooks", "create", "rotate", "codex-userns", "bwrap-userns", "print-apparmor"];
|
|
5
5
|
export function parse(argv) {
|
|
6
6
|
const options = {};
|
|
7
7
|
for (const f of STRING_FLAGS)
|
package/dist/commands/admin.js
CHANGED
|
@@ -8,7 +8,7 @@ import { CliError } from "../errors.js";
|
|
|
8
8
|
import { table } from "../output.js";
|
|
9
9
|
import { milestoneWith, milestonesWith } from "./wu.js";
|
|
10
10
|
import { agentMove, machineAdmin, poolAdmin, projectCheckoutAdmin, projectRepoAdmin } from "./machine-admin.js";
|
|
11
|
-
import { accountAdmin, answerAdmin, keysAdmin, needsAdmin, notifierAdmin, processAdmin, skillAdmin, tagList, worktreeAdmin } from "./operator.js";
|
|
11
|
+
import { accountAdmin, answerAdmin, explainAdmin, keysAdmin, needsAdmin, notifierAdmin, processAdmin, skillAdmin, tagList, worktreeAdmin } from "./operator.js";
|
|
12
12
|
function adminClient(p) {
|
|
13
13
|
return Client.forAdmin(loadAdmin(resolveAdminName(str(p.flags, "admin"))));
|
|
14
14
|
}
|
|
@@ -90,6 +90,8 @@ export async function admin(p, out) {
|
|
|
90
90
|
return needsAdmin(p, out);
|
|
91
91
|
case "answer":
|
|
92
92
|
return answerAdmin([action, ...rest].filter((x) => x !== undefined), p, out);
|
|
93
|
+
case "explain":
|
|
94
|
+
return explainAdmin([action, ...rest].filter((x) => x !== undefined), p, out);
|
|
93
95
|
case "notifier":
|
|
94
96
|
return notifierAdmin(p, out);
|
|
95
97
|
case "account":
|
|
@@ -12,26 +12,33 @@ import { CODEX_MANAGED_MARK } from "../harness.js";
|
|
|
12
12
|
import { readState, writeState } from "../state.js";
|
|
13
13
|
import { join } from "./join.js";
|
|
14
14
|
import { installWatcherService } from "./watch.js";
|
|
15
|
+
import { randomUUID } from "node:crypto";
|
|
16
|
+
import { HARNESS_BIN, HARNESS_LABEL, claudeResultError, claudeResultFile, claudeSettings, claudeTranscript } from "../harnesses.js";
|
|
15
17
|
const SANDBOXES = ["read-only", "workspace-write", "danger-full-access"];
|
|
16
18
|
/**
|
|
17
|
-
* `bschat codex start
|
|
18
|
-
* app involved, so it works the same over ssh on a remote machine. It enrolls the
|
|
19
|
-
* invite token), starts its
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* the Codex app's queue silently not delivering wake-ups (fabricbios luna-worker, ten hours).
|
|
19
|
+
* `bschat start` (and `bschat codex start`): one command that brings an agent up on this machine
|
|
20
|
+
* headless, with no app involved, so it works the same over ssh on a remote machine. It enrolls the
|
|
21
|
+
* agent (with an invite token), starts its session with an onboarding turn, binds it so the hooks
|
|
22
|
+
* deliver to it, and installs a turn-mode watcher that runs each later turn itself (Codex: `codex exec
|
|
23
|
+
* resume`; Claude Code: `claude -p --resume`). `--thread` adopts an existing session instead. Learned
|
|
24
|
+
* from the Codex app's queue silently not delivering wake-ups (fabricbios luna-worker, ten hours).
|
|
23
25
|
*
|
|
24
|
-
* bschat
|
|
25
|
-
*
|
|
26
|
+
* bschat start --harness codex|claude-code --as <name> --sandbox <mode> [--token bs_enroll_...]
|
|
27
|
+
* [--thread <id>] [--model m] [--effort e] [--turn-timeout 180] [--interval 30] [--prune]
|
|
26
28
|
*/
|
|
27
29
|
export async function codexStart(p, out) {
|
|
30
|
+
return harnessStart(p, out, "codex");
|
|
31
|
+
}
|
|
32
|
+
export async function harnessStart(p, out, harness) {
|
|
33
|
+
const label = HARNESS_LABEL[harness];
|
|
34
|
+
const cmd = harness === "codex" ? "codex start" : "start";
|
|
28
35
|
const name = str(p.flags, "as");
|
|
29
36
|
if (!name)
|
|
30
|
-
throw new CliError("usage",
|
|
37
|
+
throw new CliError("usage", `${cmd} needs --as <agent-name>`);
|
|
31
38
|
const sandbox = str(p.flags, "sandbox");
|
|
32
39
|
// No default: what a headless agent may touch on this machine is the operator's call, every time.
|
|
33
40
|
if (!sandbox || !SANDBOXES.includes(sandbox))
|
|
34
|
-
throw new CliError("usage",
|
|
41
|
+
throw new CliError("usage", `${cmd} needs --sandbox <${SANDBOXES.join("|")}>: what the agent may do on this machine, since a headless turn cannot ask for approval`);
|
|
35
42
|
const turnTimeout = Number(str(p.flags, "turn-timeout") ?? "180");
|
|
36
43
|
if (!Number.isInteger(turnTimeout) || turnTimeout < 5)
|
|
37
44
|
throw new CliError("usage", "--turn-timeout must be a whole number of minutes, at least 5");
|
|
@@ -39,75 +46,130 @@ export async function codexStart(p, out) {
|
|
|
39
46
|
if (!Number.isInteger(interval) || interval < 5)
|
|
40
47
|
throw new CliError("usage", "--interval must be an integer number of seconds, at least 5");
|
|
41
48
|
if (process.platform !== "darwin" && process.platform !== "linux")
|
|
42
|
-
throw new CliError("unsupported",
|
|
43
|
-
const
|
|
49
|
+
throw new CliError("unsupported", `${cmd} installs its watcher with launchd (macOS) or systemd (Linux)`);
|
|
50
|
+
const bin = which(HARNESS_BIN[harness], harness === "codex" ? "install the Codex CLI (npm i -g @openai/codex)" : "install Claude Code (npm i -g @anthropic-ai/claude-code)");
|
|
44
51
|
const model = str(p.flags, "model");
|
|
45
52
|
const effort = str(p.flags, "effort");
|
|
46
|
-
const adopt = str(p.flags, "thread");
|
|
53
|
+
const adopt = str(p.flags, "thread") ?? str(p.flags, "session");
|
|
54
|
+
// The machine's toolchain and job folders a sandboxed agent may also write (bschat-admin machine writable).
|
|
55
|
+
const writable = (str(p.flags, "writable") ?? "").split(",").map((w) => w.trim()).filter(Boolean).map((w) => (w.startsWith("~/") ? joinPath(homedir(), w.slice(2)) : w));
|
|
56
|
+
if (writable.some((w) => !w.startsWith("/")))
|
|
57
|
+
throw new CliError("usage", "--writable takes absolute or ~/ paths, comma separated");
|
|
58
|
+
// Refuses a sandbox the harness cannot honour before anything is enrolled.
|
|
59
|
+
const settings = harness === "codex"
|
|
60
|
+
? codexSettings(sandbox, model, effort, process.cwd(), configRoot(), writable)
|
|
61
|
+
: claudeSettings(sandbox, model, effort, process.cwd(), configRoot(), writable);
|
|
47
62
|
// 1. Who: enroll with the invite token, or use credentials already on this machine.
|
|
48
63
|
const lines = [];
|
|
49
64
|
const token = str(p.flags, "token");
|
|
50
65
|
if (token) {
|
|
51
66
|
const joined = [];
|
|
52
|
-
await join({ ...p, flags: { ...p.flags, vendor:
|
|
67
|
+
await join({ ...p, flags: { ...p.flags, vendor: harness, model } }, { json: false, print: (h) => joined.push(h) });
|
|
53
68
|
lines.push(joined.join("\n").split("\n")[0]);
|
|
54
69
|
}
|
|
55
70
|
const creds = loadAgent(name);
|
|
56
|
-
if (creds.vendor && creds.vendor !==
|
|
57
|
-
throw new CliError("vendor_mismatch", `${agentRef(creds)} is saved as ${creds.vendor}, not
|
|
71
|
+
if (creds.vendor && creds.vendor !== harness)
|
|
72
|
+
throw new CliError("vendor_mismatch", `${agentRef(creds)} is saved as ${creds.vendor}, not ${harness}`);
|
|
58
73
|
const ref = agentRef(creds);
|
|
59
74
|
requireInstall();
|
|
60
|
-
// 2. Its
|
|
61
|
-
|
|
62
|
-
const writable = (str(p.flags, "writable") ?? "").split(",").map((w) => w.trim()).filter(Boolean).map((w) => (w.startsWith("~/") ? joinPath(homedir(), w.slice(2)) : w));
|
|
63
|
-
if (writable.some((w) => !w.startsWith("/")))
|
|
64
|
-
throw new CliError("usage", "--writable takes absolute or ~/ paths, comma separated");
|
|
65
|
-
const settings = codexSettings(sandbox, model, effort, process.cwd(), configRoot(), writable);
|
|
66
|
-
let thread;
|
|
75
|
+
// 2. Its session: adopt one, or start one headless with an onboarding turn.
|
|
76
|
+
let session;
|
|
67
77
|
let firstTurnLog = null;
|
|
68
78
|
if (adopt) {
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
session = adopt.toLowerCase();
|
|
80
|
+
if (harness === "codex") {
|
|
81
|
+
if (!codexRollout(session)) {
|
|
82
|
+
if (codexArchivedRollout(session))
|
|
83
|
+
throw new CliError("archived", `Codex thread ${session} is archived (its session file is in ~/.codex/archived_sessions)`, "Unarchive it in the Codex app, then leave it unopened there and run this again");
|
|
84
|
+
throw new CliError("not_found", `no Codex session file for thread ${session} under ~/.codex/sessions on this machine`);
|
|
85
|
+
}
|
|
86
|
+
lines.push(`Adopted Codex thread ${session}. Leave it unopened in the Codex app (do not archive it: that moves its session file away): from now on the watcher runs its turns, and two clients on one thread conflict.`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (!claudeTranscript(session))
|
|
90
|
+
throw new CliError("not_found", `no Claude Code transcript for session ${session} under ~/.claude/projects on this machine`);
|
|
91
|
+
lines.push(`Adopted Claude Code session ${session}. Do not resume it in a terminal while the watcher runs it: two clients on one session conflict.`);
|
|
74
92
|
}
|
|
75
|
-
lines.push(`Adopted Codex thread ${thread}. Leave it unopened in the Codex app (do not archive it: that moves its session file away): from now on the watcher runs its turns, and two clients on one thread conflict.`);
|
|
76
93
|
}
|
|
77
94
|
else {
|
|
78
95
|
const logDir = joinPath(homedir(), ".bschat", "logs");
|
|
79
96
|
mkdirSync(logDir, { recursive: true });
|
|
80
|
-
firstTurnLog = joinPath(logDir,
|
|
97
|
+
firstTurnLog = joinPath(logDir, `${harness}.${ref.replace("/", ".")}.first-turn.${harness === "codex" ? "jsonl" : "json"}`);
|
|
81
98
|
const prompt = [
|
|
82
|
-
`[bschat] You are ${ref}, a BenignSwarm agent, started headless by \`bschat
|
|
99
|
+
`[bschat] You are ${ref}, a BenignSwarm agent, started headless by \`bschat ${cmd}\`; nobody is typing to you.`,
|
|
83
100
|
`Your watcher starts a turn for you whenever something needs you, so end your turn when nothing is left to do.`,
|
|
84
101
|
`Now: run \`bschat me\`, \`bschat process\` and \`bschat inbox --unread\`, then do what your role and inbox ask.`,
|
|
85
102
|
`If you ran on another machine before, read your latest note first: \`bschat handoffs --agent ${creds.agent}\` (your units, branches and chat are on the server as before).`,
|
|
86
103
|
].join("\n");
|
|
87
|
-
|
|
88
|
-
|
|
104
|
+
if (harness === "codex") {
|
|
105
|
+
session = await startThread(bin, ["exec", "--json", ...settings, prompt], firstTurnLog, ref);
|
|
106
|
+
lines.push(`Started Codex thread ${session}; its first turn (reading its role and inbox) is running, log: ${firstTurnLog}`);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// Claude Code takes the session id from us, so nothing has to be read back from its output.
|
|
110
|
+
session = randomUUID();
|
|
111
|
+
await startClaudeSession(bin, ["-p", prompt, ...settings, "--session-id", session, "--output-format", "json"], firstTurnLog, ref, session);
|
|
112
|
+
lines.push(`Started Claude Code session ${session}; its first turn (reading its role and inbox) is running, result: ${firstTurnLog}`);
|
|
113
|
+
}
|
|
89
114
|
}
|
|
90
|
-
// 3. Bind it, so the hooks in that
|
|
91
|
-
|
|
92
|
-
|
|
115
|
+
// 3. Bind it, so the hooks in that session deliver to this agent and nobody else. Claude Code's
|
|
116
|
+
// hook knows the agent from BSCHAT_AGENT (the watcher sets it for every turn), so it needs no map.
|
|
117
|
+
if (harness === "codex")
|
|
118
|
+
bindSession("codex", session, ref);
|
|
119
|
+
// A session adopted here may end in a usage-limit error from the machine it came from, written in
|
|
93
120
|
// that machine's local time ("3:32 PM" Central read as UTC on ronald: six hours off). Only errors
|
|
94
121
|
// from turns on this machine pause it; if the account is still limited, the next turn says so here.
|
|
95
122
|
if (adopt)
|
|
96
123
|
writeState(ref, { ...readState(ref), turn_unpaused_at: Date.now() });
|
|
97
124
|
// 4. The watcher, in turn mode: it runs each later turn itself.
|
|
98
|
-
const exec =
|
|
125
|
+
const exec = harness === "codex"
|
|
126
|
+
? [bin, "exec", "resume", session, ...settings].map(shq).join(" ") + " {text}"
|
|
127
|
+
// The result goes to a file the watcher reads when the turn ends: Claude Code can exit 0 with is_error set.
|
|
128
|
+
: `${shq(bin)} -p {text} ${[...settings, "--resume", session, "--output-format", "json"].map(shq).join(" ")} > ${shq(claudeResultFile(ref))}`;
|
|
99
129
|
const watcherOut = [];
|
|
100
|
-
installWatcherService(ref, exec, interval, Number(str(p.flags, "follow-delay") ?? "300"), {}, undefined, { json: false, print: (h) => watcherOut.push(h) }, bool(p.flags, "prune"), turnTimeout);
|
|
130
|
+
installWatcherService(ref, exec, interval, Number(str(p.flags, "follow-delay") ?? "300"), {}, undefined, { json: false, print: (h) => watcherOut.push(h) }, bool(p.flags, "prune"), { harness, session, timeout: turnTimeout });
|
|
101
131
|
const wl = watcherOut.join("\n").split("\n");
|
|
102
132
|
lines.push(wl[0].replace(/^Wrote /, "Watcher: wrote "), ...wl.filter((l) => l.startsWith("Linger is off")));
|
|
103
|
-
// 5. Hooks
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
133
|
+
// 5. Hooks.
|
|
134
|
+
let missing = [];
|
|
135
|
+
if (harness === "codex") {
|
|
136
|
+
// A headless turn cannot show Codex's trust prompt, and bschat never pre-approves it.
|
|
137
|
+
missing = untrustedHooks();
|
|
138
|
+
lines.push(missing.length
|
|
139
|
+
? `Codex has not trusted bschat's hooks (${missing.join(", ")}) on this machine, so turns run without them: no standing rules at session start, no continuing when work arrives mid-turn. Wake-ups still work. To trust them, run \`codex\` once in a terminal here and approve the hooks when it asks.`
|
|
140
|
+
: `Codex has trust entries for bschat's hooks here. If they changed since they were trusted, Codex skips them until approved again in an interactive \`codex\`.`);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
lines.push(`Claude Code runs bschat's hooks from this checkout's .claude/settings.local.json (written by join).`);
|
|
144
|
+
}
|
|
145
|
+
lines.push(`Follow it: tail -f ~/.bschat/logs/watch.${ref.replace("/", ".")}.err.log; ${harness === "codex" ? `read its thread with codex resume ${session}` : `read its transcript under ~/.claude/projects (session ${session})`} only while no turn is running.`);
|
|
146
|
+
lines.push(`If the ${label} account hits its usage limit, the watcher pauses turns until the time ${label} gives; after switching to an account with quota, resume at once: bschat unpause --as ${ref}`);
|
|
147
|
+
out.print(lines.join("\n"), { agent: ref, harness, thread: session, session, sandbox, model: model ?? null, effort: effort ?? null, exec, first_turn_log: firstTurnLog, untrusted_hooks: missing });
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Starts a headless Claude Code session in its own process group (the first turn may take many
|
|
151
|
+
* minutes; this command does not wait for it) and returns once its transcript exists, or fails
|
|
152
|
+
* with Claude Code's own error when it exits first.
|
|
153
|
+
*/
|
|
154
|
+
async function startClaudeSession(bin, args, logPath, agent, session) {
|
|
155
|
+
const fd = openSync(logPath, "w");
|
|
156
|
+
const child = spawn(bin, args, { stdio: ["ignore", fd, fd], detached: true, cwd: process.cwd(), env: { ...process.env, BSCHAT_AGENT: agent } });
|
|
157
|
+
closeSync(fd);
|
|
158
|
+
let exited = null;
|
|
159
|
+
child.on("exit", (code) => { exited = code ?? 1; });
|
|
160
|
+
child.unref();
|
|
161
|
+
for (let i = 0; i < 180; i++) {
|
|
162
|
+
if (exited !== null) {
|
|
163
|
+
const error = claudeResultError(readFileSync(logPath, "utf8"));
|
|
164
|
+
if (exited !== 0 || error)
|
|
165
|
+
throw new CliError("claude_failed", `claude exited ${exited} in its first turn: ${error ?? "no error reported"}; see ${logPath}`);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (claudeTranscript(session))
|
|
169
|
+
return;
|
|
170
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
171
|
+
}
|
|
172
|
+
throw new CliError("claude_failed", `Claude Code wrote no transcript for session ${session} within 90 s; see ${logPath}`);
|
|
111
173
|
}
|
|
112
174
|
/**
|
|
113
175
|
* The Codex settings a headless turn runs with. Under workspace-write the agent still has to reach
|
|
@@ -175,11 +237,11 @@ function readCodexConfig() {
|
|
|
175
237
|
const f = joinPath(process.env.CODEX_HOME ?? joinPath(homedir(), ".codex"), "config.toml");
|
|
176
238
|
return existsSync(f) ? readFileSync(f, "utf8") : "";
|
|
177
239
|
}
|
|
178
|
-
function which(bin) {
|
|
240
|
+
function which(bin, install) {
|
|
179
241
|
const r = spawnSync("/bin/sh", ["-c", `command -v ${bin}`], { encoding: "utf8" });
|
|
180
242
|
const path = r.stdout.trim();
|
|
181
243
|
if (r.status !== 0 || !path)
|
|
182
|
-
throw new CliError("not_found", `${bin} is not on PATH; install
|
|
244
|
+
throw new CliError("not_found", `${bin} is not on PATH; ${install} first`);
|
|
183
245
|
return path;
|
|
184
246
|
}
|
|
185
247
|
const shq = (s) => (/^[\w./=:@-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`);
|
package/dist/commands/codex.js
CHANGED
|
@@ -51,14 +51,17 @@ export async function codex(p, out) {
|
|
|
51
51
|
}
|
|
52
52
|
if (sub === "start")
|
|
53
53
|
return codexStart(p, out);
|
|
54
|
-
if (sub === "unpause")
|
|
55
|
-
|
|
56
|
-
// switched Codex to an account with quota, this lets the next poll start a turn instead.
|
|
57
|
-
const name = resolveAgentName(str(p.flags, "as"));
|
|
58
|
-
writeState(name, { ...readState(name), turn_unpaused_at: Date.now() });
|
|
59
|
-
out.print(`Turns for ${name} may start again: its watcher lifts the usage-limit pause on its next poll (within its --interval).`, { agent: name, unpaused: true });
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
54
|
+
if (sub === "unpause")
|
|
55
|
+
return unpause(p, out);
|
|
62
56
|
throw new CliError("usage", "codex hooks | codex bind <thread-id> [--as <agent>] | codex sync | codex start --as <name> --sandbox <mode> [--token ...] [--thread <id>] | codex unpause [--as <agent>]");
|
|
63
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* After a usage limit the watcher waits for the reset time the harness gave. When the operator has
|
|
60
|
+
* switched the harness to an account with quota, this lets the next poll start a turn instead.
|
|
61
|
+
*/
|
|
62
|
+
export async function unpause(p, out) {
|
|
63
|
+
const name = resolveAgentName(str(p.flags, "as"));
|
|
64
|
+
writeState(name, { ...readState(name), turn_unpaused_at: Date.now() });
|
|
65
|
+
out.print(`Turns for ${name} may start again: its watcher lifts the usage-limit pause on its next poll (within its --interval).`, { agent: name, unpaused: true });
|
|
66
|
+
}
|
|
64
67
|
export const codexHooksPath = () => join(process.env.CODEX_HOME ?? join(homedir(), ".codex"), "hooks.json");
|
|
@@ -10,7 +10,7 @@ import { CLI_VERSION } from "../version.js";
|
|
|
10
10
|
* sessions they run (docs/REMOTE-MACHINES.md). The server never sees an ssh credential: every ssh
|
|
11
11
|
* call here runs in the operator's terminal, and the machine key reaches the machine on ssh's stdin.
|
|
12
12
|
*
|
|
13
|
-
* machine add <name> --ssh <host> [--rotate] [--codex-userns]
|
|
13
|
+
* machine add <name> --ssh <host> [--rotate] [--codex-userns] [--bwrap-userns]
|
|
14
14
|
* machine list | show <name> | remove <name>
|
|
15
15
|
* machine session add <machine> <project>/<agent> --dir <path> --sandbox <mode> [--create --role r] [--model m] [--effort e] [--thread id] [--turn-timeout min]
|
|
16
16
|
* machine session stop|start|remove <machine> <project>/<agent>
|
|
@@ -70,7 +70,7 @@ export async function machineAdmin(action, rest, p, out) {
|
|
|
70
70
|
const name = rest[0];
|
|
71
71
|
const host = str(p.flags, "ssh");
|
|
72
72
|
if (!name || !host)
|
|
73
|
-
throw new CliError("usage", "machine add <name> --ssh <host> [--rotate] [--codex-userns] (the host as your ssh knows it: an alias, user@host)");
|
|
73
|
+
throw new CliError("usage", "machine add <name> --ssh <host> [--rotate] [--codex-userns] [--bwrap-userns] (the host as your ssh knows it: an alias, user@host)");
|
|
74
74
|
const lines = [];
|
|
75
75
|
const say = (l) => { lines.push(l); if (!out.json)
|
|
76
76
|
process.stderr.write(`${l}\n`); };
|
|
@@ -82,7 +82,7 @@ export async function machineAdmin(action, rest, p, out) {
|
|
|
82
82
|
if (boot.status !== 0)
|
|
83
83
|
throw new CliError("provision_failed", `bootstrapping ${host} failed${steps.length ? `: ${steps[steps.length - 1]}` : `: ${boot.stderr.trim().slice(-300)}`}`);
|
|
84
84
|
// 2. Linger, Codex, managed hooks: checked and fixed on the machine itself.
|
|
85
|
-
const prep = remoteBschat(host, `machine prepare --json${bool(p.flags, "codex-userns") ? " --codex-userns" : ""}`);
|
|
85
|
+
const prep = remoteBschat(host, `machine prepare --json${bool(p.flags, "codex-userns") ? " --codex-userns" : ""}${bool(p.flags, "bwrap-userns") ? " --bwrap-userns" : ""}`);
|
|
86
86
|
if (prep.status !== 0)
|
|
87
87
|
throw new CliError("provision_failed", `bschat machine prepare on ${host} failed: ${prep.stderr.trim().slice(-300)}`);
|
|
88
88
|
const prepared = JSON.parse(prep.stdout).steps;
|
|
@@ -330,6 +330,8 @@ export async function agentMove(rest, p, out) {
|
|
|
330
330
|
throw new CliError("usage", "agent move <project>/<agent> --to <machine> --sandbox <mode> [--dir <path>|auto] [--carry note|thread] [--from local|<ssh host>] [--model m] [--effort e] [--wait min] [--force]");
|
|
331
331
|
if (carry !== "note" && carry !== "thread")
|
|
332
332
|
throw new CliError("usage", "--carry note (a resume note it writes now) or thread (its Codex thread, copied)");
|
|
333
|
+
if (carry === "thread" && (str(p.flags, "harness") ?? "codex") !== "codex")
|
|
334
|
+
throw new CliError("usage", "--carry thread copies a Codex thread; a Claude Code agent moves with --carry note (its resume note), and its new machine starts a fresh session");
|
|
333
335
|
if (carry === "thread" && !from)
|
|
334
336
|
throw new CliError("usage", "--carry thread needs --from local|<ssh host>: the machine whose ~/.codex holds its thread");
|
|
335
337
|
const c = adminClient(p);
|
package/dist/commands/machine.js
CHANGED
|
@@ -6,11 +6,10 @@ import { str } from "../args.js";
|
|
|
6
6
|
import { Client } from "../client.js";
|
|
7
7
|
import { configRoot, loadAgent, saveAgent } from "../config.js";
|
|
8
8
|
import { CliError } from "../errors.js";
|
|
9
|
-
import { CODEX_APPARMOR_PATH, CODEX_MANAGED_DIR, CODEX_MANAGED_MARK, codexAppArmorProfile, codexManagedHooks } from "../harness.js";
|
|
9
|
+
import { BWRAP_APPARMOR_PATH, bwrapAppArmorProfile, CODEX_APPARMOR_PATH, CODEX_MANAGED_DIR, CODEX_MANAGED_MARK, codexAppArmorProfile, codexManagedHooks } from "../harness.js";
|
|
10
10
|
import { applySparse } from "../git.js";
|
|
11
|
-
import {
|
|
11
|
+
import { TURN_HARNESSES, claudeFacts, claudeSandbox, probeFor, sessionProcesses } from "../harnesses.js";
|
|
12
12
|
import { readState, writeState } from "../state.js";
|
|
13
|
-
import { readTurnPhase, usageLimitUntil } from "../turn.js";
|
|
14
13
|
import { installService, lingerEnabled, MACHINE_LABEL, removeService, requireInstall, restartWatcher, serviceActive, WATCH_LABEL_PREFIX, watcherServices } from "../install.js";
|
|
15
14
|
import { CLI_VERSION } from "../version.js";
|
|
16
15
|
export const machineFile = () => join(configRoot(), "machine.json");
|
|
@@ -29,10 +28,10 @@ function writeMachineState(s) {
|
|
|
29
28
|
/** What a session's watcher is started with; a change means re-running codex start. The thread is compared separately. */
|
|
30
29
|
export const sessionFingerprint = (s, writable = []) => JSON.stringify([s.harness, s.dir, s.sandbox, s.model, s.effort, s.turn_timeout, ...(writable.length ? [writable] : [])]);
|
|
31
30
|
export const watchLabelOf = (ref) => `${WATCH_LABEL_PREFIX}${ref.replace("/", ".")}`;
|
|
32
|
-
/** The `bschat
|
|
31
|
+
/** The `bschat start` arguments that bring a session up (adopting its thread or session when known). */
|
|
33
32
|
export function startArgs(s, thread, writable = []) {
|
|
34
33
|
return [
|
|
35
|
-
"
|
|
34
|
+
"start", "--harness", s.harness, "--as", s.agent, "--sandbox", s.sandbox, "--turn-timeout", String(s.turn_timeout), "--json",
|
|
36
35
|
...(s.model ? ["--model", s.model] : []),
|
|
37
36
|
...(s.effort ? ["--effort", s.effort] : []),
|
|
38
37
|
...(thread ? ["--thread", thread] : []),
|
|
@@ -64,7 +63,7 @@ export async function reconcile(m, log) {
|
|
|
64
63
|
out.push({ id: s.id, state: "stopped" });
|
|
65
64
|
continue;
|
|
66
65
|
}
|
|
67
|
-
if (s.harness
|
|
66
|
+
if (!TURN_HARNESSES.includes(s.harness))
|
|
68
67
|
throw new Error(`harness ${s.harness} is not supported by this bschat ${CLI_VERSION}`);
|
|
69
68
|
if (!s.dir) {
|
|
70
69
|
// A pool session: the daemon makes the checkout (clone once per machine, a worktree per agent).
|
|
@@ -85,10 +84,10 @@ export async function reconcile(m, log) {
|
|
|
85
84
|
if (!svc() || !local || local.fingerprint !== fp || threadChanged) {
|
|
86
85
|
const r = spawnSync(bin, startArgs(s, thread, writable), { cwd: s.dir, encoding: "utf8", timeout: 180_000 });
|
|
87
86
|
if (r.status !== 0)
|
|
88
|
-
throw new Error(`
|
|
87
|
+
throw new Error(`bschat start failed: ${errorText(r.stderr || r.stdout)}`);
|
|
89
88
|
const started = JSON.parse(r.stdout);
|
|
90
89
|
state.sessions[s.id] = { label, fingerprint: fp, thread: started.thread, key_checked_at: state.sessions[s.id]?.key_checked_at ?? Date.now() };
|
|
91
|
-
log(`${s.agent}: ${thread ?
|
|
90
|
+
log(`${s.agent}: ${thread ? "adopted" : "started"} ${s.harness === "codex" ? "thread" : "session"} ${started.thread} in ${s.dir}`);
|
|
92
91
|
}
|
|
93
92
|
else {
|
|
94
93
|
const w = svc();
|
|
@@ -106,7 +105,7 @@ export async function reconcile(m, log) {
|
|
|
106
105
|
state.sessions[s.id].unpause_applied = s.unpause_at;
|
|
107
106
|
log(`${s.agent}: usage-limit pause lifted by the operator`);
|
|
108
107
|
}
|
|
109
|
-
out.push({ id: s.id, state: "running", dir: s.dir, thread: th, watcher: w && serviceActive(w) ? "active" : "inactive", last_turn: lastTurnLine(s.agent), ...turnFacts(s.agent, th) });
|
|
108
|
+
out.push({ id: s.id, state: "running", dir: s.dir, thread: th, watcher: w && serviceActive(w) ? "active" : "inactive", last_turn: lastTurnLine(s.agent), ...turnFacts(s.agent, s.harness, th) });
|
|
110
109
|
}
|
|
111
110
|
catch (e) {
|
|
112
111
|
const error = e.message.slice(0, 1000);
|
|
@@ -279,20 +278,23 @@ function errorText(s) {
|
|
|
279
278
|
return last.slice(0, 500);
|
|
280
279
|
}
|
|
281
280
|
}
|
|
282
|
-
/** Whether the
|
|
283
|
-
function turnFacts(agent, thread) {
|
|
284
|
-
const
|
|
285
|
-
if (!thread || !
|
|
281
|
+
/** Whether the session has a turn running, its process, and a usage-limit pause still in force. */
|
|
282
|
+
function turnFacts(agent, harness, thread) {
|
|
283
|
+
const ph = thread ? probeFor(harness, thread, agent).phase() : null;
|
|
284
|
+
if (!thread || !ph || "missing" in ph)
|
|
286
285
|
return { turn: { running: false, since: null }, process: null, paused_until: null };
|
|
287
|
-
const
|
|
288
|
-
const until = !ph.running ? usageLimitUntil(ph.lastError) : null;
|
|
286
|
+
const until = !ph.running ? probeFor(harness, thread, agent).limitUntil(ph.lastError) : null;
|
|
289
287
|
const unpausedAt = readState(agent).turn_unpaused_at ?? 0;
|
|
290
|
-
const paused = until && until > Date.now() && Date.parse(ph.
|
|
291
|
-
return { turn: { running: ph.running, since: ph.running ? ph.startedAt : ph.lastEventAt }, process: ph.running ? turnProcess(thread) : null, paused_until: paused };
|
|
288
|
+
const paused = until && until > Date.now() && Date.parse(ph.lastErrorAt ?? "") > unpausedAt ? new Date(until).toISOString() : null;
|
|
289
|
+
return { turn: { running: ph.running, since: ph.running ? ph.startedAt : ph.lastEventAt }, process: ph.running ? turnProcess(thread, harness) : null, paused_until: paused };
|
|
292
290
|
}
|
|
293
|
-
/** The
|
|
294
|
-
export function turnProcess(thread, psOutput) {
|
|
291
|
+
/** The harness process running a turn of this session (`codex exec resume <thread>`, `claude ... --resume <id>`), from ps. */
|
|
292
|
+
export function turnProcess(thread, harness = "codex", psOutput) {
|
|
295
293
|
const out = psOutput ?? (spawnSync("ps", ["-axo", "pid=,pcpu=,rss=,args="], { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 }).stdout ?? "");
|
|
294
|
+
if (harness === "claude-code") {
|
|
295
|
+
const p = sessionProcesses(thread, out)[0];
|
|
296
|
+
return p ? { pid: p.pid, cpu: p.cpu, rss_bytes: p.rss_bytes } : null;
|
|
297
|
+
}
|
|
296
298
|
for (const line of out.split("\n")) {
|
|
297
299
|
const m = /^\s*(\d+)\s+([\d.]+)\s+(\d+)\s+(.*)$/.exec(line);
|
|
298
300
|
if (m && /\bcodex\b/.test(m[4]) && m[4].includes(`exec resume ${thread}`) && !m[4].startsWith("/bin/sh"))
|
|
@@ -336,6 +338,16 @@ function memAvailable() {
|
|
|
336
338
|
}
|
|
337
339
|
return freemem();
|
|
338
340
|
}
|
|
341
|
+
/** Claude Code's version, login and sandbox; the sandbox check runs at most every 10 min. */
|
|
342
|
+
let claudeSandboxCache = null;
|
|
343
|
+
function claudeReport() {
|
|
344
|
+
const f = claudeFacts();
|
|
345
|
+
if (!f)
|
|
346
|
+
return null;
|
|
347
|
+
if (!claudeSandboxCache || Date.now() - claudeSandboxCache.at > 10 * 60_000)
|
|
348
|
+
claudeSandboxCache = { at: Date.now(), result: claudeSandbox() };
|
|
349
|
+
return { ...f, sandbox: claudeSandboxCache.result };
|
|
350
|
+
}
|
|
339
351
|
/** What the operator needs to know about this machine, reported with every pass. */
|
|
340
352
|
export function machineFacts() {
|
|
341
353
|
const codex = spawnSync("codex", ["--version"], { encoding: "utf8" });
|
|
@@ -354,6 +366,7 @@ export function machineFacts() {
|
|
|
354
366
|
load: loadavg().map((x) => Math.round(x * 100) / 100), mem_available_bytes: memAvailable(),
|
|
355
367
|
bschat: { version: CLI_VERSION, bin: requireInstall().bin },
|
|
356
368
|
codex: codex.status === 0 ? { version: codex.stdout.trim(), logged_in: login?.status === 0 && /logged in/i.test(`${login.stdout}${login.stderr}`), login: `${login?.stdout ?? ""}${login?.stderr ?? ""}`.trim().slice(0, 200), sandbox: codexSandbox() } : null,
|
|
369
|
+
"claude-code": claudeReport(),
|
|
357
370
|
managed_hooks: existsSync(req) && readFileSync(req, "utf8").includes(CODEX_MANAGED_MARK),
|
|
358
371
|
linger: platform() === "linux" ? lingerEnabled() : null,
|
|
359
372
|
disk_free_bytes: diskFree,
|
|
@@ -405,6 +418,29 @@ export function prepare(opts = {}) {
|
|
|
405
418
|
: { step: "codex sandbox", result: "failed", detail: l.status !== 0 ? `installing ${CODEX_APPARMOR_PATH}: ${(l.stderr ?? "").trim()}` : `profile installed but the sandbox still fails: ${sb.error}` });
|
|
406
419
|
}
|
|
407
420
|
}
|
|
421
|
+
// Claude Code is optional on a machine; when it is there, say whether it can run agents.
|
|
422
|
+
const claude = claudeFacts();
|
|
423
|
+
if (claude) {
|
|
424
|
+
steps.push({ step: "claude code", result: claude.logged_in ? "ok" : "failed", detail: claude.logged_in ? `${claude.version}, ${claude.login}` : `${claude.version}, ${claude.login}: run claude auth login on this machine (over ssh it prints a link to open in your browser and asks for the code)` });
|
|
425
|
+
let sb = claudeSandbox();
|
|
426
|
+
const userns = platform() === "linux" && /RTM_NEWADDR|uid map|Operation not permitted|Permission denied/i.test(sb.error ?? "");
|
|
427
|
+
if (sb.ok)
|
|
428
|
+
steps.push({ step: "claude code sandbox", result: "ok", detail: "sandboxed (workspace-write) Claude Code agents can run here" });
|
|
429
|
+
else if (!userns)
|
|
430
|
+
steps.push({ step: "claude code sandbox", result: "failed", detail: `${sb.error}; only danger-full-access Claude Code agents can run here` });
|
|
431
|
+
else if (!opts.bwrapUserns)
|
|
432
|
+
steps.push({ step: "claude code sandbox", result: "failed", detail: `${sb.error}: this system restricts the user namespaces bubblewrap needs. Re-run machine add with --bwrap-userns to install an AppArmor profile for /usr/bin/bwrap (${BWRAP_APPARMOR_PATH}; any local user may then use bubblewrap's namespaces), or run only danger-full-access Claude Code agents here` });
|
|
433
|
+
else if (!sudo)
|
|
434
|
+
steps.push({ step: "claude code sandbox", result: "failed", detail: `--bwrap-userns needs passwordless sudo; install ${BWRAP_APPARMOR_PATH} by hand (bschat machine prepare --print-apparmor shows it) and run sudo apparmor_parser -r on it` });
|
|
435
|
+
else {
|
|
436
|
+
const t = spawnSync("sudo", ["-n", "tee", BWRAP_APPARMOR_PATH], { input: bwrapAppArmorProfile(), stdio: ["pipe", "ignore", "pipe"], encoding: "utf8" });
|
|
437
|
+
const l = t.status === 0 ? spawnSync("sudo", ["-n", "apparmor_parser", "-r", BWRAP_APPARMOR_PATH], { encoding: "utf8" }) : t;
|
|
438
|
+
sb = claudeSandbox();
|
|
439
|
+
steps.push(l.status === 0 && sb.ok
|
|
440
|
+
? { step: "claude code sandbox", result: "done", detail: `installed ${BWRAP_APPARMOR_PATH}; the sandbox works` }
|
|
441
|
+
: { step: "claude code sandbox", result: "failed", detail: l.status !== 0 ? `installing ${BWRAP_APPARMOR_PATH}: ${(l.stderr ?? "").trim()}` : `profile installed but the sandbox still fails: ${sb.error}` });
|
|
442
|
+
}
|
|
443
|
+
}
|
|
408
444
|
const req = "/etc/codex/requirements.toml";
|
|
409
445
|
const { requirements, wrapper } = codexManagedHooks(requireInstall().bin);
|
|
410
446
|
const current = existsSync(req) ? readFileSync(req, "utf8") : null;
|
|
@@ -446,8 +482,8 @@ export async function machine(p, out) {
|
|
|
446
482
|
if (p.flags["print-hooks"])
|
|
447
483
|
return out.print(codexManagedHooks(requireInstall().bin).requirements, codexManagedHooks(requireInstall().bin));
|
|
448
484
|
if (p.flags["print-apparmor"])
|
|
449
|
-
return out.print(codexAppArmorProfile()
|
|
450
|
-
const steps = prepare({ codexUserns: p.flags["codex-userns"] === true });
|
|
485
|
+
return out.print(`${CODEX_APPARMOR_PATH}:\n${codexAppArmorProfile()}\n${BWRAP_APPARMOR_PATH}:\n${bwrapAppArmorProfile()}`, { [CODEX_APPARMOR_PATH]: codexAppArmorProfile(), [BWRAP_APPARMOR_PATH]: bwrapAppArmorProfile() });
|
|
486
|
+
const steps = prepare({ codexUserns: p.flags["codex-userns"] === true, bwrapUserns: p.flags["bwrap-userns"] === true });
|
|
451
487
|
return out.print(steps.map((s) => `${s.result.padEnd(8)} ${s.step}: ${s.detail}`).join("\n"), { steps });
|
|
452
488
|
}
|
|
453
489
|
if (sub === "service") {
|
|
@@ -241,7 +241,33 @@ export async function needsAdmin(p, out) {
|
|
|
241
241
|
const r = await adminClient(p).call("GET", "/account/needs");
|
|
242
242
|
if (!r.needs.length)
|
|
243
243
|
return out.print("Nothing is waiting on you.", r);
|
|
244
|
-
|
|
244
|
+
const ind = (t) => t.replace(/\n/g, "\n ");
|
|
245
|
+
out.print(r.needs.map((n, i) => [
|
|
246
|
+
`${i + 1}. [${n.project}] ${n.kind === "unit_question" ? `WU #${n.unit} question` : n.kind === "wake_broken" ? "wake path" : n.kind === "notifier" ? "your alerts" : "decision"} · ${n.asked_by} · since ${n.since.slice(0, 16).replace("T", " ")} UTC`,
|
|
247
|
+
n.plain ? ` In plain words: ${ind(n.plain)}` : n.unexplained ? ` In plain words: (${n.asked_by} did not explain this; bschat-admin explain ${n.key})` : null,
|
|
248
|
+
n.blocks ? ` What's stuck: ${ind(n.blocks)}` : null,
|
|
249
|
+
` ${n.kind === "ask" ? "What I need from you: " : ""}${ind(n.text)}`,
|
|
250
|
+
n.if_yes ? ` If yes: ${ind(n.if_yes)}` : null,
|
|
251
|
+
n.if_no ? ` If no: ${ind(n.if_no)}` : null,
|
|
252
|
+
n.proposal ? ` Proposed by ${n.proposed_by}: ${ind(n.proposal)}` : null,
|
|
253
|
+
n.explanation ? ` Explained by ${n.explained_by}: ${ind(n.explanation)}` : n.explain_requested_at ? ` (explanation asked for ${n.explain_requested_at.slice(0, 16).replace("T", " ")} UTC)` : null,
|
|
254
|
+
` key: ${n.key}`,
|
|
255
|
+
].filter(Boolean).join("\n")).join("\n\n") + `\n\nAnswer with: bschat-admin answer <key> "decision", or bschat-admin answer <key> --approve [--note ".."] to accept a proposal; bschat-admin explain <key> asks the agent to explain it in plain words`, r);
|
|
256
|
+
}
|
|
257
|
+
/** bschat-admin explain <key>: the console's Explain; the agent is mentioned and asked to put it in plain words. */
|
|
258
|
+
export async function explainAdmin(rest, p, out) {
|
|
259
|
+
const key = rest[0];
|
|
260
|
+
if (!key)
|
|
261
|
+
throw new CliError("usage", "admin explain <key from admin needs>");
|
|
262
|
+
const c = adminClient(p);
|
|
263
|
+
const n = (await c.call("GET", "/account/needs")).needs.find((x) => x.key === key);
|
|
264
|
+
if (!n)
|
|
265
|
+
throw new CliError("not_found", `nothing waiting with key ${key}; list them with: bschat-admin needs`);
|
|
266
|
+
if (n.kind === "ask")
|
|
267
|
+
return out.print(`Asked ${n.asked_by} to explain; it appears with the decision (bschat-admin needs) and in the next report to you.`, await c.call("POST", `/projects/${n.project}/asks/${n.ask_id}/explain`, {}));
|
|
268
|
+
if (n.kind === "unit_question")
|
|
269
|
+
return out.print(`Asked for WU #${n.unit}'s question in plain words; it appears with the question (bschat-admin needs).`, await c.call("POST", `/projects/${n.project}/work-units/${n.unit}/question/explain`, {}));
|
|
270
|
+
throw new CliError("not_answerable", "only decisions (asks and unit questions) can be explained");
|
|
245
271
|
}
|
|
246
272
|
export async function answerAdmin(rest, p, out) {
|
|
247
273
|
const [key, ...words] = rest;
|