@botbuddy/cli 1.105.1 → 1.106.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.106.1
4
+
5
+ - `bb run status --help` shows the status, inspection and log commands without reporting an invalid run or contacting BotBuddy.
6
+
7
+ ## 1.106.0
8
+
9
+ - BOT-3464: a test child on a fleet host can report its own timing. `bb stack run --test-child` binds the test run it records (`BOTBUDDY_TEST_RUN_ID`, set by `bb test`), and the host daemon gives the child a credential of its own run, 0600 at `$BOTBUDDY_HOST_CHILD_CREDENTIAL_FILE`. Inside the child `bb` is the daemon binary, whose `bb call` now sends `get_stack_lease` and `update_test_run` (only those) with that credential to the daemon's own control plane (`BOTBUDDY_SERVER_URL`); the Node CLI's `bb call` does the same in a host child when no other credential resolves. Both read it only from an owner-only regular file. It reads only the run's lease (`get_stack_lease`) and merges only `<name>_timing` metadata into only the bound test run (`update_test_run`), while the run is live. Needs MCP 2.146.0 and this daemon on the host; an older side keeps today's behaviour.
10
+
3
11
  ## 1.105.1
4
12
 
5
13
  - BOT-3413: a version-only release with no behavior change. m8-oct's automatic updater took 1.105.0 overnight, so the `"testChild"` upgrade that switches its host test children on (BOT-3408) needs a newer candidate; this release is that candidate.
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.105.1",
3
- "source_commit": "fe90066dedb7f8c174ffdb7da87eaf0f98006284",
4
- "source_sha256": "7fa0a73386038d61d1826256de99292b95e2e0bc148484c695f3b3be361900a5",
2
+ "release_version": "1.106.1",
3
+ "source_commit": "a42995651757e19e32e9b95da4fbdb804613f469",
4
+ "source_sha256": "187860770903800533170769d60ef4079bd936b19a675854228f891011b6647f",
5
5
  "target": "darwin-arm64",
6
- "sha256": "f9018a79d7a10c4c441c600b3b905dc6aea4cbf8e260fc8069fd69945dfbebc2"
6
+ "sha256": "d7f4b731ffb2e93cab1111085ea653eee141726f2517fdc896cd6a417001a0b3"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.105.1",
3
- "source_commit": "fe90066dedb7f8c174ffdb7da87eaf0f98006284",
4
- "source_sha256": "7fa0a73386038d61d1826256de99292b95e2e0bc148484c695f3b3be361900a5",
2
+ "release_version": "1.106.1",
3
+ "source_commit": "a42995651757e19e32e9b95da4fbdb804613f469",
4
+ "source_sha256": "187860770903800533170769d60ef4079bd936b19a675854228f891011b6647f",
5
5
  "target": "linux-x64",
6
- "sha256": "3311aa19493ddcb543078bab5fafad8603275bcd9d8de7c973f27bf9ed880d6f"
6
+ "sha256": "4e67cd6cfec582e7eef01faa6d27697b860ba14edc25821bcb3fb9b140ff763d"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.105.1",
4
- "source_commit": "fe90066dedb7f8c174ffdb7da87eaf0f98006284",
5
- "source_sha256": "7fa0a73386038d61d1826256de99292b95e2e0bc148484c695f3b3be361900a5",
3
+ "release_version": "1.106.1",
4
+ "source_commit": "a42995651757e19e32e9b95da4fbdb804613f469",
5
+ "source_sha256": "187860770903800533170769d60ef4079bd936b19a675854228f891011b6647f",
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": "f9018a79d7a10c4c441c600b3b905dc6aea4cbf8e260fc8069fd69945dfbebc2",
11
+ "sha256": "d7f4b731ffb2e93cab1111085ea653eee141726f2517fdc896cd6a417001a0b3",
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": "3311aa19493ddcb543078bab5fafad8603275bcd9d8de7c973f27bf9ed880d6f",
18
+ "sha256": "4e67cd6cfec582e7eef01faa6d27697b860ba14edc25821bcb3fb9b140ff763d",
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.105.1",
3
+ "version": "1.106.1",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
package/src/api.mjs CHANGED
@@ -7,6 +7,8 @@ import { AGENT_KEY_RE } from "./agent-key.mjs";
7
7
  // only CALLS the other's functions at request time, never at module evaluation.
8
8
  import { resolveAgentSessionCredential } from "./agent-session.mjs";
9
9
  import { die, red, cyan, dim, yellow, prettyJson } from "./utils.mjs";
10
+ import { closeSync, fstatSync, openSync, readSync, constants as fsConstants } from "node:fs";
11
+ import { isAbsolute } from "node:path";
10
12
 
11
13
  // Same slug shape the server accepts on `?tenant=`.
12
14
  const TENANT_PIN_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
@@ -338,6 +340,31 @@ export async function callTool(toolName, args = {}, { fetchImpl = fetch, auth =
338
340
  // bootstrap, mcp-key, telemetry attestation) deliberately act as the durable
339
341
  // principal. Identity-minting tools the server refuses for a session token never
340
342
  // ride it (SESSION_TOKEN_DENIED_TOOLS).
343
+ // BOT-3464: a host test child's own run credential, written 0600 for the child's uid by the
344
+ // daemon. Read only inside a host child, only from an absolute path, never through a symlink,
345
+ // and only when owner-only and exactly one well-formed token; anything else is null (fail closed).
346
+ const HOST_CHILD_CREDENTIAL_RE = /^bb_child_[0-9a-f]{64}$/;
347
+ export function resolveHostChildCredential(env = process.env) {
348
+ const path = env.BOTBUDDY_HOST_CHILD_CREDENTIAL_FILE;
349
+ if (env.BOTBUDDY_STACK_EXECUTION_MODE !== "host_child" || typeof path !== "string" || !isAbsolute(path)) return null;
350
+ let fd;
351
+ try {
352
+ // The daemon bind-mounts a regular file; a symlink at the path is refused rather than followed.
353
+ fd = openSync(path, fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0));
354
+ const st = fstatSync(fd);
355
+ if (!st.isFile() || (st.mode & 0o077) !== 0 || st.size > 256) return null;
356
+ const buf = Buffer.alloc(st.size);
357
+ readSync(fd, buf, 0, st.size, 0);
358
+ const text = buf.toString("utf8");
359
+ const token = text.replace(/\n$/, "");
360
+ return HOST_CHILD_CREDENTIAL_RE.test(token) ? token : null;
361
+ } catch {
362
+ return null;
363
+ } finally {
364
+ if (fd !== undefined) { try { closeSync(fd); } catch { /* closed */ } }
365
+ }
366
+ }
367
+
341
368
  export async function resolveCallAuth({
342
369
  toolName = null,
343
370
  preferSession = false,
@@ -381,6 +408,9 @@ export async function resolveCallAuth({
381
408
  const agentKey = await refusedForOrigin(() => resolveAgentKeyFn());
382
409
  if (agentKey) return { auth: { "x-agent-api-key": agentKey }, source: "mcp_key" };
383
410
  if (owner) return { error: { ok: false, auth: true, error: "token_expired" } };
411
+ // BOT-3464: last, so a real credential always wins; the server scopes it to the child's own run.
412
+ const childCredential = resolveHostChildCredential(env);
413
+ if (childCredential) return { auth: { Authorization: `Bearer ${childCredential}` }, source: "host_child" };
384
414
  if (originMismatch) {
385
415
  return { error: { ok: false, auth: true, error: originMismatch.code, message: originMismatch.message, recovery: originMismatch.recovery ?? null } };
386
416
  }
package/src/commands.mjs CHANGED
@@ -15,7 +15,7 @@ import { CallUsageError, discoveryUrlFor, formatDiscovery, parseCallArgs } from
15
15
  import { cmdStack } from "./stack.mjs";
16
16
  import { cmdManagedAllocation } from "./managed-allocation.mjs";
17
17
  import { cmdDocker } from "./docker-hygiene.mjs";
18
- import { cmdRun } from "./run.mjs";
18
+ import { cmdRun, isRunStatusHelp } from "./run.mjs";
19
19
  import { cmdPush } from "./push.mjs";
20
20
  import { cmdTest } from "./test-lane.mjs";
21
21
  import { cmdEvidence } from "./evidence.mjs";
@@ -118,6 +118,7 @@ export async function run(argv, {
118
118
  // Creating or reading local feedback guidance must work even when the
119
119
  // credential store or network is the reason the agent is blocked.
120
120
  if (command === "feedback" && (args[0] === "init" || HELP_WORDS.has(args[0]))) return cmdFeedback(args);
121
+ if (command === "run" && isRunStatusHelp(args)) return cmdRun(args);
121
122
 
122
123
  await load();
123
124
  if (shouldCheckForUpdates([command, ...args])) await warnStale({ version: VERSION });
@@ -54,6 +54,13 @@ export function buildHeadBundle(worktreeRoot, { run = spawnSync, maxBytes = HOST
54
54
  };
55
55
  }
56
56
 
57
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
58
+ /** BOT-3464: the test run this requester records (`bb test` sets it), bound to the host run, or null. */
59
+ export function testRunIdFrom(env = process.env) {
60
+ const raw = typeof env.BOTBUDDY_TEST_RUN_ID === "string" ? env.BOTBUDDY_TEST_RUN_ID.trim().toLowerCase() : "";
61
+ return UUID_RE.test(raw) ? raw : null;
62
+ }
63
+
57
64
  /** `--child-env NAME` takes NAME's value from this shell; the server refuses credential names. */
58
65
  export function childEnvFrom(names, env = process.env) {
59
66
  const out = {};
@@ -99,7 +106,7 @@ export function hostRunExitCode(run) {
99
106
  export async function startHostChild({
100
107
  api, upload, slotId, argv, env = {}, worktreeRoot, maxRuntimeSeconds = HOST_CHILD_DEFAULT_MAX_RUNTIME_S,
101
108
  bundle: prebuilt = null, wait = defaultHostChildWait, log = () => {}, writeOutput = (s) => process.stdout.write(s), now = Date.now,
102
- signal = undefined, artifactGlobs = [], fetchArtifacts = fetch,
109
+ signal = undefined, artifactGlobs = [], fetchArtifacts = fetch, testRunId = null,
103
110
  }) {
104
111
  const bundle = prebuilt ?? buildHeadBundle(worktreeRoot);
105
112
  if (!bundle.ok) return { ok: false, code: "HOST_CHILD_BUNDLE_FAILED", error: bundle.error };
@@ -107,7 +114,9 @@ export async function startHostChild({
107
114
  let created;
108
115
  try {
109
116
  created = await api.create({ slot_id: slotId, argv, cwd: "", env, bundle_sha256: bundle.sha256, bundle_size_bytes: bundle.sizeBytes, max_runtime_seconds: maxRuntimeSeconds,
110
- ...(artifactGlobs.length ? { artifact_globs: artifactGlobs } : {}) });
117
+ ...(artifactGlobs.length ? { artifact_globs: artifactGlobs } : {}),
118
+ // BOT-3464: the child's own run credential may add timing to this test run only.
119
+ ...(testRunId ? { test_run_id: testRunId } : {}) });
111
120
  } catch (error) { created = { ok: false, error: String(error?.message ?? error) }; }
112
121
  const c = created?.data;
113
122
  if (!created?.ok || !c?.success) {
package/src/run.mjs CHANGED
@@ -1280,6 +1280,13 @@ export async function retryTerminalUpdate(context, update, call, {
1280
1280
  }
1281
1281
  }
1282
1282
 
1283
+ export function isRunStatusHelp(args) {
1284
+ if (args[0] !== "status") return false;
1285
+ const separator = args.indexOf("--");
1286
+ const flags = separator < 0 ? args : args.slice(0, separator);
1287
+ return flags.includes("--help") || flags.includes("-h");
1288
+ }
1289
+
1283
1290
  export async function cmdRun(args) {
1284
1291
  if (args[0] === "--worker") {
1285
1292
  await runWorker(args[1]);
@@ -1300,6 +1307,12 @@ export async function cmdRun(args) {
1300
1307
  process.exitCode = result.classification === "rejected" ? EXIT.INVALID : EXIT.OK;
1301
1308
  return;
1302
1309
  }
1310
+ if (isRunStatusHelp(args)) {
1311
+ const candidate = args.slice(1).find((arg) => !arg.startsWith("-"));
1312
+ const id = candidate && /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(candidate) ? candidate : "<run_id>";
1313
+ console.log(`bb run status ${id}\n Show observed test counts and exact receipt, test-event and log commands when available. Unknown counts remain unknown.\n\nbb run inspect ${id}\n Inspect the owned detached run and its observed state.\n\nbb run logs ${id} --tail 100\n Read the owned local log snapshot when available.\n\n${id === "<run_id>" ? "Replace <run_id> with your run ID. " : ""}The status response contains the exact available local commands and paths for this run.`);
1314
+ return;
1315
+ }
1303
1316
  if (args[0] === "status") {
1304
1317
  const result = await statusRun(args[1] ?? "");
1305
1318
  oneLine(result, false);
package/src/stack.mjs CHANGED
@@ -62,7 +62,7 @@ import { bold, dim, yellow } from "./utils.mjs";
62
62
  import { STACK_RELEASE_INTENT_ENV, classifyStackRunOutcome, observeStackRunSignal, ownerReleaseHeld, reportStackRunOutcome } from "./stack-run-outcome.mjs";
63
63
  import { REQUESTER_NETWORK_CANDIDATE_CODES, REQUESTER_NETWORK_FAILURE_SLACK_MS, REQUESTER_NETWORK_LOOKBACK_MS, REQUESTER_NETWORK_LOST_CODE, STACK_DEGRADED_GRACE_MAX_MS, createRequesterNetworkWatch, requesterNetworkLostMessage } from "./requester-network.mjs";
64
64
  import { provisionFailureFields, provisionFailureLine } from "./stack-provision-failure.mjs";
65
- import { hostChildApi, hostChildReceiptFields, startHostChild, childEnvFrom, HOST_CHILD_DEFAULT_MAX_RUNTIME_S } from "./host-child.mjs";
65
+ import { hostChildApi, hostChildReceiptFields, startHostChild, childEnvFrom, testRunIdFrom, HOST_CHILD_DEFAULT_MAX_RUNTIME_S } from "./host-child.mjs";
66
66
  import { HOST_CHILD_ARTIFACT_GLOBS_MAX, returnHostChildArtifacts, validateChildArtifactGlob } from "./host-child-artifacts.mjs";
67
67
  import { childLayerPrerequisites, headDeclaresChildLayer, headToolchain, toolchainConflictError, toolchainPrerequisites } from "./host-toolchain.mjs";
68
68
  import { acquireTestChildSlot, CHILD_PLACEMENT_REQUIRED, defaultTestChildWait, readPs, requesterSample, startChildSampler, testChildApi, testChildReceiptFields } from "./test-child.mjs";
@@ -5704,6 +5704,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5704
5704
  ...(adapters.hostChildWait ? { wait: adapters.hostChildWait } : {}),
5705
5705
  log: stderrLine, ...(adapters.hostChildOutput ? { writeOutput: adapters.hostChildOutput } : {}),
5706
5706
  signal: activeWaitAbort.signal, artifactGlobs: opts.childArtifacts ?? [],
5707
+ testRunId: adapters.hostChildTestRunId !== undefined ? adapters.hostChildTestRunId : testRunIdFrom(),
5707
5708
  ...(adapters.hostChildFetch ? { fetchArtifacts: adapters.hostChildFetch } : {}),
5708
5709
  });
5709
5710
  } finally {