benignswarm 0.12.87 → 0.12.88

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.
@@ -118,6 +118,9 @@ export async function join(p, out) {
118
118
  written = [...new Set(written)];
119
119
  }
120
120
  const selfTest = !noBind && !bool(p.flags, "no-skill") && harnessList(p, vendor).includes("claude-code") ? verifyClaudeHook(root, ref) : null;
121
+ const codexHookPath = vendor === "codex" ? installCodexHooks(inst.bin) : null;
122
+ const hasLocalHook = !!selfTest || !!codexHookPath || written.some((file) => file.endsWith(".agents/hooks.json"));
123
+ const wakePathWarnings = hasLocalHook ? [] : (json.wake_path_warnings ?? []);
121
124
  const human = [
122
125
  json.project
123
126
  ? `Joined project "${json.project.name}" as agent "${name}" (${vendor})${json.agent.role_name ? ` with role ${json.agent.role_name}` : ""}.`
@@ -129,6 +132,7 @@ export async function join(p, out) {
129
132
  : `This repo now maps ${vendor} -> ${ref} in ${idPath}, so b9s commands here know who you are, even after a reboot.`,
130
133
  written.length ? `Harness files written: ${written.join(", ")}` : null,
131
134
  selfTest,
135
+ ...wakePathWarnings.map((warning) => `No verified wake path${warning.project ? ` for ${warning.project}` : ""}: ${warning.consequence} Set a check schedule with b9s status set --checks-every 30 or run b9s watch --launchd so reminders have somewhere to go.`),
132
136
  ``,
133
137
  `Your model is detected automatically (hook, transcript or harness config); override with --model or BSCHAT_MODEL only if it reports "unknown".`,
134
138
  json.revived && json.resume ? `` : null,
@@ -136,10 +140,10 @@ export async function join(p, out) {
136
140
  json.revived && json.resume ? `--- ${json.resume.title} ---\n${json.resume.body}\n---${json.resume.evidence.length ? `\nevidence: ${json.resume.evidence.map((e) => `evidence:${e}`).join(" ")}` : ""}` : null,
137
141
  json.revived && json.resume ? `Read it before doing anything else.` : null,
138
142
  ``,
139
- vendor === "codex" ? `Codex: b9s's hooks are in ${installCodexHooks(inst.bin)} (approve them when Codex asks); they deliver your mentions and assignments inside your thread once b9s knows which thread is you: b9s codex bind <thread-id>, or a watcher (b9s watch --launchd), which is still what wakes you when you are idle.` : vendor === "antigravity" ? `Antigravity: .agents/hooks.json now delivers your mentions and assignments inside your conversation, once b9s knows which conversation is you: b9s antigravity bind <conversation-id> (the folder name under ~/.gemini/antigravity/brain/ holding your artifacts). A watcher (b9s watch --launchd) also binds it, and is still what wakes you when you are idle.` : vendor !== "claude-code" ? `No hook exists for ${vendor}: you will not be told about replies unless you run a watcher. See the skill's "Knowing when someone talks to you" section (b9s watch --launchd).` : null,
143
+ vendor === "codex" ? `Codex: b9s's hooks are in ${codexHookPath} (approve them when Codex asks); they deliver your mentions and assignments inside your thread once b9s knows which thread is you: b9s codex bind <thread-id>, or a watcher (b9s watch --launchd), which is still what wakes you when you are idle.` : vendor === "antigravity" ? `Antigravity: .agents/hooks.json now delivers your mentions and assignments inside your conversation, once b9s knows which conversation is you: b9s antigravity bind <conversation-id> (the folder name under ~/.gemini/antigravity/brain/ holding your artifacts). A watcher (b9s watch --launchd) also binds it, and is still what wakes you when you are idle.` : vendor !== "claude-code" ? `No hook exists for ${vendor}: you will not be told about replies unless you run a watcher. See the skill's "Knowing when someone talks to you" section (b9s watch --launchd).` : null,
140
144
  `Next: b9s me && b9s who && b9s inbox && b9s handoffs --open`,
141
145
  ].filter((l) => l !== null).join("\n");
142
- out.print(human, { install: inst, agent: json.agent, project: json.project, saved: path, identity: idPath, bound: !noBind, written, revived: !!json.revived, resume: json.resume ?? null, export: { BSCHAT_AGENT: ref } });
146
+ out.print(human, { install: inst, agent: json.agent, project: json.project, saved: path, identity: idPath, bound: !noBind, written, wake_path_warnings: wakePathWarnings, revived: !!json.revived, resume: json.resume ?? null, export: { BSCHAT_AGENT: ref } });
143
147
  }
144
148
  /**
145
149
  * Runs the hook command exactly as Claude Code will, with the settings file's own env, and
@@ -104,17 +104,18 @@ export async function machineAdmin(action, rest, p, out) {
104
104
  if (wrote.status !== 0)
105
105
  throw new CliError("provision_failed", `writing ~/.b9s/machine.json on ${host} failed: ${wrote.stderr.trim()}`);
106
106
  // 4. The daemon.
107
- const svc = remoteBschat(host, "machine service");
107
+ const svc = remoteBschat(host, "machine service --json");
108
108
  if (svc.status !== 0)
109
109
  throw new CliError("provision_failed", `installing the machine daemon on ${host} failed: ${svc.stderr.trim().slice(-300)}`);
110
- say(` daemon: ${svc.stdout.trim().split("\n")[0]}`);
110
+ const daemon = JSON.parse(svc.stdout);
111
+ say(` daemon: ${daemon.path} with PATH ${daemon.daemon_path}`);
111
112
  const failed = prepared.filter((s) => s.result === "failed");
112
113
  return out.print([
113
114
  `Machine ${name} (${host}) is provisioned and its daemon is running.`,
114
115
  ...lines,
115
116
  failed.length ? `Still to do on the machine: ${failed.map((s) => `${s.step} (${s.detail})`).join("; ")}` : null,
116
117
  `Declare what it runs: b9s-admin machine session add ${name} <project>/<agent> --dir <checkout on ${host}> --sandbox <mode> [--create --role <role>]`,
117
- ].filter(Boolean).join("\n"), { machine: name, host, bootstrap: steps, prepare: prepared });
118
+ ].filter(Boolean).join("\n"), { machine: name, host, bootstrap: steps, prepare: prepared, daemon_path: daemon.daemon_path });
118
119
  }
119
120
  if (action === "list" || action === undefined) {
120
121
  const r = await c.call("GET", "/machines");
@@ -11,7 +11,7 @@ import { applySparse } from "../git.js";
11
11
  import { drainingUntil, writeMaintenance } from "../maintenance.js";
12
12
  import { TURN_HARNESSES, claudeFacts, claudeSandbox, dshFacts, dshProcesses, probeFor, sessionProcesses } from "../harnesses.js";
13
13
  import { readState, writeState } from "../state.js";
14
- import { installService, lingerEnabled, MACHINE_LABEL, removeService, requireInstall, restartWatcher, serviceActive, WATCH_LABEL_PREFIX, watcherServices } from "../install.js";
14
+ import { installService, lingerEnabled, MACHINE_LABEL, machineDaemonPath, removeService, requireInstall, restartWatcher, serviceActive, WATCH_LABEL_PREFIX, watcherServices } from "../install.js";
15
15
  import { CLI_VERSION } from "../version.js";
16
16
  import { probeCapabilities } from "../capabilities.js";
17
17
  import { diskSpaceNotice } from "../notices.js";
@@ -511,12 +511,12 @@ function volumeSpace(path, label) {
511
511
  }
512
512
  /** Whether Codex's own sandbox runs here (`codex sandbox -- true`), with its error; checked at most every 10 min. */
513
513
  let sandboxCache = null;
514
- export function codexSandbox(force = false) {
515
- if (!force && sandboxCache && Date.now() - sandboxCache.at < 10 * 60_000)
514
+ export function codexSandbox(force = false, path = process.env.PATH ?? "") {
515
+ if (!force && sandboxCache && sandboxCache.path === path && Date.now() - sandboxCache.at < 10 * 60_000)
516
516
  return sandboxCache.result;
517
- const r = spawnSync("codex", ["sandbox", "--", "true"], { encoding: "utf8", timeout: 60_000 });
517
+ const r = spawnSync("codex", ["sandbox", "--", "true"], { encoding: "utf8", timeout: 60_000, env: { ...process.env, PATH: path } });
518
518
  const result = r.status === 0 ? { ok: true, error: null } : { ok: false, error: `${r.stderr ?? ""}${r.stdout ?? ""}`.trim().split("\n")[0].slice(0, 300) || `exit ${r.status}` };
519
- sandboxCache = { at: Date.now(), result };
519
+ sandboxCache = { at: Date.now(), result, path };
520
520
  return result;
521
521
  }
522
522
  /** Memory a new process could use: Linux's MemAvailable (free alone undercounts the page cache), else free. */
@@ -530,19 +530,21 @@ function memAvailable() {
530
530
  }
531
531
  /** Claude Code's version, login and sandbox; the sandbox check runs at most every 10 min. */
532
532
  let claudeSandboxCache = null;
533
- function claudeReport() {
534
- const f = claudeFacts();
533
+ function claudeReport(path = process.env.PATH ?? "") {
534
+ const f = claudeFacts(undefined, path);
535
535
  if (!f)
536
536
  return null;
537
- if (!claudeSandboxCache || Date.now() - claudeSandboxCache.at > 10 * 60_000)
538
- claudeSandboxCache = { at: Date.now(), result: claudeSandbox() };
537
+ if (!claudeSandboxCache || claudeSandboxCache.path !== path || Date.now() - claudeSandboxCache.at > 10 * 60_000)
538
+ claudeSandboxCache = { at: Date.now(), result: claudeSandbox(path), path };
539
539
  return { ...f, sandbox: claudeSandboxCache.result };
540
540
  }
541
541
  /** What the operator needs to know about this machine, reported with every pass. */
542
542
  export function machineFacts() {
543
- const dsh = dshFacts();
544
- const codex = spawnSync("codex", ["--version"], { encoding: "utf8" });
545
- const login = codex.status === 0 ? spawnSync("codex", ["login", "status"], { encoding: "utf8" }) : null;
543
+ const path = process.env.PATH ?? "";
544
+ const env = { ...process.env, PATH: path };
545
+ const codex = spawnSync("codex", ["--version"], { encoding: "utf8", env });
546
+ const login = codex.status === 0 ? spawnSync("codex", ["login", "status"], { encoding: "utf8", env }) : null;
547
+ const dsh = dshFacts(platform(), path);
546
548
  let diskFree = null;
547
549
  try {
548
550
  const st = statfsSync(homedir());
@@ -557,9 +559,10 @@ export function machineFacts() {
557
559
  load: loadavg().map((x) => Math.round(x * 100) / 100), mem_available_bytes: memAvailable(),
558
560
  // When this machine last booted: the server ends a maintenance window once the machine is back.
559
561
  booted_at: new Date(Math.floor((Date.now() - uptime() * 1000) / 60_000) * 60_000).toISOString(),
562
+ daemon_path: path,
560
563
  bschat: { version: CLI_VERSION, bin: requireInstall().bin },
561
- codex: codex.status === 0 ? { version: codex.stdout.trim(), logged_in: login?.status === 0 && /logged in/i.test(`${login.stdout}${login.stderr}`), login: `${login?.stdout ?? ""}${login?.stderr ?? ""}`.trim().slice(0, 200), sandbox: codexSandbox() } : null,
562
- "claude-code": claudeReport(),
564
+ codex: codex.status === 0 ? { version: codex.stdout.trim(), logged_in: login?.status === 0 && /logged in/i.test(`${login.stdout}${login.stderr}`), login: `${login?.stdout ?? ""}${login?.stderr ?? ""}`.trim().slice(0, 200), sandbox: codexSandbox(false, path) } : null,
565
+ "claude-code": claudeReport(path),
563
566
  dsh,
564
567
  managed_hooks: existsSync(req) && isCodexManagedRequirements(readFileSync(req, "utf8")),
565
568
  linger: platform() === "linux" ? lingerEnabled() : null,
@@ -574,6 +577,9 @@ export function machineFacts() {
574
577
  */
575
578
  export function prepare(opts = {}) {
576
579
  const steps = [];
580
+ const daemonPath = machineDaemonPath();
581
+ const daemonEnv = { ...process.env, PATH: daemonPath };
582
+ steps.push({ step: "daemon PATH", result: "ok", detail: daemonPath });
577
583
  const sudo = spawnSync("sudo", ["-n", "true"], { stdio: "ignore" }).status === 0;
578
584
  if (platform() === "linux") {
579
585
  const l = lingerEnabled();
@@ -585,20 +591,20 @@ export function prepare(opts = {}) {
585
591
  steps.push(lingerEnabled() ? { step: "linger", result: "done", detail: "enabled" } : { step: "linger", result: "failed", detail: `${(r2.stderr ?? "").trim()} (run: sudo loginctl enable-linger ${userInfo().username})` });
586
592
  }
587
593
  }
588
- const dsh = dshFacts();
594
+ const dsh = dshFacts(platform(), daemonPath);
589
595
  steps.push(dsh.available
590
596
  ? { step: "dsh", result: "ok", detail: `${dsh.version}, ${dsh.path}` }
591
597
  : { step: "dsh", result: platform() === "linux" ? "skipped" : "failed", detail: dsh.error ?? "DeepSeek Harness dsh CLI is unavailable" });
592
- const codex = spawnSync("codex", ["--version"], { encoding: "utf8" });
598
+ const codex = spawnSync("codex", ["--version"], { encoding: "utf8", env: daemonEnv });
593
599
  if (codex.status !== 0)
594
600
  steps.push({ step: "codex", result: "failed", detail: "codex is not on PATH; install the Codex CLI (npm i -g @openai/codex) and log in (codex login --device-auth)" });
595
601
  else {
596
- const login = spawnSync("codex", ["login", "status"], { encoding: "utf8" });
602
+ const login = spawnSync("codex", ["login", "status"], { encoding: "utf8", env: daemonEnv });
597
603
  const ok = login.status === 0 && /logged in/i.test(`${login.stdout}${login.stderr}`);
598
604
  steps.push({ step: "codex", result: ok ? "ok" : "failed", detail: ok ? `${codex.stdout.trim()}, ${`${login.stdout}${login.stderr}`.trim()}` : `${codex.stdout.trim()} is not logged in: run codex login --device-auth on this machine` });
599
605
  }
600
606
  if (codex.status === 0) {
601
- let sb = codexSandbox(true);
607
+ let sb = codexSandbox(true, daemonPath);
602
608
  if (sb.ok)
603
609
  steps.push({ step: "codex sandbox", result: "ok", detail: "sandboxed (read-only, workspace-write) agents can run here" });
604
610
  else if (platform() !== "linux" || !/userns|uid map|RTM_NEWADDR|Operation not permitted|Permission denied/i.test(sb.error ?? ""))
@@ -610,17 +616,17 @@ export function prepare(opts = {}) {
610
616
  else {
611
617
  const t = spawnSync("sudo", ["-n", "tee", CODEX_APPARMOR_PATH], { input: codexAppArmorProfile(), stdio: ["pipe", "ignore", "pipe"], encoding: "utf8" });
612
618
  const l = t.status === 0 ? spawnSync("sudo", ["-n", "apparmor_parser", "-r", CODEX_APPARMOR_PATH], { encoding: "utf8" }) : t;
613
- sb = codexSandbox(true);
619
+ sb = codexSandbox(true, daemonPath);
614
620
  steps.push(l.status === 0 && sb.ok
615
621
  ? { step: "codex sandbox", result: "done", detail: `installed ${CODEX_APPARMOR_PATH} (Codex only); the sandbox works` }
616
622
  : { step: "codex sandbox", result: "failed", detail: l.status !== 0 ? `installing ${CODEX_APPARMOR_PATH}: ${(l.stderr ?? "").trim()}` : `profile installed but the sandbox still fails: ${sb.error}` });
617
623
  }
618
624
  }
619
625
  // Claude Code is optional on a machine; when it is there, say whether it can run agents.
620
- const claude = claudeFacts();
626
+ const claude = claudeFacts(undefined, daemonPath);
621
627
  if (claude) {
622
628
  steps.push({ step: "claude code", result: claude.logged_in ? "ok" : "failed", detail: claude.logged_in ? `${claude.version}, ${claude.login}` : `${claude.version}, ${claude.login}: run claude auth login on this machine (over ssh it prints a link to open in your browser and asks for the code)` });
623
- let sb = claudeSandbox();
629
+ let sb = claudeSandbox(daemonPath);
624
630
  const userns = platform() === "linux" && /RTM_NEWADDR|uid map|Operation not permitted|Permission denied/i.test(sb.error ?? "");
625
631
  if (sb.ok)
626
632
  steps.push({ step: "claude code sandbox", result: "ok", detail: "sandboxed (workspace-write) Claude Code agents can run here" });
@@ -633,7 +639,7 @@ export function prepare(opts = {}) {
633
639
  else {
634
640
  const t = spawnSync("sudo", ["-n", "tee", BWRAP_APPARMOR_PATH], { input: bwrapAppArmorProfile(), stdio: ["pipe", "ignore", "pipe"], encoding: "utf8" });
635
641
  const l = t.status === 0 ? spawnSync("sudo", ["-n", "apparmor_parser", "-r", BWRAP_APPARMOR_PATH], { encoding: "utf8" }) : t;
636
- sb = claudeSandbox();
642
+ sb = claudeSandbox(daemonPath);
637
643
  steps.push(l.status === 0 && sb.ok
638
644
  ? { step: "claude code sandbox", result: "done", detail: `installed ${BWRAP_APPARMOR_PATH}; the sandbox works` }
639
645
  : { step: "claude code sandbox", result: "failed", detail: l.status !== 0 ? `installing ${BWRAP_APPARMOR_PATH}: ${(l.stderr ?? "").trim()}` : `profile installed but the sandbox still fails: ${sb.error}` });
@@ -687,8 +693,9 @@ export async function machine(p, out) {
687
693
  if (sub === "service") {
688
694
  loadMachine();
689
695
  const bin = requireInstall().bin;
690
- const path = installService(MACHINE_LABEL, [bin, "machine", "run"], homedir(), { PATH: process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin", HOME: homedir() }, "machine");
691
- return out.print(`Wrote ${path} and (re)started it: the machine daemon runs ${bin} machine run. Logs: ~/.b9s/logs/machine.*.log`, { path, label: MACHINE_LABEL });
696
+ const daemonPath = machineDaemonPath();
697
+ const path = installService(MACHINE_LABEL, [bin, "machine", "run"], homedir(), { PATH: daemonPath, HOME: homedir() }, "machine");
698
+ return out.print(`Wrote ${path} and (re)started it: the machine daemon runs ${bin} machine run with PATH ${daemonPath}. Logs: ~/.b9s/logs/machine.*.log`, { path, label: MACHINE_LABEL, daemon_path: daemonPath });
692
699
  }
693
700
  const m = loadMachine();
694
701
  const log = (s) => process.stderr.write(`${new Date().toISOString()} b9s machine[${m.name}]: ${s}\n`);
@@ -655,6 +655,7 @@ export async function processCmd(p, out) {
655
655
  `Untagged units are approved by ${d.default_approver_role ?? "nobody (set a default approver)"}.${d.classification === "classifier" ? ` A ${d.classifier_role} confirms tags before review.` : ""}`,
656
656
  `A unit needs a title${d.require_scope ? ", a scope statement" : ""}${d.require_evidence_to_submit ? ", evidence before review" : ""}. Nothing is done until every tag is approved by someone qualified; never your own unit.`,
657
657
  `Review SLA ${d.review_sla_minutes} min; after ${d.escalate_after_minutes} min another qualified reviewer takes over. Max ${d.max_open_per_agent} open units per agent. Announcements in #${d.channel}.`,
658
+ ...(r.wake_path_warnings?.length ? [`No verified wake path:`, ...r.wake_path_warnings.map((warning) => ` ${warning.consequence}`)] : []),
658
659
  `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>)" : ""}.`,
659
660
  r.process.agreements ? `\nWorking agreements:\n${r.process.agreements}` : null,
660
661
  r.process.charter ? `\nCharter (how this project weighs its trade-offs; judge reviews and questions by it):\n${r.process.charter}` : null,
package/dist/harnesses.js CHANGED
@@ -418,11 +418,12 @@ export function claudeSettings(sandbox, model, effort, cwd, bschatHome, extraWri
418
418
  * the credentials file changes and at most every 6 hours otherwise; only an authentication error
419
419
  * counts as logged out, and any other failure is reported as unverified with its error.
420
420
  */
421
- export function claudeFacts(verify = verifyClaudeLoginCached) {
422
- const v = spawnSync("claude", ["--version"], { encoding: "utf8", timeout: 30_000 });
421
+ export function claudeFacts(verify, path = process.env.PATH ?? "") {
422
+ const env = { ...process.env, PATH: path };
423
+ const v = spawnSync("claude", ["--version"], { encoding: "utf8", timeout: 30_000, env });
423
424
  if (v.status !== 0)
424
425
  return null;
425
- const s = spawnSync("claude", ["auth", "status"], { encoding: "utf8", timeout: 30_000 });
426
+ const s = spawnSync("claude", ["auth", "status"], { encoding: "utf8", timeout: 30_000, env });
426
427
  let stored = false;
427
428
  let method = "unknown method";
428
429
  try {
@@ -435,13 +436,13 @@ export function claudeFacts(verify = verifyClaudeLoginCached) {
435
436
  }
436
437
  if (!stored)
437
438
  return { version: v.stdout.trim(), logged_in: false, login: "not logged in", verified: { ok: false, error: "no stored login" } };
438
- const verified = verify();
439
+ const verified = (verify ?? (() => verifyClaudeLoginCached(env)))();
439
440
  const login = verified.ok === true ? `logged in (${method})` : verified.ok === false ? `stored login rejected: ${verified.error}` : `logged in (${method}), not verified: ${verified.error}`;
440
441
  return { version: v.stdout.trim(), logged_in: verified.ok !== false, login: login.slice(0, 200), verified };
441
442
  }
442
443
  /** One minimal headless call; ok false only when Claude Code reports an authentication failure. */
443
- export function verifyClaudeLogin() {
444
- const r = spawnSync("claude", ["-p", "Reply OK", "--model", "claude-haiku-4-5-20251001", "--output-format", "json"], { encoding: "utf8", timeout: 120_000, cwd: homedir() });
444
+ export function verifyClaudeLogin(env = process.env) {
445
+ const r = spawnSync("claude", ["-p", "Reply OK", "--model", "claude-haiku-4-5-20251001", "--output-format", "json"], { encoding: "utf8", timeout: 120_000, cwd: homedir(), env });
445
446
  const error = claudeResultError(r.stdout ?? "") ?? (r.status !== 0 ? `${r.stderr ?? ""}`.trim().split("\n")[0] || `exit ${r.status}` : null);
446
447
  if (!error)
447
448
  return { ok: true, error: null };
@@ -449,12 +450,13 @@ export function verifyClaudeLogin() {
449
450
  }
450
451
  export const claudeIsAuthError = (e) => /401|403|authenticat|not logged in|\/login|oauth token|invalid api key/i.test(e);
451
452
  let loginCache = null;
452
- function verifyClaudeLoginCached() {
453
+ function verifyClaudeLoginCached(env = process.env) {
453
454
  const cred = join(claudeHome(), ".credentials.json");
454
455
  const key = existsSync(cred) ? String(statSync(cred).mtimeMs) : "keychain";
455
- if (loginCache && loginCache.key === key && Date.now() - loginCache.at < 6 * 60 * 60_000)
456
+ const cacheKey = `${key}\0${env.PATH ?? ""}`;
457
+ if (loginCache && loginCache.key === cacheKey && Date.now() - loginCache.at < 6 * 60 * 60_000)
456
458
  return loginCache.result;
457
- loginCache = { key, at: Date.now(), result: verifyClaudeLogin() };
459
+ loginCache = { key: cacheKey, at: Date.now(), result: verifyClaudeLogin(env) };
458
460
  return loginCache.result;
459
461
  }
460
462
  /**
@@ -462,14 +464,15 @@ function verifyClaudeLoginCached() {
462
464
  * bubblewrap and socat, and bubblewrap needs unprivileged user namespaces (Ubuntu 24.04 restricts
463
465
  * them with AppArmor), so this runs bubblewrap the way a sandboxed command would.
464
466
  */
465
- export function claudeSandbox() {
467
+ export function claudeSandbox(path = process.env.PATH ?? "") {
466
468
  if (process.platform === "darwin")
467
469
  return existsSync("/usr/bin/sandbox-exec") ? { ok: true, error: null } : { ok: false, error: "sandbox-exec is missing" };
468
470
  if (process.platform !== "linux")
469
471
  return { ok: false, error: `no Claude Code sandbox on ${process.platform}` };
470
- const missing = ["bwrap", "socat"].filter((b) => spawnSync("/bin/sh", ["-c", `command -v ${b}`]).status !== 0);
472
+ const env = { ...process.env, PATH: path };
473
+ const missing = ["bwrap", "socat"].filter((b) => spawnSync("/bin/sh", ["-c", `command -v ${b}`], { env }).status !== 0);
471
474
  if (missing.length)
472
475
  return { ok: false, error: `${missing.join(" and ")} not installed (sudo apt-get install bubblewrap socat)` };
473
- const r = spawnSync("bwrap", ["--ro-bind", "/", "/", "--dev", "/dev", "--proc", "/proc", "--unshare-all", "--die-with-parent", "true"], { encoding: "utf8", timeout: 30_000 });
476
+ const r = spawnSync("bwrap", ["--ro-bind", "/", "/", "--dev", "/dev", "--proc", "/proc", "--unshare-all", "--die-with-parent", "true"], { encoding: "utf8", timeout: 30_000, env });
474
477
  return r.status === 0 ? { ok: true, error: null } : { ok: false, error: `bubblewrap cannot start: ${`${r.stderr ?? ""}`.trim().split("\n")[0].slice(0, 250) || `exit ${r.status}`}` };
475
478
  }
package/dist/help.js CHANGED
@@ -41,7 +41,7 @@ Agent commands
41
41
  b9s inbox [--unread] [--after <iso-time>] [--limit n] mentions of you and replies to your messages
42
42
  b9s follow <channel> | unfollow <channel> | following followed channels' new messages are injected by the hook;
43
43
  other channels appear as a one-line unread digest
44
- b9s process the project's process: tag vocabulary, scope templates, reviewer focus, machine/path requirements, slice defaults, agreements
44
+ b9s process the project's process: tag vocabulary, reviewers, wake-path warnings, scope templates, requirements, agreements
45
45
  b9s wu open "<title>" --scope "..." [--scope-file <path> | --scope-from <n>] [--tags a,b] [--tier routine|careful|expert] [--requires cap,cap] [--force] [--evidence id[,id...]] [--target <branch>] [--here] open a work unit in its own
46
46
  worktree; tags come from the vocabulary; --target is the branch it lands in (default: the
47
47
  process target), e.g. a lane branch; wu target <n> <branch|default> changes it before review
package/dist/install.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
2
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
3
3
  import { homedir, userInfo } from "node:os";
4
4
  import { basename, delimiter, dirname, join, resolve } from "node:path";
5
5
  import { configRoot } from "./config.js";
@@ -34,6 +34,57 @@ export function requireInstall() {
34
34
  }
35
35
  return r;
36
36
  }
37
+ /** Build the environment installed for the machine daemon and used by its harness checks. */
38
+ export function composeMachinePath(options) {
39
+ const isDirectory = options.exists ?? ((path) => {
40
+ try {
41
+ return statSync(path).isDirectory();
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ });
47
+ const preferred = [
48
+ join(options.home, ".local", "bin"),
49
+ dirname(options.installBin),
50
+ dirname(options.npmBin),
51
+ ...(options.platform === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : []),
52
+ ];
53
+ const entries = [];
54
+ const seen = new Set();
55
+ for (const entry of [...preferred.filter(isDirectory), ...options.currentPath.split(delimiter).filter(Boolean)]) {
56
+ if (seen.has(entry))
57
+ continue;
58
+ seen.add(entry);
59
+ entries.push(entry);
60
+ }
61
+ return entries.join(delimiter);
62
+ }
63
+ /** The machine daemon must not inherit PATH from whichever shell happened to install it. */
64
+ export function machineDaemonPath(currentPath = process.env.PATH ?? "", platformName = process.platform, home = homedir()) {
65
+ const install = requireInstall();
66
+ // npm is commonly a #!/usr/bin/env node script. Give it the known runtime locations
67
+ // before asking it for the prefix, since the shell that provisioned this machine may
68
+ // not have ~/.local/bin (or the recorded install's bin) on PATH yet.
69
+ const discoveryPath = composeMachinePath({
70
+ platform: platformName,
71
+ home,
72
+ installBin: install.bin,
73
+ npmBin: install.npm,
74
+ currentPath,
75
+ });
76
+ const prefix = spawnSync(install.npm, ["prefix", "-g"], {
77
+ encoding: "utf8",
78
+ timeout: 30_000,
79
+ env: { ...process.env, PATH: discoveryPath },
80
+ });
81
+ if (prefix.status !== 0)
82
+ throw new CliError("npm_prefix_failed", `${install.npm} prefix -g failed while preparing the machine daemon PATH`, (prefix.stderr ?? "").trim().slice(0, 300));
83
+ const globalPrefix = (prefix.stdout ?? "").trim();
84
+ if (!globalPrefix || !globalPrefix.startsWith("/"))
85
+ throw new CliError("npm_prefix_invalid", `${install.npm} prefix -g did not return an absolute path`, (prefix.stdout ?? "").trim().slice(0, 300));
86
+ return composeMachinePath({ platform: platformName, home, installBin: install.bin, npmBin: join(globalPrefix, "bin", "npm"), currentPath });
87
+ }
37
88
  /** "b9s 0.12.38" -> "0.12.38"; null when the binary cannot run. */
38
89
  export function binVersion(bin) {
39
90
  const r = spawnSync(bin, ["--version"], { encoding: "utf8", timeout: 20_000 });
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.87";
1
+ export const CLI_VERSION = "0.12.88";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.87",
3
+ "version": "0.12.88",
4
4
  "description": "b9s: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {