benignswarm 0.12.90 → 0.12.92

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/help.js CHANGED
@@ -50,18 +50,21 @@ Agent commands
50
50
  b9s wu open "<title>" --scope "..." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--reworks n,m] [--after <n>[,<m>]] [--tier routine|careful|expert] [--requires cap,cap] [--force] [--evidence id[,id...]] [--target <branch>] [--here] open a work unit in its own
51
51
  worktree; tags come from the vocabulary; --target is the branch it lands in (default: the
52
52
  process target), e.g. a lane branch; wu target <n> <branch|default> changes it before review
53
- b9s wu assign "<title>" --to <agent|auto|queue> --scope ".." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--reworks n,m] [--after <n>[,<m>]] [--tier routine|careful|expert] [--requires cap,cap] [--force] [--replay-of n] [--template] [--reason "why"] hand out a unit (assigner roles);
53
+ b9s wu assign "<title>" --to <agent|auto|queue> --scope ".." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--reworks n,m] [--after <n>[,<m>]] [--tier routine|careful|expert] [--allow-lower-tier --reason "why"] [--requires cap,cap] [--force] [--replay-of n] [--template] [--reason "why"] hand out a unit (assigner roles);
54
54
  --to auto picks the active qualified worker with the lightest load; it queues when nobody fits,
55
55
  reports why candidates were passed over, and the sweep chases it;
56
56
  --to queue waits deliberately; naming a busy worker reserves it for them (theirs when free,
57
57
  anyone's after the takeover window); --hold keeps it assigned to them however long it takes;
58
58
  --template --tags a,b prints the scope skeleton; --force records missing required sections, including for queue.
59
- b9s wu assign <n> --to <agent> [--reason "why"] reassign an assigned or queued unit in place
59
+ b9s wu assign <n> --to <agent> [--reason "why"] [--allow-lower-tier] reassign an assigned or queued unit in place; a lower-tier target needs both flags and a reason
60
60
  b9s wu take <n> [--to <agent>] [--reason "why"] pull a unit or hand it to someone
61
61
  reason is required when an assigner uses its assign_outside_qualifications role capability
62
62
  b9s wu next take the oldest queued unit you qualify for
63
63
  b9s wu decline <n> --note "why" [--waits-on <milestone,...> | --defer] decline and requeue an assignment (use wu abandon to close); a steward planning unit
64
64
  ("Advance milestone X") needs the plan decision: what X waits on, or defer X
65
+ b9s wu park <n> --note "why" assigner or operator: park open or sent-back work, keep its owner/branch and free its in-progress slot
66
+ b9s wu unpark <n> assigner or operator: return parked work to open when its owner's slot is free
67
+ b9s wu requeue <n> --note "why" assigner or operator: return an assigned, unstarted unit to the queue; history and branch stay
65
68
  b9s wu start <n> [--branch b | --here] take it up: makes ../<repo>-wu<n> on branch wu/<n>-<slug> (replays: from the
66
69
  target as of the original); a worktree left half-written by an interrupted
67
70
  checkout is removed and made again; wu open does the same for your own units;
@@ -102,7 +105,7 @@ Agent commands
102
105
  b9s wu proceed <n> --note ".." reviewer: this step is good, carry on; back to the owner, NOT an approval
103
106
  b9s wu reopen <n> --note ".." owner or reviewer: withdraw an unmerged approval (verification failed); resubmit the same unit
104
107
  b9s wu supersede <n> --by <m> owner or assigner: this unit continues as #m; anyone blocked on #n now waits on #m
105
- b9s wu ask <n> "question" owner, reviewer or assigner: a decision this unit cannot move without (tag expert first, then the operator)
108
+ b9s wu ask <n> "question" owner, reviewer or assigner: a decision this unit cannot move without, including queued units (tag expert first, then the operator)
106
109
  b9s wu rule <n> "decision" | --approve the tag's expert: answer an open question, or approve its proposal as written (operator questions are answered in the console)
107
110
  b9s wu propose <n> "answer" owner, reviewer, assigner or expert: recommend an answer to the unit's open question, approvable as written
108
111
  b9s wu escalate <n> [--note ..] the tag's expert: pass the question to the operator
@@ -157,8 +160,9 @@ Agent commands
157
160
  b9s doctor every b9s on this machine and who runs which (PATH, npx caches, this repo's
158
161
  hook and instructions, each watcher's plist versus what launchd runs), with fixes
159
162
  b9s codex hooks | bind <thread-id> | sync install b9s's Codex hooks (~/.codex/hooks.json) and say which thread is you
160
- b9s start --harness codex|claude-code|dsh --as <a> --sandbox <mode> [--provider anthropic|deepseek] [--token t] [--thread id] [--model m] [--effort e] [--turns-per-hour 1..20] [--dsh path]
163
+ b9s start --harness codex|claude-code|dsh --as <a> --sandbox <mode> [--provider anthropic|deepseek] [--token t] [--thread id] [--model m] [--effort e] [--max-budget-usd n] [--turns-per-hour 1..20] [--dsh path]
161
164
  run an agent headless: enroll, start or adopt its session, turn-mode watcher
165
+ Claude Code workspace-write defaults to a $1 per-turn cap; configure it with --max-budget-usd
162
166
  (b9s codex start is the same with --harness codex)
163
167
  b9s unpause [--as <a>] lift a usage-limit pause now (the harness was switched to an account with quota)
164
168
  b9s machine run | once | status | prepare | service the machine daemon (prepare checks dsh availability/version; Linux reports no DeepSeek build)
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync
2
2
  import { dirname, join } from "node:path";
3
3
  import { configRoot } from "./config.js";
4
4
  export const DRAIN_MS = 15 * 60_000;
5
- const file = () => join(configRoot(), "state", "maintenance.json");
5
+ const file = (env = process.env) => join(configRoot(env), "state", "maintenance.json");
6
6
  export function writeMaintenance(w) {
7
7
  if (!w) {
8
8
  rmSync(file(), { force: true });
@@ -14,8 +14,8 @@ export function writeMaintenance(w) {
14
14
  renameSync(tmp, file());
15
15
  }
16
16
  /** The window holding turns back now, or null. */
17
- export function drainingUntil(nowMs = Date.now(), text) {
18
- const raw = text ?? (existsSync(file()) ? readFileSync(file(), "utf8") : null);
17
+ export function drainingUntil(nowMs = Date.now(), text, env = process.env) {
18
+ const raw = text ?? (existsSync(file(env)) ? readFileSync(file(env), "utf8") : null);
19
19
  if (!raw)
20
20
  return null;
21
21
  const w = JSON.parse(raw);
package/dist/turn.js CHANGED
@@ -57,9 +57,17 @@ export function readTurnPhase(rollout) {
57
57
  */
58
58
  export function startTurn(cmd, env, seq, stdin) {
59
59
  const child = spawn("/bin/sh", ["-c", cmd], { stdio: [stdin === undefined ? "ignore" : "pipe", "inherit", "inherit"], env: { ...process.env, ...env }, detached: true });
60
- if (stdin !== undefined)
61
- child.stdin?.end(stdin);
62
60
  const turn = { seq, child, startedMs: Date.now(), confirmed: false };
61
+ if (stdin !== undefined && child.stdin) {
62
+ child.stdin.on("error", (error) => {
63
+ if (error.code === "EPIPE") {
64
+ turn.stdinError = "harness exited before reading its prompt";
65
+ return;
66
+ }
67
+ throw error;
68
+ });
69
+ child.stdin.end(stdin);
70
+ }
63
71
  child.on("close", (code, signal) => { turn.exit = { code, signal }; });
64
72
  child.on("error", () => { turn.exit = { code: 127, signal: null }; });
65
73
  return turn;
package/dist/usage.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
- import { dshUsage } from "./harnesses.js";
2
+ import { claudeTranscript, dshUsage } from "./harnesses.js";
3
3
  const zero = () => ({ input: 0, cached_input: 0, output: 0, reasoning: 0, total: 0 });
4
4
  function lines(path) {
5
5
  return readFileSync(path, "utf8").split("\n").filter(Boolean).flatMap((l) => {
@@ -69,15 +69,19 @@ export function claudeUsage(path, since, until) {
69
69
  }
70
70
  /** The usage for a harness session the hook recorded, or an honest "unavailable" record. */
71
71
  export function sessionUsage(session, since, until) {
72
- const none = (harness, reason) => ({ harness, source: "none", scope: "session", since, until, tokens: null, reason });
72
+ const none = (harness, reason) => ({ harness, ...(session?.provider ? { provider: session.provider } : {}), source: "none", scope: "session", since, until, tokens: null, reason });
73
73
  if (!session)
74
74
  return none("unknown", "no hook has reported this agent's session on this machine");
75
- if (!existsSync(session.transcript))
76
- return none(session.harness, `the session file ${session.transcript} is gone`);
75
+ const transcript = session.harness === "claude-code" && session.session_id
76
+ ? (session.transcript && existsSync(session.transcript) ? session.transcript : claudeTranscript(session.session_id) ?? session.transcript)
77
+ : session.transcript;
78
+ if (!existsSync(transcript))
79
+ return none(session.harness, `the session file ${transcript || session.session_id || "(unknown)"} is gone`);
80
+ const withProvider = (usage) => session.provider ? { ...usage, provider: session.provider } : usage;
77
81
  if (session.harness === "codex")
78
- return codexUsage(session.transcript, since, until);
82
+ return withProvider(codexUsage(transcript, since, until));
79
83
  if (session.harness === "claude-code")
80
- return claudeUsage(session.transcript, since, until);
84
+ return withProvider(claudeUsage(transcript, since, until));
81
85
  if (session.harness === "dsh") {
82
86
  const text = readFileSync(session.transcript, "utf8");
83
87
  if (!/"type"\s*:\s*"b9s_invocation_start"/.test(text))
@@ -88,3 +92,13 @@ export function sessionUsage(session, since, until) {
88
92
  }
89
93
  return none(session.harness, `${session.harness} keeps no readable token counts locally`);
90
94
  }
95
+ /** Usage for a Claude Code session identified by the watcher, when no hook bound it to this agent. */
96
+ export function watcherClaudeUsage(sessionId, since, until, provider) {
97
+ const transcript = claudeTranscript(sessionId);
98
+ if (!transcript)
99
+ return {
100
+ harness: "claude-code", ...(provider ? { provider } : {}), source: "none", scope: "session", since, until, tokens: null,
101
+ reason: `no Claude Code transcript for watcher session ${sessionId} under ~/.claude/projects on this machine`,
102
+ };
103
+ return sessionUsage({ harness: "claude-code", transcript, provider }, since, until);
104
+ }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.90";
1
+ export const CLI_VERSION = "0.12.92";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.90",
3
+ "version": "0.12.92",
4
4
  "description": "b9s: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {