@sleds/cli 0.1.65 → 0.1.66
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 +75 -25
- package/package.json +1 -1
package/dist/sleds.mjs
CHANGED
|
@@ -11822,7 +11822,7 @@ function beatBody(state, flags, host = {}, cap = {}) {
|
|
|
11822
11822
|
name: flags.name,
|
|
11823
11823
|
os: host.os ?? process.platform,
|
|
11824
11824
|
runner: flags.runner,
|
|
11825
|
-
version: host.version ?? "0.1.
|
|
11825
|
+
version: host.version ?? "0.1.66" ?? "dev",
|
|
11826
11826
|
running: live.length,
|
|
11827
11827
|
items: live.slice(0, BEAT_ITEMS).map((r) => `${r.item}/${r.node}`),
|
|
11828
11828
|
...cap.atOnce !== undefined ? { atOnce: cap.atOnce } : {},
|
|
@@ -18640,7 +18640,7 @@ async function fetchVersion(o) {
|
|
|
18640
18640
|
const platform = o.platform ?? process.platform;
|
|
18641
18641
|
const arch = o.arch ?? process.arch;
|
|
18642
18642
|
const publicKey = o.publicKey ?? RELEASE_PUBLIC_KEY;
|
|
18643
|
-
const running = o.running ?? "0.1.
|
|
18643
|
+
const running = o.running ?? "0.1.66";
|
|
18644
18644
|
if (!publicKey)
|
|
18645
18645
|
return { ok: false, why: "no release key yet" };
|
|
18646
18646
|
if (!VERSION_RE2.test(o.version))
|
|
@@ -19866,7 +19866,7 @@ function engineUpdater(o) {
|
|
|
19866
19866
|
|
|
19867
19867
|
// src/version.ts
|
|
19868
19868
|
function cliVersion(env) {
|
|
19869
|
-
return "0.1.
|
|
19869
|
+
return "0.1.66";
|
|
19870
19870
|
}
|
|
19871
19871
|
|
|
19872
19872
|
// src/commands/update.ts
|
|
@@ -20252,7 +20252,7 @@ function engineClient(o, org, breaker) {
|
|
|
20252
20252
|
...src,
|
|
20253
20253
|
...breaker ? { fetchFn: breaker.fetch } : {},
|
|
20254
20254
|
timeoutMs: ENGINE_TIMEOUT_MS,
|
|
20255
|
-
version: "0.1.
|
|
20255
|
+
version: "0.1.66"
|
|
20256
20256
|
});
|
|
20257
20257
|
const asked = org?.trim() || env.SLEDS_ORG?.trim();
|
|
20258
20258
|
if (asked && !selectOrg(readConfig(o.home), org, env).seat)
|
|
@@ -20558,7 +20558,7 @@ async function driveEngine(o, flags, deps, until = {}) {
|
|
|
20558
20558
|
runner: deps.runner.name,
|
|
20559
20559
|
atOnce: flags.atOnce,
|
|
20560
20560
|
interval: flags.interval,
|
|
20561
|
-
cliVersion: "0.1.
|
|
20561
|
+
cliVersion: "0.1.66"
|
|
20562
20562
|
};
|
|
20563
20563
|
const beat = (checkedAt) => {
|
|
20564
20564
|
const m = deps.machine;
|
|
@@ -22427,7 +22427,7 @@ function engineClient2(o, org, breaker) {
|
|
|
22427
22427
|
...src,
|
|
22428
22428
|
...breaker ? { fetchFn: breaker.fetch } : {},
|
|
22429
22429
|
timeoutMs: ENGINE_TIMEOUT_MS2,
|
|
22430
|
-
version: "0.1.
|
|
22430
|
+
version: "0.1.66"
|
|
22431
22431
|
});
|
|
22432
22432
|
const asked = org?.trim() || env.SLEDS_ORG?.trim();
|
|
22433
22433
|
if (asked && !selectOrg(readConfig(o.home), org, env).seat)
|
|
@@ -22768,7 +22768,7 @@ async function driveEngine2(o, flags, deps, until = {}) {
|
|
|
22768
22768
|
runner: deps.runner.name,
|
|
22769
22769
|
atOnce: flags.atOnce,
|
|
22770
22770
|
interval: flags.interval,
|
|
22771
|
-
cliVersion: "0.1.
|
|
22771
|
+
cliVersion: "0.1.66"
|
|
22772
22772
|
};
|
|
22773
22773
|
const beat = (checkedAt) => {
|
|
22774
22774
|
const m = deps.machine;
|
|
@@ -24879,7 +24879,7 @@ function contextFor(deps) {
|
|
|
24879
24879
|
...src,
|
|
24880
24880
|
fetchFn: deps.fetchFn,
|
|
24881
24881
|
timeoutMs: deps.timeoutMs,
|
|
24882
|
-
version: "0.1.
|
|
24882
|
+
version: "0.1.66"
|
|
24883
24883
|
}), deps.home, now) : null;
|
|
24884
24884
|
return {
|
|
24885
24885
|
channel: "code",
|
|
@@ -28487,8 +28487,38 @@ var sleuthClient = (o) => {
|
|
|
28487
28487
|
};
|
|
28488
28488
|
|
|
28489
28489
|
// src/sleuth/schema.ts
|
|
28490
|
-
var
|
|
28490
|
+
var MAX_QUERY_DEPTH = 10;
|
|
28491
|
+
var TYPE_REF = "kind name ofType { kind name ofType { kind name ofType { kind name } } }";
|
|
28491
28492
|
var INTROSPECTION_QUERY = `query SledsSleuthIntrospection { __schema { queryType { name } types { kind name fields(includeDeprecated: false) { name args { name defaultValue type { ${TYPE_REF} } } type { ${TYPE_REF} } } inputFields { name defaultValue type { ${TYPE_REF} } } } } }`;
|
|
28493
|
+
var queryDepth = (query) => {
|
|
28494
|
+
let braces = 0;
|
|
28495
|
+
let parens = 0;
|
|
28496
|
+
let inString = false;
|
|
28497
|
+
let max = 0;
|
|
28498
|
+
for (let i = 0;i < query.length; i++) {
|
|
28499
|
+
const c = query[i];
|
|
28500
|
+
if (inString) {
|
|
28501
|
+
if (c === "\\")
|
|
28502
|
+
i++;
|
|
28503
|
+
else if (c === '"')
|
|
28504
|
+
inString = false;
|
|
28505
|
+
} else if (c === '"')
|
|
28506
|
+
inString = true;
|
|
28507
|
+
else if (c === "(")
|
|
28508
|
+
parens++;
|
|
28509
|
+
else if (c === ")")
|
|
28510
|
+
parens--;
|
|
28511
|
+
else if (parens > 0)
|
|
28512
|
+
continue;
|
|
28513
|
+
else if (c === "{")
|
|
28514
|
+
braces++;
|
|
28515
|
+
else if (c === "}")
|
|
28516
|
+
braces--;
|
|
28517
|
+
else if (braces > max && /[A-Za-z_]/.test(c))
|
|
28518
|
+
max = braces;
|
|
28519
|
+
}
|
|
28520
|
+
return max;
|
|
28521
|
+
};
|
|
28492
28522
|
var indexSchema = (intro) => ({
|
|
28493
28523
|
query: intro.__schema.queryType.name,
|
|
28494
28524
|
types: new Map(intro.__schema.types.map((t) => [t.name, t]))
|
|
@@ -28877,6 +28907,7 @@ var jsonl = (items) => items.length ? `${items.map((i) => JSON.stringify(i)).joi
|
|
|
28877
28907
|
var readJsonl = (path) => readFileSync32(path, "utf8").split(`
|
|
28878
28908
|
`).filter((l) => l.trim()).map((l) => JSON.parse(l));
|
|
28879
28909
|
var CANNOT_QUERY = /Cannot query field "(\w+)" on type "(\w+)"/;
|
|
28910
|
+
var TOO_DEEP = /\bmax(imum)?\b.{0,24}\bdepth\b|\btoo deep\b/i;
|
|
28880
28911
|
var exportSleuth = async (o) => {
|
|
28881
28912
|
const log = o.log ?? (() => {});
|
|
28882
28913
|
const now = (o.now ?? (() => new Date))();
|
|
@@ -28922,13 +28953,23 @@ var exportSleuth = async (o) => {
|
|
|
28922
28953
|
`);
|
|
28923
28954
|
const schema = indexSchema(intro.data);
|
|
28924
28955
|
manifest.schema.types = schema.types.size;
|
|
28956
|
+
const fitDepth = new Map;
|
|
28925
28957
|
const ask = async (build, steps) => {
|
|
28926
28958
|
const keep = structural(steps);
|
|
28927
28959
|
const root = steps[0]?.field.name ?? "";
|
|
28960
|
+
const path = steps.map((s) => s.field.name).join(".");
|
|
28961
|
+
let depth = fitDepth.get(path) ?? o.depth;
|
|
28928
28962
|
for (let i = 0;i < 25; i++) {
|
|
28929
|
-
const r = await o.client.request(build());
|
|
28963
|
+
const r = await o.client.request(build(depth));
|
|
28930
28964
|
if (r.data && !r.errors.length)
|
|
28931
28965
|
return r.data;
|
|
28966
|
+
const tooDeep = r.errors.some((e) => TOO_DEEP.test(e.message));
|
|
28967
|
+
if (!r.data && tooDeep && depth > 0) {
|
|
28968
|
+
depth--;
|
|
28969
|
+
fitDepth.set(path, depth);
|
|
28970
|
+
log(`sleuth said the query was too deep — reading nested objects ${depth} deep`);
|
|
28971
|
+
continue;
|
|
28972
|
+
}
|
|
28932
28973
|
const prune = new Set;
|
|
28933
28974
|
for (const e of r.errors) {
|
|
28934
28975
|
const m = CANNOT_QUERY.exec(e.message);
|
|
@@ -28946,7 +28987,7 @@ var exportSleuth = async (o) => {
|
|
|
28946
28987
|
}
|
|
28947
28988
|
const why = r.errors.slice(0, 3).map((e) => e.message).join("; ");
|
|
28948
28989
|
if (empty)
|
|
28949
|
-
throw new SleuthError(why || "Sleuth answered with no data",
|
|
28990
|
+
throw new SleuthError(why || "Sleuth answered with no data", !tooDeep);
|
|
28950
28991
|
for (const e of r.errors) {
|
|
28951
28992
|
const tf = e.path ? typeFieldAt(schema, e.path) : undefined;
|
|
28952
28993
|
warn(`${tf ? `${tf}: ` : ""}${e.message}`);
|
|
@@ -28955,7 +28996,7 @@ var exportSleuth = async (o) => {
|
|
|
28955
28996
|
}
|
|
28956
28997
|
throw new SleuthError("Sleuth kept refusing fields after 25 tries", false);
|
|
28957
28998
|
};
|
|
28958
|
-
const buildQuery = (steps, leafValues) => {
|
|
28999
|
+
const buildQuery = (steps, leafValues, depth) => {
|
|
28959
29000
|
const last = steps.length - 1;
|
|
28960
29001
|
const argsAt = (i) => {
|
|
28961
29002
|
const st = steps[i];
|
|
@@ -28964,15 +29005,24 @@ var exportSleuth = async (o) => {
|
|
|
28964
29005
|
return renderArgs(st.args, { org: o.org, ...st.args.size ? { size: NESTED_SIZE } : {} });
|
|
28965
29006
|
};
|
|
28966
29007
|
const leaf = steps[last];
|
|
28967
|
-
const
|
|
28968
|
-
|
|
28969
|
-
|
|
28970
|
-
|
|
28971
|
-
|
|
28972
|
-
|
|
28973
|
-
|
|
28974
|
-
|
|
28975
|
-
|
|
29008
|
+
const render = (d) => {
|
|
29009
|
+
const sel = buildSelection(schema, leaf.shape.item, d, exclude) ?? "{ __typename }";
|
|
29010
|
+
let inner = `${leaf.field.name}${argsAt(last)} ${wrapShape(leaf.shape, sel)}`;
|
|
29011
|
+
for (let i = last - 1;i >= 0; i--) {
|
|
29012
|
+
const st = steps[i];
|
|
29013
|
+
const ident = identitySelection(schema, st.shape.item, exclude);
|
|
29014
|
+
const body = `{ ${ident ? `${ident.slice(2, -2)} ` : ""}${inner} }`;
|
|
29015
|
+
inner = `${st.field.name}${argsAt(i)} ${wrapShape(st.shape, body)}`;
|
|
29016
|
+
}
|
|
29017
|
+
return `query { ${inner} }`;
|
|
29018
|
+
};
|
|
29019
|
+
let d = depth;
|
|
29020
|
+
let q = render(d);
|
|
29021
|
+
while (d > 0 && queryDepth(q) > MAX_QUERY_DEPTH)
|
|
29022
|
+
q = render(--d);
|
|
29023
|
+
if (d < o.depth)
|
|
29024
|
+
warn(`${leaf.field.name}: nested objects read ${d} deep, not ${o.depth} — Sleuth's max depth`);
|
|
29025
|
+
return q;
|
|
28976
29026
|
};
|
|
28977
29027
|
const extract = (steps, data) => {
|
|
28978
29028
|
let level = [
|
|
@@ -29018,7 +29068,7 @@ var exportSleuth = async (o) => {
|
|
|
29018
29068
|
...canPage && a.page ? { page } : {},
|
|
29019
29069
|
...canPage && !a.cursor && !a.page && a.offset ? { offset } : {}
|
|
29020
29070
|
};
|
|
29021
|
-
const data = await ask(() => buildQuery(steps, values), steps);
|
|
29071
|
+
const data = await ask((depth) => buildQuery(steps, values, depth), steps);
|
|
29022
29072
|
const { items, infos } = extract(steps, data);
|
|
29023
29073
|
if (!canPage) {
|
|
29024
29074
|
const full = oneParent && a.size !== undefined && items.length >= (values.size ?? 0);
|
|
@@ -30179,7 +30229,7 @@ var realPidAlive4 = (pid) => {
|
|
|
30179
30229
|
};
|
|
30180
30230
|
function machineClient(home, env) {
|
|
30181
30231
|
const src = meterSource(home, undefined, { env });
|
|
30182
|
-
return src ? fetchClient({ ...src, version: "0.1.
|
|
30232
|
+
return src ? fetchClient({ ...src, version: "0.1.66" }) : null;
|
|
30183
30233
|
}
|
|
30184
30234
|
async function noteAnswer2(home, a, now) {
|
|
30185
30235
|
try {
|
|
@@ -31053,7 +31103,7 @@ var main = async (argv) => {
|
|
|
31053
31103
|
now: Date.now(),
|
|
31054
31104
|
stderr: (line) => console.error(line),
|
|
31055
31105
|
isTTY: !!process.stderr.isTTY,
|
|
31056
|
-
version: "0.1.
|
|
31106
|
+
version: "0.1.66"
|
|
31057
31107
|
});
|
|
31058
31108
|
switch (cmd) {
|
|
31059
31109
|
case "update":
|
|
@@ -31288,7 +31338,7 @@ ${renderHelpText(argv[1])}`);
|
|
|
31288
31338
|
case "version":
|
|
31289
31339
|
case "--version":
|
|
31290
31340
|
case "-v":
|
|
31291
|
-
console.log("sleds 0.1.
|
|
31341
|
+
console.log("sleds 0.1.66");
|
|
31292
31342
|
return 0;
|
|
31293
31343
|
default:
|
|
31294
31344
|
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.66",
|
|
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",
|