@sleds/cli 0.1.45 → 0.1.46
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/dist/sleds.mjs +62 -17
- package/package.json +1 -1
package/dist/sleds.mjs
CHANGED
|
@@ -11131,7 +11131,7 @@ function beatBody(state, flags, host = {}, cap = {}) {
|
|
|
11131
11131
|
name: flags.name,
|
|
11132
11132
|
os: host.os ?? process.platform,
|
|
11133
11133
|
runner: flags.runner,
|
|
11134
|
-
version: host.version ?? "0.1.
|
|
11134
|
+
version: host.version ?? "0.1.46" ?? "dev",
|
|
11135
11135
|
running: live.length,
|
|
11136
11136
|
items: live.slice(0, BEAT_ITEMS).map((r) => `${r.item}/${r.node}`),
|
|
11137
11137
|
...cap.atOnce !== undefined ? { atOnce: cap.atOnce } : {},
|
|
@@ -12322,21 +12322,17 @@ async function readProfile(client) {
|
|
|
12322
12322
|
}
|
|
12323
12323
|
function nextPickup(r, o) {
|
|
12324
12324
|
const mine = Array.isArray(r.mine) ? r.mine.filter(isObject8) : [];
|
|
12325
|
-
let running = 0;
|
|
12326
12325
|
for (const row of mine) {
|
|
12327
12326
|
const route = row.route;
|
|
12328
|
-
if (isObject8(route)
|
|
12329
|
-
running++;
|
|
12330
|
-
if (!isObject8(route) || !isObject8(route.armed))
|
|
12327
|
+
if (!isObject8(route) || !armedFor(route.armed, o.engine))
|
|
12331
12328
|
continue;
|
|
12332
12329
|
const states = isObject8(route.states) ? route.states : {};
|
|
12333
|
-
|
|
12334
|
-
if (!armedFor(route.armed, o.engine) || statesLanded(states))
|
|
12330
|
+
if (statesLanded(states))
|
|
12335
12331
|
continue;
|
|
12336
12332
|
if (strings(route.ready).length > 0)
|
|
12337
12333
|
return null;
|
|
12338
12334
|
}
|
|
12339
|
-
if (
|
|
12335
|
+
if (sledRunning(mine) >= o.atOnce)
|
|
12340
12336
|
return null;
|
|
12341
12337
|
for (const row of mine) {
|
|
12342
12338
|
const route = row.route;
|
|
@@ -12352,6 +12348,33 @@ function nextPickup(r, o) {
|
|
|
12352
12348
|
}
|
|
12353
12349
|
return null;
|
|
12354
12350
|
}
|
|
12351
|
+
function sledRunning(r) {
|
|
12352
|
+
const mine = Array.isArray(r) ? r : Array.isArray(r.mine) ? r.mine.filter(isObject8) : [];
|
|
12353
|
+
let running = 0;
|
|
12354
|
+
for (const row of mine) {
|
|
12355
|
+
const route = row.route;
|
|
12356
|
+
if (isObject8(route) && route.drafting === true)
|
|
12357
|
+
running++;
|
|
12358
|
+
if (!isObject8(route) || !isObject8(route.armed))
|
|
12359
|
+
continue;
|
|
12360
|
+
running += keysIn(isObject8(route.states) ? route.states : {}, "running").length;
|
|
12361
|
+
}
|
|
12362
|
+
return running;
|
|
12363
|
+
}
|
|
12364
|
+
function armedDrafts(r, engine) {
|
|
12365
|
+
const mine = Array.isArray(r.mine) ? r.mine.filter(isObject8) : [];
|
|
12366
|
+
return mine.filter((row) => {
|
|
12367
|
+
const route = row.route;
|
|
12368
|
+
if (!isObject8(route) || !armedFor(route.armed, engine) || route.implicit !== true)
|
|
12369
|
+
return false;
|
|
12370
|
+
if (route.drafting === true || route.proposed === true || route.draftParked)
|
|
12371
|
+
return false;
|
|
12372
|
+
if (strings(route.needsRoute).length === 0 || isPrMirror(row.source))
|
|
12373
|
+
return false;
|
|
12374
|
+
const states = isObject8(route.states) ? route.states : {};
|
|
12375
|
+
return !statesLanded(states) && keysIn(states, "running").length === 0;
|
|
12376
|
+
});
|
|
12377
|
+
}
|
|
12355
12378
|
function redraftDue(route) {
|
|
12356
12379
|
return isObject8(route) && isObject8(route.redraft) && route.drafting !== true && route.proposed !== true;
|
|
12357
12380
|
}
|
|
@@ -12365,14 +12388,15 @@ function routeText(route, states) {
|
|
|
12365
12388
|
}
|
|
12366
12389
|
function sledsSource(client, o) {
|
|
12367
12390
|
const routeOf = (q) => client.get(`/proxy/route?q=${encodeURIComponent(q)}`);
|
|
12368
|
-
async function pickup(sled) {
|
|
12391
|
+
async function pickup(sled, drafted) {
|
|
12369
12392
|
const engine = o.engine;
|
|
12370
12393
|
const profile = await readProfile(client);
|
|
12371
12394
|
if (profile?.pickup !== "auto")
|
|
12372
12395
|
return null;
|
|
12373
12396
|
if (profile.engine && !sameEngine(profile.engine, engine))
|
|
12374
12397
|
return null;
|
|
12375
|
-
const
|
|
12398
|
+
const atOnce = (o.atOnce ?? profile.atOnce ?? 1) - drafted;
|
|
12399
|
+
const row = nextPickup(sled, { atOnce, engine });
|
|
12376
12400
|
if (!row)
|
|
12377
12401
|
return null;
|
|
12378
12402
|
const item = str6(row.key) ?? String(row.project);
|
|
@@ -12400,7 +12424,7 @@ function sledsSource(client, o) {
|
|
|
12400
12424
|
...armedTerms(armed)
|
|
12401
12425
|
};
|
|
12402
12426
|
}
|
|
12403
|
-
async function draft(row, item, why) {
|
|
12427
|
+
async function draft(row, item, why, started = false) {
|
|
12404
12428
|
const project = str6(row.project) ?? item;
|
|
12405
12429
|
const pending = isObject8(row.route) && isObject8(row.route.redraft) ? row.route.redraft : null;
|
|
12406
12430
|
const runner = typeof o.runner === "function" ? o.runner() : o.runner;
|
|
@@ -12412,7 +12436,7 @@ function sledsSource(client, o) {
|
|
|
12412
12436
|
...o.leaseMin !== undefined ? { leaseMin: o.leaseMin } : {}
|
|
12413
12437
|
});
|
|
12414
12438
|
if (!r || r.status >= 300 || !r.json || r.json.ok === false) {
|
|
12415
|
-
o.log?.(`${pending ? `${item}: could not claim the re-draft` : `Pickup: Auto could not claim ${item} for drafting`} — ${r ? serverMessage(r) : UNREACHABLE2}`);
|
|
12439
|
+
o.log?.(`${pending ? `${item}: could not claim the re-draft` : started ? `${item}: Start could not claim it for drafting` : `Pickup: Auto could not claim ${item} for drafting`} — ${r ? serverMessage(r) : UNREACHABLE2}`);
|
|
12416
12440
|
return null;
|
|
12417
12441
|
}
|
|
12418
12442
|
const j = r.json;
|
|
@@ -12434,7 +12458,7 @@ function sledsSource(client, o) {
|
|
|
12434
12458
|
route: routeText(brief, isObject8(row.route) ? row.route.states : null)
|
|
12435
12459
|
};
|
|
12436
12460
|
}
|
|
12437
|
-
o.log?.(redraft ? `${item}: re-drafting the route from ${redraft.by}'s answer — it waits for a yes` : `Pickup: Auto is drafting ${item}'s route first (${why.join(", ")}) — it waits for a yes`);
|
|
12461
|
+
o.log?.(redraft ? `${item}: re-drafting the route from ${redraft.by}'s answer — it waits for a yes` : `${started ? `${item}: Start` : "Pickup: Auto"} is drafting ${started ? "its" : `${item}'s`} route first (${why.join(", ")}) — it waits for a yes`);
|
|
12438
12462
|
const leaseUntil = num5(j.leaseUntil);
|
|
12439
12463
|
const claim = {
|
|
12440
12464
|
item,
|
|
@@ -12474,7 +12498,28 @@ function sledsSource(client, o) {
|
|
|
12474
12498
|
if (claimed?.draft && it)
|
|
12475
12499
|
it.draft = claimed.draft;
|
|
12476
12500
|
}
|
|
12477
|
-
const
|
|
12501
|
+
const waiting = armedDrafts(r, o.engine);
|
|
12502
|
+
let drafted = 0;
|
|
12503
|
+
if (waiting.length > 0) {
|
|
12504
|
+
const cap = o.atOnce ?? (await readProfile(client))?.atOnce ?? 1;
|
|
12505
|
+
let room = cap - sledRunning(r);
|
|
12506
|
+
for (const row of waiting) {
|
|
12507
|
+
const item = str6(row.key) ?? String(row.project);
|
|
12508
|
+
const it = items.find((x) => x.item === item);
|
|
12509
|
+
if (it)
|
|
12510
|
+
it.ready = [];
|
|
12511
|
+
if (room <= 0)
|
|
12512
|
+
continue;
|
|
12513
|
+
const route = isObject8(row.route) ? row.route : {};
|
|
12514
|
+
const claimed = await draft(row, item, strings(route.needsRoute), true);
|
|
12515
|
+
if (claimed?.draft && it) {
|
|
12516
|
+
it.draft = claimed.draft;
|
|
12517
|
+
drafted++;
|
|
12518
|
+
room--;
|
|
12519
|
+
}
|
|
12520
|
+
}
|
|
12521
|
+
}
|
|
12522
|
+
const picked = await pickup(r, drafted);
|
|
12478
12523
|
if (picked)
|
|
12479
12524
|
items.push(picked);
|
|
12480
12525
|
}
|
|
@@ -17001,7 +17046,7 @@ async function driveEngine(o, flags, deps, until = {}) {
|
|
|
17001
17046
|
runner: deps.runner.name,
|
|
17002
17047
|
atOnce: flags.atOnce,
|
|
17003
17048
|
interval: flags.interval,
|
|
17004
|
-
cliVersion: "0.1.
|
|
17049
|
+
cliVersion: "0.1.46"
|
|
17005
17050
|
};
|
|
17006
17051
|
const beat = (checkedAt) => {
|
|
17007
17052
|
const m = deps.machine;
|
|
@@ -19138,7 +19183,7 @@ async function driveEngine2(o, flags, deps, until = {}) {
|
|
|
19138
19183
|
runner: deps.runner.name,
|
|
19139
19184
|
atOnce: flags.atOnce,
|
|
19140
19185
|
interval: flags.interval,
|
|
19141
|
-
cliVersion: "0.1.
|
|
19186
|
+
cliVersion: "0.1.46"
|
|
19142
19187
|
};
|
|
19143
19188
|
const beat = (checkedAt) => {
|
|
19144
19189
|
const m = deps.machine;
|
|
@@ -25790,7 +25835,7 @@ ${renderHelpText(argv[1])}`);
|
|
|
25790
25835
|
case "version":
|
|
25791
25836
|
case "--version":
|
|
25792
25837
|
case "-v":
|
|
25793
|
-
console.log("sleds 0.1.
|
|
25838
|
+
console.log("sleds 0.1.46");
|
|
25794
25839
|
return 0;
|
|
25795
25840
|
default:
|
|
25796
25841
|
console.error(`unknown command: ${cmd}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleds/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.46",
|
|
4
4
|
"description": "SLEDS CLI — the cost and limits of AI agent work, decided at the wall. Point Claude Code at a SLEDS proxy; estimate before you run; hold, switch model, or run overnight when you hit a limit.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|