@botbuddy/cli 1.123.1 → 1.123.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.123.3
4
+
5
+ - BOT-3667: a new Claude session in a reused worktree connects to BB at once. Claude Desktop reuses worktree folders, and the previous session's BB identity was treated as live for 30 minutes after its transcript was last written, so the new session's band showed "BB identity belongs to another session" and the SessionStart hook did not register it. `bb status-band read` and `bb bootstrap --type claude` now ask Claude's running-session registry (`~/.claude/sessions/<pid>.json`, kept only while a session's process runs): a holder with no entry for a live process has exited, and its cache is set aside at once. A holder that is still running is never taken over. A host with no readable registry, and a holder with no Claude transcript (another harness), keep the previous rules. The band (1.12.2) also retries recoverable identity failures (`session_mismatch`, `session_missing`, `session_bind_failed`, `session_renewal_failed`, `session_changed`) by itself on the same 30 s to 5 min backoff, so it binds once the other session exits. Configuration failures still wait for a fix.
6
+
7
+ ## 1.123.2
8
+
9
+ - BOT-3660: when staging is red, the bb-status band's `Open staging ↗` opens `/release-readiness/staging/sha/<red commit>?tenant=<tenant>`, the failing release in the tenant whose staging is red, instead of `/release-readiness/staging/latest` in whichever tenant the browser had active. `bb status-band read` passes the new `staging.red_sha` from `get_session_status` (a full SHA only); without one the link is `/release-readiness/staging/latest?tenant=<tenant>`. The plugin version moves to 1.12.1, so `bb update` installs it.
10
+
3
11
  ## 1.123.1
4
12
 
5
13
  - BOT-3596: the fleet host daemon stays up when the control plane answers HTTP 402 with no BotBuddy error code, which is how the hosting provider answers every call while it restricts the project (2026-11-18: about six hours, 288 daemon exits on each Linux host). The daemon now treats that 402 like a 5xx: it keeps polling every 15 s, admits no work, logs one `foreground cycle deferred: … cause=control_plane_http_402` line for the whole outage and one `recovered after=<s>` line when the control plane answers again, and re-registers on the next poll. A 402 that carries a BotBuddy refusal code, and every 401 or 403, still stop the daemon as before.
@@ -11,7 +11,7 @@
11
11
  "name": "bb-status",
12
12
  "source": "./bb-status",
13
13
  "description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, for BotBuddy and Supply Guard sessions",
14
- "version": "1.12.0"
14
+ "version": "1.12.2"
15
15
  },
16
16
  {
17
17
  "name": "bb-session",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bb-status",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, live only while the session is on screen.",
5
5
  "author": {
6
6
  "name": "BotBuddy"
@@ -24,8 +24,9 @@ no band at all. Normal Chat and Cowork do not load this UI.
24
24
  failed read shows "Couldn't read …" instead, never the empty state. Each PR row
25
25
  shows its code-review rounds (`pr_state.review_rounds`, which `get_pr_state`
26
26
  returns as `reviewRounds`). While the tenant's staging is red, a `▲ Staging red`
27
- banner links to `/release-readiness/staging/latest`, the web Staging chip's
28
- status and link. Unreadable staging says `staging: couldn't read`, never green.
27
+ banner links to the failing release in that tenant (BOT-3660):
28
+ `/release-readiness/staging/sha/<red_sha>?tenant=<tenant>`, or
29
+ `/release-readiness/staging/latest?tenant=<tenant>` when BB names no commit. Unreadable staging says `staging: couldn't read`, never green.
29
30
  The relay is parked, with no child and no server wait, while
30
31
  `$.session.surfaces()` is empty, which is the case while Desktop shows another
31
32
  session. Once a surface draws the session again, the 5 s display tick does one
@@ -22,6 +22,11 @@ let relayFault = null;
22
22
  // BOT-3644 AC-4/5: a transient read failure keeps the last good snapshot on
23
23
  // screen (marked STALE with its code) and retries by itself with backoff.
24
24
  const TRANSIENT = new Set(["source_unreachable", "source_unavailable", "invalid_response", "status_unavailable"]);
25
+ // BOT-3667 AC-4: identity failures that clear on their own (another live session
26
+ // holds the worktree until it exits; a bind, renewal or read that raced) clear
27
+ // the drawn status, as any identity failure must, and retry on the same backoff.
28
+ const RECOVERABLE = new Set(["session_mismatch", "session_missing", "session_bind_failed", "session_renewal_failed", "session_changed"]);
29
+ const retries = (code) => TRANSIENT.has(code) || RECOVERABLE.has(code);
25
30
  const READ_RETRY_FIRST_MS = 30000;
26
31
  const READ_RETRY_MAX_MS = 300000;
27
32
  let readFault = null;
@@ -321,6 +326,8 @@ function validSnapshot(value, harness, now) {
321
326
  typeof value.staging.configured === "boolean" &&
322
327
  typeof value.staging.red === "boolean" &&
323
328
  (value.staging.since === null || Number.isFinite(Date.parse(value.staging.since))) &&
329
+ // BOT-3660: the red commit is a full lower-case SHA or absent; it goes into a URL.
330
+ (value.staging.red_sha === undefined || (typeof value.staging.red_sha === "string" && /^[0-9a-f]{40}$/.test(value.staging.red_sha))) &&
324
331
  // BOT-3241: the release manager: absent (unknown), null (none) or a
325
332
  // safe name with a verified session link or none.
326
333
  (value.staging.release_manager == null ||
@@ -373,8 +380,11 @@ const LINKS = {
373
380
  wait: (id) => APP + "/waits?wait=" + id,
374
381
  // BOT-3394: a push held for compute opens /waits, where every held push is listed.
375
382
  pushes: APP + "/waits",
376
- // BOT-3152 AC-2: the web top bar's Staging chip link (STAGING_HREF).
377
- staging: APP + "/release-readiness/staging/latest",
383
+ // BOT-3152 AC-2 / BOT-3660: the red tenant's failing release. The web app's
384
+ // deep-link resolver switches to `tenant` (membership-gated) before the page
385
+ // reads; without a known commit it opens that tenant's newest staging SHA.
386
+ staging: (tenant, sha) =>
387
+ APP + "/release-readiness/staging/" + (sha ? "sha/" + sha : "latest") + "?tenant=" + encodeURIComponent(tenant),
378
388
  // BOT-3501: the web top bar's Docker queue chip link (the /docker Queue section).
379
389
  dockerQueue: APP + "/docker#docker-queue",
380
390
  };
@@ -567,7 +577,7 @@ async function refresh($, { wake = false, keep = false } = {}) {
567
577
  snapshot = null;
568
578
  readFault = null;
569
579
  }
570
- if (TRANSIENT.has(errorCode)) retryRead($, request);
580
+ if (retries(errorCode)) retryRead($, request);
571
581
  else readBackoffMs = 0;
572
582
  // BOT-3222: the hook is still registering this session; read once more
573
583
  // when the adapter says, unless another read has started since.
@@ -602,7 +612,7 @@ function retryRead($, request) {
602
612
  const after = readBackoffMs;
603
613
  void (async () => {
604
614
  await delay($, after + 500);
605
- if (request !== generation || mode !== "live" || !TRANSIENT.has(errorCode)) return;
615
+ if (request !== generation || mode !== "live" || !retries(errorCode)) return;
606
616
  if (parked || !(await onScreen($))) {
607
617
  parked = true;
608
618
  return;
@@ -1432,7 +1442,7 @@ function blockerBadges(el, $, key, s) {
1432
1442
  if (s.blockers.length > out.length) out.push(dim(el, "+" + (s.blockers.length - out.length) + " more"));
1433
1443
  return out;
1434
1444
  }
1435
- function stagingBanner(el, $, key, since, rm) {
1445
+ function stagingBanner(el, $, key, since, rm, href) {
1436
1446
  const text = "▲ Staging red" + (since ? " " + shortAge(since, currentTime) : "");
1437
1447
  return el.Box({
1438
1448
  key,
@@ -1452,7 +1462,7 @@ function stagingBanner(el, $, key, since, rm) {
1452
1462
  children: [el.Text({ color: "#ffffff", bold: true, children: [text] })],
1453
1463
  }),
1454
1464
  ...releaseManager(el, $, rm),
1455
- el.Link({ href: LINKS.staging, label: "Open staging ↗" }),
1465
+ el.Link({ href, label: "Open staging ↗" }),
1456
1466
  ],
1457
1467
  });
1458
1468
  }
@@ -1603,7 +1613,7 @@ function bandLines(el, $, inPane) {
1603
1613
  const statuses = [
1604
1614
  // BOT-3286: the project's coordinator leads the first row.
1605
1615
  ...(s.epic ? coordinatorBadge(el, $, k("line-coordinator"), s.epic.coordinator) : []),
1606
- ...(s.staging?.red ? [stagingBanner(el, $, k("line-staging"), s.staging.since, s.staging.release_manager)] : []),
1616
+ ...(s.staging?.red ? [stagingBanner(el, $, k("line-staging"), s.staging.since, s.staging.release_manager, LINKS.staging(s.tenant, s.staging.red_sha))] : []),
1607
1617
  ...contextBadge(el, k("line-context")),
1608
1618
  ...uncategorisedBadge(el, k("line-project"), s.epic),
1609
1619
  // BOT-3501: whether a new session would join a host queue.
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.123.1",
3
- "source_commit": "b144ad9539e51f35fb6946ec6c1db45d0dfefa3b",
4
- "source_sha256": "3fcb83f2fb2e31030d5ac00332049fce0560ba9c4f85f156fca8748765fe6496",
2
+ "release_version": "1.123.3",
3
+ "source_commit": "81598ae767d6a28ec5615319c87b45a56292c6ab",
4
+ "source_sha256": "dfda001e9197f3e42cc30d57a182f8b4d39adbc1cd21e3ffd4bef5764345f61d",
5
5
  "target": "darwin-arm64",
6
- "sha256": "42f0bb138f5207db53af57a0a8df863317b3f0d9475847236561c5f0679a738e"
6
+ "sha256": "efddc5acb85b5f35ca797c9119dceb918ba618e14e445c62a4079db5a95abdc8"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.123.1",
3
- "source_commit": "b144ad9539e51f35fb6946ec6c1db45d0dfefa3b",
4
- "source_sha256": "3fcb83f2fb2e31030d5ac00332049fce0560ba9c4f85f156fca8748765fe6496",
2
+ "release_version": "1.123.3",
3
+ "source_commit": "81598ae767d6a28ec5615319c87b45a56292c6ab",
4
+ "source_sha256": "dfda001e9197f3e42cc30d57a182f8b4d39adbc1cd21e3ffd4bef5764345f61d",
5
5
  "target": "linux-x64",
6
- "sha256": "91492c277027390e0eb8461ade1d360b3259454189f951fe1f5e3f10890f6be1"
6
+ "sha256": "e789286cb13b8220cf074c412d7f00c93d3d4795107f6ee89ba87b1723fb997f"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.123.1",
4
- "source_commit": "b144ad9539e51f35fb6946ec6c1db45d0dfefa3b",
5
- "source_sha256": "3fcb83f2fb2e31030d5ac00332049fce0560ba9c4f85f156fca8748765fe6496",
3
+ "release_version": "1.123.3",
4
+ "source_commit": "81598ae767d6a28ec5615319c87b45a56292c6ab",
5
+ "source_sha256": "dfda001e9197f3e42cc30d57a182f8b4d39adbc1cd21e3ffd4bef5764345f61d",
6
6
  "targets": {
7
7
  "darwin-arm64": {
8
8
  "goos": "darwin",
9
9
  "goarch": "arm64",
10
10
  "binary": "daemon/bin/darwin-arm64/botbuddy-daemon",
11
- "sha256": "42f0bb138f5207db53af57a0a8df863317b3f0d9475847236561c5f0679a738e",
11
+ "sha256": "efddc5acb85b5f35ca797c9119dceb918ba618e14e445c62a4079db5a95abdc8",
12
12
  "mode": "0755"
13
13
  },
14
14
  "linux-x64": {
15
15
  "goos": "linux",
16
16
  "goarch": "amd64",
17
17
  "binary": "daemon/bin/linux-x64/botbuddy-daemon",
18
- "sha256": "91492c277027390e0eb8461ade1d360b3259454189f951fe1f5e3f10890f6be1",
18
+ "sha256": "e789286cb13b8220cf074c412d7f00c93d3d4795107f6ee89ba87b1723fb997f",
19
19
  "mode": "0755"
20
20
  }
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbuddy/cli",
3
- "version": "1.123.1",
3
+ "version": "1.123.3",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -39,9 +39,64 @@ export async function worktreeHarnessSessionId(cwd, env = process.env) {
39
39
  }
40
40
  }
41
41
 
42
- // true: the holder's transcript was written within HOLDER_IDLE_MS; false: it
43
- // exists and has been silent longer; null: no transcript found (unknown).
44
- export async function claudeHolderActive(holder, worktree, { env = process.env, now = () => Date.now() } = {}) {
42
+ // BOT-3667: is the process still there? `kill(pid, 0)` sends nothing. Only
43
+ // ESRCH proves it gone; EPERM (someone else's process) or any other doubt
44
+ // counts as running, so a session that might be live is never taken over.
45
+ function processAlive(pid) {
46
+ try {
47
+ process.kill(pid, 0);
48
+ return true;
49
+ } catch (error) {
50
+ return error?.code !== "ESRCH";
51
+ }
52
+ }
53
+ // BOT-3667: Claude Code keeps <config>/sessions/<pid>.json ({ pid, sessionId,
54
+ // … }) for each running session and removes it on exit. true/false when the
55
+ // registry is readable and maintained (at least one well-formed entry, which
56
+ // the session running this command always has); null when it cannot tell.
57
+ async function claudeHolderRunning(id, env, alive) {
58
+ const dir = join(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"), "sessions");
59
+ let names;
60
+ try {
61
+ names = (await readdir(dir)).filter((name) => /^[0-9]{1,10}\.json$/.test(name));
62
+ } catch {
63
+ return null;
64
+ }
65
+ let maintained = false;
66
+ // Codex P2 on #2042: an entry that cannot be read (written mid-read, corrupt,
67
+ // missing its pid or sessionId) could be the holder's own, so "no entry for
68
+ // the holder" is no longer proof that it exited.
69
+ let unreadable = false;
70
+ for (const name of names) {
71
+ let entry;
72
+ try {
73
+ entry = JSON.parse(await readFile(join(dir, name), "utf8"));
74
+ } catch (error) {
75
+ if (error?.code !== "ENOENT") unreadable = true; // removed since readdir: its process exited
76
+ continue;
77
+ }
78
+ if (!Number.isSafeInteger(entry?.pid) || entry.pid <= 0 || typeof entry?.sessionId !== "string") {
79
+ unreadable = true;
80
+ continue;
81
+ }
82
+ maintained = true;
83
+ if (entry.sessionId.toLowerCase() !== id) continue;
84
+ let running;
85
+ try {
86
+ running = alive(entry.pid) !== false;
87
+ } catch (error) {
88
+ running = error?.code !== "ESRCH";
89
+ }
90
+ if (running) return true;
91
+ }
92
+ return maintained && !unreadable ? false : null;
93
+ }
94
+
95
+ // true: the holder is running (its registry entry names a live process) or,
96
+ // with no usable registry, its transcript was written within HOLDER_IDLE_MS;
97
+ // false: it has exited, or its transcript has been silent longer; null: no
98
+ // transcript found, so it is not known to be a Claude session (unknown).
99
+ export async function claudeHolderActive(holder, worktree, { env = process.env, now = () => Date.now(), alive = processAlive } = {}) {
45
100
  const id = String(holder || "").toLowerCase();
46
101
  if (!UUID_ONLY.test(id)) return null;
47
102
  const projects = claudeProjects(env);
@@ -66,6 +121,9 @@ export async function claudeHolderActive(holder, worktree, { env = process.env,
66
121
  }
67
122
  }
68
123
  if (at == null) return null;
124
+ // A known Claude session: the running-session registry decides when it can.
125
+ const running = await claudeHolderRunning(id, env, alive);
126
+ if (running !== null) return running;
69
127
  return now() - at < HOLDER_IDLE_MS;
70
128
  }
71
129
  // Returns false (never bind), true (bootstrap as is), or { aside } — another
@@ -72,6 +72,9 @@ function stagingOf(own) {
72
72
  if (!st || typeof st !== "object" || typeof st.configured !== "boolean") return null;
73
73
  const since = typeof st.open_since === "string" && Number.isFinite(Date.parse(st.open_since)) ? new Date(st.open_since).toISOString() : null;
74
74
  const out = { configured: st.configured, red: st.configured && since !== null, since: st.configured ? since : null };
75
+ // BOT-3660: the red commit, so the band's link opens that release. Only a full
76
+ // SHA ever reaches a URL; anything else is left out (the link then names the tenant only).
77
+ if (out.red && typeof st.red_sha === "string" && /^[0-9a-f]{40}$/i.test(st.red_sha)) out.red_sha = st.red_sha.toLowerCase();
75
78
  // BOT-3241: a red staging's elected release manager, linked only to a verified
76
79
  // Claude Desktop session or Codex thread. null = none elected; no key = BB did
77
80
  // not say (an older server, a failed read or an unsafe name): the band shows nothing.