@botbuddy/cli 1.87.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.
|
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/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()) {
|