benignswarm 0.12.111 → 0.12.113
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/antigravity.js +3 -1
- package/dist/args.js +29 -4
- package/dist/brief.js +11 -1
- package/dist/client.js +8 -2
- package/dist/commands/admin.js +3 -0
- package/dist/commands/agent.js +2 -0
- package/dist/commands/hook.js +57 -24
- package/dist/commands/install.js +77 -13
- package/dist/commands/join.js +3 -5
- package/dist/commands/lists.js +2 -2
- package/dist/commands/machine-admin.js +125 -18
- package/dist/commands/machine.js +175 -33
- package/dist/commands/standing-rules.js +129 -0
- package/dist/commands/watch.js +3 -3
- package/dist/commands/worktrees.js +1 -1
- package/dist/commands/wu.js +10 -2
- package/dist/git.js +57 -4
- package/dist/harnesses.js +1 -1
- package/dist/help.js +28 -8
- package/dist/index.js +2 -0
- package/dist/install.js +122 -24
- package/dist/lock.js +2 -1
- package/dist/log-rotation.js +65 -0
- package/dist/standing-rules.js +78 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { bool, str } from "../args.js";
|
|
2
|
+
import { Client } from "../client.js";
|
|
3
|
+
import { loadAdmin, loadAgent, resolveAdminName, resolveAgentName } from "../config.js";
|
|
4
|
+
import { CliError } from "../errors.js";
|
|
5
|
+
import { formatStandingRuleSet } from "../standing-rules.js";
|
|
6
|
+
import { projectOf } from "./agent.js";
|
|
7
|
+
function path(project) {
|
|
8
|
+
return `/projects/${encodeURIComponent(project)}/standing-rules`;
|
|
9
|
+
}
|
|
10
|
+
async function managementHistory(client, project, identifier) {
|
|
11
|
+
const base = `${path(project)}/manage${identifier === undefined ? "" : `/${encodeURIComponent(identifier)}`}`;
|
|
12
|
+
const rules = [];
|
|
13
|
+
const cursors = new Set();
|
|
14
|
+
let cursor;
|
|
15
|
+
let result;
|
|
16
|
+
do {
|
|
17
|
+
const query = new URLSearchParams({ limit: "100", ...(cursor === undefined ? {} : { cursor }) });
|
|
18
|
+
result = await client.call("GET", `${base}?${query.toString()}`);
|
|
19
|
+
if (!Array.isArray(result.rules))
|
|
20
|
+
throw new CliError("invalid_response", "standing-rule management response did not include a rules array");
|
|
21
|
+
rules.push(...result.rules);
|
|
22
|
+
const next = result.next_cursor;
|
|
23
|
+
if (next !== null && next !== undefined) {
|
|
24
|
+
if (typeof next !== "string" || !next || cursors.has(next))
|
|
25
|
+
throw new CliError("invalid_response", "standing-rule management returned an invalid or repeated cursor");
|
|
26
|
+
cursors.add(next);
|
|
27
|
+
cursor = next;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
cursor = undefined;
|
|
31
|
+
}
|
|
32
|
+
} while (cursor !== undefined);
|
|
33
|
+
return { ...result, rules, next_cursor: null, complete: true };
|
|
34
|
+
}
|
|
35
|
+
function formatRuleRows(rules, history = []) {
|
|
36
|
+
const rows = [...rules, ...history];
|
|
37
|
+
if (!rows.length)
|
|
38
|
+
return "(no standing rules)";
|
|
39
|
+
return rows.map((rule) => [
|
|
40
|
+
`${rule.id} r${rule.revision} [${rule.status}] ${rule.scope.kind}:${rule.scope.id}`,
|
|
41
|
+
` by ${rule.author.name} (${rule.author.kind}) · created ${rule.created_at}${rule.expires_at ? ` · expires ${rule.expires_at}` : ""}`,
|
|
42
|
+
` ${rule.text}`,
|
|
43
|
+
...(rule.conflicts?.length ? [` unresolved conflicts: ${rule.conflicts.map((conflict) => conflict.rule_id).join(", ")}`] : []),
|
|
44
|
+
].join("\n")).join("\n");
|
|
45
|
+
}
|
|
46
|
+
function body(p) {
|
|
47
|
+
const text = str(p.flags, "text");
|
|
48
|
+
if (!text?.trim())
|
|
49
|
+
throw new CliError("usage", "rule add/supersede needs --text <rule text>");
|
|
50
|
+
const conflicts = str(p.flags, "conflicts-with");
|
|
51
|
+
return {
|
|
52
|
+
text,
|
|
53
|
+
compatibility_confirmed: true,
|
|
54
|
+
...(str(p.flags, "expires-at") === undefined ? {} : { expires_at: str(p.flags, "expires-at") }),
|
|
55
|
+
...(conflicts === undefined ? {} : { conflicts_with: conflicts.split(",").map((value) => value.trim()).filter(Boolean) }),
|
|
56
|
+
...(str(p.flags, "source-channel-id") === undefined ? {} : { source_channel_id: str(p.flags, "source-channel-id") }),
|
|
57
|
+
...(str(p.flags, "source-message-id") === undefined ? {} : { source_message_id: str(p.flags, "source-message-id") }),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function showPolicyBeforeWrite(client, project, p) {
|
|
61
|
+
const response = await client.call("GET", `/projects/${encodeURIComponent(project)}/process`);
|
|
62
|
+
const proc = response.process;
|
|
63
|
+
process.stdout.write(`Current charter for ${project}:\n${proc.charter || "(none)"}\n\nCurrent working agreements:\n${proc.agreements || "(none)"}\n\n`);
|
|
64
|
+
if (!bool(p.flags, "confirm-compatible")) {
|
|
65
|
+
throw new CliError("compatibility_confirmation", "Review the charter and working agreements above, then repeat with --confirm-compatible; no rule was written.");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function runRuleAction(client, project, action, identifier, p, out) {
|
|
69
|
+
const base = path(project);
|
|
70
|
+
if (action === "list") {
|
|
71
|
+
const result = await managementHistory(client, project);
|
|
72
|
+
out.print(formatRuleRows(result.rules), result);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (action === "show") {
|
|
76
|
+
if (!identifier)
|
|
77
|
+
throw new CliError("usage", "rule show <rule-id>");
|
|
78
|
+
const result = await managementHistory(client, project, identifier);
|
|
79
|
+
if (!result.rules.length)
|
|
80
|
+
throw new CliError("not_found", `standing rule ${identifier} was not found in ${project}`);
|
|
81
|
+
out.print(formatRuleRows(result.rules), result);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (action === "add") {
|
|
85
|
+
const scope = str(p.flags, "scope");
|
|
86
|
+
if (!scope)
|
|
87
|
+
throw new CliError("usage", "rule add --scope account|project|role:<name>|agent:<name> --text <text>");
|
|
88
|
+
await showPolicyBeforeWrite(client, project, p);
|
|
89
|
+
const result = await client.call("POST", base, { ...body(p), scope });
|
|
90
|
+
out.print(`Created ${result.rule.scope.kind}:${result.rule.scope.id} standing rule ${result.rule.id} revision ${result.rule.revision}.`, result);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (action === "supersede") {
|
|
94
|
+
if (!identifier)
|
|
95
|
+
throw new CliError("usage", "rule supersede <rule-id> --text <new text> --confirm-compatible");
|
|
96
|
+
await showPolicyBeforeWrite(client, project, p);
|
|
97
|
+
const result = await client.call("POST", `${base}/${encodeURIComponent(identifier)}/supersede`, body(p));
|
|
98
|
+
out.print(`Superseded ${identifier} with revision ${result.rule.revision}.`, result);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (action === "retire") {
|
|
102
|
+
if (!identifier)
|
|
103
|
+
throw new CliError("usage", "rule retire <rule-id>");
|
|
104
|
+
const result = await client.call("POST", `${base}/${encodeURIComponent(identifier)}/retire`, {});
|
|
105
|
+
out.print(`Retired standing rule ${identifier}.`, result);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
throw new CliError("usage", "rule <list|show|add|supersede|retire>");
|
|
109
|
+
}
|
|
110
|
+
export async function standingRuleCommand(p, out) {
|
|
111
|
+
const name = resolveAgentName(str(p.flags, "as"));
|
|
112
|
+
const creds = loadAgent(name);
|
|
113
|
+
const project = projectOf(p, creds);
|
|
114
|
+
const client = Client.forAgent(creds, undefined);
|
|
115
|
+
const action = p.positionals[1];
|
|
116
|
+
const identifier = p.positionals[2];
|
|
117
|
+
await runRuleAction(client, project, action ?? "list", identifier, p, out);
|
|
118
|
+
}
|
|
119
|
+
export async function standingRuleAdmin(action, rest, p, out) {
|
|
120
|
+
const project = rest[0];
|
|
121
|
+
if (!project)
|
|
122
|
+
throw new CliError("usage", "b9s-admin rule <list|show|add|supersede|retire> <project> [rule-id] ...");
|
|
123
|
+
const creds = loadAdmin(resolveAdminName(str(p.flags, "admin")));
|
|
124
|
+
const client = Client.forAdmin(creds);
|
|
125
|
+
await runRuleAction(client, project, action ?? "list", rest[1], p, out);
|
|
126
|
+
}
|
|
127
|
+
export function formatOwnRuleSet(set, label) {
|
|
128
|
+
return formatStandingRuleSet(set, label);
|
|
129
|
+
}
|
package/dist/commands/watch.js
CHANGED
|
@@ -4,7 +4,7 @@ import { DEFAULT_TURN_COALESCE_SECONDS, MAX_TURN_COALESCE_SECONDS, shouldDeferTu
|
|
|
4
4
|
import { drainingUntil } from "../maintenance.js";
|
|
5
5
|
import { probeFor, turnHarness } from "../harnesses.js";
|
|
6
6
|
import { applyAck } from "./wake.js";
|
|
7
|
-
import { lingerEnabled, loadSystemdUnit, reloadLaunchAgent, removeService, requireInstall, systemdUnit, systemdUserDir, WATCH_LABEL_PREFIX, watcherServices } from "../install.js";
|
|
7
|
+
import { launchdSessionTypeXml, lingerEnabled, plistLaunchdDomain, loadSystemdUnit, reloadLaunchAgent, removeService, requireInstall, systemdUnit, systemdUserDir, WATCH_LABEL_PREFIX, watcherServices } from "../install.js";
|
|
8
8
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { homedir, userInfo } from "node:os";
|
|
@@ -1369,7 +1369,7 @@ function installLaunchd(name, exec, interval, followDelay, extraEnv, activity, o
|
|
|
1369
1369
|
<key>EnvironmentVariables</key><dict><key>PATH</key><string>${escapeXml(process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin")}</string><key>HOME</key><string>${homedir()}</string>${Object.entries(extraEnv).map(([k, v]) => `<key>${escapeXml(k)}</key><string>${escapeXml(v)}</string>`).join("")}</dict>
|
|
1370
1370
|
<key>WorkingDirectory</key><string>${escapeXml(process.cwd())}</string>
|
|
1371
1371
|
<key>RunAtLoad</key><true/>
|
|
1372
|
-
<key>KeepAlive</key><true
|
|
1372
|
+
<key>KeepAlive</key><true/>${launchdSessionTypeXml()}
|
|
1373
1373
|
<key>StandardOutPath</key><string>${join(logDir, `watch.${slug}.out.log`)}</string>
|
|
1374
1374
|
<key>StandardErrorPath</key><string>${join(logDir, `watch.${slug}.err.log`)}</string>
|
|
1375
1375
|
</dict></plist>
|
|
@@ -1383,7 +1383,7 @@ function installLaunchd(name, exec, interval, followDelay, extraEnv, activity, o
|
|
|
1383
1383
|
const sess = sessionOfExec(exec);
|
|
1384
1384
|
if (sess)
|
|
1385
1385
|
bindSession(sess.kind, sess.id, name);
|
|
1386
|
-
out.print(`Wrote ${path} and (re)loaded it: the watcher is running ${program[0]}.${Object.keys(extraEnv).length ? `\nCaptured env: ${Object.keys(extraEnv).join(", ")} (re-run this command if the harness restarts and these change)` : ""}\nStop it: launchctl bootout
|
|
1386
|
+
out.print(`Wrote ${path} and (re)loaded it: the watcher is running ${program[0]}.${Object.keys(extraEnv).length ? `\nCaptured env: ${Object.keys(extraEnv).join(", ")} (re-run this command if the harness restarts and these change)` : ""}\nStop it: launchctl bootout ${plistLaunchdDomain(path)}/${label}\nLogs: ${logDir}/watch.${slug}.*.log\nCheck it: b9s doctor\nThe watcher runs from ${process.cwd()} so the repo identity file applies.`, { plist: path, label, program: program[0] });
|
|
1387
1387
|
}
|
|
1388
1388
|
export const turnArgs = (t) => (t ? ["--turn", "--turn-timeout", String(t.timeout), "--turns-per-hour", String(t.turnsPerHour), "--unproductive-per-hour", String(t.unproductivePerHour ?? DEFAULT_UNPRODUCTIVE_PER_HOUR), "--turn-coalesce-seconds", String(t.coalesceSeconds), "--harness", t.harness, "--session", t.session, ...(t.machineSessionId ? ["--machine-session-id", t.machineSessionId] : []), ...(t.provider === "deepseek" ? ["--provider", t.provider] : []), ...(t.model ? ["--model", t.model] : [])] : []);
|
|
1389
1389
|
function escapeXml(s) {
|
|
@@ -204,7 +204,7 @@ export async function scanProject(creds, project, options = {}) {
|
|
|
204
204
|
const scan = scanWorktrees(options.cwd ?? process.cwd(), options);
|
|
205
205
|
if (!scan)
|
|
206
206
|
throw new CliError("not_a_repo", "the current directory is not inside a git repository", "Run b9s worktrees scan from a checkout of the project's repository.");
|
|
207
|
-
const machine =
|
|
207
|
+
const machine = defaultMachine();
|
|
208
208
|
const client = Client.forAgent(creds, undefined, { presence: false });
|
|
209
209
|
const timeoutMs = options.requestTimeoutMs ?? WORKTREE_SCAN_TIMEOUT_MS;
|
|
210
210
|
options.onProgress?.(`Reporting worktrees for project ${project} (timeout ${timeoutMs} ms)`);
|
package/dist/commands/wu.js
CHANGED
|
@@ -8,7 +8,7 @@ import { readState, writeState } from "../state.js";
|
|
|
8
8
|
import { codexRollout, sessionsOf } from "../sessions.js";
|
|
9
9
|
import { claudeSessionWithHookMetadata, sessionCompactions, sessionContext, sessionStart, sessionUsage } from "../usage.js";
|
|
10
10
|
import { CliError, WrittenReceiptMismatchError } from "../errors.js";
|
|
11
|
-
import { branchAndHead, commitAtTime, ensureReviewWorktree, ensureWorktree, fetchRef, fetchRemoteBranch, findRemoteCommitBranch, formatRemoteCommitFailure, formatRemoteCommitSuccess, fullSha, isAncestor, isShaBranchName, removeWorktreeIfClean, repoName, repoParent, symbolicBranch, verifyMergedCommit, verifyNoCommitsBeyondTarget, worktreeForBranch } from "../git.js";
|
|
11
|
+
import { branchAndHead, commitAtTime, defaultMachine, ensureReviewWorktree, ensureWorktree, fetchRef, fetchRemoteBranch, findRemoteCommitBranch, formatRemoteCommitFailure, formatRemoteCommitSuccess, fullSha, isAncestor, isShaBranchName, removeWorktreeIfClean, repoName, repoParent, symbolicBranch, verifyMergedCommit, verifyNoCommitsBeyondTarget, worktreeForBranch } from "../git.js";
|
|
12
12
|
import { join, resolve } from "node:path";
|
|
13
13
|
import { table } from "../output.js";
|
|
14
14
|
import { restoreRecoveryArchive, sha256 as recoverySha256 } from "../recovery-archive.js";
|
|
@@ -16,6 +16,7 @@ import { createRecoveryArchive } from "../recovery-archive.js";
|
|
|
16
16
|
import { tmpdir } from "node:os";
|
|
17
17
|
import { chooseAgentContextAction, contextModeFromRuntime, explicitContextCompactSupport, hasCorrectionHistory } from "../context-policy.js";
|
|
18
18
|
import { formatConfidenceMatrix, formatExplorationSummary, formatUnitRoutingExplanation } from "./routing-admin.js";
|
|
19
|
+
import { formatStandingRuleSet } from "../standing-rules.js";
|
|
19
20
|
/** Only Claude's workspace-write sandbox needs SSH origins rewritten for its HTTP-only proxy. */
|
|
20
21
|
export function shouldInheritClaudeSandboxUrlRewrites(env = process.env) {
|
|
21
22
|
return env.CLAUDECODE === "1" && env.BSCHAT_CLAUDE_SANDBOX === "workspace-write";
|
|
@@ -1282,8 +1283,13 @@ export async function processCmd(p, out) {
|
|
|
1282
1283
|
`Merging: ${d.merge.merged_by === "owner" ? "the owner" : d.merge.merged_by === "approver" ? "an approver" : `a ${d.merge.integrator_role}`} merges approved work into ${d.merge.target_branch}${d.merge.require_rebased ? "; the branch must contain " + d.merge.target_branch + " before review" : ""}${d.merge.require_merge_commit ? "; done carries the merge commit (b9s wu done <n> --merged <sha>)" : ""}.`,
|
|
1283
1284
|
r.process.agreements ? `\nWorking agreements:\n${r.process.agreements}` : null,
|
|
1284
1285
|
r.process.charter ? `\nCharter (how this project weighs its trade-offs; judge reviews and questions by it):\n${r.process.charter}` : null,
|
|
1286
|
+
`\n${formatStandingRuleSet(r.standing_rules, project)}`,
|
|
1285
1287
|
].filter(Boolean);
|
|
1286
1288
|
out.print(lines.join("\n"), { ...r, roles });
|
|
1289
|
+
const standingRules = r.standing_rules;
|
|
1290
|
+
if (standingRules?.complete === true && standingRules.fingerprint && standingRules.acknowledged !== true) {
|
|
1291
|
+
await client.call("POST", `/projects/${encodeURIComponent(project)}/agents/me/standing-rules/ack`, { fingerprint: standingRules.fingerprint, delivered: true });
|
|
1292
|
+
}
|
|
1287
1293
|
if (creds.project && r.process.version > 0)
|
|
1288
1294
|
await client.call("POST", `/projects/${project}/process/ack`, { version: r.process.version });
|
|
1289
1295
|
}
|
|
@@ -1608,9 +1614,11 @@ export async function lock(p, out) {
|
|
|
1608
1614
|
out.print(r.lock.holder_name ? `${lockName} released; now held by ${r.lock.holder_name}${r.lock.unit ? ` (WU #${r.lock.unit})` : ""}.` : `${lockName} released; free.`, r);
|
|
1609
1615
|
return;
|
|
1610
1616
|
}
|
|
1617
|
+
if (str(p.flags, "machine") !== undefined)
|
|
1618
|
+
throw new CliError("usage", "lock acquisition is scoped to the host running the CLI; --machine is only for unlock");
|
|
1611
1619
|
const unit = str(p.flags, "unit");
|
|
1612
1620
|
// Scoped to this machine unless --shared: the resource is this box's CPU and disk.
|
|
1613
|
-
const r = await client.call("POST", `/projects/${project}/locks/${lockName}/acquire`, { unit: unit ? Number(unit) : null, note: str(p.flags, "note") ?? "", shared: bool(p.flags, "shared"), machine:
|
|
1621
|
+
const r = await client.call("POST", `/projects/${project}/locks/${lockName}/acquire`, { unit: unit ? Number(unit) : null, note: str(p.flags, "note") ?? "", shared: bool(p.flags, "shared"), machine: defaultMachine() });
|
|
1614
1622
|
out.print(r.maintenance
|
|
1615
1623
|
? `${lockName} is not handed out now: ${r.maintenance}. You are #${r.position} in line and will be @mentioned when it is yours after the window; do not poll. Leave the queue: b9s unlock ${lockName}`
|
|
1616
1624
|
: r.acquired
|
package/dist/git.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { copyFileSync, existsSync, readdirSync, realpathSync, rmSync, statSync, statfsSync } from "node:fs";
|
|
1
|
+
import { copyFileSync, existsSync, lstatSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, statfsSync } from "node:fs";
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
3
|
import { hostname } from "node:os";
|
|
4
4
|
import { dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
5
5
|
import { CliError } from "./errors.js";
|
|
6
|
+
import { configDirectory } from "./directories.js";
|
|
6
7
|
export const PRUNE_STATUS_TIMEOUT_MS = 30_000;
|
|
7
8
|
function status(cwd, timeoutMs) {
|
|
8
9
|
const r = spawnSync("git", ["status", "--porcelain"], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 512 * 1024 * 1024, ...(timeoutMs === undefined ? {} : { timeout: timeoutMs }) });
|
|
@@ -108,9 +109,61 @@ export function scanWorktrees(cwd = process.cwd(), options = {}) {
|
|
|
108
109
|
});
|
|
109
110
|
return { repo, worktrees };
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
function registeredMachineLabel(env) {
|
|
113
|
+
let path;
|
|
114
|
+
try {
|
|
115
|
+
path = join(configDirectory(env), "machine.json");
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
const detail = error instanceof Error ? `: ${error.message}` : "";
|
|
119
|
+
throw new CliError("machine_identity_unavailable", `cannot resolve the machine registration directory${detail}; fix the .bschat/.b9s directory conflict before using host-scoped locks or status`);
|
|
120
|
+
}
|
|
121
|
+
let raw;
|
|
122
|
+
try {
|
|
123
|
+
raw = readFileSync(path, "utf8");
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
const code = error.code;
|
|
127
|
+
if (code === "ENOENT") {
|
|
128
|
+
try {
|
|
129
|
+
lstatSync(path);
|
|
130
|
+
}
|
|
131
|
+
catch (statError) {
|
|
132
|
+
if (statError.code === "ENOENT")
|
|
133
|
+
return undefined;
|
|
134
|
+
throw new CliError("machine_identity_unavailable", `cannot inspect machine registration ${path}; fix its permissions or path before using host-scoped locks or status`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
throw new CliError("machine_identity_unavailable", `cannot read machine registration ${path} (${code ?? "unknown error"}); fix its permissions or registration before using host-scoped locks or status`);
|
|
138
|
+
}
|
|
139
|
+
let value;
|
|
140
|
+
try {
|
|
141
|
+
value = JSON.parse(raw);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
throw new CliError("machine_identity_unavailable", `machine registration ${path} is malformed; repair or remove it only if this host is unregistered before using host-scoped locks or status`);
|
|
145
|
+
}
|
|
146
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || typeof value.name !== "string" || !value.name.trim()) {
|
|
147
|
+
throw new CliError("machine_identity_unavailable", `machine registration ${path} has no valid name; repair or remove it only if this host is unregistered before using host-scoped locks or status`);
|
|
148
|
+
}
|
|
149
|
+
return value.name.trim();
|
|
150
|
+
}
|
|
151
|
+
/** The machine shared by every CLI identity running on this host. Saved agent machine fields are not identity. */
|
|
152
|
+
export function defaultMachine(label, env = process.env, host = hostname()) {
|
|
153
|
+
const h = host.trim();
|
|
154
|
+
const registered = registeredMachineLabel(env);
|
|
155
|
+
const resolvedLabel = registered ?? label?.trim();
|
|
156
|
+
return resolvedLabel ? `${h}/${resolvedLabel}` : h;
|
|
157
|
+
}
|
|
158
|
+
/** Use the current host for status and locks; retain a copied identity's machine field only as a diagnostic label. */
|
|
159
|
+
const warnedMachineMismatches = new Set();
|
|
160
|
+
export function machineIdentityForAgent(savedMachine, env = process.env, host = hostname(), warn = (line) => process.stderr.write(`${line}\n`)) {
|
|
161
|
+
const current = defaultMachine(undefined, env, host);
|
|
162
|
+
if (savedMachine && savedMachine !== current && !warnedMachineMismatches.has(`${savedMachine}\0${current}`)) {
|
|
163
|
+
warnedMachineMismatches.add(`${savedMachine}\0${current}`);
|
|
164
|
+
warn(`[b9s] saved machine label "${savedMachine}" differs from this host "${current}"; using the host identity`);
|
|
165
|
+
}
|
|
166
|
+
return current;
|
|
114
167
|
}
|
|
115
168
|
/** True when `ancestor` is reachable from `ref` in the repo at cwd; null when either is unknown to git. */
|
|
116
169
|
export function isAncestor(ancestor, ref, cwd = process.cwd()) {
|
package/dist/harnesses.js
CHANGED
|
@@ -381,7 +381,7 @@ function codexProbe(thread) {
|
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
383
|
// ---- Claude Code ----
|
|
384
|
-
const claudeHome = () => process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), ".claude");
|
|
384
|
+
export const claudeHome = () => process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), ".claude");
|
|
385
385
|
/** A Claude Code session's transcript (~/.claude/projects/<folder>/<id>.jsonl), wherever its folder is. */
|
|
386
386
|
export function claudeTranscript(session) {
|
|
387
387
|
const root = join(claudeHome(), "projects");
|
package/dist/help.js
CHANGED
|
@@ -22,8 +22,10 @@ GET /account/usage reports used and allowed micro-dollars, uncertain calls and t
|
|
|
22
22
|
Session/admin clients can use GET /assistant/conversations, GET /assistant/conversations/:id/messages (paged history with saved tool notices), POST /assistant/conversations/:id/messages (SSE), and DELETE /assistant/conversations/:id. Old assistant messages report notices_available=false. The assistant can draft changes; POST /assistant/proposals/:id/apply or /discard is the operator's explicit action. See the agent/operator skill API reference for events and tools.
|
|
23
23
|
Free and paid accounts without a live Stripe subscription use the UTC calendar month; subscribed paid accounts reset at current_period_end.
|
|
24
24
|
|
|
25
|
+
Mac capacity/signing records and the hosted lease allocate/drain intents are documented in docs/MACOS-MACHINES-API.md. Allocation consumes WU #403's reviewed controller outputs; the API does not widen IAM. There is no CLI stop/release bypass. Operator controls are in the named hosted Mac lease console unit WU #381; signing remains a separate trusted worker.
|
|
25
26
|
Mac capacity/signing API (profiles, leases, signer-only references, TestFlight approvals, and the isolated signer job contract) is documented in docs/MACOS-MACHINES-API.md. There is no CLI command to issue signer-host credentials or trigger release; operator controls are WU #286, real host/provider integration is WU #288.
|
|
26
|
-
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
|
|
27
|
+
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.
|
|
28
|
+
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.
|
|
27
29
|
|
|
28
30
|
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. 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.
|
|
29
31
|
|
|
@@ -60,9 +62,12 @@ Agent commands
|
|
|
60
62
|
b9s follow <channel> | unfollow <channel> | following followed channels' new messages are injected by the hook;
|
|
61
63
|
other channels appear as a one-line unread digest
|
|
62
64
|
b9s process the project's process: tag vocabulary, reviewers, wake-path warnings, scope templates, agreements and active standing rules
|
|
63
|
-
b9s
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
b9s rule list [--project <p>] list authorized project rules; assigner history uses API WU #459
|
|
66
|
+
b9s rule show <rule-id> [--project <p>]
|
|
67
|
+
b9s rule add --scope account|project|role:<name>|agent:<name> --text "..." [--expires-at <UTC>] [--conflicts-with id,id] [--source-channel-id <id> --source-message-id <id>] --confirm-compatible
|
|
68
|
+
b9s rule supersede <rule-id> --text "..." [--expires-at <UTC>] [--conflicts-with id,id] --confirm-compatible
|
|
69
|
+
b9s rule retire <rule-id> authorized assigner; project agent credentials restrict scope
|
|
70
|
+
review current charter/agreements before --confirm-compatible; no rule is inferred from chat
|
|
66
71
|
b9s wu open "<title>" --scope "..." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--lands-with <n>] [--reworks n,m] [--after <n>[,<m>]] [--requires cap,cap] [--force] [--evidence id[,id...]] [--target <branch>] [--here] [--json] open a work unit in its own
|
|
67
72
|
worktree; tags come from the vocabulary; --target is the branch it lands in (default: the
|
|
68
73
|
process target), e.g. a lane branch; wu target <n> <branch|default> changes it before review
|
|
@@ -118,6 +123,7 @@ Agent commands
|
|
|
118
123
|
b9s milestone review <key> assigner or operator: request a closure review now (the steward does it when the last unit closes)
|
|
119
124
|
b9s lock <name> [--unit n] [--note ..] [--shared] take this machine's <name> (build slot, scratch) or queue; --shared for a project-wide resource (a test board)
|
|
120
125
|
acquisition queues through a machine maintenance drain/window and resumes after it
|
|
126
|
+
machine identity is this host's hostname plus its registered label, shared by all agents here
|
|
121
127
|
b9s unlock <name> [--machine <label>|--shared] [--remove-empty] | b9s locks
|
|
122
128
|
release it (also released when your unit closes); assigners/operators can remove an empty scoped lock with --remove-empty
|
|
123
129
|
lock names acquire/list/release/show/status are reserved: use lock <name>, locks, or unlock <name> as suggested
|
|
@@ -234,6 +240,7 @@ Machine placement shares capacity across the account's projects: session seats a
|
|
|
234
240
|
b9s machine run [--interval seconds] | once | build-images | status | prepare [--agy-userns] [--print-apparmor] | service
|
|
235
241
|
default interval 30s, 1..3600; prepare checks harnesses; --agy-userns opts into an AppArmor
|
|
236
242
|
profile for the resolved agy binary if Ubuntu blocks its workspace-write terminal sandbox (passwordless sudo)
|
|
243
|
+
Antigravity workspace-write readiness makes an authenticated b9s me call inside the sandbox
|
|
237
244
|
b9s machine processes --worktree <path> [--as <project>/<agent>] [--json] read-only host process sample for a project-owned worktree
|
|
238
245
|
includes pid/parent, start/elapsed, command (120 chars), cwd, TCP listeners and sample time
|
|
239
246
|
project agents only; stale samples are labelled; command credentials are redacted; no environment values or signaling
|
|
@@ -359,6 +366,10 @@ the returned object and warning, then exits 3. Inspect the object and do not ret
|
|
|
359
366
|
b9s-admin process assigners <project> role1,role2 | agreements <project> --file agreements.md
|
|
360
367
|
b9s-admin process charter <project> --file charter.md how the project weighs trade-offs; sent with every expert question
|
|
361
368
|
b9s-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)
|
|
369
|
+
b9s-admin rule list <project> | show <project> <rule-id>
|
|
370
|
+
b9s-admin rule add <project> --scope account|project|role:<name>|agent:<name> --text "..." [--expires-at <UTC>] [--conflicts-with id,id] [--source-channel-id <id> --source-message-id <id>] --confirm-compatible
|
|
371
|
+
b9s-admin rule supersede <project> <rule-id> --text "..." [--expires-at <UTC>] [--conflicts-with id,id] --confirm-compatible | retire <project> <rule-id>
|
|
372
|
+
rules are audited revisions; review charter and agreements first. Console promotion is the primary management surface.
|
|
362
373
|
b9s-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)
|
|
363
374
|
b9s-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
|
|
364
375
|
b9s-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
|
|
@@ -411,6 +422,7 @@ Machines (provisioned over your own ssh; a daemon on each runs the agent session
|
|
|
411
422
|
refuses newer destination state and avoids duplicate Codex hooks under managed policy,
|
|
412
423
|
then commits the session only after handoff succeeds; work left on the source requires both flags
|
|
413
424
|
b9s-admin machine label <name> <label...> [--remove a,b] what cannot be measured (lab-lan, builds); pools' --needs match it
|
|
425
|
+
b9s-admin machine headroom [name] latest resource headroom, freshness, session ceiling and reservations (console WU #118)
|
|
414
426
|
b9s-admin machine slots <name> <n | auto> how many sessions it takes (auto: one per 4 GB of RAM)
|
|
415
427
|
b9s-admin machine writable <name> <path...> | none folders workspace-write agents there may also write (~/.cargo, ~/.ester)
|
|
416
428
|
b9s-admin machine workdir <name> <path | default> where its daemon clones projects for pool sessions (default ~/bschat)
|
|
@@ -438,18 +450,26 @@ Project devcontainer images & immutable registry builds (console controls in WU
|
|
|
438
450
|
b9s-admin project image activate <project> <sha256:...> explicitly select a ready candidate for future or restarted sessions
|
|
439
451
|
b9s-admin project image rollback <project> (<sha256:...> | clear) select a prior ready digest or clear the active image selection without mutating tags
|
|
440
452
|
|
|
441
|
-
Pools (
|
|
453
|
+
Pools (fixed or adaptive; the server names the agents and places them on machines)
|
|
442
454
|
b9s-admin project repo <project> <git url | none> what machines clone for the project's pool sessions
|
|
443
455
|
b9s-admin project checkout <project> --exclude <path,path | none> paths new worktrees leave out (sparse checkout), e.g. logs/
|
|
444
456
|
b9s-admin pool set <project>/<name> --role <role> --variant [tag=]harness:model[:effort][*weight][@anthropic|deepseek] [--variant ...]
|
|
445
|
-
--count <n> --sandbox <mode> [--needs label,label] [--min-ram GB] [--turn-timeout min] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60]
|
|
457
|
+
--count <n> | --min <n> --max <n> [--count <target>] --sandbox <mode> [--needs label,label] [--min-ram GB] [--turn-timeout min] [--turns-per-hour 1..60] [--unproductive-per-hour 1..60]
|
|
458
|
+
fixed pools retain count; adaptive pools are opt-in, with target bounded by min/max and account/machine capacity
|
|
446
459
|
slots are agents named <name>-<tag>-<n>; fewer retires the extra ones
|
|
447
|
-
|
|
460
|
+
[--quota-substitution | --no-quota-substitution] allows another eligible variant after authoritative quota exhaustion
|
|
461
|
+
pool writes first show a server impact preview; confirm a fresh revision with --impact-revision <revision>
|
|
462
|
+
b9s-admin pool list [project] | show <project>/<name> | events <project>/<name> [--limit 1..100]
|
|
463
|
+
b9s-admin pool pause|resume <project>/<name> [--reason <text>] pause only automatic scaling; sessions keep running
|
|
464
|
+
b9s-admin pool pin <project>/<name> <slot> --machine <name> [--until <ISO>] [--reason <text>] | unpin <project>/<name> <slot>
|
|
465
|
+
b9s-admin pool suspend|restore <project>/<name> <slot> [--reason <text>] [--note <text>] suspend keeps the same slot and does not create a replacement
|
|
466
|
+
b9s-admin pool remove <project>/<name> retires its agents; their units go back to the queue
|
|
467
|
+
Console controls and impact previews are specified by WU #118.
|
|
448
468
|
b9s-admin pool slot stop <project>/<pool>/<slot> [--reason text] suspend one slot and stop its session
|
|
449
469
|
b9s-admin pool move <project>/<name> --from <source-machine> --to <destination-machine> [--carry note|thread] [--ssh-from local|<host>] [--to-ssh <host>]
|
|
450
470
|
verifies each source slot independently; unsafe slots stay placed with a reason
|
|
451
471
|
b9s-admin pool suggestions <project> [--status pending|accepted|rejected|superseded|all] inspect explicit non-mutating pool-weight suggestions
|
|
452
472
|
b9s-admin pool suggestion accept <project> <id> [--note "..."] apply a pending pool-weight suggestion and audit it
|
|
453
|
-
b9s-admin pool suggestion reject <project> <id> [--reason "..."] reject a pool-weight suggestion with an audit note
|
|
473
|
+
b9s-admin pool suggestion reject <project> <id> [--reason "..."] reject a pending pool-weight suggestion with an audit note
|
|
454
474
|
b9s-admin delete-account --confirm "delete everything"
|
|
455
475
|
`;
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ import { agentNotice } from "./commands/notices.js";
|
|
|
35
35
|
import { versionLine, warnLegacyAlias } from "./legacy-alias.js";
|
|
36
36
|
import { gitCredentialMain } from "./commands/git-credential.js";
|
|
37
37
|
import { templates } from "./commands/templates.js";
|
|
38
|
+
import { standingRuleCommand } from "./commands/standing-rules.js";
|
|
38
39
|
import { testResults } from "./commands/test-results.js";
|
|
39
40
|
import { environment } from "./commands/environment.js";
|
|
40
41
|
import { runCommandSafely } from "./command-runner.js";
|
|
@@ -96,6 +97,7 @@ const COMMANDS = {
|
|
|
96
97
|
doctor,
|
|
97
98
|
wu,
|
|
98
99
|
process: processCmd,
|
|
100
|
+
rule: standingRuleCommand,
|
|
99
101
|
record,
|
|
100
102
|
milestones,
|
|
101
103
|
milestone,
|