@botbuddy/cli 1.86.0 → 1.88.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/release-notes.mjs +83 -1
- package/src/test-child.mjs +32 -4
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.88.0",
|
|
3
|
+
"source_commit": "a7e1965978a24dc9a14e1442c5f40ab26f5732ef",
|
|
4
|
+
"source_sha256": "feb7f17ea84d6a3c072d20ef5f4868c2dec25be6d84ed04c7b5e5ebefcaec446",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "fbef823e6769dfe0e8ff6f624f1aaff2e0adacb19df27f073d7917d722f03f70"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.88.0",
|
|
3
|
+
"source_commit": "a7e1965978a24dc9a14e1442c5f40ab26f5732ef",
|
|
4
|
+
"source_sha256": "feb7f17ea84d6a3c072d20ef5f4868c2dec25be6d84ed04c7b5e5ebefcaec446",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "15170a14e8bfdcc0f76c6ffdaa178451a68c746c67a14dc8704ebef646e17435"
|
|
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.88.0",
|
|
4
|
+
"source_commit": "a7e1965978a24dc9a14e1442c5f40ab26f5732ef",
|
|
5
|
+
"source_sha256": "feb7f17ea84d6a3c072d20ef5f4868c2dec25be6d84ed04c7b5e5ebefcaec446",
|
|
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": "fbef823e6769dfe0e8ff6f624f1aaff2e0adacb19df27f073d7917d722f03f70",
|
|
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": "15170a14e8bfdcc0f76c6ffdaa178451a68c746c67a14dc8704ebef646e17435",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/release-notes.mjs
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// validator: the CLI sends the file's JSON unchanged (no rewriting, no filling
|
|
4
4
|
// in), records the route as `cli`, and prints the stored source key, state and
|
|
5
5
|
// revision, or the named refusal. The tenant is the authenticated agent's.
|
|
6
|
-
import {
|
|
6
|
+
import { randomBytes } from "node:crypto";
|
|
7
|
+
import { open, readFile, rename, rm } from "node:fs/promises";
|
|
7
8
|
import { CALL_EXIT, callToolJson, resolveCallAuth } from "./api.mjs";
|
|
8
9
|
import { cmdReleaseNotesKeys, cmdReleaseNotesOrigins, RELEASE_NOTES_KEYS_USAGE } from "./release-notes-keys.mjs";
|
|
9
10
|
|
|
@@ -13,6 +14,7 @@ export const RELEASE_NOTES_USAGE = `Usage: bb release-notes submit <note.json> [
|
|
|
13
14
|
bb release-notes list [--tag <group>=<value>]... [--type <type>] [--state <state>] [--cursor <cursor>] [--json]
|
|
14
15
|
bb release-notes get <source_key> [--json]
|
|
15
16
|
bb release-notes digest --release <version> --voice internal|external [--format markdown|json|slack] [--repository owner/name] [--json]
|
|
17
|
+
bb release-notes pack --release <version> [--format md] [--customer <name>] [--repository owner/name] [--out <file>] [--json]
|
|
16
18
|
bb release-notes grants list [--tenant <slug>] [--json]
|
|
17
19
|
bb release-notes grants add <email> <submit|manage> [--tenant <slug>] [--json]
|
|
18
20
|
bb release-notes grants remove <email> <submit|manage> [--tenant <slug>] [--json]
|
|
@@ -114,6 +116,13 @@ with no notes prints an explicit empty digest. --json prints the whole answer
|
|
|
114
116
|
repository_required, release_not_shipped, no_previous_release,
|
|
115
117
|
release_range_unavailable, entitlement_missing, scope_missing.
|
|
116
118
|
|
|
119
|
+
Pack (BOT-3261). pack prints the internal release pack for one production
|
|
120
|
+
release as Markdown: a cover section with counts and affected customers, release
|
|
121
|
+
readiness, risks and remaining work, and every change with Before, After, Benefit
|
|
122
|
+
and UI. --customer keeps the changes that customer raised. --out writes a file
|
|
123
|
+
only you can read. The pack is internal: do not send it outside your company.
|
|
124
|
+
Refusals: customer_unknown and the digest's refusals.
|
|
125
|
+
|
|
117
126
|
Exit codes: 0 stored or read · 1 refused or not found · 2 usage · 3 authentication · 5 BotBuddy unreachable.
|
|
118
127
|
|
|
119
128
|
Viewer keys and origins (tenant owners, BOT-3158):
|
|
@@ -128,6 +137,7 @@ export async function cmdReleaseNotes(args, {
|
|
|
128
137
|
log = console.log,
|
|
129
138
|
errorLog = console.error,
|
|
130
139
|
write = (text) => process.stdout.write(text),
|
|
140
|
+
writeFile = writePrivateFile,
|
|
131
141
|
isTTY = process.stdout.isTTY === true,
|
|
132
142
|
} = {}) {
|
|
133
143
|
if (args.length === 0 || ["help", "--help", "-h"].includes(args[0])) {
|
|
@@ -145,6 +155,8 @@ export async function cmdReleaseNotes(args, {
|
|
|
145
155
|
if (args[0] === "origins") return await cmdReleaseNotesOrigins(args.slice(1), { resolveAuth, call, log, errorLog });
|
|
146
156
|
// BOT-3204: the per-release digest.
|
|
147
157
|
if (args[0] === "digest") return await cmdDigest(args.slice(1), { resolveAuth, call, log, errorLog, write, isTTY });
|
|
158
|
+
// BOT-3261: the internal release pack.
|
|
159
|
+
if (args[0] === "pack") return await cmdPack(args.slice(1), { resolveAuth, call, log, errorLog, write, writeFile, isTTY });
|
|
148
160
|
const json = args.includes("--json");
|
|
149
161
|
let rest = args.filter((a) => a !== "--json");
|
|
150
162
|
// BOT-3260: --pack <pack.json>, anywhere after submit.
|
|
@@ -573,6 +585,76 @@ export async function cmdDigest(argv, { resolveAuth, call, log, errorLog, write,
|
|
|
573
585
|
return printRefusalOrFailure(result, json, log, errorLog, "Nothing was changed.");
|
|
574
586
|
}
|
|
575
587
|
|
|
588
|
+
// ── BOT-3261: bb release-notes pack ───────────────────────────────────
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Write a confidential file only its owner can read. An existing file keeps its
|
|
592
|
+
* own permissions when written in place, so a new private file replaces it.
|
|
593
|
+
*/
|
|
594
|
+
export async function writePrivateFile(path, bytes) {
|
|
595
|
+
const temporary = `${path}.${randomBytes(6).toString("hex")}.tmp`;
|
|
596
|
+
const handle = await open(temporary, "wx", 0o600);
|
|
597
|
+
try {
|
|
598
|
+
await handle.writeFile(bytes);
|
|
599
|
+
await handle.close();
|
|
600
|
+
await rename(temporary, path);
|
|
601
|
+
} catch (error) {
|
|
602
|
+
await handle.close().catch(() => {});
|
|
603
|
+
await rm(temporary, { force: true });
|
|
604
|
+
throw error;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
const PACK_TOOL = "get_release_note_pack";
|
|
609
|
+
const PACK_FLAGS = { "--release": "release", "--format": "format", "--customer": "customer", "--repository": "repository", "--out": "out" };
|
|
610
|
+
|
|
611
|
+
export async function cmdPack(argv, { resolveAuth, call, log, errorLog, write, writeFile, isTTY = false }) {
|
|
612
|
+
const json = argv.includes("--json");
|
|
613
|
+
const opts = {};
|
|
614
|
+
for (let i = 0; i < argv.length; i++) {
|
|
615
|
+
const a = argv[i];
|
|
616
|
+
if (a === "--json") continue;
|
|
617
|
+
const key = PACK_FLAGS[a];
|
|
618
|
+
const v = argv[i + 1];
|
|
619
|
+
if (!key || !v || v.startsWith("--") || key in opts) {
|
|
620
|
+
errorLog(RELEASE_NOTES_USAGE);
|
|
621
|
+
return 2;
|
|
622
|
+
}
|
|
623
|
+
opts[key] = v;
|
|
624
|
+
i++;
|
|
625
|
+
}
|
|
626
|
+
if (!opts.release || (opts.format !== undefined && opts.format !== "md")) {
|
|
627
|
+
errorLog(RELEASE_NOTES_USAGE);
|
|
628
|
+
return 2;
|
|
629
|
+
}
|
|
630
|
+
const { out, ...args } = opts;
|
|
631
|
+
|
|
632
|
+
let result;
|
|
633
|
+
try {
|
|
634
|
+
const resolved = await resolveAuth({ toolName: PACK_TOOL, preferSession: true });
|
|
635
|
+
result = resolved?.error || !resolved?.auth
|
|
636
|
+
? { ok: false, auth: true }
|
|
637
|
+
: await call(PACK_TOOL, args, { auth: resolved.auth, signal: AbortSignal.timeout(120_000) });
|
|
638
|
+
} catch {
|
|
639
|
+
result = { ok: false, status: null };
|
|
640
|
+
}
|
|
641
|
+
const data = result?.data;
|
|
642
|
+
if (result?.ok && data?.ok === true && typeof data.body === "string") {
|
|
643
|
+
if (json) log(JSON.stringify(data));
|
|
644
|
+
else if (out) {
|
|
645
|
+
await writeFile(out, data.body);
|
|
646
|
+
log(`Wrote ${out}`);
|
|
647
|
+
} else write(isTTY ? data.body.split("\t").map(termClean).join("\t") : data.body);
|
|
648
|
+
return CALL_EXIT.OK;
|
|
649
|
+
}
|
|
650
|
+
if (result?.ok && data?.ok !== false) {
|
|
651
|
+
if (json) log(JSON.stringify({ ok: false, error: "receipt_unavailable" }));
|
|
652
|
+
errorLog("✗ BotBuddy did not return a pack. Retry the same command; a pack is a read and changes nothing.");
|
|
653
|
+
return CALL_EXIT.ERROR;
|
|
654
|
+
}
|
|
655
|
+
return printRefusalOrFailure(result, json, log, errorLog, "Nothing was changed.");
|
|
656
|
+
}
|
|
657
|
+
|
|
576
658
|
// ── BOT-3166: bb release-notes list | get ──────────────────────────────
|
|
577
659
|
|
|
578
660
|
function readUsage(errorLog) {
|
package/src/test-child.mjs
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// refuses one it cannot execute (CHILD_PLACEMENT_UNSUPPORTED), never running it elsewhere.
|
|
12
12
|
|
|
13
13
|
import { spawn, spawnSync } from "node:child_process";
|
|
14
|
+
import { readFileSync } from "node:fs";
|
|
14
15
|
import { cpus, freemem, loadavg, totalmem } from "node:os";
|
|
15
16
|
|
|
16
17
|
export const TEST_CHILD_CAPACITY = "TEST_CHILD_CAPACITY";
|
|
@@ -24,12 +25,36 @@ export const SAMPLE_METHOD = "ps_tree_sample";
|
|
|
24
25
|
/** The three tool calls, over the run's retrying caller. */
|
|
25
26
|
export function testChildApi(rpc) {
|
|
26
27
|
return {
|
|
27
|
-
place: (leaseId) => rpc.call("place_test_child", { lease_id: leaseId }),
|
|
28
|
+
place: (leaseId, requesterSample) => rpc.call("place_test_child", { lease_id: leaseId, ...(requesterSample ? { requester_sample: requesterSample } : {}) }),
|
|
28
29
|
renew: (slotId) => rpc.call("renew_test_child_slot", { slot_id: slotId }),
|
|
29
30
|
release: (slotId, childResources) => rpc.call("release_test_child_slot", { slot_id: slotId, ...(childResources ? { child_resources: childResources } : {}) }),
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
const roundTo2 = (n) => Math.round(n * 100) / 100;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* BOT-2969: the requester's CPU, memory and load, sent with each placement so a machine that
|
|
38
|
+
* reports no host samples can still be held to its resource limits. Free memory leaves out
|
|
39
|
+
* reclaimable cache, so macOS uses the kernel's memory-pressure level and Linux MemAvailable.
|
|
40
|
+
*/
|
|
41
|
+
export function placementSample({ platform = process.platform, ncpu = cpus().length, total = totalmem(), free = freemem(), load = loadavg(), run = spawnSync, readFile = readFileSync } = {}) {
|
|
42
|
+
let available = free;
|
|
43
|
+
if (platform === "linux") {
|
|
44
|
+
try {
|
|
45
|
+
const kib = Number(/^MemAvailable:\s+(\d+) kB$/m.exec(readFile("/proc/meminfo", "utf8"))?.[1]);
|
|
46
|
+
if (Number.isFinite(kib) && kib > 0) available = kib * 1024;
|
|
47
|
+
} catch { /* no /proc: free memory is the closest reading */ }
|
|
48
|
+
}
|
|
49
|
+
if (platform === "darwin") {
|
|
50
|
+
// nosemgrep: javascript.lang.security.detect-child-process.detect-child-process -- fixed argv, no shell.
|
|
51
|
+
const level = run("sysctl", ["-n", "kern.memorystatus_level"], { encoding: "utf8", timeout: 2_000 });
|
|
52
|
+
const percent = level?.status === 0 ? Number(String(level.stdout).trim()) : NaN;
|
|
53
|
+
if (Number.isFinite(percent) && percent >= 0 && percent <= 100) available = total * percent / 100;
|
|
54
|
+
}
|
|
55
|
+
return { ncpu, mem_total_gb: roundTo2(total / 1024 ** 3), mem_free_gb: roundTo2(available / 1024 ** 3), load1: roundTo2(load?.[0] ?? 0) };
|
|
56
|
+
}
|
|
57
|
+
|
|
33
58
|
/**
|
|
34
59
|
* Codex #1691 P1: a full pool parks on ONE platform wait that wakes when a slot in its pool is
|
|
35
60
|
* released (the `test_child_slot` spine signal, subject = run host) or when the pool's oldest
|
|
@@ -63,11 +88,14 @@ export function defaultTestChildWait(target, { bin = process.execPath, cli = pro
|
|
|
63
88
|
* Returns `{ ok: true, slotId, ttlSeconds, placement, waits }` or
|
|
64
89
|
* `{ ok: false, code, error, placement?, waits }`. Never throws.
|
|
65
90
|
*/
|
|
66
|
-
export async function acquireTestChildSlot({ api, leaseId, wait = defaultTestChildWait, log = () => {}, isStopped = () => false, maxWaits = Infinity, onPark = async () => {}, signal = null }) {
|
|
91
|
+
export async function acquireTestChildSlot({ api, leaseId, wait = defaultTestChildWait, log = () => {}, isStopped = () => false, maxWaits = Infinity, onPark = async () => {}, signal = null, sample = placementSample }) {
|
|
67
92
|
const waits = [];
|
|
68
93
|
for (;;) {
|
|
94
|
+
// A reading that fails never blocks the run: the server then falls back to the host's cap.
|
|
95
|
+
let reading;
|
|
96
|
+
try { reading = sample(); } catch { reading = undefined; }
|
|
69
97
|
let answer;
|
|
70
|
-
try { answer = await api.place(leaseId); } catch (error) { answer = { ok: false, error: String(error?.message ?? error) }; }
|
|
98
|
+
try { answer = await api.place(leaseId, reading); } catch (error) { answer = { ok: false, error: String(error?.message ?? error) }; }
|
|
71
99
|
const data = answer?.data;
|
|
72
100
|
if (answer?.ok && data?.success) {
|
|
73
101
|
const placement = data.child_placement ?? null;
|
|
@@ -82,7 +110,7 @@ export async function acquireTestChildSlot({ api, leaseId, wait = defaultTestChi
|
|
|
82
110
|
const expiryMs = Date.parse(data.next_expiry_at ?? "");
|
|
83
111
|
const deadline = Number.isFinite(expiryMs) ? new Date(expiryMs).toISOString() : new Date(Date.now() + FALLBACK_PARK_MS).toISOString();
|
|
84
112
|
if (waits.length === 0) {
|
|
85
|
-
log(`stack: ${TEST_CHILD_CAPACITY}: all ${data.slots} test_child slot(s) on ${data.run_host} are held — waiting (no slot is held while waiting)`);
|
|
113
|
+
log(`stack: ${TEST_CHILD_CAPACITY}: all ${data.slots} test_child slot(s) on ${data.run_host} are held — waiting (no slot is held while waiting)${data.limit ? ` · limit: ${data.limit}` : ""}`);
|
|
86
114
|
}
|
|
87
115
|
waits.push({ at: new Date().toISOString(), held: data.held ?? null, slots: data.slots ?? null, run_host: data.run_host ?? null });
|
|
88
116
|
if (waits.length > maxWaits || isStopped()) {
|