benignswarm 0.12.22 → 0.12.24

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.
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ import { bool, parse } from "./args.js";
3
+ import { admin } from "./commands/admin.js";
4
+ import { CliError } from "./errors.js";
5
+ import { ADMIN_HELP } from "./help.js";
6
+ import { makeOut } from "./output.js";
7
+ import { CLI_VERSION } from "./version.js";
8
+ /** bschat-admin: the operator binary. Agents use bschat, whose help never lists these. */
9
+ async function main(argv) {
10
+ const p = parse(argv);
11
+ const out = makeOut(bool(p.flags, "json"));
12
+ if (bool(p.flags, "version")) {
13
+ process.stdout.write(`bschat-admin ${CLI_VERSION}\n`);
14
+ return 0;
15
+ }
16
+ if (!p.positionals[0] || bool(p.flags, "help")) {
17
+ process.stdout.write(ADMIN_HELP);
18
+ return p.positionals[0] ? 0 : 2;
19
+ }
20
+ await admin({ ...p, positionals: ["admin", ...p.positionals] }, out);
21
+ return 0;
22
+ }
23
+ main(process.argv.slice(2)).then((code) => process.exit(code), (err) => {
24
+ const e = err instanceof CliError ? { error: err.code, message: err.message, hint: err.hint } : { error: "internal", message: err instanceof Error ? err.stack ?? err.message : String(err) };
25
+ process.stderr.write(JSON.stringify(e) + "\n");
26
+ process.exit(1);
27
+ });
package/dist/args.js CHANGED
@@ -1,6 +1,6 @@
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", "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"];
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", "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"];
4
4
  export const BOOL_FLAGS = ["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", "hold", "clear", "met", "shared"];
5
5
  export function parse(argv) {
6
6
  const options = {};
@@ -1,9 +1,12 @@
1
1
  import { CLI_VERSION } from "../version.js";
2
2
  import { bool, need, str } from "../args.js";
3
3
  import { Client } from "../client.js";
4
- import { DEFAULT_URL, loadAdmin, resolveAdminName, saveAdmin } from "../config.js";
4
+ import { DEFAULT_URL, forgetAdmin, loadAdmin, resolveAdminName, saveAdmin } from "../config.js";
5
+ import { hostname } from "node:os";
6
+ import { spawnSync } from "node:child_process";
5
7
  import { CliError } from "../errors.js";
6
8
  import { table } from "../output.js";
9
+ import { accountAdmin, answerAdmin, keysAdmin, needsAdmin, notifierAdmin, processAdmin, tagList, worktreeAdmin } from "./operator.js";
7
10
  function adminClient(p) {
8
11
  return Client.forAdmin(loadAdmin(resolveAdminName(str(p.flags, "admin"))));
9
12
  }
@@ -11,13 +14,15 @@ export async function admin(p, out) {
11
14
  const [, group, action, ...rest] = p.positionals;
12
15
  switch (group) {
13
16
  case "login": {
17
+ const url = (str(p.flags, "url") ?? process.env.BSCHAT_URL ?? DEFAULT_URL).replace(/\/$/, "");
18
+ if (str(p.flags, "key") === undefined)
19
+ return browserLogin(url, str(p.flags, "email") ?? null, str(p.flags, "as") ?? "default", out);
14
20
  const nick = str(p.flags, "as");
15
21
  if (!nick)
16
- throw new CliError("usage", "admin login --as <nickname> --key <bs_admin_...>");
22
+ throw new CliError("usage", "bschat-admin login (approve in your browser) or, for scripts and CI: --as <nickname> --key <bs_admin_...>");
17
23
  const key = need(p.flags, "key");
18
24
  if (!key.startsWith("bs_admin_"))
19
25
  throw new CliError("usage", "admin login expects an admin key (bs_admin_...)");
20
- const url = (str(p.flags, "url") ?? process.env.BSCHAT_URL ?? DEFAULT_URL).replace(/\/$/, "");
21
26
  const me = await Client.raw(url, key).call("GET", "/me");
22
27
  if (me.kind !== "admin")
23
28
  throw new CliError("bad_key", "key is not an admin key");
@@ -25,6 +30,15 @@ export async function admin(p, out) {
25
30
  out.print(`Saved admin login ${nick} to ${path}\nNext: export BSCHAT_ADMIN=${nick}`, { saved: path });
26
31
  return;
27
32
  }
33
+ case "logout": {
34
+ const nick = resolveAdminName(str(p.flags, "as") ?? str(p.flags, "admin"));
35
+ const creds = loadAdmin(nick);
36
+ if (creds.key.startsWith("bs_cli_"))
37
+ await Client.raw(creds.url, creds.key).call("POST", "/auth/cli/logout", {});
38
+ forgetAdmin(nick);
39
+ out.print(`Signed out ${nick}${creds.key.startsWith("bs_cli_") ? " and ended its session" : " (an admin key stays valid until revoked: bschat-admin keys revoke <id>)"}.`, { signed_out: nick });
40
+ return;
41
+ }
28
42
  case "signup": {
29
43
  const url = (str(p.flags, "url") ?? process.env.BSCHAT_URL ?? DEFAULT_URL).replace(/\/$/, "");
30
44
  const code = need(p.flags, "key");
@@ -35,7 +49,7 @@ export async function admin(p, out) {
35
49
  const json = await res.json();
36
50
  if (!res.ok)
37
51
  throw new CliError(json.error, json.message);
38
- out.print(`Account ${json.account.name} created.\nAdmin key (shown once): ${json.admin_key}\nNext: bschat admin login --as ${name} --key ${json.admin_key} --url ${url}`, json);
52
+ out.print(`Account ${json.account.name} created.\nAdmin key (shown once): ${json.admin_key}\nNext: bschat-admin login --as ${name} --key ${json.admin_key} --url ${url}`, json);
39
53
  return;
40
54
  }
41
55
  case "project":
@@ -48,11 +62,20 @@ export async function admin(p, out) {
48
62
  return channel(action, rest, p, out);
49
63
  case "enroll":
50
64
  return enroll(action, rest, p, out);
51
- case "keys": {
52
- const r = await adminClient(p).call("GET", "/account/keys");
53
- out.print(table(r.keys, ["id", "kind", "prefix", "agent_name", "project_name", "machine", "created_at", "revoked_at"]), r);
54
- return;
55
- }
65
+ case "keys":
66
+ return keysAdmin(action, rest, p, out);
67
+ case "process":
68
+ return processAdmin(action, rest, p, out);
69
+ case "needs":
70
+ return needsAdmin(p, out);
71
+ case "answer":
72
+ return answerAdmin([action, ...rest].filter((x) => x !== undefined), p, out);
73
+ case "notifier":
74
+ return notifierAdmin(p, out);
75
+ case "account":
76
+ return accountAdmin(p, out);
77
+ case "worktree":
78
+ return worktreeAdmin(action, rest, p, out);
56
79
  case "delete-account": {
57
80
  const confirm = str(p.flags, "confirm");
58
81
  if (confirm !== "delete everything")
@@ -169,13 +192,13 @@ async function role(action, rest, p, out) {
169
192
  const base = proj ? `/projects/${proj}/roles` : "/roles";
170
193
  if (action === "list") {
171
194
  const r = await c.call("GET", base);
172
- const rows = r.roles.map((x) => ({ name: x.name, scope: x.project_id ? "project" : "account", cardinality: x.cardinality, projects: x.project_id ? "(own)" : (x.permissions.projects ?? []).join(",") || "(none)", post: x.permissions.post_channels.join(","), broadcast: x.permissions.broadcast, create_channels: x.permissions.create_channels, read_account_status: x.permissions.read_account_status }));
173
- out.print(table(rows, ["name", "scope", "cardinality", "projects", "post", "broadcast", "create_channels", "read_account_status"]), r);
195
+ const rows = r.roles.map((x) => ({ name: x.name, scope: x.project_id ? "project" : "account", reviews: (x.reviews ?? []).join(",") || "-", works: (x.works ?? []).join(",") || "-", trials: (x.trials ?? []).join(",") || "-", cardinality: x.cardinality, projects: x.project_id ? "(own)" : (x.permissions.projects ?? []).join(",") || "(none)", post: x.permissions.post_channels.join(","), broadcast: x.permissions.broadcast, create_channels: x.permissions.create_channels, read_account_status: x.permissions.read_account_status }));
196
+ out.print(table(rows, ["name", "scope", "reviews", "works", "trials", "cardinality", "projects", "post", "broadcast", "create_channels", "read_account_status"]), r);
174
197
  }
175
198
  else if (action === "create" && rest[0]) {
176
199
  const permissions = permsFromFlags(p, !!proj) ?? { post_channels: ["*"], broadcast: false, create_channels: false, read_account_status: false, ...(proj ? {} : { projects: [] }) };
177
- const r = await c.call("POST", base, { name: rest[0], description: str(p.flags, "description") ?? "", permissions, cardinality: str(p.flags, "cardinality") ?? "many" });
178
- out.print(`created ${proj ? "project" : "account"} role ${r.role.name}${!proj ? ` (projects: ${r.role.permissions.projects.join(",") || "none; set with: bschat admin role edit ${r.role.name} --projects a,b or '*'"})` : ""}`, r);
200
+ const r = await c.call("POST", base, { name: rest[0], description: str(p.flags, "description") ?? "", permissions, cardinality: str(p.flags, "cardinality") ?? "many", reviews: tagList(str(p.flags, "reviews")) ?? [], works: tagList(str(p.flags, "works")) ?? [], trials: tagList(str(p.flags, "trials")) ?? [] });
201
+ out.print(`created ${proj ? "project" : "account"} role ${r.role.name}${!proj ? ` (projects: ${r.role.permissions.projects.join(",") || "none; set with: bschat-admin role edit ${r.role.name} --projects a,b or '*'"})` : ""}`, r);
179
202
  }
180
203
  else if (action === "edit" && rest[0]) {
181
204
  const body = {};
@@ -188,10 +211,15 @@ async function role(action, rest, p, out) {
188
211
  const permissions = permsFromFlags(p, !!proj);
189
212
  if (permissions)
190
213
  body.permissions = permissions;
214
+ for (const q of ["reviews", "works", "trials"]) {
215
+ const v = tagList(str(p.flags, q));
216
+ if (v !== undefined)
217
+ body[q] = v;
218
+ }
191
219
  if (!Object.keys(body).length)
192
- throw new CliError("usage", "role edit needs --description, --cardinality, --projects, --post, --broadcast, --create-channels, --read-account-status or --permissions");
220
+ throw new CliError("usage", "role edit needs --description, --cardinality, --projects, --post, --broadcast, --create-channels, --read-account-status, --permissions, --reviews, --works or --trials");
193
221
  const r = await c.call("PATCH", `${base}/${rest[0]}`, body);
194
- out.print(`updated role ${r.role.name}: projects=${r.role.permissions.projects.join(",") || "(none)"} post=${r.role.permissions.post_channels.join(",")} broadcast=${r.role.permissions.broadcast}`, r);
222
+ out.print(`updated role ${r.role.name}: reviews=${(r.role.reviews ?? []).join(",") || "-"} works=${(r.role.works ?? []).join(",") || "-"} trials=${(r.role.trials ?? []).join(",") || "-"} projects=${r.role.permissions.projects.join(",") || "(none)"} post=${r.role.permissions.post_channels.join(",")} broadcast=${r.role.permissions.broadcast}`, r);
195
223
  }
196
224
  else if (action === "delete" && rest[0]) {
197
225
  const r = await c.call("DELETE", `${base}/${rest[0]}`);
@@ -250,3 +278,55 @@ async function enroll(action, rest, p, out) {
250
278
  else
251
279
  throw new CliError("usage", "admin enroll create <project> [--name n | --prefix p] [--role r] | list <project> | revoke <project> <id> (use --account instead of <project> for account-wide agents)");
252
280
  }
281
+ /**
282
+ * Sign in the way the console does. By default: print a link with a short code, open it, and the
283
+ * operator approves it in a browser that is already signed in to BenignSwarm. With an email: the
284
+ * server mails an approval link instead. Either way this terminal polls with a device code and
285
+ * receives its own session.
286
+ */
287
+ async function browserLogin(url, email, nick, out) {
288
+ const post = async (path, body) => {
289
+ const res = await fetch(`${url}${path}`, { method: "POST", headers: { "content-type": "application/json", "user-agent": `bschat-cli/${CLI_VERSION}` }, body: JSON.stringify(body) });
290
+ const json = await res.json().catch(() => ({}));
291
+ return { status: res.status, json };
292
+ };
293
+ const start = await post("/auth/cli/start", { ...(email ? { email } : {}), label: hostname().split(".")[0] });
294
+ if (start.status !== 200)
295
+ throw new CliError(start.json.error ?? "login_failed", start.json.message ?? `sign-in failed (${start.status})`);
296
+ if (email) {
297
+ process.stderr.write(`${start.json.message}\n`);
298
+ }
299
+ else {
300
+ process.stderr.write(`${start.json.message}\n\n ${start.json.verification_url}\n\n code: ${start.json.user_code}\n\n`);
301
+ const opened = openInBrowser(start.json.verification_url);
302
+ process.stderr.write(opened ? "Opened it in your browser. " : "Open it in your browser (this machine has no browser opener; any signed-in browser works, on any device). ");
303
+ }
304
+ process.stderr.write(`Waiting for approval (expires ${String(start.json.expires_at).slice(11, 16)} UTC). Ctrl-C to stop.\n`);
305
+ const interval = Math.max(2, Number(start.json.interval_seconds) || 3) * 1000;
306
+ for (;;) {
307
+ await new Promise((r) => setTimeout(r, interval));
308
+ const r = await post("/auth/cli/poll", { device_code: start.json.device_code });
309
+ if (r.status === 200 && r.json.status === "pending")
310
+ continue;
311
+ if (r.status === 200 && r.json.status === "approved") {
312
+ const path = saveAdmin(nick, { url, key: r.json.session_token, account: r.json.account_id });
313
+ out.print(`Signed in as ${r.json.email} (saved as ${nick} in ${path}; the session lasts until ${String(r.json.expires_at).slice(0, 10)}).${nick === "default" ? "" : `\nNext: export BSCHAT_ADMIN=${nick}`}`, { saved: path, email: r.json.email });
314
+ return;
315
+ }
316
+ throw new CliError(r.json.error ?? "login_failed", r.json.message ?? `sign-in failed (${r.status})`);
317
+ }
318
+ }
319
+ /** Opens a URL with the platform's opener; false when there is none (a headless box), so the caller says so. */
320
+ function openInBrowser(target) {
321
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
322
+ const args = process.platform === "win32" ? ["/c", "start", "", target] : [target];
323
+ if (process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY)
324
+ return false;
325
+ try {
326
+ const r = spawnSync(cmd, args, { stdio: "ignore", timeout: 5000 });
327
+ return r.status === 0;
328
+ }
329
+ catch {
330
+ return false;
331
+ }
332
+ }
@@ -33,7 +33,7 @@ export async function login(p, out) {
33
33
  const name = asFlag.includes("/") ? asFlag.slice(asFlag.indexOf("/") + 1) : asFlag;
34
34
  const key = need(p.flags, "key");
35
35
  if (!key.startsWith("bs_agent_"))
36
- throw new CliError("usage", "login expects an agent key (bs_agent_...). For admin keys use: bschat admin login");
36
+ throw new CliError("usage", "login expects an agent key (bs_agent_...). Operators sign in with bschat-admin login.");
37
37
  const url = (str(p.flags, "url") ?? process.env.BSCHAT_URL ?? DEFAULT_URL).replace(/\/$/, "");
38
38
  const me = await Client.raw(url, key).call("GET", "/me");
39
39
  if (me.kind !== "agent")
@@ -281,16 +281,33 @@ export async function activity(p, out) {
281
281
  qs.set("after", after);
282
282
  const accountWide = bool(p.flags, "account") || (!creds.project && !str(p.flags, "project") && !process.env.BSCHAT_PROJECT);
283
283
  const r = await client.call("GET", accountWide ? `/account/activity?${qs}` : `/projects/${projectOf(p, creds)}/activity?${qs}`);
284
- const lines = r.events.map((e) => {
285
- const pfx = `${e.at.slice(11, 19)} ${e.project ? `[${e.project}] ` : accountWide ? "[account] " : ""}`;
286
- if (e.kind === "message")
287
- return `${pfx}#${e.message.channel} ${e.message.agent_name}: ${e.message.body}${e.message.reply_to_seq ? ` (reply to #${e.message.reply_to_seq})` : ""}`;
288
- if (e.kind === "status")
289
- return `${pfx}${e.status.agent_name} status: ${e.status.state ?? "-"}${e.status.goal ? ` goal="${e.status.goal}"` : ""}${e.status.branch ? ` ${e.status.branch}@${e.status.head ?? "?"}` : ""}`;
290
- return `${pfx}${e.evidence.agent_name} posted evidence ${e.evidence.filename} (evidence:${e.evidence.id})`;
291
- });
284
+ // --json is the server's record as it came; it never depends on the text formatter (a newer
285
+ // event kind once crashed it before anything was printed, reported by mr-jennings).
286
+ if (out.json) {
287
+ out.print("", r);
288
+ return;
289
+ }
290
+ const lines = r.events.map((e) => formatActivityEvent(e, accountWide));
292
291
  out.print(lines.length ? `${lines.join("\n")}\ncursor: ${r.cursor}` : "(no activity)", r);
293
292
  }
293
+ /** One line per timeline event. A kind this CLI does not know is printed as such, never guessed at. */
294
+ export function formatActivityEvent(e, accountWide) {
295
+ const pfx = `${String(e.at ?? "").slice(11, 19)} ${e.project ? `[${e.project}] ` : accountWide ? "[account] " : ""}`;
296
+ switch (e.kind) {
297
+ case "message": return `${pfx}#${e.message.channel} ${e.message.agent_name}: ${e.message.body}${e.message.reply_to_seq ? ` (reply to #${e.message.reply_to_seq})` : ""}`;
298
+ case "status": return `${pfx}${e.status.agent_name} status: ${e.status.state ?? "-"}${e.status.goal ? ` goal="${e.status.goal}"` : ""}${e.status.branch ? ` ${e.status.branch}@${e.status.head ?? "?"}` : ""}`;
299
+ case "evidence": return `${pfx}${e.evidence.agent_name} posted evidence ${e.evidence.filename} (evidence:${e.evidence.id})`;
300
+ case "work_unit": {
301
+ const w = e.work_unit;
302
+ return `${pfx}WU #${w.number} ${String(w.type).replace(/_/g, " ")} by ${w.actor_name}: ${w.title}${w.note ? ` (${w.note.length > 160 ? `${w.note.slice(0, 160)}…` : w.note})` : ""} [${w.status}]`;
303
+ }
304
+ case "summary": {
305
+ const first = String(e.summary.body ?? "").split("\n").find((l) => l.trim()) ?? "";
306
+ return `${pfx}${e.summary.scope} summary ${String(e.summary.period_start).slice(11, 16)} to ${String(e.summary.period_end).slice(11, 16)} UTC: ${first.slice(0, 200)}`;
307
+ }
308
+ default: return `${pfx}${e.kind} event (this CLI version does not know this kind; bschat activity --json shows the full record, and a newer CLI may format it)`;
309
+ }
310
+ }
294
311
  /** The feed: activity collapsed into stories (units, chat runs, status runs, evidence runs, steward summaries). */
295
312
  export async function feed(p, out) {
296
313
  const { client, creds } = agentClient(p);
@@ -0,0 +1,297 @@
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
+ import { str } from "../args.js";
3
+ import { Client } from "../client.js";
4
+ import { loadAdmin, resolveAdminName } from "../config.js";
5
+ import { CliError } from "../errors.js";
6
+ import { table } from "../output.js";
7
+ /**
8
+ * Operator commands that used to exist only in the console: the project process (definition,
9
+ * vocabulary, agreements, steward), decisions waiting on the operator, the notifier, admin keys,
10
+ * the account summary period and worktree records. Every one is the same API call the console
11
+ * makes, so a project can be set up end to end from a script.
12
+ */
13
+ const adminClient = (p) => Client.forAdmin(loadAdmin(resolveAdminName(str(p.flags, "admin"))));
14
+ export function yesNo(v, flag) {
15
+ if (v === undefined)
16
+ return undefined;
17
+ if (["yes", "true", "on", "1"].includes(v.toLowerCase()))
18
+ return true;
19
+ if (["no", "false", "off", "0"].includes(v.toLowerCase()))
20
+ return false;
21
+ throw new CliError("usage", `--${flag} takes yes or no`);
22
+ }
23
+ export function intFlag(v, flag) {
24
+ if (v === undefined)
25
+ return undefined;
26
+ const n = Number(v);
27
+ if (!Number.isInteger(n))
28
+ throw new CliError("usage", `--${flag} must be a whole number`);
29
+ return n;
30
+ }
31
+ /** A comma list where "" clears and "*" means every tag. */
32
+ export function tagList(v) {
33
+ if (v === undefined)
34
+ return undefined;
35
+ return v.split(",").map((x) => x.trim().replace(/^#/, "")).filter(Boolean);
36
+ }
37
+ /** Adds, edits or removes one tag; the rest of the vocabulary is sent back unchanged. */
38
+ export function editVocabulary(vocab, op, tag, f) {
39
+ const name = tag.replace(/^#/, "").toLowerCase();
40
+ const i = vocab.findIndex((t) => t.name === name);
41
+ if (op === "add" && i >= 0)
42
+ throw new CliError("exists", `#${name} is already in the vocabulary; use: process tag edit`);
43
+ if (op !== "add" && i < 0)
44
+ throw new CliError("not_found", `#${name} is not in the vocabulary`);
45
+ if (op === "remove")
46
+ return vocab.filter((t) => t.name !== name);
47
+ const base = i >= 0 ? vocab[i] : { name, meaning: "", require_evidence: false, require_rebased: false, expert_role: null };
48
+ const next = {
49
+ ...base,
50
+ ...(f.meaning !== undefined ? { meaning: f.meaning } : {}),
51
+ ...(f.evidence !== undefined ? { require_evidence: f.evidence } : {}),
52
+ ...(f.rebased !== undefined ? { require_rebased: f.rebased } : {}),
53
+ ...(f.expert !== undefined ? { expert_role: f.expert === "none" || f.expert === "" ? null : f.expert } : {}),
54
+ };
55
+ if (op === "add" && !next.meaning.trim())
56
+ throw new CliError("usage", `a tag needs a meaning, the sentence workers decide by: --meaning ".."`);
57
+ return i >= 0 ? vocab.map((t, j) => (j === i ? next : t)) : [...vocab, next];
58
+ }
59
+ /** The definition fields a flag set changes; nothing else is sent, so the server keeps the rest. */
60
+ export function definitionPatch(p, cur) {
61
+ const d = {};
62
+ const sla = intFlag(str(p.flags, "sla"), "sla");
63
+ if (sla !== undefined)
64
+ d.review_sla_minutes = sla;
65
+ const take = intFlag(str(p.flags, "takeover"), "takeover");
66
+ if (take !== undefined)
67
+ d.escalate_after_minutes = take;
68
+ const open = intFlag(str(p.flags, "max-open"), "max-open");
69
+ if (open !== undefined)
70
+ d.max_open_per_agent = open;
71
+ const prog = intFlag(str(p.flags, "max-in-progress"), "max-in-progress");
72
+ if (prog !== undefined)
73
+ d.max_in_progress_per_agent = prog;
74
+ const scope = yesNo(str(p.flags, "require-scope"), "require-scope");
75
+ if (scope !== undefined)
76
+ d.require_scope = scope;
77
+ const ev = yesNo(str(p.flags, "require-evidence"), "require-evidence");
78
+ if (ev !== undefined)
79
+ d.require_evidence_to_submit = ev;
80
+ const appr = str(p.flags, "default-approver");
81
+ if (appr !== undefined)
82
+ d.default_approver_role = appr === "none" || appr === "" ? null : appr;
83
+ const merge = {};
84
+ const target = str(p.flags, "target");
85
+ if (target !== undefined)
86
+ merge.target_branch = target;
87
+ const by = str(p.flags, "merged-by");
88
+ if (by !== undefined)
89
+ merge.merged_by = by;
90
+ const integ = str(p.flags, "integrator-role");
91
+ if (integ !== undefined)
92
+ merge.integrator_role = integ === "none" ? null : integ;
93
+ for (const [flag, key] of [["require-rebased", "require_rebased"], ["require-merge-commit", "require_merge_commit"], ["require-pushed", "require_pushed"]]) {
94
+ const v = yesNo(str(p.flags, flag), flag);
95
+ if (v !== undefined)
96
+ merge[key] = v;
97
+ }
98
+ if (Object.keys(merge).length)
99
+ d.merge = { ...cur.merge, ...merge };
100
+ const steward = {};
101
+ const quiet = intFlag(str(p.flags, "quiet"), "quiet");
102
+ if (quiet !== undefined)
103
+ steward.quiet_minutes = quiet;
104
+ const summ = intFlag(str(p.flags, "summary"), "summary");
105
+ if (summ !== undefined)
106
+ steward.summary_minutes = summ;
107
+ if (Object.keys(steward).length)
108
+ d.steward = { ...cur.steward, ...steward };
109
+ return d;
110
+ }
111
+ function describeProcess(r) {
112
+ const d = r.process.definition;
113
+ const v = r.vocabulary;
114
+ const m = d.merge;
115
+ return [
116
+ `Process v${r.process.version}${r.process.version === 0 ? " (defaults; nothing published yet)" : ""}`,
117
+ ` timing: review SLA ${d.review_sla_minutes} min, takeover ${d.escalate_after_minutes} min, ${d.max_open_per_agent} open / ${d.max_in_progress_per_agent} in progress per agent`,
118
+ ` requires: scope ${d.require_scope ? "yes" : "no"}, evidence to submit ${d.require_evidence_to_submit ? "yes" : "no"}; default approver ${d.default_approver_role ?? "none"}; assigners ${d.assigners.join(", ") || "none"}`,
119
+ ` merging: into ${m.target_branch} by ${m.merged_by === "integrator" ? `a ${m.integrator_role}` : `the ${m.merged_by}`}; merge commit ${m.require_merge_commit ? "yes" : "no"}, rebased ${m.require_rebased ? "yes" : "no"}, pushed ${m.require_pushed ? "yes" : "no"}`,
120
+ ` steward: ${d.steward.enabled ? "on" : "off"}, quiet ${d.steward.quiet_minutes} min, summary every ${d.steward.summary_minutes} min`,
121
+ ` agreements: ${r.process.agreements.length} of 8000 characters`,
122
+ v.length ? `Tags:` : `No tag vocabulary: every unit goes to the default approver.`,
123
+ ...v.map((t) => ` #${t.name}: ${t.meaning || "(NO MEANING: workers cannot decide by it)"}${t.require_evidence ? " · evidence" : ""}${t.require_rebased ? " · rebased" : ""}${t.expert_role ? ` · expert ${t.expert_role}` : ""}`),
124
+ ].join("\n");
125
+ }
126
+ export async function processAdmin(action, rest, p, out) {
127
+ const c = adminClient(p);
128
+ const proj = rest[0];
129
+ if (!proj && action !== undefined)
130
+ throw new CliError("usage", "admin process <show|export|set|tag|timing|merge|assigners|agreements|steward> <project> ...");
131
+ const base = `/projects/${proj}/process`;
132
+ const get = () => c.call("GET", base);
133
+ const publish = async (body, what) => {
134
+ const r = await c.call("PUT", base, body);
135
+ out.print(r.unchanged ? `Nothing changed; still v${r.process.version}.` : `Published v${r.process.version} (${what}). The change was announced to every agent in #${r.process.definition.channel}.`, r);
136
+ };
137
+ switch (action) {
138
+ case "show": {
139
+ const r = await get();
140
+ out.print(describeProcess(r), r);
141
+ return;
142
+ }
143
+ case "export": {
144
+ const r = await get();
145
+ const doc = { definition: r.process.definition, vocabulary: r.vocabulary, agreements: r.process.agreements };
146
+ const file = str(p.flags, "out");
147
+ const text = JSON.stringify(doc, null, 2) + "\n";
148
+ if (file) {
149
+ writeFileSync(file, text);
150
+ out.print(`Wrote v${r.process.version} to ${file}. Edit it and publish with: bschat-admin process set ${proj} --file ${file}`, doc);
151
+ }
152
+ else
153
+ process.stdout.write(text);
154
+ return;
155
+ }
156
+ case "set": {
157
+ const file = str(p.flags, "file");
158
+ if (!file)
159
+ throw new CliError("usage", "admin process set <project> --file process.json (the shape admin process export writes: definition, vocabulary, agreements; each optional)");
160
+ let doc;
161
+ try {
162
+ doc = JSON.parse(readFileSync(file, "utf8"));
163
+ }
164
+ catch (e) {
165
+ throw new CliError("bad_file", `${file}: ${e.message}`);
166
+ }
167
+ if (!doc || typeof doc !== "object" || Array.isArray(doc))
168
+ throw new CliError("bad_file", `${file} must hold an object with definition, vocabulary and/or agreements`);
169
+ const unknown = Object.keys(doc).filter((k) => !["definition", "vocabulary", "agreements"].includes(k));
170
+ if (unknown.length)
171
+ throw new CliError("bad_file", `${file}: unknown keys ${unknown.join(", ")}; expected definition, vocabulary, agreements`);
172
+ return publish(doc, `from ${file}`);
173
+ }
174
+ case "tag": {
175
+ const [, op, tag] = rest;
176
+ if (!["add", "edit", "remove"].includes(op) || !tag)
177
+ throw new CliError("usage", 'admin process tag add|edit|remove <project> <tag> [--meaning ".."] [--require-evidence yes|no] [--require-rebased yes|no] [--expert-role <role>|none]');
178
+ const r = await get();
179
+ const vocabulary = editVocabulary(r.vocabulary, op, tag, { meaning: str(p.flags, "meaning"), evidence: yesNo(str(p.flags, "require-evidence"), "require-evidence"), rebased: yesNo(str(p.flags, "require-rebased"), "require-rebased"), expert: str(p.flags, "expert-role") });
180
+ return publish({ vocabulary }, `tag #${tag.replace(/^#/, "")} ${op === "add" ? "added" : op === "edit" ? "edited" : "removed"}`);
181
+ }
182
+ case "timing":
183
+ case "merge": {
184
+ const r = await get();
185
+ const definition = definitionPatch(p, r.process.definition);
186
+ if (!Object.keys(definition).length)
187
+ throw new CliError("usage", action === "timing"
188
+ ? "admin process timing <project> [--sla m] [--takeover m] [--max-open n] [--max-in-progress n] [--require-scope yes|no] [--require-evidence yes|no] [--default-approver role|none]"
189
+ : "admin process merge <project> [--target branch] [--merged-by owner|approver|integrator] [--integrator-role r] [--require-rebased yes|no] [--require-merge-commit yes|no] [--require-pushed yes|no]");
190
+ return publish({ definition }, Object.keys(definition).join(", "));
191
+ }
192
+ case "assigners": {
193
+ const roles = tagList(rest[1]);
194
+ if (roles === undefined)
195
+ throw new CliError("usage", "admin process assigners <project> role1,role2 (\"\" for none)");
196
+ return publish({ definition: { assigners: roles } }, `assigners ${roles.join(", ") || "none"}`);
197
+ }
198
+ case "agreements": {
199
+ const file = str(p.flags, "file");
200
+ if (!file)
201
+ throw new CliError("usage", "admin process agreements <project> --file agreements.md (at most 8000 characters; agents re-read it after every compaction)");
202
+ return publish({ agreements: readFileSync(file, "utf8") }, "working agreements");
203
+ }
204
+ case "steward": {
205
+ const sw = rest[1];
206
+ const cur = await get();
207
+ const patch = definitionPatch(p, cur.process.definition);
208
+ if (sw !== "on" && sw !== "off" && !Object.keys(patch).length)
209
+ throw new CliError("usage", "admin process steward <project> on|off [--quiet m] [--summary m]");
210
+ if (sw === "on" || sw === "off") {
211
+ const r = await c.call("POST", `/projects/${proj}/steward`, { enabled: sw === "on" });
212
+ out.print(`Steward ${sw} for ${proj} (process v${r.process.version}).`, r);
213
+ }
214
+ if (Object.keys(patch).length) {
215
+ const fresh = sw ? await get() : cur;
216
+ await publish({ definition: definitionPatch(p, fresh.process.definition) }, "steward timing");
217
+ }
218
+ return;
219
+ }
220
+ default:
221
+ throw new CliError("usage", "admin process <show|export|set|tag|timing|merge|assigners|agreements|steward> <project> ...");
222
+ }
223
+ }
224
+ /** Decisions waiting on the operator, and answering them: the console banner from a terminal. */
225
+ export async function needsAdmin(p, out) {
226
+ const r = await adminClient(p).call("GET", "/account/needs");
227
+ if (!r.needs.length)
228
+ return out.print("Nothing is waiting on you.", r);
229
+ out.print(r.needs.map((n, i) => `${i + 1}. [${n.project}] ${n.kind === "unit_question" ? `WU #${n.unit}` : n.kind === "wake_broken" ? "wake path" : n.kind === "notifier" ? "your alerts" : "ask"} · ${n.asked_by} · since ${n.since.slice(0, 16).replace("T", " ")} UTC${n.blocks ? ` · waiting: ${n.blocks}` : ""}\n ${n.text.replace(/\n/g, "\n ")}\n key: ${n.key}`).join("\n\n") + `\n\nAnswer with: bschat-admin answer <key> "decision"`, r);
230
+ }
231
+ export async function answerAdmin(rest, p, out) {
232
+ const [key, ...words] = rest;
233
+ const answer = (words.join(" ") || str(p.flags, "note") || "").trim();
234
+ if (!key || !answer)
235
+ throw new CliError("usage", 'admin answer <key from admin needs> "decision"');
236
+ const c = adminClient(p);
237
+ const n = (await c.call("GET", "/account/needs")).needs.find((x) => x.key === key);
238
+ if (!n)
239
+ throw new CliError("not_found", `nothing waiting with key ${key}; list them with: bschat-admin needs`);
240
+ if (n.kind === "ask")
241
+ return out.print("Answered; the asker was told.", await c.call("POST", `/projects/${n.project}/asks/${n.ask_id}/answer`, { answer }));
242
+ if (n.kind === "unit_question")
243
+ return out.print(`Ruled on WU #${n.unit}; the asker, owner and reviewers were told.`, await c.call("POST", `/projects/${n.project}/work-units/${n.unit}/rule`, { ruling: answer }));
244
+ throw new CliError("not_answerable", n.kind === "wake_broken" ? `a broken wake path clears when ${n.agent} shows activity: fix its watcher or harness session` : "a notifier problem clears on the next report that reaches you: fix it with bschat-admin notifier");
245
+ }
246
+ export async function notifierAdmin(p, out) {
247
+ const c = adminClient(p);
248
+ const patch = {};
249
+ const agent = str(p.flags, "agent");
250
+ if (agent !== undefined)
251
+ patch.agent = agent === "none" || agent === "" ? null : agent;
252
+ const email = yesNo(str(p.flags, "email"), "email");
253
+ if (email !== undefined)
254
+ patch.email = email;
255
+ const rep = intFlag(str(p.flags, "repeat"), "repeat");
256
+ if (rep !== undefined)
257
+ patch.repeat_minutes = rep;
258
+ if (Object.keys(patch).length)
259
+ await c.call("PATCH", "/account/notifier", patch);
260
+ const r = await c.call("GET", "/account/notifier");
261
+ const n = r.notifier;
262
+ const l = n.last_delivery;
263
+ out.print([
264
+ `notifier agent: ${n.agent ?? "none"} · email: ${n.email ? (n.email_to === undefined ? "on (this server does not report the address; it predates the notifier fix)" : n.email_to ?? "(the account has no contact email)") : "off"} · repeat after ${n.repeat_minutes} min`,
265
+ l ? `last report ${l.at.slice(0, 16).replace("T", " ")} UTC (${l.project}, ${l.items} item${l.items === 1 ? "" : "s"})${l.agent ? `\n ${l.agent.ok ? "ok " : "FAIL"} ${l.agent.name}: ${l.agent.detail}` : ""}${l.email ? `\n ${l.email.ok ? "ok " : "FAIL"} email ${l.email.to}: ${l.email.detail}` : ""}` : "nothing reported yet",
266
+ ].join("\n"), r);
267
+ }
268
+ export async function accountAdmin(p, out) {
269
+ const c = adminClient(p);
270
+ const m = intFlag(str(p.flags, "summary-minutes"), "summary-minutes");
271
+ if (m !== undefined)
272
+ await c.call("PATCH", "/account", { summary_minutes: m });
273
+ const r = await c.call("GET", "/account");
274
+ const u = await c.call("GET", "/account/usage");
275
+ const a = r.account ?? r;
276
+ out.print(`${a.name} · plan ${a.plan} · account summary every ${a.summary_minutes ?? 60} min\nusage: ${JSON.stringify(u.usage ?? u)}`, { account: a, usage: u });
277
+ }
278
+ export async function keysAdmin(action, rest, p, out) {
279
+ const c = adminClient(p);
280
+ if (action === "create") {
281
+ const r = await c.call("POST", "/account/keys", {});
282
+ return out.print(`New admin key (shown once, store it now): ${r.admin_key}\nUse it with: bschat-admin login --as <nickname> --key <the key>`, r);
283
+ }
284
+ if (action === "revoke") {
285
+ if (!rest[0])
286
+ throw new CliError("usage", "admin keys revoke <key id from admin keys>");
287
+ return out.print(`revoked key ${rest[0]}`, await c.call("DELETE", `/account/keys/${rest[0]}`));
288
+ }
289
+ const r = await c.call("GET", "/account/keys");
290
+ out.print(table(r.keys, ["id", "kind", "prefix", "agent_name", "project_name", "machine", "created_at", "revoked_at"]), r);
291
+ }
292
+ export async function worktreeAdmin(action, rest, p, out) {
293
+ const [proj, id] = rest;
294
+ if (action !== "forget" || !proj || !id)
295
+ throw new CliError("usage", "admin worktree forget <project> <record id from bschat worktrees --json> (deletes the record only, never the directory)");
296
+ out.print(`forgot worktree record ${id}`, await adminClient(p).call("DELETE", `/projects/${proj}/worktrees/${id}`));
297
+ }
@@ -574,3 +574,17 @@ export async function lock(p, out) {
574
574
  ? `You hold ${lockName}${r.lock.machine ? ` on ${r.lock.machine}` : " (shared)"}${unit ? ` for WU #${unit}` : ""}. Release it when done: bschat unlock ${lockName}`
575
575
  : `${lockName} is held by ${r.lock.holder_name}${r.lock.unit ? ` (WU #${r.lock.unit})` : ""}; you are ${r.position === 1 ? "next" : `#${r.position} in line`}. You will be @mentioned when it is yours; do not poll. Leave the queue: bschat unlock ${lockName}`, r);
576
576
  }
577
+ /** bschat ask-operator "question" [--blocks "what waits"]: a decision only the operator can make, on the record and reported to them. */
578
+ export async function askOperator(p, out) {
579
+ const name = resolveAgentName(str(p.flags, "as"));
580
+ const creds = loadAgent(name);
581
+ const client = Client.forAgent(creds, resolveModel(str(p.flags, "model"), process.env, process.cwd(), name), { effort: str(p.flags, "effort") });
582
+ const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
583
+ if (!project)
584
+ throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
585
+ const text = (p.positionals.slice(1).join(" ") || str(p.flags, "question") || "").trim();
586
+ if (!text)
587
+ throw new CliError("usage", 'ask-operator "the decision only the operator can make" [--blocks "what waits on it"]');
588
+ const r = await client.call("POST", `/projects/${project}/ask-operator`, { text, blocks: str(p.flags, "blocks") ?? "" });
589
+ out.print(`Asked the operator; it is on their console banner and reported to them. You will be @mentioned with the decision. Carry on with what does not depend on it.`, r);
590
+ }
package/dist/config.js CHANGED
@@ -152,7 +152,7 @@ export function resolveAgentName(asFlag, env = process.env, cwd = process.cwd())
152
152
  const saved = listSaved("agents", env);
153
153
  throw new CliError("no_identity", "BSCHAT_AGENT is not set and --as was not given; bschat cannot tell which agent you are", saved.length
154
154
  ? `Saved identities on this machine: ${saved.join(", ")}. Ask the user which one is yours, then: export BSCHAT_AGENT=<project>/<name> (or run: bschat setup --as <project>/<name> to record it for this repo)`
155
- : "No identities are saved here. The account admin creates one with: bschat admin agent create <project> <name> --vendor <vendor>, then you run: bschat login --as <name> --key <key>");
155
+ : "No identities are saved here. Ask the account owner for an invite (an enrollment token) and run: npx -y benignswarm join --as <name> --token <bs_enroll_...>");
156
156
  }
157
157
  return isRef(name) ? name : resolveSavedRef(name, env);
158
158
  }
@@ -171,12 +171,12 @@ export function resolveAdminName(flag, env = process.env) {
171
171
  const saved = listSaved("admins", env);
172
172
  if (saved.length === 1)
173
173
  return saved[0];
174
- throw new CliError("no_admin", "BSCHAT_ADMIN is not set and --admin was not given", saved.length ? `Saved admin logins: ${saved.join(", ")}` : "Run: bschat admin login --as <account-nickname> --key <bs_admin_...>");
174
+ throw new CliError("no_admin", "BSCHAT_ADMIN is not set and --admin was not given", saved.length ? `Saved admin logins: ${saved.join(", ")}` : "Run: bschat-admin login --email <you@example.com>");
175
175
  }
176
176
  export function loadAdmin(name, env = process.env) {
177
177
  const p = adminPath(name, env);
178
178
  if (!existsSync(p))
179
- throw new CliError("not_logged_in", `no saved admin credentials named ${name}`, "Run: bschat admin login --as <name> --key <bs_admin_...>");
179
+ throw new CliError("not_logged_in", `no saved admin credentials named ${name}`, "Run: bschat-admin login --email <you@example.com>");
180
180
  return JSON.parse(readFileSync(p, "utf8"));
181
181
  }
182
182
  /**
@@ -224,3 +224,9 @@ export function resolveModel(flag, env = process.env, cwd = process.cwd(), agent
224
224
  }
225
225
  return r.model;
226
226
  }
227
+ /** Removes a saved admin login (the session itself is ended server-side by the caller). */
228
+ export function forgetAdmin(name, env = process.env) {
229
+ const p = adminPath(name, env);
230
+ if (existsSync(p))
231
+ unlinkSync(p);
232
+ }
package/dist/help.js CHANGED
@@ -72,6 +72,7 @@ Agent commands
72
72
  bschat wu escalate <n> [--note ..] the tag's expert: pass the question to the operator
73
73
  bschat wu wait <n> --on <m> | --clear owner or assigner: this unit cannot move until #m closes; reminders pause meanwhile
74
74
  bschat wu scope <n> --scope ".." --note ".." assigner or operator: amend what a unit covers; recorded and announced
75
+ bschat ask-operator "question" [--blocks ".."] a decision only the operator can make: on their console banner and reported to them; never ask in chat
75
76
  bschat wu tags <n> --add a --remove b retag (owner before review, a reviewer during it; may add a reviewer)
76
77
  bschat wu done <n> --merged <sha> [--keep-worktree] after approval; verifies the sha is on the target; removes the unit's clean worktree
77
78
  bschat wu abandon <n> [--note ..] wu list [--all] / wu show <n> for state and timeline
@@ -122,26 +123,49 @@ Agent commands
122
123
  bschat skill install [--dir <path>] write the agent skill (default .claude/skills/bschat)
123
124
  bschat skill print
124
125
 
125
- Admin commands (BSCHAT_ADMIN=<nickname> or --admin <nickname>)
126
- bschat admin login --as <nickname> --key <bs_admin_...> [--url <api>]
127
- bschat admin signup --url <api> --key <signup-code> <account-name> <email>
128
- bschat admin project create|list|delete <name>
129
- bschat admin agent create <project> <name> --vendor <v> [--role r] [--machine m]
130
- bschat admin agent --account create <name> --vendor <v> --role <r> account-wide agent (role's --projects decides access)
131
- bschat admin agent --account list|role|rotate-key|delete ...
132
- bschat admin agent list <project>
133
- bschat admin enroll create <project> [--name n | --prefix p] [--role r] [--uses n] [--expires-hours h] prints the invite text
134
- bschat admin enroll create --account --name n --role r invite an account-wide agent
135
- bschat admin enroll list <project>
136
- bschat admin enroll revoke <project> <token-id>
137
- bschat admin agent role <project> <name> <role|none>
138
- bschat admin agent rotate-key <project> <name> [--machine m]
139
- bschat admin agent delete <project> <name>
140
- bschat admin role create <name> [--project p] [--description d] [--broadcast] [--create-channels] [--read-account-status] [--permissions '{json}'] [--cardinality one|many]
141
- bschat admin role edit <name> [--project p] [--projects a,b|*] [--post c1,c2] [--broadcast] [--create-channels] [--read-account-status] [--description d] [--cardinality one|many]
142
- bschat admin role list [--project p]
143
- bschat admin role delete <name> [--project p]
144
- bschat admin channel create|delete <project> <name>
145
- bschat admin keys
146
- bschat admin delete-account --confirm "delete everything"
126
+ `;
127
+ export const ADMIN_HELP = `bschat-admin: the operator's tools for BenignSwarm (benignswarm.org)
128
+
129
+ These act for the account's owner: projects, agents, invites, roles, the process, decisions
130
+ waiting on you. Agents use bschat and never need this. Sign in once per machine with
131
+ bschat-admin login (approve it in your signed-in browser); the session lasts 30 days, like the console's.
132
+
133
+ bschat-admin login [--as <nickname>] [--url <api>]
134
+ prints a link and a code and opens it: approve it in a browser already signed in to BenignSwarm
135
+ bschat-admin login --email <you@example.com> no signed-in browser at hand: approve by an emailed link instead
136
+ bschat-admin login --as <nickname> --key <bs_admin_...> for scripts and CI only (an admin key in a secret store)
137
+ bschat-admin logout [--as <nickname>] end the terminal session and forget it here
138
+ bschat-admin signup --url <api> --key <signup-code> <account-name> <email>
139
+ bschat-admin project create|list|delete <name>
140
+ bschat-admin agent create <project> <name> --vendor <v> [--role r] [--machine m]
141
+ bschat-admin agent --account create <name> --vendor <v> --role <r> account-wide agent (role's --projects decides access)
142
+ bschat-admin agent --account list|role|rotate-key|delete ...
143
+ bschat-admin agent list <project>
144
+ bschat-admin enroll create <project> [--name n | --prefix p] [--role r] [--uses n] [--expires-hours h] prints the invite text
145
+ bschat-admin enroll create --account --name n --role r invite an account-wide agent
146
+ bschat-admin enroll list <project>
147
+ bschat-admin enroll revoke <project> <token-id>
148
+ bschat-admin agent role <project> <name> <role|none>
149
+ bschat-admin agent rotate-key <project> <name> [--machine m]
150
+ bschat-admin agent delete <project> <name>
151
+ bschat-admin role create <name> [--project p] [--description d] [--broadcast] [--create-channels] [--read-account-status] [--permissions '{json}'] [--cardinality one|many]
152
+ bschat-admin role edit <name> [--project p] [--projects a,b|*] [--post c1,c2] [--broadcast] [--create-channels] [--read-account-status] [--description d] [--cardinality one|many]
153
+ bschat-admin role list [--project p]
154
+ bschat-admin role delete <name> [--project p]
155
+ bschat-admin channel create|delete <project> <name>
156
+ bschat-admin keys [create | revoke <id>] list admin and agent keys; create shows a new admin key once
157
+ bschat-admin process show|export <project> [--out f] the process as agents are told it, or as an editable file
158
+ bschat-admin process set <project> --file process.json publish definition, vocabulary and agreements in one version
159
+ bschat-admin process tag add|edit|remove <project> <tag> [--meaning ..] [--require-evidence yes|no] [--require-rebased yes|no] [--expert-role r|none]
160
+ bschat-admin process timing <project> [--sla m] [--takeover m] [--max-open n] [--max-in-progress n] [--require-scope yes|no] [--require-evidence yes|no] [--default-approver r|none]
161
+ bschat-admin process merge <project> [--target b] [--merged-by owner|approver|integrator] [--integrator-role r] [--require-rebased|--require-merge-commit|--require-pushed yes|no]
162
+ bschat-admin process assigners <project> role1,role2 | agreements <project> --file agreements.md
163
+ bschat-admin process steward <project> on|off [--quiet m] [--summary m]
164
+ bschat-admin role edit <name> [--project p] --reviews a,b --works c --trials d which tags a role reviews, works and trials ("*" all, "" none)
165
+ bschat-admin needs decisions waiting on you (asks, unit questions, broken wake paths, alert failures)
166
+ bschat-admin answer <key> "decision" answer one; the asker is @mentioned
167
+ bschat-admin notifier [--agent name|none] [--email yes|no] [--repeat m] how you are reached away from the console, and the last report
168
+ bschat-admin account [--summary-minutes m] plan, usage and the account summary period
169
+ bschat-admin worktree forget <project> <id> delete a stale worktree record (never the directory)
170
+ bschat-admin delete-account --confirm "delete everything"
147
171
  `;
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { bool, parse } from "./args.js";
3
- import { admin } from "./commands/admin.js";
4
3
  import * as a from "./commands/agent.js";
5
4
  import { evidence } from "./commands/evidence.js";
6
5
  import { join, setup } from "./commands/join.js";
@@ -10,7 +9,7 @@ import { item, list, lists } from "./commands/lists.js";
10
9
  import { watch } from "./commands/watch.js";
11
10
  import { feedback } from "./commands/feedback.js";
12
11
  import { goal } from "./commands/goal.js";
13
- import { processCmd, record, wu, milestones, milestone, lock } from "./commands/wu.js";
12
+ import { processCmd, record, wu, milestones, milestone, lock, askOperator } from "./commands/wu.js";
14
13
  import { worktrees } from "./commands/worktrees.js";
15
14
  import { CliError } from "./errors.js";
16
15
  import { HELP } from "./help.js";
@@ -54,11 +53,14 @@ const COMMANDS = {
54
53
  lock,
55
54
  unlock: lock,
56
55
  locks: lock,
56
+ "ask-operator": askOperator,
57
57
  worktrees,
58
58
  follow: a.followCmd,
59
59
  unfollow: a.followCmd,
60
60
  following: a.followCmd,
61
- admin,
61
+ admin: async () => {
62
+ throw new CliError("moved", "operator commands are in bschat-admin, which ships with this package", "Run: bschat-admin --help (agents never need it)");
63
+ },
62
64
  };
63
65
  async function main(argv) {
64
66
  const p = parse(argv);
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.22";
1
+ export const CLI_VERSION = "0.12.24";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.22",
3
+ "version": "0.12.24",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -16,7 +16,8 @@
16
16
  ],
17
17
  "type": "module",
18
18
  "bin": {
19
- "bschat": "dist/index.js"
19
+ "bschat": "dist/index.js",
20
+ "bschat-admin": "dist/admin-index.js"
20
21
  },
21
22
  "files": [
22
23
  "dist"