@rulvar/cli 1.223.0 → 1.225.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/dist/cli.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/{io-BatQdCln.js → io-Cc-obcZx.js} +105 -49
- package/package.json +7 -7
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -57,7 +57,11 @@ declare function invoiceCommand(argv: string[], context: CommandContext): Promis
|
|
|
57
57
|
* settle is recorded and is the billing boundary, and the settled
|
|
58
58
|
* fold, the invoice totals and the wire cardinality agree. Exit 1
|
|
59
59
|
* with the failing checks named when any diverge, which is exactly
|
|
60
|
-
* what a pre-RV1904 journal (the benchmark's own) reports.
|
|
60
|
+
* what a pre-RV1904 journal (the benchmark's own) reports. `--all`
|
|
61
|
+
* (RV2209) runs the same six checks over EVERY run the store lists,
|
|
62
|
+
* one summary row each, exit 1 when any run diverges: the parity
|
|
63
|
+
* sessions audited seven journals one invocation at a time, and a
|
|
64
|
+
* catalog posture check should cost one command.
|
|
61
65
|
*/
|
|
62
66
|
declare function costAuditCommand(argv: string[], context: CommandContext): Promise<number>;
|
|
63
67
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as assembleEngine, a as inspectCommand, b as looksLikeFile, c as resumeCommand, d as driveRun, f as reportOutcome, g as DEFAULT_STORE_DIR, h as renderEventLine, i as costAuditCommand, l as runCommand, m as attachProgress, n as HELP, o as invoiceCommand, p as strictExitCode, r as runCli, s as preflightCommand, t as processIo, u as runsLsCommand, v as loadCliConfig, y as loadWorkflowModule } from "./io-
|
|
1
|
+
import { _ as assembleEngine, a as inspectCommand, b as looksLikeFile, c as resumeCommand, d as driveRun, f as reportOutcome, g as DEFAULT_STORE_DIR, h as renderEventLine, i as costAuditCommand, l as runCommand, m as attachProgress, n as HELP, o as invoiceCommand, p as strictExitCode, r as runCli, s as preflightCommand, t as processIo, u as runsLsCommand, v as loadCliConfig, y as loadWorkflowModule } from "./io-Cc-obcZx.js";
|
|
2
2
|
import { ConfigError, JournalCompatibilityError, LeaseHeldError, Replayer, RulvarError, buildDeriverRegistry, compileSecretMasker, costReportFromJournal, journalPricingSnapshot, maskSecrets, normalizeEntry, persistedTerminalEnvelope, readRunMeta, scanJournalCompatibility, validateDetachedResolution } from "@rulvar/core";
|
|
3
3
|
//#region src/server.ts
|
|
4
4
|
/**
|
|
@@ -560,8 +560,13 @@ const GRAMMAR = {
|
|
|
560
560
|
},
|
|
561
561
|
"cost-audit": {
|
|
562
562
|
command: "cost-audit",
|
|
563
|
-
positionals: [
|
|
564
|
-
|
|
563
|
+
positionals: [],
|
|
564
|
+
optionalPositionals: ["<runId>"],
|
|
565
|
+
flags: [
|
|
566
|
+
STORE,
|
|
567
|
+
{ name: "all" },
|
|
568
|
+
{ name: "json" }
|
|
569
|
+
]
|
|
565
570
|
},
|
|
566
571
|
plan: {
|
|
567
572
|
command: "plan",
|
|
@@ -666,11 +671,16 @@ function renderFlags(flags) {
|
|
|
666
671
|
}
|
|
667
672
|
return tokens;
|
|
668
673
|
}
|
|
674
|
+
/** Optional positionals rendered bracketed, e.g. `[<runId>]` (RV2209). */
|
|
675
|
+
function bracketedOptionals(grammar) {
|
|
676
|
+
return (grammar.optionalPositionals ?? []).map((placeholder) => `[${placeholder}]`);
|
|
677
|
+
}
|
|
669
678
|
/** The full invocation shape, e.g. `rulvar run <file|name> [--args JSON] ...`. */
|
|
670
679
|
function invocationOf(grammar) {
|
|
671
680
|
const parts = [
|
|
672
681
|
`rulvar ${grammar.command}`,
|
|
673
682
|
...grammar.positionals,
|
|
683
|
+
...bracketedOptionals(grammar),
|
|
674
684
|
...renderFlags(grammar.flags)
|
|
675
685
|
];
|
|
676
686
|
if (grammar.note !== void 0) parts.push(grammar.note);
|
|
@@ -701,7 +711,8 @@ function helpCommandLines() {
|
|
|
701
711
|
const heads = top.map((grammar) => [
|
|
702
712
|
"rulvar",
|
|
703
713
|
grammar.command,
|
|
704
|
-
...grammar.positionals
|
|
714
|
+
...grammar.positionals,
|
|
715
|
+
...bracketedOptionals(grammar)
|
|
705
716
|
].join(" "));
|
|
706
717
|
const kbHead = "rulvar kb <list | inbox | gate | sweep>";
|
|
707
718
|
const width = Math.max(...heads.map((head) => head.length), 39);
|
|
@@ -772,8 +783,9 @@ function parseCommand(grammar, argv) {
|
|
|
772
783
|
throw error;
|
|
773
784
|
}
|
|
774
785
|
if (raw.positionals.length < grammar.positionals.length) throw new ConfigError(usageOf(grammar));
|
|
775
|
-
|
|
776
|
-
|
|
786
|
+
const maxPositionals = grammar.positionals.length + (grammar.optionalPositionals?.length ?? 0);
|
|
787
|
+
if (raw.positionals.length > maxPositionals) {
|
|
788
|
+
const extra = raw.positionals[maxPositionals];
|
|
777
789
|
throw new ConfigError(`unexpected extra argument '${extra}'; ${usageOf(grammar)}`);
|
|
778
790
|
}
|
|
779
791
|
const values = {};
|
|
@@ -1284,31 +1296,9 @@ async function invoiceCommand(argv, context) {
|
|
|
1284
1296
|
for (const item of invoice.unpriced) context.io.out(`unpriced: ${item.model} (${item.usage.inputTokens + item.usage.outputTokens} tok)`);
|
|
1285
1297
|
return 0;
|
|
1286
1298
|
}
|
|
1287
|
-
|
|
1288
|
-
* cost-audit (RV1910): the denominator diagnostic over one stored run.
|
|
1289
|
-
* The four-role benchmark's recovery run produced four mutually
|
|
1290
|
-
* inconsistent cost views; the lifecycle now admits one, and this
|
|
1291
|
-
* command VERIFIES it on a concrete journal instead of trusting the
|
|
1292
|
-
* doctrine: the roster is closed (every agent entry terminal), the
|
|
1293
|
-
* settle is recorded and is the billing boundary, and the settled
|
|
1294
|
-
* fold, the invoice totals and the wire cardinality agree. Exit 1
|
|
1295
|
-
* with the failing checks named when any diverge, which is exactly
|
|
1296
|
-
* what a pre-RV1904 journal (the benchmark's own) reports.
|
|
1297
|
-
*/
|
|
1298
|
-
async function costAuditCommand(argv, context) {
|
|
1299
|
-
const parsed = parseCommand(GRAMMAR["cost-audit"], argv);
|
|
1300
|
-
const runId = parsed.positionals[0];
|
|
1301
|
-
const store = parsed.values.store;
|
|
1302
|
-
const json = parsed.values.json === true;
|
|
1303
|
-
const assembled = assembleEngine({
|
|
1304
|
-
config: await loadCliConfig(context.cwd),
|
|
1305
|
-
...store === void 0 ? {} : { storePath: store },
|
|
1306
|
-
cwd: context.cwd
|
|
1307
|
-
});
|
|
1308
|
-
if (await readRunMeta(assembled.store, runId) === void 0) throw new ConfigError(`run '${runId}' not found in the store`);
|
|
1309
|
-
const entries = await assembled.store.load(runId);
|
|
1299
|
+
function auditJournalEntries(entries, basePriceUsd) {
|
|
1310
1300
|
const snapshot = journalPricingSnapshot(entries);
|
|
1311
|
-
const composed = snapshot === void 0 ?
|
|
1301
|
+
const composed = snapshot === void 0 ? basePriceUsd : snapshot.composedPriceUsd(basePriceUsd);
|
|
1312
1302
|
const report = costReportFromJournal(entries, composed);
|
|
1313
1303
|
const invoice = invoiceFromJournal(entries, composed);
|
|
1314
1304
|
const terminalRefs = new Set(entries.filter((entry) => entry.kind === "agent" && entry.status !== "running").map((entry) => entry.ref));
|
|
@@ -1371,30 +1361,96 @@ async function costAuditCommand(argv, context) {
|
|
|
1371
1361
|
detail: incrementalMismatches.length === 0 ? "every terminal dispatch set equals its incremental rows (RV2008; absent rows pass)" : `terminal dispatch sets diverge from the incremental rows for agent seq ${incrementalMismatches.join(", ")}`
|
|
1372
1362
|
}
|
|
1373
1363
|
];
|
|
1374
|
-
|
|
1364
|
+
return {
|
|
1365
|
+
report,
|
|
1366
|
+
invoice,
|
|
1367
|
+
checks,
|
|
1368
|
+
failed: checks.filter((check) => !check.pass)
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
/** The one JSON shape of a run's audit, shared by both command forms. */
|
|
1372
|
+
function costAuditRunJson(runId, audit) {
|
|
1373
|
+
return {
|
|
1374
|
+
runId,
|
|
1375
|
+
verdict: audit.failed.length === 0 ? "one-denominator" : "divergent",
|
|
1376
|
+
settled: {
|
|
1377
|
+
totalUsd: audit.report.totalUsd,
|
|
1378
|
+
grossUsd: audit.report.grossUsd,
|
|
1379
|
+
wireRequests: audit.report.wireRequests ?? null
|
|
1380
|
+
},
|
|
1381
|
+
invoice: {
|
|
1382
|
+
totalUsd: audit.invoice.totalUsd,
|
|
1383
|
+
rows: audit.invoice.rows.length,
|
|
1384
|
+
wireRequests: audit.invoice.cardinality.wireRequests
|
|
1385
|
+
},
|
|
1386
|
+
checks: audit.checks
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* cost-audit (RV1910): the denominator diagnostic over one stored run.
|
|
1391
|
+
* The four-role benchmark's recovery run produced four mutually
|
|
1392
|
+
* inconsistent cost views; the lifecycle now admits one, and this
|
|
1393
|
+
* command VERIFIES it on a concrete journal instead of trusting the
|
|
1394
|
+
* doctrine: the roster is closed (every agent entry terminal), the
|
|
1395
|
+
* settle is recorded and is the billing boundary, and the settled
|
|
1396
|
+
* fold, the invoice totals and the wire cardinality agree. Exit 1
|
|
1397
|
+
* with the failing checks named when any diverge, which is exactly
|
|
1398
|
+
* what a pre-RV1904 journal (the benchmark's own) reports. `--all`
|
|
1399
|
+
* (RV2209) runs the same six checks over EVERY run the store lists,
|
|
1400
|
+
* one summary row each, exit 1 when any run diverges: the parity
|
|
1401
|
+
* sessions audited seven journals one invocation at a time, and a
|
|
1402
|
+
* catalog posture check should cost one command.
|
|
1403
|
+
*/
|
|
1404
|
+
async function costAuditCommand(argv, context) {
|
|
1405
|
+
const parsed = parseCommand(GRAMMAR["cost-audit"], argv);
|
|
1406
|
+
const runId = parsed.positionals[0];
|
|
1407
|
+
const all = parsed.values.all === true;
|
|
1408
|
+
const store = parsed.values.store;
|
|
1409
|
+
const json = parsed.values.json === true;
|
|
1410
|
+
if (all && runId !== void 0) throw new ConfigError(`--all audits every run of the store; drop the '${runId}' positional; ` + usageOf(GRAMMAR["cost-audit"]));
|
|
1411
|
+
if (!all && runId === void 0) throw new ConfigError(`name a runId, or audit the whole store with --all; ${usageOf(GRAMMAR["cost-audit"])}`);
|
|
1412
|
+
const assembled = assembleEngine({
|
|
1413
|
+
config: await loadCliConfig(context.cwd),
|
|
1414
|
+
...store === void 0 ? {} : { storePath: store },
|
|
1415
|
+
cwd: context.cwd
|
|
1416
|
+
});
|
|
1417
|
+
if (runId !== void 0) {
|
|
1418
|
+
if (await readRunMeta(assembled.store, runId) === void 0) throw new ConfigError(`run '${runId}' not found in the store`);
|
|
1419
|
+
const audit = auditJournalEntries(await assembled.store.load(runId), assembled.priceUsd);
|
|
1420
|
+
if (json) {
|
|
1421
|
+
context.io.out(JSON.stringify(costAuditRunJson(runId, audit), null, 2));
|
|
1422
|
+
return audit.failed.length === 0 ? 0 : 1;
|
|
1423
|
+
}
|
|
1424
|
+
context.io.out(`run ${runId}: cost audit (${audit.failed.length === 0 ? "one denominator" : "DIVERGENT"})`);
|
|
1425
|
+
context.io.out(`settled: gross $${audit.report.grossUsd.toFixed(4)} | net $${audit.report.totalUsd.toFixed(4)} | wires ${String(audit.report.wireRequests ?? "absent")}`);
|
|
1426
|
+
context.io.out(`invoice: total $${audit.invoice.totalUsd.toFixed(4)} | rows ${String(audit.invoice.rows.length)} | wires ${String(audit.invoice.cardinality.wireRequests)}`);
|
|
1427
|
+
for (const check of audit.checks) context.io.out(` [${check.pass ? "pass" : "FAIL"}] ${check.name}: ${check.detail}`);
|
|
1428
|
+
return audit.failed.length === 0 ? 0 : 1;
|
|
1429
|
+
}
|
|
1430
|
+
const sorted = [...await assembled.store.listRuns()].sort((a, b) => a.runId < b.runId ? -1 : a.runId > b.runId ? 1 : 0);
|
|
1431
|
+
const rows = [];
|
|
1432
|
+
for (const meta of sorted) {
|
|
1433
|
+
const entries = await assembled.store.load(meta.runId);
|
|
1434
|
+
rows.push({
|
|
1435
|
+
runId: meta.runId,
|
|
1436
|
+
audit: auditJournalEntries(entries, assembled.priceUsd)
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
const divergent = rows.filter((row) => row.audit.failed.length > 0);
|
|
1375
1440
|
if (json) {
|
|
1376
1441
|
context.io.out(JSON.stringify({
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
totalUsd: report.totalUsd,
|
|
1381
|
-
grossUsd: report.grossUsd,
|
|
1382
|
-
wireRequests: report.wireRequests ?? null
|
|
1383
|
-
},
|
|
1384
|
-
invoice: {
|
|
1385
|
-
totalUsd: invoice.totalUsd,
|
|
1386
|
-
rows: invoice.rows.length,
|
|
1387
|
-
wireRequests: invoice.cardinality.wireRequests
|
|
1388
|
-
},
|
|
1389
|
-
checks
|
|
1442
|
+
verdict: divergent.length === 0 ? "one-denominator" : "divergent",
|
|
1443
|
+
divergent: divergent.length,
|
|
1444
|
+
runs: rows.map((row) => costAuditRunJson(row.runId, row.audit))
|
|
1390
1445
|
}, null, 2));
|
|
1391
|
-
return
|
|
1446
|
+
return divergent.length === 0 ? 0 : 1;
|
|
1447
|
+
}
|
|
1448
|
+
context.io.out(`cost audit: ${String(rows.length)} run${rows.length === 1 ? "" : "s"}, ${String(divergent.length)} divergent`);
|
|
1449
|
+
for (const row of rows) {
|
|
1450
|
+
const failedNames = row.audit.failed.map((check) => check.name).join(", ");
|
|
1451
|
+
context.io.out(` ${row.runId}: ${row.audit.failed.length === 0 ? "one denominator" : "DIVERGENT"} | checks ${String(row.audit.checks.length - row.audit.failed.length)}/${String(row.audit.checks.length)}${failedNames === "" ? "" : ` (failed ${failedNames})`} | gross $${row.audit.report.grossUsd.toFixed(4)} | wires ${String(row.audit.report.wireRequests ?? "absent")}`);
|
|
1392
1452
|
}
|
|
1393
|
-
|
|
1394
|
-
context.io.out(`settled: gross $${report.grossUsd.toFixed(4)} | net $${report.totalUsd.toFixed(4)} | wires ${String(report.wireRequests ?? "absent")}`);
|
|
1395
|
-
context.io.out(`invoice: total $${invoice.totalUsd.toFixed(4)} | rows ${String(invoice.rows.length)} | wires ${String(invoice.cardinality.wireRequests)}`);
|
|
1396
|
-
for (const check of checks) context.io.out(` [${check.pass ? "pass" : "FAIL"}] ${check.name}: ${check.detail}`);
|
|
1397
|
-
return failed.length === 0 ? 0 : 1;
|
|
1453
|
+
return divergent.length === 0 ? 0 : 1;
|
|
1398
1454
|
}
|
|
1399
1455
|
/** Formats an optional USD number for the preflight text rows. */
|
|
1400
1456
|
function usdOf(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.225.0",
|
|
4
4
|
"description": "Rulvar shell: run/resume/runs/inspect/plan/kb commands, TUI progress, createServer, createWorker, OTel exporter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rulvar/core": "1.
|
|
25
|
+
"@rulvar/core": "1.225.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^22.20.1",
|
|
29
29
|
"tsdown": "^0.22.14",
|
|
30
30
|
"typescript": "~6.0.3",
|
|
31
|
-
"@rulvar/
|
|
32
|
-
"@rulvar/
|
|
33
|
-
"@rulvar/
|
|
34
|
-
"@rulvar/
|
|
35
|
-
"@rulvar/
|
|
31
|
+
"@rulvar/store-sqlite": "1.225.0",
|
|
32
|
+
"@rulvar/testing": "1.225.0",
|
|
33
|
+
"@rulvar/planner": "1.225.0",
|
|
34
|
+
"@rulvar/plan": "1.225.0",
|
|
35
|
+
"@rulvar/evals": "1.225.0"
|
|
36
36
|
},
|
|
37
37
|
"bin": {
|
|
38
38
|
"rulvar": "./dist/cli.js"
|