benignswarm 0.12.85 → 0.12.87

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.
@@ -1,4 +1,4 @@
1
- import { existsSync, lstatSync, readFileSync, realpathSync, renameSync, symlinkSync, writeFileSync } from "node:fs";
1
+ import { closeSync, existsSync, lstatSync, openSync, readFileSync, readdirSync, readlinkSync, readSync, realpathSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { CliError } from "./errors.js";
@@ -15,6 +15,86 @@ function maybeLstat(path) {
15
15
  }
16
16
  function directory(path) { return maybeLstat(path)?.isDirectory() ?? false; }
17
17
  function present(path) { return maybeLstat(path) !== null; }
18
+ function treeEntries(root) {
19
+ const entries = new Map();
20
+ const visit = (path, relative) => {
21
+ const st = lstatSync(path);
22
+ if (st.isDirectory()) {
23
+ for (const name of readdirSync(path).sort())
24
+ visit(join(path, name), relative ? relative + "/" + name : name);
25
+ }
26
+ else if (st.isFile())
27
+ entries.set(relative, { kind: "file", path, size: st.size });
28
+ else if (st.isSymbolicLink())
29
+ entries.set(relative, { kind: "symlink", target: readlinkSync(path) });
30
+ else
31
+ entries.set(relative, { kind: "other", mode: st.mode });
32
+ };
33
+ visit(root, "");
34
+ return entries;
35
+ }
36
+ function sameFileBytes(left, right, size) {
37
+ const a = openSync(left, "r");
38
+ let b;
39
+ try {
40
+ b = openSync(right, "r");
41
+ const leftChunk = Buffer.allocUnsafe(64 * 1024);
42
+ const rightChunk = Buffer.allocUnsafe(64 * 1024);
43
+ let position = 0;
44
+ while (position < size) {
45
+ const expected = Math.min(leftChunk.length, size - position);
46
+ const nLeft = readSync(a, leftChunk, 0, expected, position);
47
+ const nRight = readSync(b, rightChunk, 0, expected, position);
48
+ if (nLeft !== nRight || nLeft === 0 || !leftChunk.subarray(0, nLeft).equals(rightChunk.subarray(0, nRight)))
49
+ return false;
50
+ position += nLeft;
51
+ }
52
+ return true;
53
+ }
54
+ finally {
55
+ closeSync(a);
56
+ if (b !== undefined)
57
+ closeSync(b);
58
+ }
59
+ }
60
+ function differingFiles(left, right) {
61
+ const a = treeEntries(left);
62
+ const b = treeEntries(right);
63
+ return [...new Set([...a.keys(), ...b.keys()])].sort().filter((name) => {
64
+ const x = a.get(name);
65
+ const y = b.get(name);
66
+ if (!x || !y || x.kind !== y.kind)
67
+ return true;
68
+ if (x.kind === "file" && y.kind === "file")
69
+ return x.size !== y.size || !sameFileBytes(x.path, y.path, x.size);
70
+ if (x.kind === "symlink" && y.kind === "symlink")
71
+ return x.target !== y.target;
72
+ return x.kind === "other" && y.kind === "other" && x.mode !== y.mode;
73
+ });
74
+ }
75
+ function shellQuote(value) { return "'" + value.replace(/'/g, "'\\''") + "'"; }
76
+ function conflictHint(current, old, currentName) {
77
+ let backup = old + ".conflict";
78
+ for (let n = 2; existsSync(backup); n++)
79
+ backup = old + ".conflict-" + n;
80
+ return "After reviewing the differences, keep " + current + " as the active copy and preserve the other at " + backup + ": mv -- " + shellQuote(old) + " " + shellQuote(backup) + " && ln -s -- " + shellQuote(currentName) + " " + shellQuote(old);
81
+ }
82
+ function conflictFiles(current, old, names, currentName) {
83
+ const details = names.map((name) => {
84
+ const a = join(current, name);
85
+ const b = join(old, name);
86
+ return (present(a) ? a : a + " (missing)") + " <> " + (present(b) ? b : b + " (missing)");
87
+ });
88
+ return new CliError("directory_conflict", "both " + current + " and " + old + " are real directories with different files: " + details.join("; "), conflictHint(current, old, currentName));
89
+ }
90
+ let quarantineSequence = 0;
91
+ function quarantinePath(old) {
92
+ let path;
93
+ do {
94
+ path = old + ".b9s-migrating-" + process.pid + "-" + quarantineSequence++;
95
+ } while (existsSync(path));
96
+ return path;
97
+ }
18
98
  /** Resolve a renamed state directory, preserving old paths through a symlink. */
19
99
  export function renamedDirectory(parent, currentName, oldName, report = true) {
20
100
  const current = join(parent, currentName);
@@ -23,9 +103,31 @@ export function renamedDirectory(parent, currentName, oldName, report = true) {
23
103
  const oldDir = directory(old);
24
104
  const currentExists = present(current);
25
105
  const oldExists = present(old);
26
- if (currentDir && oldDir)
27
- throw new CliError("directory_conflict", `both ${current} and ${old} are real directories; merge or remove one explicitly before continuing`);
28
- if (!currentExists && oldDir) {
106
+ if (currentDir && oldDir) {
107
+ const different = differingFiles(current, old);
108
+ if (different.length)
109
+ throw conflictFiles(current, old, different, currentName);
110
+ const quarantine = quarantinePath(old);
111
+ renameSync(old, quarantine);
112
+ const changedDuringMove = differingFiles(current, quarantine);
113
+ if (changedDuringMove.length) {
114
+ if (!present(old))
115
+ renameSync(quarantine, old);
116
+ throw conflictFiles(current, present(old) ? old : quarantine, changedDuringMove, currentName);
117
+ }
118
+ try {
119
+ symlinkSync(currentName, old, "dir");
120
+ }
121
+ catch (error) {
122
+ if (!present(old))
123
+ renameSync(quarantine, old);
124
+ throw error;
125
+ }
126
+ rmSync(quarantine, { recursive: true });
127
+ if (report)
128
+ process.stderr.write("[b9s] kept identical " + current + "; removed duplicate " + old + "; " + oldName + " now links to " + currentName + "\n");
129
+ }
130
+ else if (!currentExists && oldDir) {
29
131
  renameSync(old, current);
30
132
  symlinkSync(currentName, old, "dir");
31
133
  if (report)
@@ -67,9 +169,10 @@ export function repoDirectory(root) {
67
169
  const currentBefore = maybeLstat(currentPath);
68
170
  const oldBefore = maybeLstat(oldPath);
69
171
  const migration = oldBefore?.isDirectory() === true && currentBefore === null;
172
+ const identicalCopies = oldBefore?.isDirectory() === true && currentBefore?.isDirectory() === true;
70
173
  const compatibilityLink = oldBefore?.isSymbolicLink() === true && currentBefore?.isDirectory() === true;
71
174
  const current = renamedDirectory(root, ".b9s", ".bschat");
72
- if ((migration || compatibilityLink) && existsSync(join(root, ".git"))) {
175
+ if ((migration || identicalCopies || compatibilityLink) && existsSync(join(root, ".git"))) {
73
176
  const ignore = join(root, ".gitignore");
74
177
  const contents = existsSync(ignore) ? readFileSync(ignore, "utf8") : "";
75
178
  const lines = contents.split("\n");
package/dist/errors.js CHANGED
@@ -7,3 +7,5 @@ export class CliError extends Error {
7
7
  this.hint = hint;
8
8
  }
9
9
  }
10
+ /** systemd's EX_CONFIG status: stop restarting a watcher until its local configuration is fixed. */
11
+ export const DIRECTORY_CONFLICT_EXIT_CODE = 78;
package/dist/harnesses.js CHANGED
@@ -4,6 +4,7 @@ import { homedir } from "node:os";
4
4
  import { dirname, join } from "node:path";
5
5
  import { CliError } from "./errors.js";
6
6
  import { configRoot } from "./config.js";
7
+ import { readState, writeState } from "./state.js";
7
8
  import { codexArchivedRollout, codexRollout } from "./sessions.js";
8
9
  import { codexTurnPhase, usageLimitUntil } from "./turn.js";
9
10
  /**
@@ -13,16 +14,221 @@ import { codexTurnPhase, usageLimitUntil } from "./turn.js";
13
14
  * last turn ended. Antigravity is a desktop application with no headless turn and stays hand-run;
14
15
  * Gemini CLI no longer accepts personal logins (Google moved individuals to Antigravity).
15
16
  */
16
- export const TURN_HARNESSES = ["codex", "claude-code"];
17
+ export const TURN_HARNESSES = ["codex", "claude-code", "dsh"];
17
18
  export function turnHarness(h) {
18
19
  if (TURN_HARNESSES.includes(h))
19
20
  return h;
20
21
  throw new CliError("unsupported", `harness ${h} cannot run headless turns; supported: ${TURN_HARNESSES.join(", ")}`);
21
22
  }
22
- export const HARNESS_LABEL = { codex: "Codex", "claude-code": "Claude Code" };
23
- export const HARNESS_BIN = { codex: "codex", "claude-code": "claude" };
23
+ export const HARNESS_LABEL = { codex: "Codex", "claude-code": "Claude Code", dsh: "DeepSeek Harness" };
24
+ export const HARNESS_BIN = { codex: "codex", "claude-code": "claude", dsh: "dsh" };
24
25
  export function probeFor(harness, session, ref) {
25
- return harness === "codex" ? codexProbe(session) : claudeProbe(session, ref);
26
+ return harness === "codex" ? codexProbe(session) : harness === "claude-code" ? claudeProbe(session, ref) : dshProbe(session, ref);
27
+ }
28
+ export const dshTurnLog = (ref) => join(configRoot(), "logs", `turn.${ref.replace("/", ".")}.jsonl`);
29
+ /** The first session event identifies a newly-created DeepSeek Harness session. */
30
+ export function dshSessionFromEvents(text) {
31
+ for (const line of text.split("\n")) {
32
+ try {
33
+ const event = JSON.parse(line);
34
+ if (event.type === "session" && typeof event.sessionId === "string" && event.sessionId)
35
+ return event.sessionId;
36
+ }
37
+ catch { /* a line may still be streaming */ }
38
+ }
39
+ return null;
40
+ }
41
+ function dshEvents(text) {
42
+ return text.split("\n").flatMap((line) => {
43
+ try {
44
+ return [JSON.parse(line)];
45
+ }
46
+ catch {
47
+ return [];
48
+ }
49
+ });
50
+ }
51
+ function latestDshInvocation(text) {
52
+ let offset = 0;
53
+ let start = -1;
54
+ for (const line of text.split("\n")) {
55
+ try {
56
+ const event = JSON.parse(line);
57
+ if (event.type === "b9s_invocation_start")
58
+ start = offset;
59
+ }
60
+ catch { /* dsh can stream a partial final line */ }
61
+ offset += line.length + 1;
62
+ }
63
+ return start >= 0 ? text.slice(start) : text;
64
+ }
65
+ /** State of the latest turn in the dsh JSON event log. */
66
+ export function dshTurnPhase(text) {
67
+ let running = false;
68
+ let lastError = null;
69
+ for (const e of dshEvents(text)) {
70
+ if (e.type === "status" && e.phase === "turn_start") {
71
+ running = true;
72
+ lastError = null;
73
+ }
74
+ else if (e.type === "error") {
75
+ lastError = typeof e.message === "string" ? e.message : "DeepSeek Harness reported an error";
76
+ }
77
+ else if (e.type === "status" && e.phase === "turn_end") {
78
+ running = false;
79
+ if (e.reason?.kind !== "completed")
80
+ lastError = typeof e.message === "string" ? e.message : `turn ended: ${e.reason?.kind ?? "unknown reason"}`;
81
+ }
82
+ else if (e.type === "final") {
83
+ running = false;
84
+ if (e.reason?.kind === "completed")
85
+ lastError = null;
86
+ else
87
+ lastError = typeof e.message === "string" ? e.message : `final event reason: ${e.reason?.kind ?? "unknown reason"}`;
88
+ }
89
+ }
90
+ return { running, startedAt: null, lastEventAt: null, lastError };
91
+ }
92
+ /** Error from the current recorded turn; success requires its completed final event. */
93
+ export function dshResultError(text) {
94
+ const events = dshEvents(text);
95
+ const invocationEnd = [...events].reverse().find((e) => e.type === "b9s_invocation_end");
96
+ const exitCode = typeof invocationEnd?.exit === "number" ? invocationEnd.exit : null;
97
+ const diagnostic = text.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("{")).at(-1);
98
+ let start = -1;
99
+ for (let i = 0; i < events.length; i++)
100
+ if (events[i].type === "status" && events[i].phase === "turn_start")
101
+ start = i;
102
+ const turn = events.slice(start >= 0 ? start : 0);
103
+ for (const e of turn)
104
+ if (e.type === "error")
105
+ return (typeof e.message === "string" ? e.message : "DeepSeek Harness reported an error").slice(0, 500);
106
+ for (const e of turn)
107
+ if (e.type === "status" && e.phase === "turn_end" && e.reason?.kind !== "completed")
108
+ return (typeof e.message === "string" ? e.message : `turn ended: ${e.reason?.kind ?? "unknown reason"}`).slice(0, 500);
109
+ let finalIndex = -1;
110
+ for (let i = turn.length - 1; i >= 0; i--)
111
+ if (turn[i].type === "final") {
112
+ finalIndex = i;
113
+ break;
114
+ }
115
+ const final = finalIndex >= 0 ? turn[finalIndex] : undefined;
116
+ if (final?.reason?.kind === "completed") {
117
+ if (exitCode === null || exitCode === 0)
118
+ return null;
119
+ return `DeepSeek Harness exited with code ${exitCode}${diagnostic ? `: ${diagnostic}` : ""}`.slice(0, 500);
120
+ }
121
+ if (final)
122
+ return (typeof final.message === "string" ? final.message : `final event reason: ${final.reason?.kind ?? "unknown reason"}`).slice(0, 500);
123
+ if (exitCode !== null && exitCode !== 0)
124
+ return (diagnostic ?? `DeepSeek Harness exited with code ${exitCode}`).slice(0, 500);
125
+ return (diagnostic ?? "DeepSeek Harness exited without a completed final event").slice(0, 500);
126
+ }
127
+ /** DeepSeek emits per-step usage; sum it over the accumulated per-agent turn log. */
128
+ export function dshUsage(text, since, until) {
129
+ const result = { input: 0, cached_input: 0, output: 0, reasoning: 0, total: 0 };
130
+ const window = since !== undefined && until !== undefined ? { since: Date.parse(since), until: Date.parse(until) } : null;
131
+ let invocationAt = null;
132
+ for (const e of dshEvents(text)) {
133
+ if (e.type === "b9s_invocation_start") {
134
+ invocationAt = typeof e.at === "string" ? Date.parse(e.at) : null;
135
+ continue;
136
+ }
137
+ if (e.type === "b9s_invocation_end") {
138
+ invocationAt = null;
139
+ continue;
140
+ }
141
+ if (e.type !== "status" || e.phase !== "step_end" || !e.usage)
142
+ continue;
143
+ if (window && (invocationAt === null || invocationAt < window.since || invocationAt > window.until))
144
+ continue;
145
+ result.input += (e.usage.inputTokens ?? 0) + (e.usage.cacheReadTokens ?? 0) + (e.usage.cacheWriteTokens ?? 0);
146
+ result.cached_input += e.usage.cacheReadTokens ?? 0;
147
+ result.output += e.usage.outputTokens ?? 0;
148
+ }
149
+ result.total = result.input + result.output;
150
+ return result;
151
+ }
152
+ /** Map the user's selected sandbox to dsh's native permission mode and writable roots. */
153
+ export function dshSettings(sandbox, cwd, b9sHome, extraWritable = []) {
154
+ if (sandbox === "read-only")
155
+ throw new CliError("unsupported", "DeepSeek Harness has no read-only permission mode; use workspace-write or danger-full-access");
156
+ if (sandbox !== "workspace-write" && sandbox !== "danger-full-access")
157
+ throw new CliError("usage", `unknown sandbox ${sandbox}`);
158
+ const dirs = [...new Set([dirname(cwd), b9sHome, ...extraWritable])];
159
+ return ["--permission-mode", sandbox, "--approval-policy", "never", ...dirs.flatMap((dir) => ["--add-dir", dir])];
160
+ }
161
+ /** Locate dsh explicitly, in the macOS app bundle, or on PATH. */
162
+ export function dshPath(explicit, pathEnv = process.env.PATH ?? "", os = process.platform, home = homedir(), fileExists = existsSync) {
163
+ if (explicit)
164
+ return explicit;
165
+ const candidates = os === "darwin" ? [
166
+ "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh",
167
+ join(home, "Applications", "DeepSeek Harness.app", "Contents", "Resources", "runtime", "cli", "bin", "dsh"),
168
+ ] : [];
169
+ candidates.push(...pathEnv.split(":").filter(Boolean).map((dir) => join(dir, "dsh")));
170
+ return candidates.find(fileExists) ?? null;
171
+ }
172
+ /** The machine daemon reports dsh presence and version; this trial found no Linux distribution. */
173
+ export function dshFacts(os = process.platform, pathEnv = process.env.PATH ?? "", home = homedir()) {
174
+ if (os === "linux")
175
+ return { available: false, path: null, version: null, error: "DeepSeek Harness has no Linux build" };
176
+ const path = dshPath(undefined, pathEnv, os, home);
177
+ if (!path)
178
+ return { available: false, path: null, version: null, error: "DeepSeek Harness dsh CLI was not found in the app bundle or PATH" };
179
+ const version = spawnSync(path, ["--version"], { encoding: "utf8", timeout: 30_000 });
180
+ if (version.status !== 0)
181
+ return { available: false, path, version: null, error: `${path} --version failed: ${(version.stderr || version.stdout || `exit ${version.status}`).trim().slice(0, 250)}` };
182
+ return { available: true, path, version: version.stdout.trim(), error: null };
183
+ }
184
+ export function isDshCommand(args) {
185
+ return /^(?:dsh|\/.*\/dsh)(?:\.exe)?\s/.test(args.trimStart());
186
+ }
187
+ /** Processes whose own command is dsh and whose arguments name this session. */
188
+ export function dshProcesses(session, psOutput, initialPid) {
189
+ const out = psOutput ?? (spawnSync("ps", ["-axo", "pid=,pcpu=,rss=,args="], { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 }).stdout ?? "");
190
+ const found = [];
191
+ for (const line of out.split("\n")) {
192
+ const m = /^\s*(\d+)\s+([\d.]+)\s+(\d+)\s+(.*)$/.exec(line);
193
+ const pid = Number(m?.[1]);
194
+ const isSession = !!m && new RegExp(`(?:^|\\s)--session-id\\s+['\"]?${escapeRegExp(session)}(?:['\"]?(?:\\s|$))`).test(m[4]);
195
+ const isInitial = !!m && pid === initialPid;
196
+ if (m && isDshCommand(m[4]) && (isSession || isInitial))
197
+ found.push({ pid, cpu: Number(m[2]), rss_bytes: Number(m[3]) * 1024, args: m[4] });
198
+ }
199
+ return found;
200
+ }
201
+ function escapeRegExp(text) { return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); }
202
+ export function dshProbe(session, ref, path = dshTurnLog(ref), processes) {
203
+ const readBytes = () => existsSync(path) ? readFileSync(path) : Buffer.alloc(0);
204
+ const read = () => readBytes().toString("utf8");
205
+ const readInvocation = (offset) => readBytes().subarray(offset).toString("utf8");
206
+ let invocationOffset = 0;
207
+ return {
208
+ label: "DeepSeek Harness", what: `session ${session}`,
209
+ phase() {
210
+ if (!existsSync(path))
211
+ return { missing: `no DeepSeek Harness turn log ${path}; cannot tell whether session ${session} is running` };
212
+ const phase = dshTurnPhase(read());
213
+ const stat = statSync(path);
214
+ const initialPid = readState(ref).harness_session?.initial_pid;
215
+ const live = processes ? processes(initialPid) : dshProcesses(session, undefined, initialPid);
216
+ const lastError = live.length ? phase.lastError : dshResultError(latestDshInvocation(read())) ?? phase.lastError;
217
+ return { ...phase, running: live.length > 0, lastError, lastEventAt: stat.mtime.toISOString(), lastErrorAt: stat.mtime.toISOString() };
218
+ },
219
+ beginTurn() {
220
+ invocationOffset = existsSync(path) ? statSync(path).size : 0;
221
+ const state = readState(ref);
222
+ if (state.harness_session?.initial_pid) {
223
+ const { initial_pid: _initialPid, ...session } = state.harness_session;
224
+ writeState(ref, { ...state, harness_session: session });
225
+ }
226
+ },
227
+ startedSince() { return dshEvents(readInvocation(invocationOffset)).some((e) => e.type === "status" && e.phase === "turn_start"); },
228
+ turnError: () => dshResultError(readInvocation(invocationOffset)),
229
+ limitUntil: () => null,
230
+ isLimit: () => false,
231
+ };
26
232
  }
27
233
  function codexProbe(thread) {
28
234
  const read = () => { const r = codexRollout(thread); return r ? codexTurnPhase(readFileSync(r, "utf8")) : null; };
package/dist/help.js CHANGED
@@ -100,6 +100,8 @@ Agent commands
100
100
  b9s wu rule <n> "decision" | --approve the tag's expert: answer an open question, or approve its proposal as written (operator questions are answered in the console)
101
101
  b9s wu propose <n> "answer" owner, reviewer, assigner or expert: recommend an answer to the unit's open question, approvable as written
102
102
  b9s wu escalate <n> [--note ..] the tag's expert: pass the question to the operator
103
+ b9s wu wait <n> --on <m> --note "why" | --clear
104
+ owner, assigner or operator: wait for any non-closed unit; released when it closes
103
105
  b9s wu wait <n> --on "evidence|unit #m|ask id|machine name|text blocker" --note "why" [--partial "verdict"] | --clear
104
106
  owner or reviewer: pause review on a named blocker; reviewer may record a partial verdict
105
107
  b9s wu scope <n> --scope ".." | --scope-file <path> | --scope-from <n> --note ".." assigner or operator: replace the full scope; recorded and announced
@@ -135,19 +137,20 @@ Agent commands
135
137
  --env A,B copies those variables from this shell into the LaunchAgent (Antigravity needs
136
138
  ANTIGRAVITY_LS_ADDRESS,ANTIGRAVITY_CSRF_TOKEN). --full queues the text itself. --once /
137
139
  --service (launchd on macOS, systemd on Linux; --launchd is the same). --turn runs each turn
138
- itself (--harness codex|claude-code --session <id>); set up by b9s start.
140
+ itself (--harness codex|claude-code|dsh --session <id>); set up by b9s start.
139
141
  Codex: b9s watch --exec "codex queue --thread <id> --message {summary}" --service
140
- b9s update the same as install --latest: upgrade this machine's b9s and restart its watchers
141
- b9s install [<version> | --latest] make or upgrade this machine's one b9s (join does it once) and restart
142
- the watchers on it; hooks, repo instructions and watchers all run its path
142
+ b9s update the same as install --latest: upgrade this machine's b9s, repair PATH aliases,
143
+ restart services on that install without waiting on one stop, and report failures
144
+ b9s install [<version> | --latest] make or upgrade this machine's one b9s (join does it once), repair PATH aliases,
145
+ restart services resolving to it; other installs are left alone and named
143
146
  b9s doctor every b9s on this machine and who runs which (PATH, npx caches, this repo's
144
147
  hook and instructions, each watcher's plist versus what launchd runs), with fixes
145
148
  b9s codex hooks | bind <thread-id> | sync install b9s's Codex hooks (~/.codex/hooks.json) and say which thread is you
146
- b9s start --harness codex|claude-code --as <a> --sandbox <mode> [--token t] [--thread id] [--model m] [--effort e]
149
+ b9s start --harness codex|claude-code|dsh --as <a> --sandbox <mode> [--token t] [--thread id] [--model m] [--effort e] [--dsh path]
147
150
  run an agent headless: enroll, start or adopt its session, turn-mode watcher
148
151
  (b9s codex start is the same with --harness codex)
149
152
  b9s unpause [--as <a>] lift a usage-limit pause now (the harness was switched to an account with quota)
150
- b9s machine run | once | status | prepare | service the machine daemon (set up by b9s-admin machine add)
153
+ b9s machine run | once | status | prepare | service the machine daemon (prepare checks dsh availability/version; Linux reports no DeepSeek build)
151
154
  b9s checkpoint "<title>" --body "..." a resume note without retiring: what you are doing, open threads, next steps;
152
155
  your next session (after a move to another machine) reads it first
153
156
  b9s antigravity bind <conversation-id> | sync which Antigravity conversation is you, for its hook (watchers bind theirs)
@@ -162,7 +165,7 @@ Agent commands
162
165
  b9s channel create <name> [--topic t] needs create_channels permission
163
166
  b9s agents
164
167
  b9s roles
165
- b9s evidence post <file> [--label t] [--kind test|diagnosis|review|screenshot|log|other] [--claim "one line"] [--type ct] [--name fn] checksummed evidence
168
+ b9s evidence post <file> [--label t] [--kind test|diagnosis|review|screenshot|log|other] [--claim "one line"] [--type ct] [--name fn] checksummed raw bytes; prints stored content type
166
169
  b9s evidence list [--limit n] [--unit n] [--kind k]
167
170
  b9s evidence info <id|sha256>
168
171
  b9s evidence get <id|sha256> [--out path] verifies sha256 on download
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import { doctor, install } from "./commands/install.js";
19
19
  import { warnIfForeignCopy } from "./install.js";
20
20
  import { processCmd, record, wu, milestones, milestone, lock, askOperator, explainAsk } from "./commands/wu.js";
21
21
  import { worktrees } from "./commands/worktrees.js";
22
- import { CliError } from "./errors.js";
22
+ import { CliError, DIRECTORY_CONFLICT_EXIT_CODE } from "./errors.js";
23
23
  import { HELP } from "./help.js";
24
24
  import { CLI_VERSION } from "./version.js";
25
25
  import { makeOut } from "./output.js";
@@ -106,6 +106,7 @@ const COMMANDS = {
106
106
  const NOTICE_PREFLIGHT_EXEMPT_COMMANDS = new Set([
107
107
  "join", "setup", "login", "logout", "identities", "skill", "hook", "machine", "install", "doctor", "update", "version", "admin", "start",
108
108
  ]);
109
+ let invokedCommand;
109
110
  async function main(argv) {
110
111
  warnLegacyAlias();
111
112
  applyEnvAliases();
@@ -116,6 +117,7 @@ async function main(argv) {
116
117
  return 0;
117
118
  }
118
119
  const cmd = p.positionals[0];
120
+ invokedCommand = cmd;
119
121
  if (!cmd || bool(p.flags, "help")) {
120
122
  process.stdout.write(HELP);
121
123
  return cmd ? 0 : 2;
@@ -145,7 +147,10 @@ async function main(argv) {
145
147
  return code ?? 0;
146
148
  }
147
149
  main(process.argv.slice(2)).then((code) => { process.exitCode = code; }, (err) => {
148
- const e = err instanceof CliError ? { error: err.code, message: err.message, hint: err.hint } : { error: "internal", message: err instanceof Error ? err.stack ?? err.message : String(err) };
149
- process.exitCode = 1;
150
+ const isWatcherDirectoryConflict = err instanceof CliError && err.code === "directory_conflict" && invokedCommand === "watch";
151
+ const e = err instanceof CliError
152
+ ? { error: err.code, message: err.message, hint: err.hint, ...(isWatcherDirectoryConflict ? { watcher_exit: true } : {}) }
153
+ : { error: "internal", message: err instanceof Error ? err.stack ?? err.message : String(err) };
154
+ process.exitCode = isWatcherDirectoryConflict ? DIRECTORY_CONFLICT_EXIT_CODE : 1;
150
155
  process.stderr.write(JSON.stringify(e) + "\n");
151
156
  });