benignswarm 0.12.164 → 0.12.166
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/admin-index.js +0 -0
- package/dist/antigravity.js +10 -4
- package/dist/args.js +6 -4
- package/dist/build-caches.js +1 -1
- package/dist/client.js +85 -38
- package/dist/command-flags.js +2 -2
- package/dist/commands/admin.js +3 -0
- package/dist/commands/codex-start.js +35 -10
- package/dist/commands/flow-agent.js +88 -0
- package/dist/commands/flow.js +5 -0
- package/dist/commands/gh.js +117 -14
- package/dist/commands/git-credential.js +2 -2
- package/dist/commands/hook.js +23 -5
- package/dist/commands/join.js +20 -8
- package/dist/commands/lock-run.js +7 -15
- package/dist/commands/machine.js +188 -50
- package/dist/commands/mock-admin.js +74 -0
- package/dist/commands/mock.js +64 -0
- package/dist/commands/watch.js +5 -3
- package/dist/commands/wu.js +135 -10
- package/dist/config.js +6 -9
- package/dist/console-links.js +5 -0
- package/dist/errors.js +3 -1
- package/dist/git-sandbox-paths.js +12 -1
- package/dist/git.js +19 -9
- package/dist/harnesses.js +5 -2
- package/dist/help.js +28 -9
- package/dist/index.js +7 -2
- package/dist/install.js +22 -4
- package/dist/machine-network-health.js +50 -0
- package/dist/machine-processes.js +2 -2
- package/dist/machine-report.js +1 -1
- package/dist/merge-train.js +478 -48
- package/dist/model.js +42 -14
- package/dist/output.js +1 -0
- package/dist/scratch-cleanup.js +468 -0
- package/dist/ux-jobs.js +329 -66
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/commands/wu.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { processDeps, runUnderLock,
|
|
1
|
+
import { processDeps, runUnderLock, LOCK_RUN_RETRY_WINDOW_MS } from "./lock-run.js";
|
|
2
2
|
import { forgetLockJob, lockJobKey, lockJobsFile, rememberLockJob, savedLockJobs, tokenForRelease } from "../lock-jobs.js";
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
4
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
5
5
|
import { existsSync, lstatSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { bool, str } from "../args.js";
|
|
7
7
|
import { Client } from "../client.js";
|
|
8
|
+
import { recordMachineNetworkRequest } from "../machine-network-health.js";
|
|
8
9
|
import { agentRef, loadAgent, resolveAgentName, resolveModel } from "../config.js";
|
|
9
10
|
import { readState, updateState } from "../state.js";
|
|
10
11
|
import { codexRollout, sessionsOf } from "../sessions.js";
|
|
@@ -83,6 +84,21 @@ function jsonFlag(p, key, expected) {
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
/** Read the send-back review body's structured points before contacting the API. */
|
|
87
|
+
function questionChoices(p) {
|
|
88
|
+
const raw = str(p.flags, "choices");
|
|
89
|
+
if (raw === undefined)
|
|
90
|
+
return undefined;
|
|
91
|
+
let value;
|
|
92
|
+
try {
|
|
93
|
+
value = JSON.parse(raw);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
throw new CliError("usage", "--choices must be a JSON array");
|
|
97
|
+
}
|
|
98
|
+
if (!Array.isArray(value))
|
|
99
|
+
throw new CliError("usage", "--choices must be a JSON array");
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
86
102
|
export function sendbackRuleFromFile(file) {
|
|
87
103
|
if (!file?.trim())
|
|
88
104
|
throw new CliError("usage", "wu sendback-rule <n> --file ruling.json");
|
|
@@ -554,6 +570,80 @@ export function changedPathsAgainstTarget(target, cwd = process.cwd()) {
|
|
|
554
570
|
throw new CliError("changed_paths_failed", `git diff against ${targetRef} failed: ${diff.stderr?.trim() || "unknown git error"}`);
|
|
555
571
|
return diff.stdout.split("\0").filter((path) => path.length > 0);
|
|
556
572
|
}
|
|
573
|
+
const SUBMIT_SCRATCH_ROOT_DIRS = new Set([".tmp", "tmp", "scratch", "artifacts", "coverage", "dist", "build", ".ux-jobs"]);
|
|
574
|
+
const SUBMIT_SOURCE_EXTENSIONS = /\.(?:[cm]?[jt]sx?|vue|svelte|astro|py|go|rs|java|kt|swift|sh|sql|html|css|scss|json)$/i;
|
|
575
|
+
function isScratchUntrackedPath(path) {
|
|
576
|
+
const normalized = path.replace(/\\/g, "/");
|
|
577
|
+
const parts = normalized.split("/");
|
|
578
|
+
if (parts.includes("node_modules"))
|
|
579
|
+
return true;
|
|
580
|
+
if (SUBMIT_SCRATCH_ROOT_DIRS.has(parts[0] ?? ""))
|
|
581
|
+
return true;
|
|
582
|
+
// These directories are build outputs only in app/package roots. A package named `build`
|
|
583
|
+
// (for example packages/build/src) is source and must not be mistaken for scratch output.
|
|
584
|
+
return ["apps", "packages"].includes(parts[0] ?? "")
|
|
585
|
+
&& ["dist", ".next", ".wrangler"].includes(parts[2] ?? "");
|
|
586
|
+
}
|
|
587
|
+
/** Refuse a review submission that would omit tracked edits or untracked implementation/tests. */
|
|
588
|
+
export function dirtySubmitFiles(cwd = process.cwd()) {
|
|
589
|
+
const status = spawnSync("git", ["status", "--porcelain=v1", "-z", "--untracked-files=all"], { cwd, encoding: "utf8" });
|
|
590
|
+
if (status.error || status.status !== 0) {
|
|
591
|
+
const detail = status.error?.message ?? status.stderr?.trim() ?? `git status exited ${status.status ?? "unknown"}`;
|
|
592
|
+
throw new CliError("git_status_failed", `cannot inspect the worktree before submission: ${detail}`, "Fix the Git status error and retry b9s wu submit");
|
|
593
|
+
}
|
|
594
|
+
const tracked = [];
|
|
595
|
+
const untracked = [];
|
|
596
|
+
const records = status.stdout.split("\0");
|
|
597
|
+
for (let index = 0; index < records.length; index++) {
|
|
598
|
+
const record = records[index];
|
|
599
|
+
if (!record)
|
|
600
|
+
continue;
|
|
601
|
+
const state = record.slice(0, 2);
|
|
602
|
+
const path = record.slice(3);
|
|
603
|
+
if (!path)
|
|
604
|
+
continue;
|
|
605
|
+
if (state === "??") {
|
|
606
|
+
if (isScratchUntrackedPath(path))
|
|
607
|
+
continue;
|
|
608
|
+
const inTestDirectory = /(?:^|\/)(?:test|tests|__tests__)(?:\/|$)/i.test(path);
|
|
609
|
+
const testFile = /\.(?:test|spec)\.[^./\\]+$/i.test(path);
|
|
610
|
+
if (inTestDirectory || testFile || SUBMIT_SOURCE_EXTENSIONS.test(path))
|
|
611
|
+
untracked.push(path);
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
tracked.push(path);
|
|
615
|
+
if (state.includes("R") || state.includes("C")) {
|
|
616
|
+
const previousPath = records[++index];
|
|
617
|
+
if (previousPath)
|
|
618
|
+
tracked.push(previousPath);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return { tracked: [...new Set(tracked)].sort(), untracked: [...new Set(untracked)].sort() };
|
|
623
|
+
}
|
|
624
|
+
function assertCleanSubmitTree(cwd = process.cwd()) {
|
|
625
|
+
const dirty = dirtySubmitFiles(cwd);
|
|
626
|
+
if (!dirty.tracked.length && !dirty.untracked.length)
|
|
627
|
+
return;
|
|
628
|
+
const paths = [
|
|
629
|
+
...dirty.tracked.map((path) => ` modified tracked: ${path}`),
|
|
630
|
+
...dirty.untracked.map((path) => ` untracked source/test: ${path}`),
|
|
631
|
+
];
|
|
632
|
+
throw new CliError("dirty_worktree", `cannot submit with uncommitted work:\n${paths.join("\n")}`, "Commit the intended changes and remove unrelated edits, then run b9s wu submit again");
|
|
633
|
+
}
|
|
634
|
+
function reportSubmitHead(localHead, pushedRef, pushedHead) {
|
|
635
|
+
process.stderr.write(`b9s: pre-submit HEAD: local ${fullSha("HEAD") ?? localHead}; ${pushedRef}: ${pushedHead ?? "not found"}\n`);
|
|
636
|
+
}
|
|
637
|
+
function reportSubmitScopeChecklist(scope) {
|
|
638
|
+
const numbered = typeof scope === "string"
|
|
639
|
+
? scope.split(/\r?\n/).map((line) => line.trim()).filter((line) => /^\d+[.)]\s+/.test(line))
|
|
640
|
+
: [];
|
|
641
|
+
if (!numbered.length) {
|
|
642
|
+
process.stderr.write("b9s: pre-submit check: verify every numbered scope requirement is implemented and covered by the attached evidence\n");
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
process.stderr.write(`b9s: pre-submit scope checklist (verify each item and its evidence):\n${numbered.map((line) => ` [ ] ${line}`).join("\n")}\n`);
|
|
646
|
+
}
|
|
557
647
|
export function submitPayload(fields, hasReviewRules, target, cwd = process.cwd()) {
|
|
558
648
|
const paths = changedPathsAgainstTarget(target, cwd);
|
|
559
649
|
const directories = {}, fileKinds = {};
|
|
@@ -918,10 +1008,13 @@ export async function wu(p, out) {
|
|
|
918
1008
|
}
|
|
919
1009
|
case "submit": {
|
|
920
1010
|
const evidenceIds = list("evidence"); // validated before anything talks to the server
|
|
921
|
-
const def = await processDef();
|
|
922
1011
|
const where = branchAndHead();
|
|
1012
|
+
if (where.head)
|
|
1013
|
+
assertCleanSubmitTree();
|
|
1014
|
+
const def = await processDef();
|
|
923
1015
|
const submitRecord = await client.call("GET", `${base}/${num()}`);
|
|
924
1016
|
const submitUnit = submitRecord.unit;
|
|
1017
|
+
reportSubmitScopeChecklist(submitUnit.scope);
|
|
925
1018
|
const unitTarget = submitUnit.target ?? def.merge.target_branch;
|
|
926
1019
|
const lesson = str(p.flags, "lesson");
|
|
927
1020
|
const disputes = jsonFlag(p, "disputes", "an array of dispute objects");
|
|
@@ -951,6 +1044,7 @@ export async function wu(p, out) {
|
|
|
951
1044
|
const localBranch = where.branch;
|
|
952
1045
|
const check = findRemoteCommitBranch(where.head, localBranch);
|
|
953
1046
|
pushed = check.remoteBranch ? true : check.checked ? false : null;
|
|
1047
|
+
reportSubmitHead(where.head, check.remoteBranch ?? check.checkedRef, check.advertisedTip);
|
|
954
1048
|
if (check.remoteBranch) {
|
|
955
1049
|
remoteCommitBranch = check.remoteBranch;
|
|
956
1050
|
const containingBranch = check.remoteBranch.replace(/^origin\//, "");
|
|
@@ -974,8 +1068,12 @@ export async function wu(p, out) {
|
|
|
974
1068
|
}
|
|
975
1069
|
}
|
|
976
1070
|
else if (def.merge.require_pushed) {
|
|
1071
|
+
reportSubmitHead(where.head, "origin/<branch>", null);
|
|
977
1072
|
throw new CliError("remote_unavailable", formatRemoteCommitFailure("(detached HEAD)", "origin/<branch>", "the current checkout has no local branch name"), "Check out the unit branch and rerun b9s wu submit");
|
|
978
1073
|
}
|
|
1074
|
+
else {
|
|
1075
|
+
reportSubmitHead(where.head, "origin/<branch>", null);
|
|
1076
|
+
}
|
|
979
1077
|
}
|
|
980
1078
|
else if (submitUnit.rebase_needed) {
|
|
981
1079
|
throw new CliError("rebase_required", `WU #${num()} needs rebase onto ${unitTarget}; run b9s wu submit ${num()} from the unit worktree after rebasing`);
|
|
@@ -1025,7 +1123,7 @@ export async function wu(p, out) {
|
|
|
1025
1123
|
const text = (p.positionals.slice(3).join(" ") || str(p.flags, "propose") || "").trim();
|
|
1026
1124
|
if (!text)
|
|
1027
1125
|
throw new CliError("usage", 'wu propose <n> "the answer you recommend, and why the process allows it"');
|
|
1028
|
-
const r = await client.call("POST", `${base}/${num()}/propose`, { proposal: text });
|
|
1126
|
+
const r = await client.call("POST", `${base}/${num()}/propose`, { proposal: text, ...(questionChoices(p) === undefined ? {} : { choices: questionChoices(p) }) });
|
|
1029
1127
|
out.print(`${fmt(r.unit)}\nProposed; whoever rules on the question can approve it as written.`, r);
|
|
1030
1128
|
return;
|
|
1031
1129
|
}
|
|
@@ -1033,13 +1131,16 @@ export async function wu(p, out) {
|
|
|
1033
1131
|
case "rule": {
|
|
1034
1132
|
const approve = sub === "rule" && bool(p.flags, "approve");
|
|
1035
1133
|
const text = (p.positionals.slice(3).join(" ") || str(p.flags, sub === "ask" ? "question" : "ruling") || str(p.flags, "note") || "").trim();
|
|
1036
|
-
|
|
1134
|
+
const choice = str(p.flags, "choice")?.trim();
|
|
1135
|
+
if (p.flags.choice !== undefined && !choice)
|
|
1136
|
+
throw new CliError("usage", "--choice needs a nonempty id");
|
|
1137
|
+
if (!text && !approve && !choice)
|
|
1037
1138
|
throw new CliError("usage", sub === "ask" ? 'wu ask <n> "the decision this unit cannot move without" (works on queued units too)' : 'wu rule <n> "what was decided" | wu rule <n> --approve [--note ".."]');
|
|
1038
1139
|
const sendBackEvent = str(p.flags, "send-back-event");
|
|
1039
1140
|
const cause = str(p.flags, "cause");
|
|
1040
1141
|
if (sendBackEvent && (sub !== "rule" || !cause || !text))
|
|
1041
1142
|
throw new CliError("usage", 'wu rule <n> --send-back-event <event-id> --cause <cause> --ruling "decision"');
|
|
1042
|
-
const r = await client.call("POST", `${base}/${num()}/${sub}`, sub === "ask" ? { question: text, usage: await reviewUsage(client, project, name) } : sendBackEvent ? { send_back_event_id: sendBackEvent, cause, ruling: text } : approve ? { approve: true, ruling: text } : { ruling: text });
|
|
1143
|
+
const r = await client.call("POST", `${base}/${num()}/${sub}`, sub === "ask" ? { question: text, usage: await reviewUsage(client, project, name), ...(questionChoices(p) === undefined ? {} : { choices: questionChoices(p) }) } : sendBackEvent ? { send_back_event_id: sendBackEvent, cause, ruling: text, ...(choice ? { choice_id: choice } : {}) } : approve ? { approve: true, ruling: text, ...(choice ? { choice_id: choice } : {}) } : { ...(text ? { ruling: text } : {}), ...(choice ? { choice_id: choice } : {}) });
|
|
1043
1144
|
const q = r.unit.question;
|
|
1044
1145
|
out.print(`${fmt(r.unit)}\n${sendBackEvent ? "Retrospective ruling recorded on the unit; no chat message was added." : sub === "rule" ? "Ruled; the asker, owner and reviewers were told." : q.level === "expert" ? `Asked a ${q.roles.join(" or ")}; it goes to the operator if nobody rules in time.` : "Asked the operator."}`, r);
|
|
1045
1146
|
return;
|
|
@@ -2351,9 +2452,16 @@ export async function lock(p, out) {
|
|
|
2351
2452
|
const shared = bool(p.flags, "shared");
|
|
2352
2453
|
const runToken = str(p.flags, "token") ?? `b9sjob_${randomBytes(24).toString("hex")}`;
|
|
2353
2454
|
const machine = defaultMachine();
|
|
2354
|
-
const
|
|
2355
|
-
|
|
2356
|
-
|
|
2455
|
+
const lockClient = Client.forAgent(creds, resolveModel(str(p.flags, "model"), process.env, process.cwd(), name), {
|
|
2456
|
+
effort: str(p.flags, "effort"),
|
|
2457
|
+
requestTimeoutMs: 30_000,
|
|
2458
|
+
onRequest: (event) => { if (event.phase === "end")
|
|
2459
|
+
recordMachineNetworkRequest(event); },
|
|
2460
|
+
});
|
|
2461
|
+
const deps = processDeps((method, path, body) => lockClient.call(method, path, body, {
|
|
2462
|
+
requestTimeoutMs: path.endsWith('/running') ? 10_000 : path.endsWith('/output') ? 5_000 : 30_000,
|
|
2463
|
+
retryForMs: LOCK_RUN_RETRY_WINDOW_MS,
|
|
2464
|
+
}), (line) => process.stderr.write(`[b9s] ${line}\n`));
|
|
2357
2465
|
try {
|
|
2358
2466
|
process.exitCode = await runUnderLock({
|
|
2359
2467
|
project, identity: agentRef(creds), projectSelection: creds.project ? undefined : project,
|
|
@@ -2454,8 +2562,14 @@ export async function askOperator(p, out) {
|
|
|
2454
2562
|
if (value !== undefined)
|
|
2455
2563
|
body[field] = value;
|
|
2456
2564
|
}
|
|
2565
|
+
const decision = str(p.flags, "decision");
|
|
2566
|
+
if (decision !== undefined)
|
|
2567
|
+
body.decision = decision;
|
|
2568
|
+
const kind = str(p.flags, "kind");
|
|
2569
|
+
if (kind !== undefined)
|
|
2570
|
+
body.kind = kind;
|
|
2457
2571
|
if (!Object.keys(body).length)
|
|
2458
|
-
throw new CliError("usage", "ask-operator --amend <id> [new question] [--plain ...] [--blocks ...] [--if-yes ...] [--if-no ...] [--propose ...]");
|
|
2572
|
+
throw new CliError("usage", "ask-operator --amend <id> [new question] [--decision ...] [--kind ...] [--plain ...] [--blocks ...] [--if-yes ...] [--if-no ...] [--propose ...]");
|
|
2459
2573
|
const result = await client.call("POST", "/projects/" + project + "/asks/" + amend + "/amend", body);
|
|
2460
2574
|
out.print("Amended your open ask " + amend + "; the operator was told.", result);
|
|
2461
2575
|
return;
|
|
@@ -2466,11 +2580,22 @@ export async function askOperator(p, out) {
|
|
|
2466
2580
|
if (!text || missing.length)
|
|
2467
2581
|
throw new CliError("usage", `ask-operator "exactly what you need the operator to do or decide" --plain "one or two plain sentences for someone who has not read the thread: what this is about (no unit numbers or jargon unexplained)" --blocks "what's stuck until they answer" --if-yes "what happens then" --if-no "what happens then" [--propose "your recommended answer, approvable as written"]${missing.length ? `\nmissing: ${missing.join(", ")}` : ""}`);
|
|
2468
2582
|
const proposal = str(p.flags, "propose") ?? "";
|
|
2583
|
+
const decision = str(p.flags, "decision");
|
|
2584
|
+
const kind = str(p.flags, "kind");
|
|
2585
|
+
const askKinds = ["ci_rerun", "ci_log", "ci_artifact", "pr_label", "git_push", "decision", "approval", "scope_change", "access", "milestone_close", "other"];
|
|
2586
|
+
if (decision !== undefined && (!decision.trim() || decision.trim().length > 120 || /[\r\n]/.test(decision.trim())))
|
|
2587
|
+
throw new CliError("usage", "--decision must be a non-empty one-line headline of at most 120 characters");
|
|
2588
|
+
if (kind !== undefined && !askKinds.includes(kind))
|
|
2589
|
+
throw new CliError("usage", `--kind must be one of: ${askKinds.join(", ")}`);
|
|
2590
|
+
const headline = decision?.trim() ?? (() => {
|
|
2591
|
+
const firstLine = text.split(/[\r\n]/, 1)[0].trim();
|
|
2592
|
+
return firstLine.length <= 120 ? firstLine : `${firstLine.slice(0, 117).trimEnd()}...`;
|
|
2593
|
+
})();
|
|
2469
2594
|
const milestone = str(p.flags, "milestone");
|
|
2470
2595
|
const rawUnit = str(p.flags, "unit");
|
|
2471
2596
|
if (rawUnit !== undefined && !/^[1-9]\d*$/.test(rawUnit))
|
|
2472
2597
|
throw new CliError("usage", "--unit must be a positive work unit number");
|
|
2473
|
-
const r = await client.call("POST", `/projects/${project}/ask-operator`, { text, ...fields, proposal, ...(milestone !== undefined ? { milestone } : {}), ...(rawUnit !== undefined ? { unit: Number(rawUnit) } : {}) });
|
|
2598
|
+
const r = await client.call("POST", `/projects/${project}/ask-operator`, { text, ...fields, proposal, decision: headline, ...(kind !== undefined ? { kind } : {}), ...(milestone !== undefined ? { milestone } : {}), ...(rawUnit !== undefined ? { unit: Number(rawUnit) } : {}) });
|
|
2474
2599
|
out.print(`Asked the operator${proposal ? " with your proposal (they can approve it as written)" : ""}; 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);
|
|
2475
2600
|
}
|
|
2476
2601
|
async function reviewUsage(client, project, name) {
|
package/dist/config.js
CHANGED
|
@@ -7,7 +7,6 @@ import { writeFileAtomic } from "./shared-file.js";
|
|
|
7
7
|
import { readState, updateState } from "./state.js";
|
|
8
8
|
import { detectVendor } from "./vendor.js";
|
|
9
9
|
import { configDirectory } from "./directories.js";
|
|
10
|
-
import { CLI_VERSION } from "./version.js";
|
|
11
10
|
export const DEFAULT_URL = "https://api.benignswarm.org";
|
|
12
11
|
export function configRoot(env = process.env) {
|
|
13
12
|
return configDirectory(env);
|
|
@@ -168,7 +167,7 @@ export function resolveAgentName(asFlag, env = process.env, cwd = process.cwd())
|
|
|
168
167
|
const saved = listSaved("agents", env);
|
|
169
168
|
throw new CliError("no_identity", `BSCHAT_AGENT is not set and --as was not given; b9s cannot tell which agent you are${identityWalkStoppedAt() ? ` (it looked for this checkout's identity file up to ${identityWalkStoppedAt()}, where it is not permitted to look)` : ""}`, saved.length
|
|
170
169
|
? `Saved identities on this machine: ${saved.join(", ")}. Ask the user which one is yours, then: export BSCHAT_AGENT=<project>/<name> (or run: b9s setup --as <project>/<name> to record it for this repo)`
|
|
171
|
-
: `No identities are saved here. Ask the account owner for an invite
|
|
170
|
+
: `No identities are saved here. Ask the account owner for an invite, then follow ${DEFAULT_URL}/onboard to use the recorded install or prepare the canonical runtime.`);
|
|
172
171
|
}
|
|
173
172
|
return isRef(name) ? name : resolveSavedRef(name, env);
|
|
174
173
|
}
|
|
@@ -216,12 +215,7 @@ export function resolveModel(flag, env = process.env, cwd = process.cwd(), agent
|
|
|
216
215
|
name = undefined; // no identity: model still resolves from flag, env and harness config
|
|
217
216
|
}
|
|
218
217
|
if (name) {
|
|
219
|
-
|
|
220
|
-
hookModel = readState(name, env).model ?? null;
|
|
221
|
-
}
|
|
222
|
-
catch {
|
|
223
|
-
hookModel = null;
|
|
224
|
-
}
|
|
218
|
+
hookModel = readState(name, env).model ?? null;
|
|
225
219
|
try {
|
|
226
220
|
savedVendor = loadAgent(name, env).vendor;
|
|
227
221
|
}
|
|
@@ -231,7 +225,10 @@ export function resolveModel(flag, env = process.env, cwd = process.cwd(), agent
|
|
|
231
225
|
}
|
|
232
226
|
const r = resolveModelDetailed({ flag, env, hookModel, identityModel, cwd, vendor: savedVendor });
|
|
233
227
|
// Remember a detected model so a later call that cannot detect it reports the same value.
|
|
234
|
-
if (name && r.model !== "unknown" && (r.source === "
|
|
228
|
+
if (name && savedVendor === "antigravity" && r.model !== "unknown" && (r.source === "flag" || r.source === "env")) {
|
|
229
|
+
updateState(name, (onDisk) => onDisk.model === r.model ? undefined : ({ ...onDisk, model: r.model, model_observed_at: Date.now() }), env);
|
|
230
|
+
}
|
|
231
|
+
else if (name && r.model !== "unknown" && (r.source === "config" || r.source === "hook")) {
|
|
235
232
|
try {
|
|
236
233
|
const st = readState(name, env);
|
|
237
234
|
if (st.model !== r.model)
|
package/dist/console-links.js
CHANGED
|
@@ -2,6 +2,11 @@ const CONSOLE_URL = "https://benignswarm.org";
|
|
|
2
2
|
/** Build the canonical console destination used when CLI output names a record. */
|
|
3
3
|
export function consoleLink(kind, project, id) {
|
|
4
4
|
const base = CONSOLE_URL;
|
|
5
|
+
if (kind === "mock") {
|
|
6
|
+
if (!project)
|
|
7
|
+
throw new Error("A mock viewer link requires its project");
|
|
8
|
+
return `${base}/projects/${encodeURIComponent(project)}/mocks/${encodeURIComponent(String(id))}`;
|
|
9
|
+
}
|
|
5
10
|
if (kind === "work") {
|
|
6
11
|
if (!project)
|
|
7
12
|
throw new Error("A work-unit console link requires its project");
|
package/dist/errors.js
CHANGED
|
@@ -2,11 +2,13 @@ export class CliError extends Error {
|
|
|
2
2
|
code;
|
|
3
3
|
hint;
|
|
4
4
|
httpStatus;
|
|
5
|
-
|
|
5
|
+
cause;
|
|
6
|
+
constructor(code, message, hint, httpStatus, cause) {
|
|
6
7
|
super(message);
|
|
7
8
|
this.code = code;
|
|
8
9
|
this.hint = hint;
|
|
9
10
|
this.httpStatus = httpStatus;
|
|
11
|
+
this.cause = cause;
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
/** A 2xx response committed a write, but its text receipt did not prove the stored text. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { existsSync, lstatSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
4
|
-
import { join, resolve } from "node:path";
|
|
4
|
+
import { join, resolve, sep } from "node:path";
|
|
5
5
|
import { CliError } from "./errors.js";
|
|
6
6
|
function gitMetadata(cwd, label) {
|
|
7
7
|
const result = spawnSync("git", ["rev-parse", "--path-format=absolute", "--absolute-git-dir", "--git-common-dir"], { cwd, encoding: "utf8" });
|
|
@@ -113,6 +113,17 @@ export function gitSandboxReadablePaths(checkout, additionalCheckouts = []) {
|
|
|
113
113
|
}
|
|
114
114
|
return [...new Set([commonDir, ...metadata.map((item) => item.gitDir)])];
|
|
115
115
|
}
|
|
116
|
+
/** The exact linked-worktree admin directory, if this checkout is a linked worktree. */
|
|
117
|
+
export function gitSandboxWorktreeMetadataPath(checkout) {
|
|
118
|
+
const { gitDir, commonDir } = gitMetadata(checkout, "unit worktree");
|
|
119
|
+
if (gitDir === commonDir)
|
|
120
|
+
return null;
|
|
121
|
+
const registry = worktreeRegistryPath(commonDir);
|
|
122
|
+
if (!gitDir.startsWith(registry.endsWith(sep) ? registry : registry + sep)) {
|
|
123
|
+
throw new CliError("sandbox_git_metadata_mismatch", `workspace-write cannot grant unexpected worktree metadata path ${gitDir}`);
|
|
124
|
+
}
|
|
125
|
+
return requireDirectory(gitDir, "the unit worktree Git metadata");
|
|
126
|
+
}
|
|
116
127
|
/** Paths that must remain explicitly unwritable even as Git's mutable stores are granted. */
|
|
117
128
|
export function gitSandboxDeniedPaths(checkout, additionalCheckouts = []) {
|
|
118
129
|
const { gitDir, commonDir } = gitMetadata(checkout, "agent checkout");
|
package/dist/git.js
CHANGED
|
@@ -5,6 +5,7 @@ import { dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
|
5
5
|
import { CliError } from "./errors.js";
|
|
6
6
|
import { configDirectory } from "./directories.js";
|
|
7
7
|
import { retryGitFetchSync } from "./git-fetch.js";
|
|
8
|
+
import { inferProvider } from "./model.js";
|
|
8
9
|
export const PRUNE_STATUS_TIMEOUT_MS = 30_000;
|
|
9
10
|
function status(cwd, timeoutMs) {
|
|
10
11
|
const r = spawnSync("git", ["status", "--porcelain"], { cwd, env: gitMetadataEnv(cwd), encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 512 * 1024 * 1024, ...(timeoutMs === undefined ? {} : { timeout: timeoutMs }) });
|
|
@@ -139,25 +140,34 @@ export function collectAuto(opts) {
|
|
|
139
140
|
let base = null;
|
|
140
141
|
let merged = null;
|
|
141
142
|
let ahead = null;
|
|
143
|
+
let behind = null;
|
|
144
|
+
let base_sha = null;
|
|
142
145
|
if (worktree) {
|
|
143
146
|
branch = git(["symbolic-ref", "--short", "-q", "HEAD"], cwd) ?? git(["rev-parse", "--short", "HEAD"], cwd);
|
|
144
147
|
head = git(["rev-parse", "--short", "HEAD"], cwd);
|
|
145
148
|
const status = git(["status", "--porcelain"], cwd);
|
|
146
149
|
dirty = status === null ? null : status.length > 0;
|
|
147
|
-
({ repo, base, merged, ahead } = mergeFacts(cwd, worktree));
|
|
150
|
+
({ repo, base, merged, ahead, behind, base_sha } = mergeFacts(cwd, worktree, head));
|
|
148
151
|
}
|
|
149
|
-
|
|
152
|
+
const provider = inferProvider(opts.model, opts.harness, opts.provider);
|
|
153
|
+
return { provider, model: opts.model && opts.model.length > 0 ? opts.model : "unknown", effort: opts.effort && opts.effort.length > 0 ? opts.effort : "unknown", machine: opts.machine, cwd, worktree, branch, head, dirty, repo, base, merged, ahead, behind, base_sha };
|
|
150
154
|
}
|
|
151
155
|
/** Where this worktree belongs and how it relates to the base branch. Local facts only; nothing is fetched. */
|
|
152
|
-
export function mergeFacts(cwd, worktree) {
|
|
156
|
+
export function mergeFacts(cwd, worktree, observedHead) {
|
|
153
157
|
const common = git(["rev-parse", "--path-format=absolute", "--git-common-dir"], cwd);
|
|
154
158
|
const repo = common ? common.replace(/\/\.git$/, "") : worktree;
|
|
155
159
|
const base = ["main", "master"].find((b) => git(["rev-parse", "--verify", "-q", `${b}^{commit}`], cwd) !== null) ?? null;
|
|
156
160
|
if (!base)
|
|
157
|
-
return { repo, base: null, merged: null, ahead: null };
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
+
return { repo, base: null, merged: null, ahead: null, behind: null, base_sha: null };
|
|
162
|
+
const base_sha = git(["rev-parse", "--verify", `${base}^{commit}`], cwd);
|
|
163
|
+
const head = observedHead === null ? null : git(["rev-parse", "--verify", `${observedHead ?? "HEAD"}^{commit}`], cwd);
|
|
164
|
+
// A shallow graph cannot establish complete ahead/behind counts or ancestry.
|
|
165
|
+
if (!base_sha || !head || git(["rev-parse", "--is-shallow-repository"], cwd) !== "false")
|
|
166
|
+
return { repo, base, merged: null, ahead: null, behind: null, base_sha };
|
|
167
|
+
const ancestorStatus = spawnSync("git", ["merge-base", "--is-ancestor", head, base_sha], { cwd, env: gitMetadataEnv(cwd), stdio: "ignore" }).status;
|
|
168
|
+
const merged = ancestorStatus === 0 ? true : ancestorStatus === 1 ? false : null;
|
|
169
|
+
const count = (range) => { const value = git(["rev-list", "--count", range], cwd); return value !== null && /^\d+$/.test(value) ? Number(value) : null; };
|
|
170
|
+
return { repo, base, merged, ahead: count(`${base_sha}..${head}`), behind: count(`${head}..${base_sha}`), base_sha };
|
|
161
171
|
}
|
|
162
172
|
/** Every linked worktree of the repository at cwd, with the same facts an agent call reports. */
|
|
163
173
|
export function scanWorktrees(cwd = process.cwd(), options = {}) {
|
|
@@ -181,9 +191,9 @@ export function scanWorktrees(cwd = process.cwd(), options = {}) {
|
|
|
181
191
|
const branch = git(["symbolic-ref", "--short", "-q", "HEAD"], p) ?? git(["rev-parse", "--short", "HEAD"], p);
|
|
182
192
|
const head = git(["rev-parse", "--short", "HEAD"], p);
|
|
183
193
|
const worktreeStatus = status(p, options.statusTimeoutMs);
|
|
184
|
-
const f = head ? mergeFacts(p, p) : { base: null, merged: null, ahead: null };
|
|
194
|
+
const f = head ? mergeFacts(p, p, head) : { base: null, merged: null, ahead: null, behind: null, base_sha: null };
|
|
185
195
|
const empty = existsSync(p) && readdirSync(p).every((e) => e === ".git");
|
|
186
|
-
return { path: p, branch, head, dirty: worktreeStatus === null ? null : worktreeStatus.length > 0, base: f.base, merged: f.merged, ahead: f.ahead, empty, locked };
|
|
196
|
+
return { path: p, branch, head, dirty: worktreeStatus === null ? null : worktreeStatus.length > 0, base: f.base, merged: f.merged, ahead: f.ahead, behind: f.behind, base_sha: f.base_sha, empty, locked };
|
|
187
197
|
});
|
|
188
198
|
return { repo, worktrees };
|
|
189
199
|
}
|
package/dist/harnesses.js
CHANGED
|
@@ -33,6 +33,9 @@ export const HARNESS_BIN = { codex: "codex", "claude-code": "claude", dsh: "dsh"
|
|
|
33
33
|
export function claudeSandboxEnv(sandbox) {
|
|
34
34
|
return sandbox === "workspace-write" ? { NODE_USE_ENV_PROXY: "1", BSCHAT_CLAUDE_SANDBOX: "workspace-write" } : {};
|
|
35
35
|
}
|
|
36
|
+
export function claudeSubagentModelEnv(model) {
|
|
37
|
+
return model ? { CLAUDE_CODE_SUBAGENT_MODEL: model } : {};
|
|
38
|
+
}
|
|
36
39
|
/** Resolve PATH first, then the native Claude Code installer's versioned executables. */
|
|
37
40
|
export function claudeCodePath(path = process.env.PATH ?? "", home = homedir()) {
|
|
38
41
|
const executableFile = (candidate) => {
|
|
@@ -1381,8 +1384,8 @@ export function terminateClaudeSessionProcesses(session, signal = "SIGTERM", psO
|
|
|
1381
1384
|
* and the machine's writable folders; anything that would need a prompt is denied, since nobody
|
|
1382
1385
|
* can answer one. danger-full-access skips permissions and is refused for project secrets.
|
|
1383
1386
|
*/
|
|
1384
|
-
export function claudeSettings(sandbox, model, effort, checkoutRoot, bschatHome, extraWritable = [], unitWorktree, secretEgress) {
|
|
1385
|
-
const common = [...(model ? ["--model", model] : []), ...(effort ? ["--effort", effort] : [])];
|
|
1387
|
+
export function claudeSettings(sandbox, model, effort, checkoutRoot, bschatHome, extraWritable = [], unitWorktree, secretEgress, subagents = "default") {
|
|
1388
|
+
const common = [...(model ? ["--model", model] : []), ...(effort ? ["--effort", effort] : []), ...(subagents === "disabled" ? ["--disallowedTools", "Agent"] : [])];
|
|
1386
1389
|
if (sandbox === "danger-full-access") {
|
|
1387
1390
|
if (secretEgress) {
|
|
1388
1391
|
throw new CliError("secret_egress_unenforced_claude-code", "Claude Code secret delivery requires workspace-write sandbox with enforced domain egress");
|
package/dist/help.js
CHANGED
|
@@ -29,7 +29,7 @@ Mac capacity/signing API (profiles, leases, signer-only references, TestFlight a
|
|
|
29
29
|
Standing rules are resolved by account, project, role, and exact-agent scope. GET /agents/me/standing-rules and GET /projects/:p/standing-rules return complete authorized sets and fingerprints; their separate ack endpoints accept only a current fingerprint after complete delivery. Operators and authorized assigners manage rules through the API; limits, compatibility confirmation, audit, and authorization are in packages/skill/references/api.md. Console management and chat promotion are WU #313.
|
|
30
30
|
Claude Code, Codex, and Antigravity SessionStart hooks retrieve the complete effective rules at fresh start, resume, compaction, and clear into a new thread. They acknowledge only after complete output; an unavailable or over-budget payload points to b9s process without acknowledgment. b9s me shows concise rule text and acknowledgment, b9s process shows the full project rules and acknowledges that fingerprint after display, and b9s resume includes the effective rulesets.
|
|
31
31
|
|
|
32
|
-
GitHub connection and repository status are available in the console and through b9s-admin github status and b9s-admin project github <project> status|unlink. A repository link enables agent credentials without requiring a ruleset. An agent can inspect its effective repository permission with GET /projects/:p/git-credentials; a project admin can inspect a named agent with GET /projects/:p/git-credentials?agent=<name-or-id>. Each issuance records its permission reason without storing the token. Open or reuse a PR for a unit's pushed branch with b9s wu pr <n>; add --auto-merge to ask GitHub to merge it after required checks pass. Use b9s gh <args> for
|
|
32
|
+
GitHub connection and repository status are available in the console and through b9s-admin github status and b9s-admin project github <project> status|unlink. A repository link enables agent credentials without requiring a ruleset. An agent can inspect its effective repository permission with GET /projects/:p/git-credentials; a project admin can inspect a named agent with GET /projects/:p/git-credentials?agent=<name-or-id>. Each issuance records its permission reason without storing the token. Open or reuse a PR for a unit's pushed branch with b9s wu pr <n>; add --auto-merge to ask GitHub to merge it after required checks pass. Use b9s gh <args> for read-only PR view/checks/status and workflow run view/download/list from that linked repository. Run views support --log-failed, --job <job-id> --log-failed, or --json <fields>; downloads support -n <name> or -p <pattern> and -D <dir>; run lists support --branch, --commit, --limit, and --json. Rerun transient failures with b9s gh run rerun <run-id> --failed [--job <job-id>] --reason "..."; full-run reruns are refused, with a cap of two reruns per project/head SHA and one rerun per run ID per five minutes. This server-proxied operation requires Actions: write on the linked GitHub App and keeps credentials server-side. Workflow read commands require the linked GitHub App to grant Actions: read. The wrapper pins GH_HOST and GH_REPO, requests repository-scoped credentials, and sets GH_TOKEN only in the gh child environment. Other commands, hosts, repositories, and repository/host override flags are refused before token issuance; the token is never printed or stored. The API scopes its installation token to the linked repository, stores the PR URL on the unit, and never prints or persists the token. Verify an exact target ruleset in Account -> GitHub connection before enabling hosted merge; the CLI cannot perform this owner OAuth step. Disconnect an installation with b9s-admin github disconnect <installation-id>. Hosted merge execution and status use b9s wu merge <n> and b9s wu merge status <n>; they call POST/GET /projects/:p/work-units/:n/merge and never inspect local Git state. API role checks use merge.merged_by and operator override; operator_hold is checked, merges serialize in MergeTargetDO, and retries reconcile idempotently. Manual wu done remains disabled for enabled linked targets. Enable with b9s-admin project hosted-merge <project> enable --confirm-bypass-signal only after ruleset verification and the live GitHub bypass-change check; disable with b9s-admin project hosted-merge <project> disable. The console control is WU #196. App setup steps are in packages/skill-admin/references/setup.md.
|
|
33
33
|
|
|
34
34
|
Environment problems: agents report bounded, redacted observations with b9s environment report; reports use scoped project or machine access, account-scoped evidence, and only the agent's own blocked units. Agents can append observations but cannot claim, diagnose, or resolve issues. Operators and agents whose role has own_environment_problems can manage visible issues. Operators use Account → Environment in the console to filter and inspect issues, claim/assign/reassign, record diagnoses, and resolve with a note and verification. Manual diagnoses use source agent; doctor/daemon provenance is for actual check results. Banner links open the same issue detail with impact context. Issue detail links active notices in the same scope and current machine-session faults related to its machine or explicitly linked unit owner. The read-only steward summary lists active linked issues and currently waiting linked units, without publishing notices or creating work. Machine issue views respect linked-project access. Spending impact is unknown and creates no banner until unit-attributed telemetry lands in WU #236; see packages/skill/references/api.md.
|
|
35
35
|
|
|
@@ -46,7 +46,8 @@ Agent commands
|
|
|
46
46
|
b9s identities list saved identities on this machine
|
|
47
47
|
b9s me who am I, role, permissions, channels, standing rules and acknowledgment; --json includes your machine sessions
|
|
48
48
|
b9s git-credential get|store|erase linked GitHub helper; Git must send the repo path (credential.https://github.com.useHttpPath true)
|
|
49
|
-
b9s gh <gh arguments> run
|
|
49
|
+
b9s gh <gh arguments> read PR status and Actions run details, or request a guarded failed-job rerun from this linked checkout
|
|
50
|
+
b9s gh run rerun <run-id> --failed [--job <job-id>] --reason "..." request an audited failed-job rerun (max 2 per head SHA)
|
|
50
51
|
b9s resume compact recovery brief: units, reviews, asks, slices, decisions, outcomes, process, standing rules and notices
|
|
51
52
|
b9s notice add --project <p> "<text>" [--until <time>] [--command-pattern <regex>]
|
|
52
53
|
assigner only: add a project notice; matching commands warn but continue
|
|
@@ -157,7 +158,7 @@ Machine placement enforces configured session slots and reports machine pressure
|
|
|
157
158
|
b9s templates pack --signing-key <pem> [--root <repo>] [--out <dir>]
|
|
158
159
|
create a signed, immutable source archive from a clean catalog revision
|
|
159
160
|
Global: --effort <high|medium|low|...> reasoning effort to report (else BSCHAT_EFFORT, CLAUDE_EFFORT, codex model_reasoning_effort)
|
|
160
|
-
b9s wu submit <n> [--evidence id[,id...] ...] [--pr url] [--expect 'measure: effect'] [--lesson "..."] [--disputes '<JSON list>']
|
|
161
|
+
b9s wu submit <n> [--evidence id[,id...] ...] [--pr url] [--expect 'measure: effect'] [--lesson "..."] [--disputes '<JSON list>'] require a clean worktree; prints a numbered scope checklist and local HEAD vs pushed origin tip
|
|
161
162
|
b9s wu review <n> reviewer's checkout: fetch the submitted branch from origin and open
|
|
162
163
|
../<repo>-review-wu<n> detached at the submitted head (refused if origin differs)
|
|
163
164
|
b9s wu reviewer <n> --replace <agent> [--with <agent>] --note "why" assigner or operator: replace an owing reviewer with an available qualified reviewer; audited and announced (console control WU #733)
|
|
@@ -170,11 +171,12 @@ Machine placement enforces configured session slots and reports machine pressure
|
|
|
170
171
|
b9s wu proceed <n> --note ".." reviewer: this step is good, carry on; back to the owner, NOT an approval
|
|
171
172
|
b9s wu reopen <n> --note ".." owner or reviewer: withdraw an unmerged approval (verification failed); resubmit the same unit
|
|
172
173
|
b9s wu supersede <n> --by <m> owner or assigner: this unit continues as #m; anyone blocked on #n now waits on #m
|
|
173
|
-
b9s wu ask <n> "question" [--question <text>] owner, reviewer or assigner: a decision this unit cannot move without, including queued units (tag expert first, then the operator)
|
|
174
|
-
b9s wu rule <n>
|
|
174
|
+
b9s wu ask <n> "question" [--question <text>] [--choices <json>] owner, reviewer or assigner: a decision this unit cannot move without, including queued units (tag expert first, then the operator)
|
|
175
|
+
b9s wu rule <n> --choice <id> [--note <text>] select a structured answer
|
|
176
|
+
b9s wu rule <n> "decision" [--ruling <text>|--note <text>] [--choice <id>] [--send-back-event <id> --cause <cause>] | --approve the tag's expert: answer an open question, or approve its proposal as written (operator questions are answered in the console); the event and cause record an explicit retrospective ruling
|
|
175
177
|
b9s wu sendback-rule <n> --file ruling.json send-back reviewer: record the binding point-by-point ruling; scope_gap/missing_context also need scope_draft, confirmed by the assigner with wu scope --append; environment/stale_base opens no-blame reliability work; out_of_scope needs quote and already_met needs commit
|
|
176
178
|
b9s wu note <n> --note ".." [--annotation '<JSON object>'] add a note; assigner annotation links a cited scope finding to a cause and one-line reason
|
|
177
|
-
b9s wu propose <n> "answer" owner, reviewer, assigner or expert: recommend an answer to the unit's open question, approvable as written
|
|
179
|
+
b9s wu propose <n> "answer" [--choices <json>] owner, reviewer, assigner or expert: recommend an answer to the unit's open question, approvable as written
|
|
178
180
|
b9s wu escalate <n> [--note ..] the tag's expert: pass the question to the operator
|
|
179
181
|
b9s wu wait <n> --on <m> --note "why" | --clear
|
|
180
182
|
owner, assigner or operator: wait for any non-closed unit; released when it closes
|
|
@@ -187,8 +189,8 @@ Machine placement enforces configured session slots and reports machine pressure
|
|
|
187
189
|
b9s wu target <n> <branch|default> [--summary "reviewed work summary"] owner, assigner or operator: change where this unit lands
|
|
188
190
|
b9s wu branch <n> [<branch>] [--clear] [--reason "why"] [--base <branch-or-sha>] [--continue] assigner or operator: set, correct, or clear a unit's recorded branch
|
|
189
191
|
b9s wu head <n> <full-sha> --reason "why" assigner or operator: record a commit verified on the unit's branch
|
|
190
|
-
b9s ask-operator "what you need from them" --plain ".." --blocks ".." --if-yes ".." --if-no ".." [--propose ".."] [--milestone <key> | --unit <n>] [--question <text>]
|
|
191
|
-
b9s ask-operator --amend <id> ["new question"] [--plain ".."] [--blocks ".."] [--if-yes ".."] [--if-no ".."] [--propose ".."] [--question <text>] amend your own open ask
|
|
192
|
+
b9s ask-operator "what you need from them" [--decision "one-line headline (120 chars max)"] [--kind <ask-kind>] --plain ".." --blocks ".." --if-yes ".." --if-no ".." [--propose ".."] [--milestone <key> | --unit <n>] [--question <text>]
|
|
193
|
+
b9s ask-operator --amend <id> ["new question"] [--decision "headline"] [--kind <ask-kind>] [--plain ".."] [--blocks ".."] [--if-yes ".."] [--if-no ".."] [--propose ".."] [--question <text>] amend your own open ask
|
|
192
194
|
b9s ask-operator withdraw <key> --note "why it no longer needs an operator answer" withdraw your own ask, a steward-raised declared-wait ask, or an ask if you are a project assigner
|
|
193
195
|
b9s ask-operator refuses a second ask naming the same WU; use --amend <id>. Account needs group asks/questions by unit and can answer several together.
|
|
194
196
|
a decision only the operator can make, on their console banner and reported to them; never
|
|
@@ -226,6 +228,13 @@ Machine placement enforces configured session slots and reports machine pressure
|
|
|
226
228
|
b9s goal [set "<text>" [--state s] | achieved | paused | stalled | abandoned | clear]
|
|
227
229
|
report your harness's /goal so the board shows what you are held to (Codex app
|
|
228
230
|
threads and DeepSeek keep it where no file shows it; Claude Code's hook reads it itself)
|
|
231
|
+
b9s mock upload <studyId> <variantId> <file.html> [--summary <text>] upload and attach a mock
|
|
232
|
+
b9s mock gaps <studyId> --json <gapsJson> | --clear submit gaps (field, missing, build_summary, adapt_summary, omit_summary?, prerequisite_tags?)
|
|
233
|
+
b9s flow-agent run [--force] [--admin <name>] [--project <name>] request a Flow Agent tick
|
|
234
|
+
b9s flow-agent status Flow Agent: autonomy level, actions this hour, rolling account budget, recent actions
|
|
235
|
+
b9s flow-agent prompt [--level advisory|flow_ops|autonomous_ops]
|
|
236
|
+
the Flow Agent's operating rules for the project's level (or --level): hard
|
|
237
|
+
invariants, what the level may change, limits and the per-wake-up loop
|
|
229
238
|
b9s hook claude-code [--event E] harness hook: prints new inbox items as hook JSON (installed by join)
|
|
230
239
|
b9s watch --exec "<cmd>" [--interval seconds] [--unacked-after seconds] [--follow-delay seconds] [--startup-jitter-seconds 0..60] [--once] [--full] [--env A,B] [--activity path] [--prune] [--turn] [--harness codex|claude-code|dsh|antigravity] [--provider anthropic|deepseek] [--session id] [--machine-session-id uuid] [--turn-timeout min] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60] [--turn-coalesce-seconds 0..3600] [--turn-claude-runtime JSON] [--turn-antigravity-runtime JSON] [--service|--launchd] event bridge: queue ONE numbered wake-up when something new arrives, then
|
|
231
240
|
nothing more, for any reason, until the agent runs b9s wake ack <n>. An
|
|
@@ -268,12 +277,13 @@ Machine placement enforces configured session slots and reports machine pressure
|
|
|
268
277
|
submit a bounded observation; evidence is account-scoped, and agents may link only their own units
|
|
269
278
|
b9s codex hooks | bind <thread-id> | sync install b9s's Codex hooks (~/.codex/hooks.json) and say which thread is you
|
|
270
279
|
b9s codex start [--in-container] [--writable <path,...>] [--prune] Codex start options in addition to b9s start's session options
|
|
271
|
-
b9s start --harness codex|claude-code|dsh|antigravity --as <project>/<name> --sandbox <mode> [--provider anthropic|deepseek] [--token t] [--thread id] [--model m] [--effort e] [--writable-root path]... [--max-budget-usd n] [--turn-timeout min] [--interval seconds] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60] [--turn-coalesce-seconds 0..3600] [--startup-jitter-seconds 0..60] [--machine-session-id uuid] [--harness-binary /abs/path] [--dsh path] [--agy path] [--in-container]
|
|
280
|
+
b9s start --harness codex|claude-code|dsh|antigravity --as <project>/<name> --sandbox <mode> [--provider anthropic|deepseek] [--token t] [--thread id] [--model m] [--effort e] [--subagents default|encourage|disabled] [--subagent-model id] [--writable-root path]... [--max-budget-usd n] [--turn-timeout min] [--interval seconds] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60] [--turn-coalesce-seconds 0..3600] [--startup-jitter-seconds 0..60] [--machine-session-id uuid] [--harness-binary /abs/path] [--dsh path] [--agy path] [--in-container]
|
|
272
281
|
run an agent headless: enroll, start or adopt its session, turn-mode watcher
|
|
273
282
|
--machine-session-id is normally supplied by b9s-admin for a managed machine session
|
|
274
283
|
Persistent watcher startup waits a random logged 0..60 s by default; set --startup-jitter-seconds 0 to disable it for a deterministic start.
|
|
275
284
|
Machine pressure is advisory: it is reported, never a reason to hold a turn. A turn is refused only while
|
|
276
285
|
the checkout's or state volume has under 1 GiB or 2% free (checked fresh each time, nothing latched).
|
|
286
|
+
Subagents default to the harness setting; encourage or disable native subagents with --subagents. Claude Code supports --subagent-model; other unsupported preferences are advisory in the startup brief.
|
|
277
287
|
Machine pressure is reported as telemetry and does not hold a turn.
|
|
278
288
|
Claude Code workspace-write defaults to a $1 per-turn cap; configure it with --max-budget-usd
|
|
279
289
|
Account turn-spend caps are set by the account operator separately; token caps support subscriptions,
|
|
@@ -381,6 +391,10 @@ Project agents inspect work waits with b9s wu stalled [--all]; its default inclu
|
|
|
381
391
|
b9s-admin text-check <project> find bschat mentions in working agreements, charter, tags, roles and open scopes
|
|
382
392
|
b9s-admin signup --url <api> --key <signup-code> <account-name> <email>
|
|
383
393
|
b9s-admin project create|list|delete <name>
|
|
394
|
+
b9s-admin mock create <project> --title <text> --target <area> [--route <path>] [--intent explore|refine|focus|audit] (--brief <text> | --brief-file <path>) --variant <agent_or_model> [--variant <agent_or_model>] [--json]
|
|
395
|
+
b9s-admin mock list <project> [--status active|approved|archived] [--json]
|
|
396
|
+
b9s-admin mock iterate <project> <studyId> [--variant <variantId>] [--note <text>] [--json]
|
|
397
|
+
b9s-admin mock approve <project> <studyId> <variantId> [--json]
|
|
384
398
|
b9s-admin project pause <project> --note "why" | resume <project> stop dispatch, steward actions, escalations, stall faults and new turns; queued and assigned work stays unchanged
|
|
385
399
|
b9s-admin github status | disconnect <installation-id>
|
|
386
400
|
b9s-admin project github <project> status | unlink
|
|
@@ -433,6 +447,11 @@ Project agents inspect work waits with b9s wu stalled [--all]; its default inclu
|
|
|
433
447
|
b9s-admin role create <name> [--project p] [--description d] [--broadcast] [--create-channels] [--read-account-status] [--permissions '{json}'] [--cardinality one|many]
|
|
434
448
|
b9s-admin role edit <name> [--project p] [--projects a,b|*] [--post c1,c2] [--broadcast] [--create-channels] [--read-account-status] [--assign-outside-qualifications yes|no] [--description d] [--cardinality one|many]
|
|
435
449
|
b9s-admin role list [--project p]
|
|
450
|
+
Flow Agent: create a role whose permissions include "flow_agent": true and give it to one agent, then
|
|
451
|
+
set the process's flow_agent {enabled, autonomy_level advisory|flow_ops|autonomous_ops,
|
|
452
|
+
max_actions_per_hour}. The steward wakes its holders on coalesced stall, dependency,
|
|
453
|
+
send-back and merge-train triggers (3-minute debounce) and a 30-minute sweep while a unit is open;
|
|
454
|
+
the agent reads its rules with b9s flow-agent prompt and shared account budget with b9s flow-agent status.
|
|
436
455
|
b9s-admin wu assign <project> <n> --to <agent> [--reason "why"] operator: reassign a unit in place
|
|
437
456
|
b9s-admin wu abandon <project> <n> --note "why" operator: close work that is no longer needed
|
|
438
457
|
b9s-admin wu supersede <project> <n> --by <m> operator: close this unit as continued by #m
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { bool, parse, str } from "./args.js";
|
|
3
3
|
import * as a from "./commands/agent.js";
|
|
4
4
|
import { evidence } from "./commands/evidence.js";
|
|
5
|
+
import { mock } from "./commands/mock.js";
|
|
5
6
|
import { join, setup } from "./commands/join.js";
|
|
6
7
|
import { hook } from "./commands/hook.js";
|
|
7
8
|
import { checkpoint, handoffs, retire } from "./commands/retire.js";
|
|
@@ -9,6 +10,7 @@ import { item, list, lists } from "./commands/lists.js";
|
|
|
9
10
|
import { watch } from "./commands/watch.js";
|
|
10
11
|
import { feedback } from "./commands/feedback.js";
|
|
11
12
|
import { goal } from "./commands/goal.js";
|
|
13
|
+
import { flowAgent } from "./commands/flow-agent.js";
|
|
12
14
|
import { wake } from "./commands/wake.js";
|
|
13
15
|
import { turn } from "./commands/turn.js";
|
|
14
16
|
import { antigravity } from "./commands/antigravity.js";
|
|
@@ -78,6 +80,8 @@ const COMMANDS = {
|
|
|
78
80
|
projects: a.projects,
|
|
79
81
|
skill: a.skill,
|
|
80
82
|
evidence,
|
|
83
|
+
mock,
|
|
84
|
+
"design-study": mock,
|
|
81
85
|
hook: async (p) => hook(p),
|
|
82
86
|
retire,
|
|
83
87
|
handoffs,
|
|
@@ -87,6 +91,7 @@ const COMMANDS = {
|
|
|
87
91
|
watch,
|
|
88
92
|
feedback,
|
|
89
93
|
goal,
|
|
94
|
+
"flow-agent": flowAgent,
|
|
90
95
|
wake,
|
|
91
96
|
turn,
|
|
92
97
|
antigravity,
|
|
@@ -155,7 +160,7 @@ export async function main(argv) {
|
|
|
155
160
|
if (!fn)
|
|
156
161
|
throw new CliError("usage", `unknown command ${cmd}`, "Run: b9s --help");
|
|
157
162
|
const selectedProject = str(p.flags, "project");
|
|
158
|
-
if (selectedProject) {
|
|
163
|
+
if (selectedProject && !(cmd === "flow-agent" && p.positionals[1] === "run")) {
|
|
159
164
|
const agentName = resolveAgentName(str(p.flags, "as"));
|
|
160
165
|
const credentials = loadAgent(agentName);
|
|
161
166
|
await a.assertProjectUsable(credentials, selectedProject);
|
|
@@ -167,7 +172,7 @@ export async function main(argv) {
|
|
|
167
172
|
const localHarnessDispatch = (cmd === "codex" && ["hooks", "sync", "start"].includes(codexSubcommand ?? "")) || (cmd === "antigravity" && antigravitySubcommand === "sync") || (cmd === "claude" && p.positionals[1] === "sessions")
|
|
168
173
|
// Bare `status` is the machine's readiness report: it needs no agent identity.
|
|
169
174
|
|| (cmd === "status" && p.positionals[1] === undefined);
|
|
170
|
-
const noticePreflightExempt = NOTICE_PREFLIGHT_EXEMPT_COMMANDS.has(cmd) || localHarnessDispatch;
|
|
175
|
+
const noticePreflightExempt = NOTICE_PREFLIGHT_EXEMPT_COMMANDS.has(cmd) || localHarnessDispatch || (cmd === "flow-agent" && p.positionals[1] === "run");
|
|
171
176
|
if (!noticePreflightExempt) {
|
|
172
177
|
const agentName = resolveAgentName(str(p.flags, "as"));
|
|
173
178
|
loadAgent(agentName);
|