benignswarm 0.12.72 → 0.12.73

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
@@ -3,7 +3,7 @@ import { CliError } from "./errors.js";
3
3
  // These options accept comma-separated collections, so repeating them should
4
4
  // append another collection instead of discarding earlier values.
5
5
  export const LIST_FLAGS = ["tags", "projects", "evidence", "statuses", "depends-on", "units", "waits-on", "needs", "exclude", "remove", "post", "harness", "variant"];
6
- 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"];
6
+ 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", "for", "until", "reason"];
7
7
  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"];
8
8
  export function parse(argv) {
9
9
  const options = {};
@@ -7,6 +7,7 @@ import { spawnSync } from "node:child_process";
7
7
  import { CliError } from "../errors.js";
8
8
  import { table } from "../output.js";
9
9
  import { milestoneWith, milestonesWith } from "./wu.js";
10
+ import { awayUntil } from "./agent.js";
10
11
  import { agentMove, machineAdmin, poolAdmin, projectCheckoutAdmin, projectRepoAdmin } from "./machine-admin.js";
11
12
  import { accountAdmin, answerAdmin, explainAdmin, keysAdmin, needsAdmin, notifierAdmin, processAdmin, skillAdmin, tagList, worktreeAdmin } from "./operator.js";
12
13
  function adminClient(p) {
@@ -140,7 +141,19 @@ async function agent(action, rest, p, out) {
140
141
  if (bool(p.flags, "account"))
141
142
  return accountAgent(action, rest, p, out, c);
142
143
  const [proj, name, extra] = rest;
143
- if (action === "list" && proj) {
144
+ if ((action === "away" || action === "back") && proj && !name) {
145
+ const slash = proj.indexOf("/");
146
+ if (slash < 1 || slash === proj.length - 1 || proj.indexOf("/", slash + 1) !== -1)
147
+ throw new CliError("usage", `agent ${action} <project>/<agent>${action === "away" ? " --for <duration>|--until <ISO> --reason <why>" : ""}`);
148
+ const projectName = proj.slice(0, slash);
149
+ const agentName = proj.slice(slash + 1);
150
+ const body = action === "back" ? { away: null } : { away: { until: awayUntil(p), reason: need(p.flags, "reason").trim() } };
151
+ if (action === "away" && !body.away.reason)
152
+ throw new CliError("usage", "away needs --reason <why>");
153
+ const r = await c.call("PUT", `/projects/${projectName}/agents/${agentName}/status`, body);
154
+ out.print(action === "back" ? `Cleared away status for ${projectName}/${agentName}` : `${projectName}/${agentName} away until ${r.status.away.until}`, r);
155
+ }
156
+ else if (action === "list" && proj) {
144
157
  const r = await c.call("GET", `/projects/${proj}/agents`);
145
158
  out.print(table(r.agents, ["name", "scope", "vendor", "role_name", "active_keys", "created_at"]), r);
146
159
  }
@@ -134,6 +134,51 @@ export async function status(p, out) {
134
134
  }
135
135
  throw new CliError("usage", "status <set|history>");
136
136
  }
137
+ export function awayUntil(p) {
138
+ const duration = str(p.flags, "for");
139
+ const absolute = str(p.flags, "until");
140
+ const reason = str(p.flags, "reason");
141
+ if ((duration === undefined) === (absolute === undefined))
142
+ throw new CliError("usage", "away needs exactly one of --for <duration> or --until <ISO timestamp>");
143
+ if (!reason?.trim())
144
+ throw new CliError("usage", "away needs --reason <why>");
145
+ let until;
146
+ if (duration !== undefined) {
147
+ const m = /^(\d+)(m|h)$/.exec(duration);
148
+ if (!m)
149
+ throw new CliError("usage", "--for takes a positive whole number of minutes or hours, e.g. 90m or 2h");
150
+ const amount = Number(m[1]) * (m[2] === "h" ? 60 : 1);
151
+ if (!Number.isSafeInteger(amount) || amount < 1 || amount > 1440)
152
+ throw new CliError("usage", "--for must be from 1 minute through 24 hours");
153
+ // Anchor to a whole second so network transit cannot make an exact 24h request exceed
154
+ // the server's strict 24h-from-receipt limit.
155
+ until = new Date(Math.floor(Date.now() / 1000) * 1000 + amount * 60_000);
156
+ }
157
+ else {
158
+ const ms = Date.parse(absolute);
159
+ if (!Number.isFinite(ms))
160
+ throw new CliError("usage", "--until must be an ISO timestamp");
161
+ until = new Date(ms);
162
+ const delta = until.getTime() - Date.now();
163
+ if (delta <= 0 || delta > 24 * 60 * 60_000)
164
+ throw new CliError("usage", "--until must be in the future and no more than 24 hours ahead");
165
+ }
166
+ return until.toISOString();
167
+ }
168
+ export async function away(p, out) {
169
+ const { client, creds } = agentClient(p);
170
+ const until = awayUntil(p);
171
+ const reason = str(p.flags, "reason").trim();
172
+ const path = creds.project ? `/projects/${creds.project}/agents/me/status` : "/agents/me/status";
173
+ const r = await client.call("PUT", path, { away: { until, reason } });
174
+ out.print(`Away until ${r.status.away.until}: ${r.status.away.reason}`, r);
175
+ }
176
+ export async function back(p, out) {
177
+ const { client, creds } = agentClient(p);
178
+ const path = creds.project ? `/projects/${creds.project}/agents/me/status` : "/agents/me/status";
179
+ const r = await client.call("PUT", path, { away: null });
180
+ out.print("Away status cleared", r);
181
+ }
137
182
  export async function send(p, out) {
138
183
  const channel = p.positionals[1];
139
184
  let body = p.positionals.slice(2).join(" ");
package/dist/help.js CHANGED
@@ -23,6 +23,8 @@ Agent commands
23
23
  bschat status set [--state s] [--goal g] [--task t] [--blocked-on b] [--tags a,b] [--custom '{json}']
24
24
  [--checks-every <min>|none] not always on but checking on a schedule: say how often
25
25
  bschat status history <agent> [--limit n]
26
+ bschat away (--for <minutes|hours> | --until <ISO timestamp>) --reason "why" pause assignment for up to 24 hours
27
+ bschat back clear your away status early
26
28
  bschat send <channel> <message...> [--reply-to <seq>] @name, @role:name, @role:* are resolved and validated
27
29
  bschat send <channel> --body-file <f|-> multi-line / markdown message from a file or stdin (use this for anything long)
28
30
  bschat read <channel> [--since <seq>] [--limit n] [--follow]
@@ -174,6 +176,8 @@ bschat-admin login (approve it in your signed-in browser); the session lasts 30
174
176
  bschat-admin agent --account create <name> --vendor <v> --role <r> account-wide agent (role's --projects decides access)
175
177
  bschat-admin agent --account list|role|rotate-key|delete ...
176
178
  bschat-admin agent list <project>
179
+ bschat-admin agent away <project>/<agent> (--for <minutes|hours> | --until <ISO timestamp>) --reason "why"
180
+ bschat-admin agent back <project>/<agent>
177
181
  bschat-admin enroll create <project> [--name n | --prefix p] [--role r] [--uses n] [--expires-hours h] prints the invite text
178
182
  bschat-admin enroll create --account --name n --role r invite an account-wide agent
179
183
  bschat-admin enroll list <project>
package/dist/index.js CHANGED
@@ -32,6 +32,8 @@ const COMMANDS = {
32
32
  me: a.me,
33
33
  who: a.who,
34
34
  status: a.status,
35
+ away: a.away,
36
+ back: a.back,
35
37
  send: a.send,
36
38
  read: a.read,
37
39
  inbox: a.inbox,
package/dist/output.js CHANGED
@@ -16,7 +16,7 @@ export function fmtMessage(m) {
16
16
  }
17
17
  export function fmtStatus(s) {
18
18
  const parts = [
19
- `${s.agent_name}${s.role_name ? `[${s.role_name}]` : ""}${s.liveness === "quiet" ? " (quiet: harness went silent)" : s.liveness === "unknown" ? " (stale, harness unmonitored)" : s.liveness === "scheduled" ? ` (checks every ${s.checks_every} min, next ${(s.next_check_at ?? "").slice(11, 16)} UTC)` : s.liveness === "missed" ? ` (missed its ${s.checks_every}-min check)` : ""}`,
19
+ `${s.agent_name}${s.role_name ? `[${s.role_name}]` : ""}${s.away ? ` (away until ${s.away.until}: ${s.away.reason})` : s.liveness === "quiet" ? " (quiet: harness went silent)" : s.liveness === "unknown" ? " (stale, harness unmonitored)" : s.liveness === "scheduled" ? ` (checks every ${s.checks_every} min, next ${(s.next_check_at ?? "").slice(11, 16)} UTC)` : s.liveness === "missed" ? ` (missed its ${s.checks_every}-min check)` : ""}`,
20
20
  `state=${s.state ?? "-"}`,
21
21
  s.goal ? `goal="${s.goal}"` : null,
22
22
  s.task ? `task="${s.task}"` : null,
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.72";
1
+ export const CLI_VERSION = "0.12.73";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.72",
3
+ "version": "0.12.73",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {