@botbuddy/cli 1.118.0 → 1.118.2

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,7 +1,7 @@
1
1
  {
2
- "release_version": "1.118.0",
3
- "source_commit": "f61949cb5c11c1ab0fd33274a3d69fed41633e4f",
4
- "source_sha256": "126904b6d3e90b5ce30af5fc7c33feb99efe8023a5b1374f4c8db22a5afbf66e",
2
+ "release_version": "1.118.2",
3
+ "source_commit": "384493f578caa6f632e6ef17e46cafb2fb2a919a",
4
+ "source_sha256": "498025ce1836c9c330731eab7c89dde5164781c0505dd2c188086169b6ad2f36",
5
5
  "target": "darwin-arm64",
6
- "sha256": "a58c0dcbf5101515a362023b6e744d49bde8767ced42e68e7579053e3e077073"
6
+ "sha256": "a9cf281e8c09b428e3b87fcfc5167a37e24d310f3c71c4ec15edf38ccc95c4a6"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.118.0",
3
- "source_commit": "f61949cb5c11c1ab0fd33274a3d69fed41633e4f",
4
- "source_sha256": "126904b6d3e90b5ce30af5fc7c33feb99efe8023a5b1374f4c8db22a5afbf66e",
2
+ "release_version": "1.118.2",
3
+ "source_commit": "384493f578caa6f632e6ef17e46cafb2fb2a919a",
4
+ "source_sha256": "498025ce1836c9c330731eab7c89dde5164781c0505dd2c188086169b6ad2f36",
5
5
  "target": "linux-x64",
6
- "sha256": "b6fe4938aaebf1ac5f303b2ab7fa466314ab580426159c85de3be5c26e35ff8a"
6
+ "sha256": "b51ba74276d127800e22d9bde60d0c595c522e527422a9b0d0e4a65de5f11707"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.118.0",
4
- "source_commit": "f61949cb5c11c1ab0fd33274a3d69fed41633e4f",
5
- "source_sha256": "126904b6d3e90b5ce30af5fc7c33feb99efe8023a5b1374f4c8db22a5afbf66e",
3
+ "release_version": "1.118.2",
4
+ "source_commit": "384493f578caa6f632e6ef17e46cafb2fb2a919a",
5
+ "source_sha256": "498025ce1836c9c330731eab7c89dde5164781c0505dd2c188086169b6ad2f36",
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": "a58c0dcbf5101515a362023b6e744d49bde8767ced42e68e7579053e3e077073",
11
+ "sha256": "a9cf281e8c09b428e3b87fcfc5167a37e24d310f3c71c4ec15edf38ccc95c4a6",
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": "b6fe4938aaebf1ac5f303b2ab7fa466314ab580426159c85de3be5c26e35ff8a",
18
+ "sha256": "b51ba74276d127800e22d9bde60d0c595c522e527422a9b0d0e4a65de5f11707",
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.118.0",
3
+ "version": "1.118.2",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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
+ }
@@ -230,6 +230,8 @@ export async function cmdReleaseNotes(args, {
230
230
  ok: true, source_key: data.source_key, state: data.state, revision: data.revision, created: data.created === true, changed: data.changed === true, tenant: data.tenant ?? null,
231
231
  ...(data.customers && typeof data.customers === "object" ? { customers: data.customers } : {}),
232
232
  ...(isBinding(data.binding) ? { binding: data.binding } : {}),
233
+ // BOT-3172: what the tenant's auto-publish setting did (absent from an older server).
234
+ ...(data.auto_publish && typeof data.auto_publish === "object" ? { auto_publish: data.auto_publish } : {}),
233
235
  };
234
236
  if (json) log(JSON.stringify(receipt));
235
237
  else {
@@ -237,6 +239,8 @@ export async function cmdReleaseNotes(args, {
237
239
  log(`Release note ${receipt.source_key} ${what}: state ${receipt.state}, revision ${receipt.revision}${receipt.tenant ? `, tenant ${receipt.tenant}` : ""}.`);
238
240
  if (receipt.binding) log(termClean(describeBinding(receipt.binding)));
239
241
  if (receipt.customers) log(describeCustomers(receipt.customers));
242
+ const autoLine = describeAutoPublish(receipt.auto_publish);
243
+ if (autoLine) log(autoLine);
240
244
  }
241
245
  return CALL_EXIT.OK;
242
246
  }
@@ -806,3 +810,17 @@ async function cmdGet(argv, deps) {
806
810
  log(termClean(lines.join("\n")));
807
811
  return CALL_EXIT.OK;
808
812
  }
813
+
814
+ // BOT-3172: one line for the tenant's auto-publish outcome; none when the
815
+ // setting is off or the server predates it.
816
+ export function describeAutoPublish(ap) {
817
+ if (!ap || typeof ap !== "object") return null;
818
+ if (ap.published === true) {
819
+ const rev = Number.isInteger(ap.external_revision) ? ` (external revision ${ap.external_revision})` : "";
820
+ return `Auto-publish: published to customers${rev}; it shows on the Changelog once its change is live in production.`;
821
+ }
822
+ if (typeof ap.error === "string") return `Auto-publish: failed (${termClean(ap.error)}); the note is stored and the next submit retries it.`;
823
+ if (ap.reason === "no_external_copy") return "Auto-publish: not published: the note has no external wording, so customers will not see it.";
824
+ if (ap.reason === "withdrawn") return "Auto-publish: not published: a change manager withdrew this note.";
825
+ return null;
826
+ }
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() : "";