@botbuddy/cli 1.118.0 → 1.118.1
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/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/helper-host.mjs +8 -2
- package/src/host-upgrade.mjs +101 -0
- package/src/wait-core.mjs +10 -0
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.118.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.118.1",
|
|
3
|
+
"source_commit": "223984d2978836d0c0b6a0189e564e98660dcf84",
|
|
4
|
+
"source_sha256": "8918a3015bdde8b9939f222acf8e15847a4830986a01351eec49bee1e24a0403",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "b8a204cfcfae4486b13d8240d5928864a0df4f053fcc0038f90d5377c74b6c88"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.118.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.118.1",
|
|
3
|
+
"source_commit": "223984d2978836d0c0b6a0189e564e98660dcf84",
|
|
4
|
+
"source_sha256": "8918a3015bdde8b9939f222acf8e15847a4830986a01351eec49bee1e24a0403",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "42b817ee885c407c0bcf99c678a0dbb5e89b464a83e3dca93579246e93590958"
|
|
7
7
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
|
-
"release_version": "1.118.
|
|
4
|
-
"source_commit": "
|
|
5
|
-
"source_sha256": "
|
|
3
|
+
"release_version": "1.118.1",
|
|
4
|
+
"source_commit": "223984d2978836d0c0b6a0189e564e98660dcf84",
|
|
5
|
+
"source_sha256": "8918a3015bdde8b9939f222acf8e15847a4830986a01351eec49bee1e24a0403",
|
|
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": "b8a204cfcfae4486b13d8240d5928864a0df4f053fcc0038f90d5377c74b6c88",
|
|
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": "42b817ee885c407c0bcf99c678a0dbb5e89b464a83e3dca93579246e93590958",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/helper-host.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import { spawnSync } from "node:child_process";
|
|
|
17
17
|
import { readFileSync } from "node:fs";
|
|
18
18
|
import { homedir, platform } from "node:os";
|
|
19
19
|
import { basename, join } from "node:path";
|
|
20
|
+
import { cmdHostUpgrade, HOST_UPGRADE_USAGE } from "./host-upgrade.mjs";
|
|
20
21
|
|
|
21
22
|
export const HELPER_WORKER_LABEL = "com.botbuddy.helper.worker";
|
|
22
23
|
export const HELPER_WORKER_BINARY = "botbuddyhelper-worker";
|
|
@@ -74,7 +75,7 @@ export function readHelperHostKey({ home = homedir(), nowMs = Date.now(), readFi
|
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
const HOST_USAGE = "Usage: bb host key [--json]";
|
|
78
|
+
const HOST_USAGE = "Usage: bb host key [--json] | bb host upgrade request|status|start …";
|
|
78
79
|
|
|
79
80
|
export function hostHelp() {
|
|
80
81
|
return `${HOST_USAGE}
|
|
@@ -83,16 +84,21 @@ Prints this Mac's managed-container host key from the BotBuddy Helper's status
|
|
|
83
84
|
file, whatever the file's age: the key is this machine's static identity. A file
|
|
84
85
|
older than ${HELPER_STATUS_FRESH_SECONDS} s still prints the key (exit 0) with a freshness warning on
|
|
85
86
|
stderr. Exit 4 when the file is missing or names no host key.
|
|
86
|
-
--json prints {host_key, checked_at, age_seconds, fresh, path}
|
|
87
|
+
--json prints {host_key, checked_at, age_seconds, fresh, path}.
|
|
88
|
+
|
|
89
|
+
${HOST_UPGRADE_USAGE}
|
|
90
|
+
Pre-approved drain → daemon upgrade → undrain cycle (BOT-3551); see \`bb host upgrade --help\`.`;
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
/** `bb host key [--json]` → exit code. */
|
|
90
94
|
export async function cmdHost(args, {
|
|
91
95
|
log = (line) => console.log(line), errorLog = (line) => console.error(line),
|
|
92
96
|
read = () => readHelperHostKey(),
|
|
97
|
+
upgrade = (upgradeArgs) => cmdHostUpgrade(upgradeArgs, { log, errorLog }),
|
|
93
98
|
} = {}) {
|
|
94
99
|
const [sub, ...rest] = args;
|
|
95
100
|
if (sub === "help" || sub === "--help" || sub === "-h") { log(hostHelp()); return 0; }
|
|
101
|
+
if (sub === "upgrade") return upgrade(rest);
|
|
96
102
|
const json = rest.includes("--json");
|
|
97
103
|
const unknown = rest.filter((a) => a !== "--json");
|
|
98
104
|
if (sub !== "key" || unknown.length) { errorLog(HOST_USAGE); return 4; }
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// BOT-3551 — `bb host upgrade request|status|start`: pre-approved host upgrade
|
|
2
|
+
// cycles. A thin client of the MCP tools request_host_upgrade_grant,
|
|
3
|
+
// get_host_upgrade_grant and start_host_upgrade_cycle (ADR 2026-11-20): every
|
|
4
|
+
// permission, expiry and single-use rule is the server's. The agent session
|
|
5
|
+
// token is required so the grant binds to this session's agent.
|
|
6
|
+
//
|
|
7
|
+
// bb host upgrade request <bbh-…> [--reason <text>] [--json]
|
|
8
|
+
// → prints the code and link for the host owner, and the exact bb wait.
|
|
9
|
+
// bb host upgrade status <grant_id> [--json]
|
|
10
|
+
// bb host upgrade start <grant_id> [--json]
|
|
11
|
+
// → starts the one drain → daemon upgrade → undrain cycle.
|
|
12
|
+
import { callToolJson } from "./api.mjs";
|
|
13
|
+
|
|
14
|
+
export const HOST_UPGRADE_USAGE =
|
|
15
|
+
"Usage: bb host upgrade request <host_key> [--reason <text>] [--json] | status <grant_id> [--json] | start <grant_id> [--json]";
|
|
16
|
+
|
|
17
|
+
export function hostUpgradeHelp() {
|
|
18
|
+
return `${HOST_UPGRADE_USAGE}
|
|
19
|
+
|
|
20
|
+
Pre-approve one drain → daemon upgrade → undrain cycle on a host, the way a
|
|
21
|
+
remote \`bb login\` is approved: \`request\` prints a short code and a link on
|
|
22
|
+
app.bot-buddy.ai for the host's owner. After the owner approves, \`start\` runs
|
|
23
|
+
the cycle once (within 24 h). The host drains, takes the stable daemon release
|
|
24
|
+
when idle, and returns to active. The grant is bound to this agent session and
|
|
25
|
+
this host, single use, and revocable by the owner from the same page.
|
|
26
|
+
|
|
27
|
+
Exit codes: 0 ok · 3 refused by the server (code on stderr) · 4 usage ·
|
|
28
|
+
5 not signed in to an agent session (run \`bb doctor --fix\`) · 6 transport.`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const TOOLS = { request: "request_host_upgrade_grant", status: "get_host_upgrade_grant", start: "start_host_upgrade_cycle" };
|
|
32
|
+
|
|
33
|
+
function parse(args) {
|
|
34
|
+
const [sub, ...rest] = args;
|
|
35
|
+
if (!TOOLS[sub]) return null;
|
|
36
|
+
let json = false; let reason = null; const positional = [];
|
|
37
|
+
for (let i = 0; i < rest.length; i++) {
|
|
38
|
+
const a = rest[i];
|
|
39
|
+
if (a === "--json") json = true;
|
|
40
|
+
else if (a === "--reason" && sub === "request" && i + 1 < rest.length) reason = rest[++i];
|
|
41
|
+
else if (a.startsWith("--reason=") && sub === "request") reason = a.slice("--reason=".length);
|
|
42
|
+
else if (a.startsWith("-")) return null;
|
|
43
|
+
else positional.push(a);
|
|
44
|
+
}
|
|
45
|
+
if (positional.length !== 1) return null;
|
|
46
|
+
const toolArgs = sub === "request"
|
|
47
|
+
? { host_key: positional[0], ...(reason ? { reason } : {}) }
|
|
48
|
+
: { grant_id: positional[0] };
|
|
49
|
+
return { sub, json, toolArgs };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function describeGrant(g) {
|
|
53
|
+
if (!g) return [];
|
|
54
|
+
const lines = [`grant ${g.grant_id} · host ${g.host_key} · ${g.status}`];
|
|
55
|
+
if (g.approver_email) lines.push(`approved by ${g.approver_email}`);
|
|
56
|
+
if (g.start_by && g.status === "approved") lines.push(`start before ${g.start_by}`);
|
|
57
|
+
return lines;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** `bb host upgrade …` → exit code. */
|
|
61
|
+
export async function cmdHostUpgrade(args, {
|
|
62
|
+
log = (line) => console.log(line), errorLog = (line) => console.error(line),
|
|
63
|
+
call = (tool, toolArgs) => callToolJson(tool, toolArgs, { requireSessionToken: true }),
|
|
64
|
+
} = {}) {
|
|
65
|
+
if (args[0] === "help" || args[0] === "--help" || args[0] === "-h" || args.length === 0) {
|
|
66
|
+
(args.length === 0 ? errorLog : log)(args.length === 0 ? HOST_UPGRADE_USAGE : hostUpgradeHelp());
|
|
67
|
+
return args.length === 0 ? 4 : 0;
|
|
68
|
+
}
|
|
69
|
+
const parsed = parse(args);
|
|
70
|
+
if (!parsed) { errorLog(HOST_UPGRADE_USAGE); return 4; }
|
|
71
|
+
const res = await call(TOOLS[parsed.sub], parsed.toolArgs);
|
|
72
|
+
if (!res?.ok) {
|
|
73
|
+
if (res?.auth || res?.error === "session_token_required") {
|
|
74
|
+
errorLog("bb host upgrade: an agent session is required so the grant binds to your agent; run `bb doctor --fix` (or `bb setup`) and retry.");
|
|
75
|
+
return 5;
|
|
76
|
+
}
|
|
77
|
+
errorLog(`bb host upgrade: ${res?.code ?? res?.error ?? "request failed"}`);
|
|
78
|
+
return 6;
|
|
79
|
+
}
|
|
80
|
+
const data = res.data ?? {};
|
|
81
|
+
if (parsed.json) log(JSON.stringify(data));
|
|
82
|
+
if (data.success !== true) {
|
|
83
|
+
errorLog(`bb host upgrade ${parsed.sub}: ${data.code ?? "REFUSED"}: ${data.message ?? "refused"}`);
|
|
84
|
+
return 3;
|
|
85
|
+
}
|
|
86
|
+
if (parsed.json) return 0;
|
|
87
|
+
if (parsed.sub === "request") {
|
|
88
|
+
log(`Ask the owner of ${data.host_key} to approve this upgrade cycle:`);
|
|
89
|
+
log(` code: ${data.user_code}`);
|
|
90
|
+
log(` open: ${data.verification_uri_complete}`);
|
|
91
|
+
log(`(expires in ${data.expires_in} s; grant ${data.grant_id})`);
|
|
92
|
+
log(`Wait for the decision: ${data.wait}`);
|
|
93
|
+
log(`Then start it: bb host upgrade start ${data.grant_id}`);
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
for (const line of describeGrant(data.grant)) log(line);
|
|
97
|
+
const op = data.operation;
|
|
98
|
+
if (op) log(`operation ${op.id} · ${op.status}${op.requested_version ? ` · ${op.from_version ?? "?"} → ${op.requested_version}` : ""}${op.failure_code ? ` · ${op.failure_code}` : ""}`);
|
|
99
|
+
if (data.next) log(data.next);
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
package/src/wait-core.mjs
CHANGED
|
@@ -145,6 +145,10 @@ export const SIGNAL_TYPES = Object.freeze([
|
|
|
145
145
|
// BOT-3030: a host-placed test child started or ended (subject = the run's UUID).
|
|
146
146
|
// `bb stack run --test-child` waits on it while its child runs on the serving host.
|
|
147
147
|
"test_child_run",
|
|
148
|
+
// BOT-3551: the host owner decided (approved, denied or revoked) a pre-approved
|
|
149
|
+
// upgrade cycle (subject = the grant's lower-case UUID), recipient-scoped to
|
|
150
|
+
// the requesting agent. `bb host upgrade request` prints this exact wait.
|
|
151
|
+
"host_upgrade_grant",
|
|
148
152
|
]);
|
|
149
153
|
|
|
150
154
|
const LOCK_SUBTYPES = Object.freeze(["playwright_lane", "vite_port", "backend_port", "supabase_local"]);
|
|
@@ -604,6 +608,12 @@ const VALIDATORS = {
|
|
|
604
608
|
if (p.type === "test_child_slot" && !subject) {
|
|
605
609
|
throw new Error("event:type=test_child_slot needs subject=<run host>");
|
|
606
610
|
}
|
|
611
|
+
// BOT-3551: a host upgrade grant wait names its grant, as the emitter writes it.
|
|
612
|
+
if (p.type === "host_upgrade_grant") {
|
|
613
|
+
const id = subject ? subject.toLowerCase() : "";
|
|
614
|
+
if (!CANONICAL_UUID_RE.test(id)) throw new Error("event:type=host_upgrade_grant needs subject=<grant UUID>");
|
|
615
|
+
return { type: p.type, subject: id };
|
|
616
|
+
}
|
|
607
617
|
// BOT-3030: a test_child_run wait names its run, as the emitter writes it.
|
|
608
618
|
if (p.type === "test_child_run") {
|
|
609
619
|
const id = subject ? subject.toLowerCase() : "";
|