@botbuddy/cli 1.85.4 → 1.86.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/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/commands.mjs +2 -0
- package/src/evidence.mjs +112 -3
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.86.0",
|
|
3
|
+
"source_commit": "35caa79c6d0ff83a89faac2efcc7cbd98d5bc198",
|
|
4
|
+
"source_sha256": "7b22432ea7ee69e72c29629bca6c6d0de66b3ad5ea1a5beadb15e1b10d1a9207",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "efc9827266c5c700000faddd2020f8e1e59ccc5a3e007c511aa78c8af20e59b7"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.86.0",
|
|
3
|
+
"source_commit": "35caa79c6d0ff83a89faac2efcc7cbd98d5bc198",
|
|
4
|
+
"source_sha256": "7b22432ea7ee69e72c29629bca6c6d0de66b3ad5ea1a5beadb15e1b10d1a9207",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "de524aa0da29f62069bb844be54557a16b2f3b99c8d449f4328dc800ebfedbf5"
|
|
7
7
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
|
-
"release_version": "1.
|
|
4
|
-
"source_commit": "
|
|
5
|
-
"source_sha256": "
|
|
3
|
+
"release_version": "1.86.0",
|
|
4
|
+
"source_commit": "35caa79c6d0ff83a89faac2efcc7cbd98d5bc198",
|
|
5
|
+
"source_sha256": "7b22432ea7ee69e72c29629bca6c6d0de66b3ad5ea1a5beadb15e1b10d1a9207",
|
|
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": "efc9827266c5c700000faddd2020f8e1e59ccc5a3e007c511aa78c8af20e59b7",
|
|
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": "de524aa0da29f62069bb844be54557a16b2f3b99c8d449f4328dc800ebfedbf5",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/commands.mjs
CHANGED
|
@@ -364,6 +364,8 @@ ${bold("EVIDENCE")} (${cyan("bb help evidence")})
|
|
|
364
364
|
status-band read|relay The band's own reads and live wake (run by the mod)
|
|
365
365
|
evidence require <file> Record an exact-head evidence disposition → botbuddy/ready
|
|
366
366
|
evidence publish <file> Publish a local evidence statement → botbuddy/ready check-run
|
|
367
|
+
evidence bind <file> Bind a run's receipt to its run, on the requester after the reap
|
|
368
|
+
evidence digest <file> Print the digest of one run record
|
|
367
369
|
|
|
368
370
|
${bold("HOST + DOCKER")}
|
|
369
371
|
docker hygiene [options] Dry-run/apply safe stale Supabase cleanup on OrbStack
|
package/src/evidence.mjs
CHANGED
|
@@ -9,13 +9,59 @@
|
|
|
9
9
|
// falling back to the owner/MCP-key ladder like every other `bb` call. Prints
|
|
10
10
|
// the tool's JSON result on stdout; a refusal exits non-zero.
|
|
11
11
|
|
|
12
|
+
import { createHash } from "node:crypto";
|
|
12
13
|
import { readFileSync } from "node:fs";
|
|
13
14
|
import { CALL_EXIT, callToolJson as defaultCallToolJson, resolveCallAuth } from "./api.mjs";
|
|
14
15
|
|
|
15
16
|
export const EVIDENCE_EXIT = Object.freeze({ ...CALL_EXIT, USAGE: 2, REFUSED: 4 });
|
|
16
17
|
|
|
18
|
+
function canonical(value) {
|
|
19
|
+
if (value === null) return "null";
|
|
20
|
+
if (typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
|
|
21
|
+
if (typeof value === "number") {
|
|
22
|
+
if (!Number.isFinite(value)) throw new Error("a run record number must be finite");
|
|
23
|
+
return JSON.stringify(value);
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
26
|
+
if (typeof value === "object") {
|
|
27
|
+
const entries = Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
28
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(",")}}`;
|
|
29
|
+
}
|
|
30
|
+
throw new Error("a run record holds only JSON values");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* BOT-3312: sorted-key JSON of one run record. Must stay byte-identical to
|
|
35
|
+
* supabase/functions/_shared/lib/runReceiptBinding.ts; both sides assert one fixed vector.
|
|
36
|
+
*/
|
|
37
|
+
export function canonicalRunRecordJson(record) {
|
|
38
|
+
if (!record || typeof record !== "object" || Array.isArray(record)) throw new Error("a run record must be a JSON object");
|
|
39
|
+
return canonical(record);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function runRecordDigest(record) {
|
|
43
|
+
return `sha256:${createHash("sha256").update(canonicalRunRecordJson(record)).digest("hex")}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const sortedUnique = (values) => [...new Set(values)].sort();
|
|
47
|
+
|
|
48
|
+
/** The first field where the child's record differs from what the requester launched. */
|
|
49
|
+
function claimMismatch({ claim, record, leaseId, testRunId }) {
|
|
50
|
+
if (record.full !== claim.full) return "full";
|
|
51
|
+
const recorded = Array.isArray(record.domains) ? sortedUnique(record.domains) : [];
|
|
52
|
+
const claimed = sortedUnique(claim.domains);
|
|
53
|
+
if (recorded.length !== claimed.length || recorded.some((d, i) => d !== claimed[i])) return "domains";
|
|
54
|
+
if ((record.project ?? null) !== (claim.project ?? null)) return "project";
|
|
55
|
+
if (record.fingerprint !== claim.fingerprint) return "fingerprint";
|
|
56
|
+
if (record.lifecycle?.stackId !== leaseId) return "lifecycle.stackId";
|
|
57
|
+
if (record.runId !== testRunId) return "runId";
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
17
61
|
const USAGE = `Usage: bb evidence require <requirement.json>
|
|
18
62
|
bb evidence publish <statement.json>
|
|
63
|
+
bb evidence bind <request.json>
|
|
64
|
+
bb evidence digest <run-record.json>
|
|
19
65
|
|
|
20
66
|
require Record the impact producer's decision for one exact PR head. The file
|
|
21
67
|
is a JSON object with: repo, pr, headSha, disposition
|
|
@@ -26,14 +72,44 @@ publish Publish a local evidence statement for a PR head (after an e2e
|
|
|
26
72
|
requirement). The statement is a JSON object with:
|
|
27
73
|
repo, pr, headSha, mainSha, base, fingerprint, requirement, runs[]
|
|
28
74
|
(each with the BotBuddy runId), verdict ("pass" | "fail"), fixCommand
|
|
75
|
+
bind Bind one run's receipt to its run, after its lease is reaped. Run this
|
|
76
|
+
on the requester, never in the test child. The file is a JSON object
|
|
77
|
+
with: leaseId, testRunId, headSha, childExitCode, record (the run
|
|
78
|
+
record), and claim {full, domains, project, fingerprint}. Build the
|
|
79
|
+
claim from what you launched, not from the child's record. A record
|
|
80
|
+
that differs from the claim is refused and nothing is sent.
|
|
81
|
+
digest Print the digest of one run record. Publish it as runs[i].recordDigest.
|
|
29
82
|
|
|
30
83
|
Exit codes: 0 recorded · 2 usage · 3 auth · 4 refused · 5 unreachable`;
|
|
31
84
|
|
|
32
85
|
const SUBCOMMANDS = Object.freeze({
|
|
33
86
|
require: { tool: "publish_evidence_requirement", argName: "requirement" },
|
|
34
87
|
publish: { tool: "publish_evidence", argName: "statement" },
|
|
88
|
+
bind: { tool: "bind_run_receipt" },
|
|
89
|
+
digest: { tool: null },
|
|
35
90
|
});
|
|
36
91
|
|
|
92
|
+
/** BOT-3312: the tool arguments for `bind`, or a refusal made before anything is sent. */
|
|
93
|
+
function bindArguments(body) {
|
|
94
|
+
const { leaseId, testRunId, headSha, childExitCode, claim, record } = body ?? {};
|
|
95
|
+
if (!claim || typeof claim !== "object" || !Array.isArray(claim.domains) || !record || typeof record !== "object" || Array.isArray(record)) {
|
|
96
|
+
return { usage: "the request needs a claim {full, domains, project, fingerprint} and the run record" };
|
|
97
|
+
}
|
|
98
|
+
const field = claimMismatch({ claim, record, leaseId, testRunId });
|
|
99
|
+
if (field) {
|
|
100
|
+
return { refusal: { success: false, code: "RECEIPT_BINDING_CLAIM_MISMATCH", field,
|
|
101
|
+
message: `the run record's ${field} differs from what the requester launched; nothing was bound` } };
|
|
102
|
+
}
|
|
103
|
+
return { args: {
|
|
104
|
+
lease_id: leaseId,
|
|
105
|
+
test_run_id: testRunId,
|
|
106
|
+
head_sha: headSha,
|
|
107
|
+
run_record_digest: runRecordDigest(record),
|
|
108
|
+
child_exit_code: childExitCode,
|
|
109
|
+
claim: { full: claim.full, domains: claim.domains, project: claim.project ?? null, fingerprint: claim.fingerprint },
|
|
110
|
+
} };
|
|
111
|
+
}
|
|
112
|
+
|
|
37
113
|
export async function cmdEvidence(args, {
|
|
38
114
|
resolveAuth = resolveCallAuth,
|
|
39
115
|
callToolJson = defaultCallToolJson,
|
|
@@ -63,6 +139,31 @@ export async function cmdEvidence(args, {
|
|
|
63
139
|
return EVIDENCE_EXIT.USAGE;
|
|
64
140
|
}
|
|
65
141
|
|
|
142
|
+
if (sub === "digest") {
|
|
143
|
+
try {
|
|
144
|
+
log(JSON.stringify({ digest: runRecordDigest(body) }));
|
|
145
|
+
return EVIDENCE_EXIT.OK;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
errorLog(`✗ ${error?.message ?? error}`);
|
|
148
|
+
return EVIDENCE_EXIT.USAGE;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let toolArgs = { [spec.argName]: body };
|
|
153
|
+
if (sub === "bind") {
|
|
154
|
+
const bind = bindArguments(body);
|
|
155
|
+
if (bind.usage) {
|
|
156
|
+
errorLog(`✗ ${bind.usage}\n\n${USAGE}`);
|
|
157
|
+
return EVIDENCE_EXIT.USAGE;
|
|
158
|
+
}
|
|
159
|
+
if (bind.refusal) {
|
|
160
|
+
log(JSON.stringify(bind.refusal, null, 2));
|
|
161
|
+
errorLog(`✗ ${bind.refusal.code}: ${bind.refusal.message}`);
|
|
162
|
+
return EVIDENCE_EXIT.REFUSED;
|
|
163
|
+
}
|
|
164
|
+
toolArgs = bind.args;
|
|
165
|
+
}
|
|
166
|
+
|
|
66
167
|
const resolved = await resolveAuth({ toolName: spec.tool, preferSession: true });
|
|
67
168
|
if (resolved?.error || !resolved?.auth) {
|
|
68
169
|
log(JSON.stringify(resolved?.error ?? { ok: false, auth: true, error: "not_authenticated" }, null, 2));
|
|
@@ -70,7 +171,7 @@ export async function cmdEvidence(args, {
|
|
|
70
171
|
return EVIDENCE_EXIT.AUTH;
|
|
71
172
|
}
|
|
72
173
|
|
|
73
|
-
const res = await callToolJson(spec.tool,
|
|
174
|
+
const res = await callToolJson(spec.tool, toolArgs, { auth: resolved.auth });
|
|
74
175
|
if (!res.ok) {
|
|
75
176
|
log(JSON.stringify(res, null, 2));
|
|
76
177
|
if (res.auth) {
|
|
@@ -86,10 +187,18 @@ export async function cmdEvidence(args, {
|
|
|
86
187
|
}
|
|
87
188
|
|
|
88
189
|
log(JSON.stringify(res.data, null, 2));
|
|
89
|
-
if (res.isError || res.data?.ok === false) {
|
|
90
|
-
errorLog(`✗ ${res.data?.error ?? `${spec.tool} refused`}: ${res.data?.message ?? ""}`.trimEnd());
|
|
190
|
+
if (res.isError || res.data?.ok === false || res.data?.success === false) {
|
|
191
|
+
errorLog(`✗ ${res.data?.code ?? res.data?.error ?? `${spec.tool} refused`}: ${res.data?.message ?? ""}`.trimEnd());
|
|
91
192
|
return EVIDENCE_EXIT.REFUSED;
|
|
92
193
|
}
|
|
194
|
+
if (sub === "bind") {
|
|
195
|
+
// Success means a binding id came back; an empty answer is never "bound".
|
|
196
|
+
if (res.data?.success !== true || typeof res.data?.binding_id !== "string") {
|
|
197
|
+
errorLog("✗ BotBuddy returned no binding — nothing is known to be bound; retry.");
|
|
198
|
+
return EVIDENCE_EXIT.ERROR;
|
|
199
|
+
}
|
|
200
|
+
return EVIDENCE_EXIT.OK;
|
|
201
|
+
}
|
|
93
202
|
if (sub === "require") {
|
|
94
203
|
// Success means the control plane echoed the recorded disposition — an
|
|
95
204
|
// outage body that normalises to an empty result is never "recorded".
|