@botbuddy/cli 1.105.1 → 1.106.0

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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.106.0
4
+
5
+ - 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.
6
+
3
7
  ## 1.105.1
4
8
 
5
9
  - 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.0",
3
+ "source_commit": "ed60b09485ef31d43a1811773b14ab650fc0bc0a",
4
+ "source_sha256": "9f200bf54e41c26b5868cc5dfafc22e5f485ee106474386d272eea3abb12a213",
5
5
  "target": "darwin-arm64",
6
- "sha256": "f9018a79d7a10c4c441c600b3b905dc6aea4cbf8e260fc8069fd69945dfbebc2"
6
+ "sha256": "16c0bd09746bcf3738f8015e7d494a3f230c79dcc8f5533cb6dab701580dfa3a"
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.0",
3
+ "source_commit": "ed60b09485ef31d43a1811773b14ab650fc0bc0a",
4
+ "source_sha256": "9f200bf54e41c26b5868cc5dfafc22e5f485ee106474386d272eea3abb12a213",
5
5
  "target": "linux-x64",
6
- "sha256": "3311aa19493ddcb543078bab5fafad8603275bcd9d8de7c973f27bf9ed880d6f"
6
+ "sha256": "d7c70cebfb9f6571a9901d46c35d7af47b38b72cfc09300710ba76c1a3a82076"
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.0",
4
+ "source_commit": "ed60b09485ef31d43a1811773b14ab650fc0bc0a",
5
+ "source_sha256": "9f200bf54e41c26b5868cc5dfafc22e5f485ee106474386d272eea3abb12a213",
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": "16c0bd09746bcf3738f8015e7d494a3f230c79dcc8f5533cb6dab701580dfa3a",
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": "d7c70cebfb9f6571a9901d46c35d7af47b38b72cfc09300710ba76c1a3a82076",
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.0",
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
  }
@@ -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/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 {