benignswarm 0.12.78 → 0.12.79
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 +1 -1
- package/dist/brief.js +35 -0
- package/dist/commands/admin.js +3 -3
- package/dist/commands/evidence.js +15 -3
- package/dist/commands/hook.js +16 -1
- package/dist/commands/watch.js +42 -25
- package/dist/commands/wu.js +14 -3
- package/dist/help.js +10 -6
- package/dist/index.js +2 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
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", "default-tags", "units", "waits-on", "needs", "exclude", "remove", "post", "harness", "variant", "requires"];
|
|
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", "default-tags", "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", "at", "requires", "priority", "informs", "amend", "waive-informs", "text"];
|
|
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", "default-tags", "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", "at", "requires", "priority", "informs", "amend", "waive-informs", "text", "kind", "claim", "decision"];
|
|
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", "pending", "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", "cancel"];
|
|
8
8
|
export function parse(argv) {
|
|
9
9
|
const options = {};
|
package/dist/brief.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Client } from "./client.js";
|
|
2
|
+
import { loadAgent, resolveAgentName } from "./config.js";
|
|
3
|
+
export async function fetchRecoveryBrief(nameOrRef) {
|
|
4
|
+
const name = resolveAgentName(nameOrRef);
|
|
5
|
+
const creds = loadAgent(name);
|
|
6
|
+
const response = await Client.forAgent(creds, undefined, { presence: false }).call("GET", "/agents/me/brief");
|
|
7
|
+
return response.brief;
|
|
8
|
+
}
|
|
9
|
+
export function formatRecoveryBrief(brief) {
|
|
10
|
+
const lines = [`[bschat] Resume brief for ${brief.agent}`, `Role: ${brief.role}`];
|
|
11
|
+
if (brief.projects.length)
|
|
12
|
+
lines.push(`Process: ${brief.projects.map((p) => `${p.name} ${p.process} (${Array.isArray(p.changed_since_last_read) ? `changed since you last read: ${p.changed_since_last_read.join("; ")}` : p.changed_since_last_read})`).join("; ")}`);
|
|
13
|
+
lines.push("Units:");
|
|
14
|
+
lines.push(...(brief.units.length ? brief.units.map((u) => ` [${u.state}] ${u.project} WU #${u.number} ${u.title} — ${u.next}`) : [" none"]));
|
|
15
|
+
lines.push("Reviews waiting on you:");
|
|
16
|
+
lines.push(...(brief.reviews.length ? brief.reviews.map((r) => ` ${r.project} ${r.slice ? `slice ${r.slice}` : `WU #${r.number}`} ${r.title} — ${r.next}`) : [" none"]));
|
|
17
|
+
lines.push("Open questions and asks:");
|
|
18
|
+
lines.push(...[...brief.questions.map((q) => ` ${q.project} WU #${q.number}: ${q.question} — ${q.next}`), ...brief.asks.map((a) => ` ${a.project} ask ${a.id}: ${a.question} (${a.blocks}) — ${a.next}`)].slice(0, 10));
|
|
19
|
+
if (!brief.questions.length && !brief.asks.length)
|
|
20
|
+
lines.push(" none");
|
|
21
|
+
lines.push("Slices:");
|
|
22
|
+
lines.push(...(brief.slices.length ? brief.slices.map((s) => ` ${s.project} ${s.key}: ${s.title} — ${s.next}`) : [" none"]));
|
|
23
|
+
lines.push("Recent decisions:");
|
|
24
|
+
lines.push(...(brief.decisions.length ? brief.decisions.map((d) => ` ${d.project} ${d.slice} WU #${d.unit} (${d.source}): ${d.ruling}`) : [" none"]));
|
|
25
|
+
return lines.join("\n");
|
|
26
|
+
}
|
|
27
|
+
export const recoveryBriefUnavailableText = "[bschat] Recovery brief unavailable after compaction. Run bschat resume to retrieve the current agent state.";
|
|
28
|
+
export function recoveryBriefWasDelivered(brief, sent) {
|
|
29
|
+
return !!brief && sent;
|
|
30
|
+
}
|
|
31
|
+
export async function resume(p, out) {
|
|
32
|
+
const name = resolveAgentName(typeof p.flags.as === "string" ? p.flags.as : undefined);
|
|
33
|
+
const brief = await fetchRecoveryBrief(name);
|
|
34
|
+
out.print(formatRecoveryBrief(brief), brief);
|
|
35
|
+
}
|
package/dist/commands/admin.js
CHANGED
|
@@ -82,10 +82,10 @@ export async function admin(p, out) {
|
|
|
82
82
|
return milestonesWith(adminClient(p), action, rest[0], p, out);
|
|
83
83
|
}
|
|
84
84
|
case "milestone": {
|
|
85
|
-
// bschat-admin milestone <project> add|edit|show|close|reopen|review|verdict|gap-units <key> ...
|
|
85
|
+
// bschat-admin milestone <project> add|edit|show|decide|close|reopen|review|verdict|gap-units <key> ...
|
|
86
86
|
if (!action)
|
|
87
|
-
throw new CliError("usage", "milestone <project> <add|edit|show|close|reopen|review|verdict|gap-units> <key> ...");
|
|
88
|
-
return milestoneWith(adminClient(p), action, rest[0], rest[1], p, out);
|
|
87
|
+
throw new CliError("usage", "milestone <project> <add|edit|show|decide|close|reopen|review|verdict|gap-units> <key> ...");
|
|
88
|
+
return milestoneWith(adminClient(p), action, rest[0], rest[1], p, out, rest.slice(2));
|
|
89
89
|
}
|
|
90
90
|
case "needs":
|
|
91
91
|
return needsAdmin(p, out);
|
|
@@ -43,6 +43,12 @@ export async function evidence(p, out) {
|
|
|
43
43
|
const label = str(p.flags, "label");
|
|
44
44
|
if (label)
|
|
45
45
|
headers["x-bschat-label"] = label;
|
|
46
|
+
const kind = str(p.flags, "kind");
|
|
47
|
+
if (kind)
|
|
48
|
+
headers["x-bschat-kind"] = kind;
|
|
49
|
+
const claim = str(p.flags, "claim");
|
|
50
|
+
if (claim)
|
|
51
|
+
headers["x-bschat-claim"] = claim;
|
|
46
52
|
const res = await fetch(`${creds.url}/projects/${project}/evidence`, { method: "POST", headers, body: new Uint8Array(bytes) });
|
|
47
53
|
const json = await res.json();
|
|
48
54
|
if (!res.ok)
|
|
@@ -51,9 +57,15 @@ export async function evidence(p, out) {
|
|
|
51
57
|
return;
|
|
52
58
|
}
|
|
53
59
|
if (sub === "list") {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
const qs = new URLSearchParams({ limit: str(p.flags, "limit") ?? "50" });
|
|
61
|
+
for (const flag of ["unit", "kind"]) {
|
|
62
|
+
const value = str(p.flags, flag);
|
|
63
|
+
if (value !== undefined)
|
|
64
|
+
qs.set(flag, value);
|
|
65
|
+
}
|
|
66
|
+
const r = await client.call("GET", `/projects/${project}/evidence?${qs}`);
|
|
67
|
+
const rows = r.evidence.map((e) => ({ id: e.id, filename: e.filename, size: e.size, kind: e.kind, claim: e.claim, by: e.agent_name, label: e.label, sha256: e.sha256.slice(0, 12), created_at: e.created_at }));
|
|
68
|
+
out.print(table(rows, ["id", "filename", "size", "kind", "claim", "by", "label", "sha256", "created_at"]), r);
|
|
57
69
|
return;
|
|
58
70
|
}
|
|
59
71
|
if (sub === "info") {
|
package/dist/commands/hook.js
CHANGED
|
@@ -7,6 +7,7 @@ import { fmtMessage } from "../output.js";
|
|
|
7
7
|
import { readState, writeState } from "../state.js";
|
|
8
8
|
import { goalFromClaudeTranscript, modelFromClaudeTranscript } from "../model.js";
|
|
9
9
|
import { conversationAgent, sessionAgent, syncFromWatchers } from "../sessions.js";
|
|
10
|
+
import { fetchRecoveryBrief, formatRecoveryBrief, recoveryBriefUnavailableText } from "../brief.js";
|
|
10
11
|
const HEARTBEAT_MS = 60_000;
|
|
11
12
|
/** Reads the harness's hook payload from stdin without blocking when there is none. */
|
|
12
13
|
function readStdinJson() {
|
|
@@ -330,7 +331,10 @@ export async function hook(p) {
|
|
|
330
331
|
// Standing rules die with the context. On SessionStart (startup, resume, and after a compaction)
|
|
331
332
|
// re-deliver the role description and the project's process when the agent has not seen this
|
|
332
333
|
// version, and record that it was shown.
|
|
333
|
-
const
|
|
334
|
+
const compacted = input?.source === "compact";
|
|
335
|
+
const standing = harness === "claude-code" && event === "SessionStart"
|
|
336
|
+
? compacted ? await recoveryBrief(name) : await standingRules(name, false)
|
|
337
|
+
: null;
|
|
334
338
|
// The hook firing is proof the harness is working; tell the server, at most once a minute.
|
|
335
339
|
// The session goal (/goal) rides along from the transcript, and a change goes out at once.
|
|
336
340
|
if (harness === "claude-code") {
|
|
@@ -362,6 +366,17 @@ export async function hook(p) {
|
|
|
362
366
|
}
|
|
363
367
|
await acknowledgeStanding(name, standing, formatted.acknowledge);
|
|
364
368
|
}
|
|
369
|
+
/** After compaction, restore agent-specific state instead of repeating the standing agreements. */
|
|
370
|
+
export async function recoveryBrief(name) {
|
|
371
|
+
try {
|
|
372
|
+
const text = formatRecoveryBrief(await fetchRecoveryBrief(name));
|
|
373
|
+
return { text, deferredText: text, acknowledge: false, version: 0, project: null };
|
|
374
|
+
}
|
|
375
|
+
catch (e) {
|
|
376
|
+
process.stderr.write(`bschat: could not fetch recovery brief: ${e.message}\n`);
|
|
377
|
+
return { text: recoveryBriefUnavailableText, deferredText: recoveryBriefUnavailableText, acknowledge: false, version: 0, project: null };
|
|
378
|
+
}
|
|
379
|
+
}
|
|
365
380
|
/**
|
|
366
381
|
* The role and process the agent must hold after a new session or a compaction, when it has not
|
|
367
382
|
* seen this process version (or always after a compaction). Records that it was shown.
|
package/dist/commands/watch.js
CHANGED
|
@@ -20,6 +20,7 @@ import { acquireWatchLock } from "../lock.js";
|
|
|
20
20
|
import { formatUpdates, gatherUpdates, reportDelivery } from "./hook.js";
|
|
21
21
|
import { readState, writeState } from "../state.js";
|
|
22
22
|
import { probeCapabilities } from "../capabilities.js";
|
|
23
|
+
import { fetchRecoveryBrief, formatRecoveryBrief, recoveryBriefUnavailableText, recoveryBriefWasDelivered } from "../brief.js";
|
|
23
24
|
/** Reports host probes without refreshing the agent's presence; the host identity is still explicit. */
|
|
24
25
|
export async function reportWatcherCapabilities(creds, project, definitions, cwd = process.cwd()) {
|
|
25
26
|
const results = probeCapabilities(definitions, cwd);
|
|
@@ -134,6 +135,7 @@ export async function watch(p, out) {
|
|
|
134
135
|
let lastKeyCheck = 0;
|
|
135
136
|
const ctl = { turn: null, failedAt: 0, loggedRunning: null, pausedUntil: 0, pausedAt: 0 };
|
|
136
137
|
const probe = turn ? probeFor(turn.harness, turn.session, name) : null;
|
|
138
|
+
let resumeBriefDelivered = false;
|
|
137
139
|
while (!stopping) {
|
|
138
140
|
if (activity && heartbeatClient)
|
|
139
141
|
lastSample = await heartbeatIfActive(heartbeatClient, activity, lastSample, interval, log);
|
|
@@ -210,9 +212,14 @@ export async function watch(p, out) {
|
|
|
210
212
|
if (!full) {
|
|
211
213
|
try {
|
|
212
214
|
if (probe)
|
|
213
|
-
await turnStep(ctl, probe, turnTimeout, log, (sink) =>
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
await turnStep(ctl, probe, turnTimeout, log, async (sink) => {
|
|
216
|
+
const result = await wakeOnce(name, exec, unackedAfter, followDelay, log, str(p.flags, "model"), once, sink, !resumeBriefDelivered);
|
|
217
|
+
resumeBriefDelivered = resumeBriefDelivered || result.recoveryBriefDelivered;
|
|
218
|
+
}, name);
|
|
219
|
+
else {
|
|
220
|
+
const result = await wakeOnce(name, exec, unackedAfter, followDelay, log, str(p.flags, "model"), once, undefined, !resumeBriefDelivered);
|
|
221
|
+
resumeBriefDelivered = resumeBriefDelivered || result.recoveryBriefDelivered;
|
|
222
|
+
}
|
|
216
223
|
}
|
|
217
224
|
catch (e) {
|
|
218
225
|
if (e.code === "unauthorized" && !once) {
|
|
@@ -233,21 +240,27 @@ export async function watch(p, out) {
|
|
|
233
240
|
if (stopping)
|
|
234
241
|
return stoppingCode;
|
|
235
242
|
if (u) {
|
|
236
|
-
const
|
|
237
|
-
const
|
|
243
|
+
const recovery = resumeBriefDelivered ? null : await recoveryBriefText(name, log);
|
|
244
|
+
const update = resumeBriefDelivered ? u : formatUpdates(u, [recovery ?? recoveryBriefUnavailableText]);
|
|
245
|
+
const total = update.counts.messages + update.counts.items + update.counts.followed + update.counts.digest;
|
|
246
|
+
const summary = update.text.split("\n")[0].replace(/^\[bschat\] (Delivered by your BenignSwarm watcher, not typed by the user\. )?/, "");
|
|
247
|
+
let delivered = true;
|
|
238
248
|
if (exec) {
|
|
239
|
-
const cmd = exec.replaceAll("{count}", String(total)).replaceAll("{summary}", shellQuote(summary)).replaceAll("{text}", shellQuote(
|
|
249
|
+
const cmd = exec.replaceAll("{count}", String(total)).replaceAll("{summary}", shellQuote(summary)).replaceAll("{text}", shellQuote(update.text));
|
|
240
250
|
log(`new activity (${summary}); running: ${cmd}`);
|
|
241
|
-
const code = await run(cmd,
|
|
242
|
-
if (code !== 0)
|
|
251
|
+
const code = await run(cmd, update.text, { BSCHAT_TEXT: update.text, BSCHAT_SUMMARY: summary, BSCHAT_COUNT: String(total) });
|
|
252
|
+
if (code !== 0) {
|
|
243
253
|
log(`command exited ${code}`);
|
|
254
|
+
delivered = false;
|
|
255
|
+
}
|
|
244
256
|
}
|
|
245
257
|
else {
|
|
246
|
-
process.stdout.write(
|
|
258
|
+
process.stdout.write(update.text + "\n");
|
|
247
259
|
}
|
|
248
260
|
// Full mode delivers the update payload directly instead of using the wake path, so
|
|
249
261
|
// record the same actual payload bytes and kinds through the hook's existing metric call.
|
|
250
|
-
await reportDelivery(name,
|
|
262
|
+
await reportDelivery(name, update.text, update.delivery.by_kind, "watch");
|
|
263
|
+
resumeBriefDelivered = resumeBriefDelivered || recoveryBriefWasDelivered(recovery, delivered);
|
|
251
264
|
if (stopping)
|
|
252
265
|
return stoppingCode;
|
|
253
266
|
}
|
|
@@ -266,16 +279,7 @@ async function waitIntervalOrStop(ms, stopped) {
|
|
|
266
279
|
if (timer)
|
|
267
280
|
clearTimeout(timer);
|
|
268
281
|
}
|
|
269
|
-
|
|
270
|
-
* One numbered wake-up at a time. Each wake-up carries a sequence number and asks the agent to
|
|
271
|
-
* acknowledge it first (bschat wake ack <n>); until it does, nothing else is queued for it, for
|
|
272
|
-
* any reason. Learned from Codex: a harness delivers queued prompts only after its current turn,
|
|
273
|
-
* so the old rule (pending clears when the agent's read cursors move, an operator message or a
|
|
274
|
-
* timeout queues another) let six or seven wake-ups pile up behind a busy turn. Delivered back to
|
|
275
|
-
* back, they pulled sol-architect off its task and it stopped with the task unfinished. The
|
|
276
|
-
* cursors moved because the agent was reading while it worked, not because it saw the wake-up.
|
|
277
|
-
*/
|
|
278
|
-
async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once, turnSink) {
|
|
282
|
+
async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once, turnSink, includeResumeBrief = false) {
|
|
279
283
|
const state = readState(name);
|
|
280
284
|
const pending = state.watch_pending;
|
|
281
285
|
if (pending) {
|
|
@@ -302,7 +306,7 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
302
306
|
}
|
|
303
307
|
else if (once)
|
|
304
308
|
log(`wake-up ${st.watch_pending.seq !== undefined ? `#${st.watch_pending.seq} ` : ""}queued ${Math.round(waited / 1000)}s ago and not acknowledged; not queueing another`);
|
|
305
|
-
return;
|
|
309
|
+
return { sent: false, recoveryBriefDelivered: false };
|
|
306
310
|
}
|
|
307
311
|
const u = await gatherUpdates(name, { force: true, model, delivery: "watch", dryRun: true });
|
|
308
312
|
// A process change is news too. Watched harnesses never see the Claude Code hook re-deliver the
|
|
@@ -315,7 +319,7 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
315
319
|
if (!processNews) {
|
|
316
320
|
if (once)
|
|
317
321
|
log("nothing new");
|
|
318
|
-
return;
|
|
322
|
+
return { sent: false, recoveryBriefDelivered: false };
|
|
319
323
|
}
|
|
320
324
|
}
|
|
321
325
|
else if (u.tier === "digest" && !processNews) {
|
|
@@ -323,7 +327,7 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
323
327
|
// follow delay so bursts collapse; digest-only channels never wake it on their own.
|
|
324
328
|
if (once)
|
|
325
329
|
log("only digest-level unread; not waking");
|
|
326
|
-
return;
|
|
330
|
+
return { sent: false, recoveryBriefDelivered: false };
|
|
327
331
|
}
|
|
328
332
|
else if (u.tier === "followed" && !processNews) {
|
|
329
333
|
const since = st.watch_followed_since ?? Date.now();
|
|
@@ -333,11 +337,13 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
333
337
|
if (waited < followDelay * 1000) {
|
|
334
338
|
if (once)
|
|
335
339
|
log(`followed-channel traffic only; waiting (${Math.round(waited / 1000)}/${followDelay}s) before waking`);
|
|
336
|
-
return;
|
|
340
|
+
return { sent: false, recoveryBriefDelivered: false };
|
|
337
341
|
}
|
|
338
342
|
}
|
|
339
343
|
const seq = (st.watch_seq ?? 0) + 1;
|
|
340
344
|
const operatorNew = !!u && u.latestOperatorAt !== null && u.latestOperatorAt !== (st.watch_operator_at ?? null);
|
|
345
|
+
const recovery = includeResumeBrief ? await recoveryBriefText(name, log) : null;
|
|
346
|
+
const recoveryPrompt = includeResumeBrief ? recovery ?? recoveryBriefUnavailableText : null;
|
|
341
347
|
const wakePrefix = [
|
|
342
348
|
...(turnSink
|
|
343
349
|
? [`[bschat] Turn #${seq}, started by your BenignSwarm watcher because you were idle; not typed by the user. It is already acknowledged.`]
|
|
@@ -346,6 +352,7 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
346
352
|
`First acknowledge it: bschat wake ack ${seq} (no other wake-up comes until you do). If you are in the middle of a task, acknowledge, read, then carry on with the task.`,
|
|
347
353
|
]),
|
|
348
354
|
operatorNew ? `A human operator wrote to you directly.` : null,
|
|
355
|
+
recoveryPrompt,
|
|
349
356
|
processNews ? processLine(lag) : null,
|
|
350
357
|
].filter(Boolean);
|
|
351
358
|
const wakeSuffix = [
|
|
@@ -360,7 +367,7 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
360
367
|
// the acknowledgement, operator note, process pointer, read commands, and delivery body.
|
|
361
368
|
const line = wake;
|
|
362
369
|
if (!(await deliver(name, exec, wake, line, u ? u.tier : "process", total, log, operatorNew ? "operator message; " : "", seq, turnSink, payload?.delivery.by_kind ?? u?.delivery.by_kind)))
|
|
363
|
-
return;
|
|
370
|
+
return { sent: false, recoveryBriefDelivered: false };
|
|
364
371
|
writeState(name, {
|
|
365
372
|
...readState(name),
|
|
366
373
|
watch_seq: seq,
|
|
@@ -370,6 +377,16 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
370
377
|
watch_followed_since: undefined,
|
|
371
378
|
watch_dormant_logged_at: undefined,
|
|
372
379
|
});
|
|
380
|
+
return { sent: true, recoveryBriefDelivered: recoveryBriefWasDelivered(recovery, true) };
|
|
381
|
+
}
|
|
382
|
+
async function recoveryBriefText(name, log) {
|
|
383
|
+
try {
|
|
384
|
+
return formatRecoveryBrief(await fetchRecoveryBrief(name));
|
|
385
|
+
}
|
|
386
|
+
catch (e) {
|
|
387
|
+
log(`recovery brief unavailable: ${e.message}`);
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
373
390
|
}
|
|
374
391
|
/** Runs the wake command (or prints the wake-up without one). False when the command failed: nothing was delivered. */
|
|
375
392
|
async function deliver(name, exec, wake, summary, tier, total, log, prefix, seq, turnSink, kinds = {}) {
|
package/dist/commands/wu.js
CHANGED
|
@@ -649,15 +649,24 @@ export async function milestone(p, out) {
|
|
|
649
649
|
const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
|
|
650
650
|
if (!project)
|
|
651
651
|
throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
|
|
652
|
-
return milestoneWith(client, project, p.positionals[1], p.positionals[2], p, out);
|
|
652
|
+
return milestoneWith(client, project, p.positionals[1], p.positionals[2], p, out, p.positionals.slice(3));
|
|
653
653
|
}
|
|
654
654
|
/** One milestone, shared by agents (`bschat milestone`) and the operator (`bschat-admin milestone <project>`). */
|
|
655
|
-
export async function milestoneWith(client, project, sub, key, p, out) {
|
|
655
|
+
export async function milestoneWith(client, project, sub, key, p, out, decisionParts = p.positionals.slice(3)) {
|
|
656
656
|
if (!key)
|
|
657
657
|
throw new CliError("usage", 'milestone show <key> | milestone close <key> --note "how the exit criterion was met" [--evidence id,id] [--abandon | --defer] | milestone reopen <key>');
|
|
658
658
|
// "set" is "edit" (bschat milestone set <key> --priority 5): one slice changed, the rest untouched.
|
|
659
659
|
if (sub === "set")
|
|
660
660
|
sub = "edit";
|
|
661
|
+
if (sub === "decide") {
|
|
662
|
+
const decision = (decisionParts.join(" ") || str(p.flags, "decision") || "").trim();
|
|
663
|
+
const unit = str(p.flags, "unit");
|
|
664
|
+
if (!decision || !unit || !/^\d+$/.test(unit))
|
|
665
|
+
throw new CliError("usage", 'milestone decide <key> "ruling" --unit <n>');
|
|
666
|
+
const r = await client.call("POST", `/projects/${project}/milestones/${key}/decide`, { decision, unit: Number(unit) });
|
|
667
|
+
out.print(`Recorded milestone ${key} decision for WU #${unit}.`, r);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
661
670
|
if (sub === "add" || sub === "edit") {
|
|
662
671
|
// One slice in, the rest untouched: fetch the list, add or amend the entry, set it back.
|
|
663
672
|
const cur = (await client.call("GET", `/projects/${project}/milestones`)).milestones;
|
|
@@ -694,7 +703,9 @@ export async function milestoneWith(client, project, sub, key, p, out) {
|
|
|
694
703
|
const m = (await client.call("GET", `/projects/${project}/milestones`)).milestones.find((x) => x.key === key);
|
|
695
704
|
if (!m)
|
|
696
705
|
throw new CliError("not_found", `no milestone ${key}`);
|
|
697
|
-
|
|
706
|
+
const detail = await client.call("GET", `/projects/${project}/milestones/${key}`);
|
|
707
|
+
const decisions = (detail.decisions ?? []).map((d) => `\n ${d.created_at.slice(0, 16)} WU #${d.unit_number} (${d.source}, ${d.created_by}): ${d.ruling}`).join("");
|
|
708
|
+
out.print(`${m.key}: ${m.title} [${m.status}${m.status === "open" && !m.ready ? `, waits on ${m.waiting_on.join(", ")}` : ""}]${m.priority !== null && m.priority !== undefined ? `\n priority: ${m.priority}` : ""}\n depends on: ${m.depends_on.join(", ") || "-"}\n default tags: ${(m.default_tags ?? []).map((t) => `#${t}`).join(" ") || "-"}\n units: ${m.units.done} done, ${m.units.open} open, ${m.units.queued} queued of ${m.units.total}${m.review ? `\n closure review: ${m.review.reviewer_name} (${m.review.source}) since ${m.review.requested_at}` : ""}${m.last_verdict && !m.last_verdict.met ? `\n gaps (${m.last_verdict.by}, ${m.last_verdict.at.slice(0, 16)}): ${m.last_verdict.gaps}` : ""}\n exit: ${m.exit || "(not written)"}${m.source ? `\n source: ${m.source} (the full brief; read it when planning this slice)` : ""}${m.closed_at ? `\n closed ${m.closed_at} by ${m.closed_by}: ${m.closed_note}${m.evidence.length ? ` (${m.evidence.map((e) => `evidence:${e}`).join(" ")})` : ""}` : ""}\n decisions:${decisions || " (none)"}`, { ...m, decisions: detail.decisions });
|
|
698
709
|
return;
|
|
699
710
|
}
|
|
700
711
|
if (sub === "close") {
|
package/dist/help.js
CHANGED
|
@@ -19,6 +19,7 @@ Agent commands
|
|
|
19
19
|
bschat logout --as <name>
|
|
20
20
|
bschat identities list saved identities on this machine
|
|
21
21
|
bschat me who am I, role, permissions, channels
|
|
22
|
+
bschat resume compact recovery brief: your units, reviews, asks, slices, decisions and process version
|
|
22
23
|
bschat who [--account] what every agent is doing (--account: all projects)
|
|
23
24
|
bschat status set [--state s] [--goal g] [--task t] [--blocked-on b] [--tags a,b] [--custom '{json}']
|
|
24
25
|
[--checks-every <min>|none] not always on but checking on a schedule: say how often
|
|
@@ -59,6 +60,7 @@ Agent commands
|
|
|
59
60
|
roles or the operator); --source is where the full brief lives, read only when planning the slice;
|
|
60
61
|
no exit and no dependencies makes a container for ongoing work; milestone edit (or set) <key> amends
|
|
61
62
|
bschat milestone show <key> exit criterion, dependencies, counts; wu milestone <n> <key|none> moves a unit
|
|
63
|
+
bschat milestone decide <key> "ruling" --unit <n> record a one-line lead decision for a unit on this slice
|
|
62
64
|
bschat milestone close <key> --note ".." [--evidence a,b] [--abandon | --defer] [--waive-informs ".."] the lead closes a slice against its exit criterion
|
|
63
65
|
bschat milestone verdict <key> --met --note ".." [--evidence a,b] | --gaps ".." [--units n,m] [--waive-informs ".."] the closure reviewer judges the exit against the evidence; gap units re-trigger the review when they close
|
|
64
66
|
bschat milestone gap-units <key> --units n,m name the units (on any slice) that address its last gaps verdict: stops the chase, re-reviews when they close
|
|
@@ -70,9 +72,11 @@ Agent commands
|
|
|
70
72
|
bschat wu submit <n> [--evidence id[,id...] ...] [--pr url] ask for review; repeat --evidence or pass comma-separated ids; routed to whoever is qualified for the tags (in review: refreshes the head, approvals cleared)
|
|
71
73
|
bschat wu review <n> reviewer's checkout: fetch the submitted branch from origin and open
|
|
72
74
|
../<repo>-review-wu<n> detached at the submitted head (refused if origin differs)
|
|
73
|
-
bschat wu approve <n> --note ".."
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
bschat wu approve <n> --note ".." approval covers tags your role reviews
|
|
76
|
+
a planned reviewer still owing may approve after coverage; status stays approved until merge
|
|
77
|
+
bschat wu changes <n> --unmet ".." --note ".." send back, quoting the failed scope, exit or agreement clause; a planned reviewer still owing may send an approved, unmerged unit back
|
|
78
|
+
concerns outside those are notes (wu note) or questions (wu ask)
|
|
79
|
+
bschat wu classify <n> --tags a,b classifier: confirm or change a new unit's tags before it routes for review
|
|
76
80
|
bschat wu proceed <n> --note ".." reviewer: this step is good, carry on; back to the owner, NOT an approval
|
|
77
81
|
bschat wu reopen <n> --note ".." owner or reviewer: withdraw an unmerged approval (verification failed); resubmit the same unit
|
|
78
82
|
bschat wu supersede <n> --by <m> owner or assigner: this unit continues as #m; anyone blocked on #n now waits on #m
|
|
@@ -140,8 +144,8 @@ Agent commands
|
|
|
140
144
|
bschat channel create <name> [--topic t] needs create_channels permission
|
|
141
145
|
bschat agents
|
|
142
146
|
bschat roles
|
|
143
|
-
bschat evidence post <file> [--label t] [--type ct] [--name fn] checksummed
|
|
144
|
-
bschat evidence list [--limit n]
|
|
147
|
+
bschat evidence post <file> [--label t] [--kind test|diagnosis|review|screenshot|log|other] [--claim "one line"] [--type ct] [--name fn] checksummed evidence
|
|
148
|
+
bschat evidence list [--limit n] [--unit n] [--kind k]
|
|
145
149
|
bschat evidence info <id|sha256>
|
|
146
150
|
bschat evidence get <id|sha256> [--out path] verifies sha256 on download
|
|
147
151
|
bschat retire --title t (--body b | --body-file f) [--handoff-to @x|@role:y] [--evidence id,id] --yes
|
|
@@ -207,7 +211,7 @@ bschat-admin login (approve it in your signed-in browser); the session lasts 30
|
|
|
207
211
|
bschat-admin process steward <project> on|off [--quiet m] [--summary m] [--churn n] (--churn: ask the operator when a goal is sent back or handed over n times; 0 off)
|
|
208
212
|
bschat-admin milestones <project> [export [--out plan.json] | set --file plan.json] the plan's slices: list, the editable JSON, or replace it (keys keep their status)
|
|
209
213
|
bschat-admin milestone <project> add|edit <key> --title .. [--exit ..] [--source ..] [--depends-on a,b] [--informs c,d] [--default-tags a,b] one slice in, the rest untouched
|
|
210
|
-
bschat-admin milestone <project> show|review|reopen <key> | close <key> --note .. [--abandon|--defer] | verdict <key> --met|--gaps .. | gap-units <key> --units n,m
|
|
214
|
+
bschat-admin milestone <project> show|review|reopen <key> | decide <key> "ruling" --unit n | close <key> --note .. [--abandon|--defer] | verdict <key> --met|--gaps .. | gap-units <key> --units n,m
|
|
211
215
|
bschat-admin role edit <name> [--project p] --reviews a,b --works c --trials d which tags a role reviews, works and trials ("*" all, "" none)
|
|
212
216
|
bschat-admin needs decisions waiting on you (asks, unit questions, broken wake paths, alert failures)
|
|
213
217
|
bschat-admin answer <key> "decision" answer one; the asker is @mentioned
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { CliError } from "./errors.js";
|
|
|
23
23
|
import { HELP } from "./help.js";
|
|
24
24
|
import { CLI_VERSION } from "./version.js";
|
|
25
25
|
import { makeOut } from "./output.js";
|
|
26
|
+
import { resume } from "./brief.js";
|
|
26
27
|
const COMMANDS = {
|
|
27
28
|
join,
|
|
28
29
|
setup,
|
|
@@ -30,6 +31,7 @@ const COMMANDS = {
|
|
|
30
31
|
logout: a.logout,
|
|
31
32
|
identities: a.identities,
|
|
32
33
|
me: a.me,
|
|
34
|
+
resume,
|
|
33
35
|
who: a.who,
|
|
34
36
|
status: a.status,
|
|
35
37
|
away: a.away,
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.12.
|
|
1
|
+
export const CLI_VERSION = "0.12.79";
|