@botbuddy/cli 1.87.0 → 1.88.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/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/stack.mjs +17 -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.1",
|
|
3
|
+
"source_commit": "508207356e37ed870509edeb6d62f0701eb791fd",
|
|
4
|
+
"source_sha256": "1fcfb80e9431faf565ef098ada6526ed82f7ba00e8c17ebb71b798e098cf4a09",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "f3640cca8a17949e542670ffb5fb8b36a964d001d896b8578b15a8c684faa646"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.88.1",
|
|
3
|
+
"source_commit": "508207356e37ed870509edeb6d62f0701eb791fd",
|
|
4
|
+
"source_sha256": "1fcfb80e9431faf565ef098ada6526ed82f7ba00e8c17ebb71b798e098cf4a09",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "2d6be8f6b90df35aa201445c2e13bcd91db6194856b15286af4c513f2ac0d5e5"
|
|
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.1",
|
|
4
|
+
"source_commit": "508207356e37ed870509edeb6d62f0701eb791fd",
|
|
5
|
+
"source_sha256": "1fcfb80e9431faf565ef098ada6526ed82f7ba00e8c17ebb71b798e098cf4a09",
|
|
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": "f3640cca8a17949e542670ffb5fb8b36a964d001d896b8578b15a8c684faa646",
|
|
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": "2d6be8f6b90df35aa201445c2e13bcd91db6194856b15286af4c513f2ac0d5e5",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/stack.mjs
CHANGED
|
@@ -1533,6 +1533,19 @@ export function staleContextFenceScope(data) {
|
|
|
1533
1533
|
return data?.code === "STALE_AGENT_CONTEXT" && (data.fence_scope === "session" || data.fence_scope === "agent") ? data.fence_scope : null;
|
|
1534
1534
|
}
|
|
1535
1535
|
|
|
1536
|
+
/** BOT-3275: the shape-checked fields of a stale-context refusal, kept when an admission answer is rebuilt. */
|
|
1537
|
+
export function staleContextRefusalFields(data) {
|
|
1538
|
+
const fenceScope = staleContextFenceScope(data);
|
|
1539
|
+
const ticketField = (value) => (typeof value === "string" && STALE_CONTEXT_TICKET_RE.test(value) ? value : null);
|
|
1540
|
+
const registered = ticketField(data?.registered_ticket_id);
|
|
1541
|
+
const requested = ticketField(data?.requested_ticket_id);
|
|
1542
|
+
return {
|
|
1543
|
+
...(registered ? { registered_ticket_id: registered } : {}),
|
|
1544
|
+
...(requested ? { requested_ticket_id: requested } : {}),
|
|
1545
|
+
...(fenceScope ? { fence_scope: fenceScope } : {}),
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1536
1549
|
/** BOT-2977: the ticket this checkout's branch names (null when none), read only for a stale-context refusal. */
|
|
1537
1550
|
export async function currentBranchTicket(cwd = process.cwd()) {
|
|
1538
1551
|
try {
|
|
@@ -4668,7 +4681,10 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
4668
4681
|
...(res.data?.phase ? { phase: res.data.phase } : {}), ...(res.data?.wait ? { wait: res.data.wait } : {}),
|
|
4669
4682
|
// BOT-2812: the database ran the call and rolled it back; its SQLSTATE names the class.
|
|
4670
4683
|
...(code === "ADMISSION_FAILED" && SQLSTATE_RE.test(res.data?.sqlstate ?? "") ? { sqlstate: res.data.sqlstate } : {}),
|
|
4671
|
-
...(code === HOST_CAPACITY_SOURCE_STALE_CODE ? capacityStaleReceiptFields(res.data) : {})
|
|
4684
|
+
...(code === HOST_CAPACITY_SOURCE_STALE_CODE ? capacityStaleReceiptFields(res.data) : {}),
|
|
4685
|
+
// BOT-3275: the fence's own answer, so the hint names both tickets and the
|
|
4686
|
+
// receipt and outcome row carry which fence refused (BOT-2977).
|
|
4687
|
+
...(code === "STALE_AGENT_CONTEXT" ? staleContextRefusalFields(res.data) : {}) } };
|
|
4672
4688
|
} else {
|
|
4673
4689
|
const ack = identifiedAdmissionAck(res.data, leaseArgs.request_id);
|
|
4674
4690
|
// A malformed or foreign ACK is untrusted: never cleanup authority, never adopted.
|
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()) {
|