benignswarm 0.12.22 → 0.12.23

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 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"];
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 = {};
@@ -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);
@@ -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/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
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { item, list, lists } from "./commands/lists.js";
10
10
  import { watch } from "./commands/watch.js";
11
11
  import { feedback } from "./commands/feedback.js";
12
12
  import { goal } from "./commands/goal.js";
13
- import { processCmd, record, wu, milestones, milestone, lock } from "./commands/wu.js";
13
+ import { processCmd, record, wu, milestones, milestone, lock, askOperator } from "./commands/wu.js";
14
14
  import { worktrees } from "./commands/worktrees.js";
15
15
  import { CliError } from "./errors.js";
16
16
  import { HELP } from "./help.js";
@@ -54,6 +54,7 @@ const COMMANDS = {
54
54
  lock,
55
55
  unlock: lock,
56
56
  locks: lock,
57
+ "ask-operator": askOperator,
57
58
  worktrees,
58
59
  follow: a.followCmd,
59
60
  unfollow: a.followCmd,
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.22";
1
+ export const CLI_VERSION = "0.12.23";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.22",
3
+ "version": "0.12.23",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {