@botbuddy/cli 1.85.0 → 1.85.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 +12 -0
- package/daemon/bin/darwin-arm64/botbuddy-daemon +0 -0
- package/daemon/bin/linux-x64/botbuddy-daemon +0 -0
- package/daemon-release/darwin-arm64.json +4 -4
- package/daemon-release/linux-x64.json +4 -4
- package/daemon-release/manifest.json +5 -5
- package/package.json +1 -1
- package/src/agent-doctor.mjs +4 -0
- package/src/agent-session.mjs +12 -1
- package/src/harness-holder.mjs +29 -10
- package/src/session-bootstrap.mjs +22 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.85.3
|
|
4
|
+
|
|
5
|
+
- Ships the `bb doctor --fix` reused-worktree repair to npm (BOT-3307). A sub-agent working in another worktree keeps that worktree's own identity.
|
|
6
|
+
|
|
7
|
+
## 1.85.2
|
|
8
|
+
|
|
9
|
+
- `bb doctor --fix` repairs the current session's identity in a reused worktree (BOT-3307): a Claude Desktop session whose transcript is in the worktree replaces a previous session's cache once that session has gone, instead of renewing it and leaving the bb-status band refusing with "BB identity belongs to another session". A session still active in the worktree keeps its cache, and doctor says so with `session_still_active`.
|
|
10
|
+
|
|
11
|
+
## 1.85.1
|
|
12
|
+
|
|
13
|
+
- `bb bootstrap` connects in a reused worktree when you are signed in as the owner (BOT-3253): another session's stale cached session is retired with its own credential instead of failing with `agent_identity_required`, and a cached credential the server no longer accepts is left to expire. A session that is still live keeps its cache and waits, and the command names it and says what to do next.
|
|
14
|
+
|
|
3
15
|
## 1.85.0
|
|
4
16
|
|
|
5
17
|
- `bb release-notes digest --release <version> --voice internal|external` prints one production release's notes as Markdown, JSON (the bbrn-digest-1 schema) or Slack Block Kit (`--format`), byte for byte as the API returns them when piped, so a GitHub Actions step can post it to your own Slack or email (BOT-3204). On a terminal, control characters in a note print as visible escapes. `--repository owner/name` names the repository when a version exists in more than one; `--json` prints the whole answer.
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.85.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.85.3",
|
|
3
|
+
"source_commit": "f50cff97138fdb3acd0b3f65cacdd5fed4fd3281",
|
|
4
|
+
"source_sha256": "ea892b69f5b20bb442632b518c1b29c3df3509296847cef4da168f52aec01be4",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "34b0c7bf77043626f94db8162888a65ecff5e964b24fcb57131076ae8d9775eb"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.85.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.85.3",
|
|
3
|
+
"source_commit": "f50cff97138fdb3acd0b3f65cacdd5fed4fd3281",
|
|
4
|
+
"source_sha256": "ea892b69f5b20bb442632b518c1b29c3df3509296847cef4da168f52aec01be4",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "8cdad6a23bbf3fecb3a140a7e5f8834ddd29cbca93af3733abe2e67130b10efe"
|
|
7
7
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
|
-
"release_version": "1.85.
|
|
4
|
-
"source_commit": "
|
|
5
|
-
"source_sha256": "
|
|
3
|
+
"release_version": "1.85.3",
|
|
4
|
+
"source_commit": "f50cff97138fdb3acd0b3f65cacdd5fed4fd3281",
|
|
5
|
+
"source_sha256": "ea892b69f5b20bb442632b518c1b29c3df3509296847cef4da168f52aec01be4",
|
|
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": "
|
|
11
|
+
"sha256": "34b0c7bf77043626f94db8162888a65ecff5e964b24fcb57131076ae8d9775eb",
|
|
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": "
|
|
18
|
+
"sha256": "8cdad6a23bbf3fecb3a140a7e5f8834ddd29cbca93af3733abe2e67130b10efe",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/agent-doctor.mjs
CHANGED
|
@@ -96,6 +96,10 @@ export function repairFailureRecovery(code, error = null) {
|
|
|
96
96
|
if (code === "client_key_unavailable") {
|
|
97
97
|
return "the client key could not be read (locked or failing credential store); unlock it, then run `bb doctor --fix`";
|
|
98
98
|
}
|
|
99
|
+
// BOT-3307: another session is still working in this worktree; its cache is kept.
|
|
100
|
+
if (code === "session_still_active") {
|
|
101
|
+
return "another session is still active in this worktree and keeps its identity; use another worktree, or run `bb doctor --fix` once that session has ended";
|
|
102
|
+
}
|
|
99
103
|
// BOT-1787: this is a server-side identity conflict, not an authentication
|
|
100
104
|
// failure. Preserve the real remedy so a healthy credential is never needlessly
|
|
101
105
|
// rotated; `bb setup` clears this worktree's cache and re-registers it.
|
package/src/agent-session.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import { getConfig } from "./config.mjs";
|
|
|
16
16
|
import { acquireStackLock } from "./stack-file-lock.mjs";
|
|
17
17
|
import { AGENT_KEY_RE, readAgentSessionTokenEnv, legacyAgentAliasHint } from "./agent-key.mjs";
|
|
18
18
|
import { agentStatePath, cacheBelongsToHarness, clearAgentState, harnessSessionIdFromEnv, isAgentStateFresh, readAgentState, resolveMachineId, worktreeRoot, writeAgentState } from "./agent-state.mjs";
|
|
19
|
+
import { claudeHolderActive, worktreeHarnessSessionId } from "./harness-holder.mjs";
|
|
19
20
|
import { machineUuid } from "./machine-id.mjs";
|
|
20
21
|
import { machineHost } from "./machine-host.mjs";
|
|
21
22
|
|
|
@@ -265,12 +266,22 @@ export async function selfHealAgentSession({
|
|
|
265
266
|
const renewal = rejectedCredential !== null;
|
|
266
267
|
// BOT-2425: the harness session this process runs in (exported by the
|
|
267
268
|
// SessionStart hook). A cache belongs to it only when it recorded the same id.
|
|
268
|
-
|
|
269
|
+
// BOT-3307: a Claude Desktop shell is recognised by its transcript in this
|
|
270
|
+
// worktree. A rejected-token renewal keeps the cached identity either way.
|
|
271
|
+
const envHarness = renewal ? harnessSessionIdFromEnv(env) : await worktreeHarnessSessionId(cwd, env);
|
|
269
272
|
// BOT-3257 (Codex P1): a cache minted by another server origin is never
|
|
270
273
|
// reused, renewed or compared here — its token must not reach this server.
|
|
271
274
|
// It is treated as absent: a mint for this origin replaces it.
|
|
272
275
|
const sameServer = !current || cacheBelongsToServer(current, env);
|
|
273
276
|
const ownCache = !!current && sameServer && cacheBelongsToHarness(current, envHarness);
|
|
277
|
+
// BOT-3307: the same holder rule as the band and `bb bootstrap` (BOT-3281): a
|
|
278
|
+
// session still working here keeps its cache, and one that has gone is replaced.
|
|
279
|
+
if (!renewal && env?.CLAUDE_CODE_CHILD_SESSION === "1" && envHarness && current && sameServer && !ownCache && current.harness_session_id) {
|
|
280
|
+
const active = await claudeHolderActive(current.harness_session_id, await worktreeRoot(cwd), { env, now: () => now().getTime() }).catch(() => null);
|
|
281
|
+
if (active === true || (active === null && isFresh(current, now()))) {
|
|
282
|
+
throw missing("session_still_active", `BB session ${current.session_id} is still live and holds this worktree's session cache, so it was left running. Use another worktree, or retry once that session has ended.`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
274
285
|
let bound;
|
|
275
286
|
let registrationWorktree = cwd;
|
|
276
287
|
if (renewal) {
|
package/src/harness-holder.mjs
CHANGED
|
@@ -13,15 +13,38 @@
|
|
|
13
13
|
import { readFile, readdir, realpath, rename, stat } from "node:fs/promises";
|
|
14
14
|
import { join } from "node:path";
|
|
15
15
|
import { homedir } from "node:os";
|
|
16
|
+
import { harnessSessionIdFromEnv, worktreeRoot } from "./agent-state.mjs";
|
|
16
17
|
|
|
17
18
|
export const HOLDER_IDLE_MS = 30 * 60 * 1000;
|
|
18
19
|
const UUID_ONLY = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
20
|
+
const claudeProjects = (env) => join(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"), "projects");
|
|
21
|
+
// Claude Code names a project's directory after its path, every
|
|
22
|
+
// non-alphanumeric character replaced by "-".
|
|
23
|
+
const claudeProjectDir = (worktree) => String(worktree).replace(/[^a-zA-Z0-9]/g, "-");
|
|
24
|
+
|
|
25
|
+
// BOT-3307: the harness session running in this worktree. Claude Desktop sets
|
|
26
|
+
// CLAUDE_CODE_CHILD_SESSION=1 in main-thread and sub-agent shells alike, with
|
|
27
|
+
// identical environments, so the flag alone cannot name the session. The
|
|
28
|
+
// session's transcript can: it lives under the directory the session runs in,
|
|
29
|
+
// so a sub-agent in another worktree still never claims its parent's id.
|
|
30
|
+
export async function worktreeHarnessSessionId(cwd, env = process.env) {
|
|
31
|
+
if (env?.CLAUDE_CODE_CHILD_SESSION !== "1") return harnessSessionIdFromEnv(env);
|
|
32
|
+
const claimed = harnessSessionIdFromEnv({ ...env, CLAUDE_CODE_CHILD_SESSION: undefined });
|
|
33
|
+
if (!claimed) return null;
|
|
34
|
+
try {
|
|
35
|
+
await stat(join(claudeProjects(env), claudeProjectDir(await worktreeRoot(cwd)), `${claimed}.jsonl`));
|
|
36
|
+
return claimed;
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
19
42
|
// true: the holder's transcript was written within HOLDER_IDLE_MS; false: it
|
|
20
43
|
// exists and has been silent longer; null: no transcript found (unknown).
|
|
21
44
|
export async function claudeHolderActive(holder, worktree, { env = process.env, now = () => Date.now() } = {}) {
|
|
22
45
|
const id = String(holder || "").toLowerCase();
|
|
23
46
|
if (!UUID_ONLY.test(id)) return null;
|
|
24
|
-
const projects =
|
|
47
|
+
const projects = claudeProjects(env);
|
|
25
48
|
const mtime = async (dir) => {
|
|
26
49
|
try {
|
|
27
50
|
return (await stat(join(projects, dir, `${id}.jsonl`))).mtimeMs;
|
|
@@ -29,9 +52,7 @@ export async function claudeHolderActive(holder, worktree, { env = process.env,
|
|
|
29
52
|
return null;
|
|
30
53
|
}
|
|
31
54
|
};
|
|
32
|
-
|
|
33
|
-
// non-alphanumeric character replaced by "-".
|
|
34
|
-
let at = await mtime(String(worktree).replace(/[^a-zA-Z0-9]/g, "-"));
|
|
55
|
+
let at = await mtime(claudeProjectDir(worktree));
|
|
35
56
|
if (at == null) {
|
|
36
57
|
let dirs = [];
|
|
37
58
|
try {
|
|
@@ -50,12 +71,10 @@ export async function claudeHolderActive(holder, worktree, { env = process.env,
|
|
|
50
71
|
// Returns false (never bind), true (bootstrap as is), or { aside } — another
|
|
51
72
|
// holder's cache to move out of the way first. The bootstrap would otherwise
|
|
52
73
|
// try to retire that BB session and discard the new one when it cannot: the
|
|
53
|
-
// server refuses the retirement for a live
|
|
54
|
-
// other sessions still run on its token),
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
// session" forever in a reused worktree). Set aside, a live session expires on
|
|
58
|
-
// its own once nothing renews it; the file is kept for recovery.
|
|
74
|
+
// server refuses the retirement for a session that is live in BB (which would
|
|
75
|
+
// end the waits other sessions still run on its token), even when its Claude
|
|
76
|
+
// session has gone. Set aside, a live session expires on its own once nothing
|
|
77
|
+
// renews it; the file is kept for recovery.
|
|
59
78
|
export async function bindable(cwd, harnessSessionId, now, holderActive) {
|
|
60
79
|
let state;
|
|
61
80
|
let root;
|
|
@@ -474,7 +474,20 @@ export async function bootstrapHarnessSession({
|
|
|
474
474
|
}
|
|
475
475
|
retired = confirm;
|
|
476
476
|
}
|
|
477
|
-
|
|
477
|
+
// BOT-3253: close_session needs an agent identity, so an owner sign-in is
|
|
478
|
+
// always refused here. The cached session's own bearer can retire it, and
|
|
479
|
+
// if_stale still protects a live holder. A bearer the server rejects is
|
|
480
|
+
// dead for every process reading this cache, so that session is left to
|
|
481
|
+
// expire on its own.
|
|
482
|
+
let leftToExpire = false;
|
|
483
|
+
if ((retired?.data?.error || retired?.error) === "agent_identity_required" && cached.session_token) {
|
|
484
|
+
const own = await call("close_session", cachedCloseArgs, {
|
|
485
|
+
auth: { "x-agent-api-key": cached.session_token },
|
|
486
|
+
}).catch((error) => ({ ok: false, error: error?.message }));
|
|
487
|
+
if (own?.auth && !own.code) leftToExpire = true;
|
|
488
|
+
else retired = own;
|
|
489
|
+
}
|
|
490
|
+
if (!leftToExpire && (!retired?.ok || retired.isError)) {
|
|
478
491
|
try {
|
|
479
492
|
await discardNewSession();
|
|
480
493
|
} catch (discardError) {
|
|
@@ -482,8 +495,15 @@ export async function bootstrapHarnessSession({
|
|
|
482
495
|
// orphan and fail closed (propagating any marker-write failure).
|
|
483
496
|
await recordOrphanAndFail({ session, cwd: worktree, retirementError: discardError });
|
|
484
497
|
}
|
|
485
|
-
|
|
498
|
+
const refusal = retired?.data?.error || retired?.error;
|
|
499
|
+
if (refusal === "session_still_active") {
|
|
500
|
+
throw Object.assign(new Error(
|
|
501
|
+
`session_still_active: BB session ${cached.session_id} is still live and holds this worktree's session cache, so it was left running. Use another worktree, or retry once that session has ended.`,
|
|
502
|
+
), { code: refusal });
|
|
503
|
+
}
|
|
504
|
+
throw new Error(refusal || "cached harness session is still live or could not be retired");
|
|
486
505
|
}
|
|
506
|
+
replacedCachedSession = { session_id: cached.session_id, retired: !leftToExpire };
|
|
487
507
|
await clearHarnessSession(cached.session_id, {
|
|
488
508
|
cwd: worktree,
|
|
489
509
|
sessionToken: cached.session_token,
|