@rulvar/cli 1.59.4 → 1.61.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 +12 -1
- package/dist/index.js +2 -2
- package/dist/{io-DzlCfHd9.js → io-Dp8Qkr9V.js} +55 -2
- package/package.json +7 -7
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,17 @@ declare function runCommand(argv: string[], context: CommandContext): Promise<nu
|
|
|
31
31
|
declare function resumeCommand(argv: string[], context: CommandContext): Promise<number>;
|
|
32
32
|
declare function runsLsCommand(argv: string[], context: CommandContext): Promise<number>;
|
|
33
33
|
declare function inspectCommand(argv: string[], context: CommandContext): Promise<number>;
|
|
34
|
+
/**
|
|
35
|
+
* rulvar invoice (P1.3): the per-dispatch reconciliation export from
|
|
36
|
+
* the journal's providerCalls ledger, one row per billable provider
|
|
37
|
+
* call with the provider's response id when the adapter surfaced one,
|
|
38
|
+
* plus the gross/net ledger totals (`totalUsd` here is the GROSS
|
|
39
|
+
* figure: abandoned subtrees included, exactly what a provider invoice
|
|
40
|
+
* bills). --json prints the machine-readable InvoiceExport; the text
|
|
41
|
+
* form prints one line per row. Pricing folds at read time from the
|
|
42
|
+
* assembled price table, the same numbers rulvar inspect reports.
|
|
43
|
+
*/
|
|
44
|
+
declare function invoiceCommand(argv: string[], context: CommandContext): Promise<number>;
|
|
34
45
|
//#endregion
|
|
35
46
|
//#region src/config.d.ts
|
|
36
47
|
/** The shape both the config module and a workflow module may export. */
|
|
@@ -375,4 +386,4 @@ declare function toOtel(run: {
|
|
|
375
386
|
result: Promise<RunOutcome<unknown>>;
|
|
376
387
|
}, tracer: TracerLike, options?: ToOtelOptions): Promise<number>;
|
|
377
388
|
//#endregion
|
|
378
|
-
export { type AssembledCli, type CliConfig, type CliIo, type CommandContext, type CreateServerOptions, type CreateWorkerOptions, DEFAULT_MAX_PENDING_EVENTS_PER_CLIENT, DEFAULT_STORE_DIR, DEFAULT_WORKER_TTL_MS, HELP, type KbSweepCliConfig, type LoadedWorkflowModule, type OtelContextApi, type RulvarServer, type SpanLike, type ToOtelOptions, type TracerLike, type Worker, assembleEngine, attachProgress, createServer, createWorker, driveRun, inspectCommand, loadCliConfig, loadWorkflowModule, looksLikeFile, processIo, renderEventLine, reportOutcome, resumeCommand, runCli, runCommand, runsLsCommand, strictExitCode, toOtel };
|
|
389
|
+
export { type AssembledCli, type CliConfig, type CliIo, type CommandContext, type CreateServerOptions, type CreateWorkerOptions, DEFAULT_MAX_PENDING_EVENTS_PER_CLIENT, DEFAULT_STORE_DIR, DEFAULT_WORKER_TTL_MS, HELP, type KbSweepCliConfig, type LoadedWorkflowModule, type OtelContextApi, type RulvarServer, type SpanLike, type ToOtelOptions, type TracerLike, type Worker, assembleEngine, attachProgress, createServer, createWorker, driveRun, inspectCommand, invoiceCommand, loadCliConfig, loadWorkflowModule, looksLikeFile, processIo, renderEventLine, reportOutcome, resumeCommand, runCli, runCommand, runsLsCommand, strictExitCode, toOtel };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as loadWorkflowModule, a as invoiceCommand, c as runsLsCommand, d as strictExitCode, f as attachProgress, g as loadCliConfig, h as assembleEngine, i as inspectCommand, l as driveRun, m as DEFAULT_STORE_DIR, n as HELP, o as resumeCommand, p as renderEventLine, r as runCli, s as runCommand, t as processIo, u as reportOutcome, v as looksLikeFile } from "./io-Dp8Qkr9V.js";
|
|
2
2
|
import { ConfigError, InvalidResolutionError, JournalCompatibilityError, LeaseHeldError, Replayer, RulvarError, buildDeriverRegistry, compileSecretMasker, costReportFromJournal, maskSecrets, normalizeEntry, readRunMeta, scanJournalCompatibility, validateSchemaSpec } from "@rulvar/core";
|
|
3
3
|
//#region src/server.ts
|
|
4
4
|
/**
|
|
@@ -961,4 +961,4 @@ async function toOtel(run, tracer, options = {}) {
|
|
|
961
961
|
return created;
|
|
962
962
|
}
|
|
963
963
|
//#endregion
|
|
964
|
-
export { DEFAULT_MAX_PENDING_EVENTS_PER_CLIENT, DEFAULT_STORE_DIR, DEFAULT_WORKER_TTL_MS, HELP, assembleEngine, attachProgress, createServer, createWorker, driveRun, inspectCommand, loadCliConfig, loadWorkflowModule, looksLikeFile, processIo, renderEventLine, reportOutcome, resumeCommand, runCli, runCommand, runsLsCommand, strictExitCode, toOtel };
|
|
964
|
+
export { DEFAULT_MAX_PENDING_EVENTS_PER_CLIENT, DEFAULT_STORE_DIR, DEFAULT_WORKER_TTL_MS, HELP, assembleEngine, attachProgress, createServer, createWorker, driveRun, inspectCommand, invoiceCommand, loadCliConfig, loadWorkflowModule, looksLikeFile, processIo, renderEventLine, reportOutcome, resumeCommand, runCli, runCommand, runsLsCommand, strictExitCode, toOtel };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigError, FileModelKnowledgeStore, INBOX_PROPOSAL_TTL_DAYS, JsonlFileStore, LeaseHeldError, auditRuns, claimExpired, claimExpiry, compilePermissionPreset, costReportFromJournal, createEngine, hashRunArgs, hashRunOutput, lastRunSettle, parseModelRef, priceUsdOf, proposalStatement, readRunMeta, reconcileRunMeta, remeasureQueue, resolvePricing, runProfile, sanitizeTerminalText } from "@rulvar/core";
|
|
1
|
+
import { ConfigError, FileModelKnowledgeStore, INBOX_PROPOSAL_TTL_DAYS, JsonlFileStore, LeaseHeldError, auditRuns, claimExpired, claimExpiry, compilePermissionPreset, costReportFromJournal, createEngine, hashRunArgs, hashRunOutput, invoiceFromJournal, lastRunSettle, parseModelRef, priceUsdOf, proposalStatement, readRunMeta, reconcileRunMeta, remeasureQueue, resolvePricing, runProfile, sanitizeTerminalText } from "@rulvar/core";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import { existsSync, statSync } from "node:fs";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -474,6 +474,11 @@ const GRAMMAR = {
|
|
|
474
474
|
positionals: ["<runId>"],
|
|
475
475
|
flags: [STORE]
|
|
476
476
|
},
|
|
477
|
+
invoice: {
|
|
478
|
+
command: "invoice",
|
|
479
|
+
positionals: ["<runId>"],
|
|
480
|
+
flags: [STORE, { name: "json" }]
|
|
481
|
+
},
|
|
477
482
|
plan: {
|
|
478
483
|
command: "plan",
|
|
479
484
|
positionals: ["\"<goal>\""],
|
|
@@ -585,6 +590,7 @@ function helpCommandLines() {
|
|
|
585
590
|
GRAMMAR["runs ls"],
|
|
586
591
|
GRAMMAR["runs audit"],
|
|
587
592
|
GRAMMAR.inspect,
|
|
593
|
+
GRAMMAR.invoice,
|
|
588
594
|
GRAMMAR.plan
|
|
589
595
|
];
|
|
590
596
|
const heads = top.map((grammar) => [
|
|
@@ -1074,6 +1080,7 @@ async function inspectCommand(argv, context) {
|
|
|
1074
1080
|
context.io.out(`open suspensions: ${openSuspensions}`);
|
|
1075
1081
|
const cost = costReportFromJournal(entries, assembled.priceUsd);
|
|
1076
1082
|
context.io.out(`cost: $${cost.totalUsd.toFixed(4)}`);
|
|
1083
|
+
if (cost.abandoned.usd > 0) context.io.out(`gross: $${cost.grossUsd.toFixed(4)} (abandoned: $${cost.abandoned.usd.toFixed(4)}; see rulvar invoice)`);
|
|
1077
1084
|
for (const [model, usd] of Object.entries(cost.byModel)) context.io.out(` ${model}: $${usd.toFixed(4)}`);
|
|
1078
1085
|
for (const item of cost.unpriced) context.io.out(` unpriced: ${item.model} (${item.usage.inputTokens + item.usage.outputTokens} tok)`);
|
|
1079
1086
|
for (const entry of entries) {
|
|
@@ -1084,6 +1091,46 @@ async function inspectCommand(argv, context) {
|
|
|
1084
1091
|
return 0;
|
|
1085
1092
|
}
|
|
1086
1093
|
/**
|
|
1094
|
+
* rulvar invoice (P1.3): the per-dispatch reconciliation export from
|
|
1095
|
+
* the journal's providerCalls ledger, one row per billable provider
|
|
1096
|
+
* call with the provider's response id when the adapter surfaced one,
|
|
1097
|
+
* plus the gross/net ledger totals (`totalUsd` here is the GROSS
|
|
1098
|
+
* figure: abandoned subtrees included, exactly what a provider invoice
|
|
1099
|
+
* bills). --json prints the machine-readable InvoiceExport; the text
|
|
1100
|
+
* form prints one line per row. Pricing folds at read time from the
|
|
1101
|
+
* assembled price table, the same numbers rulvar inspect reports.
|
|
1102
|
+
*/
|
|
1103
|
+
async function invoiceCommand(argv, context) {
|
|
1104
|
+
const parsed = parseCommand(GRAMMAR.invoice, argv);
|
|
1105
|
+
const runId = parsed.positionals[0];
|
|
1106
|
+
const store = parsed.values.store;
|
|
1107
|
+
const json = parsed.values.json === true;
|
|
1108
|
+
const assembled = assembleEngine({
|
|
1109
|
+
config: await loadCliConfig(context.cwd),
|
|
1110
|
+
...store === void 0 ? {} : { storePath: store },
|
|
1111
|
+
cwd: context.cwd
|
|
1112
|
+
});
|
|
1113
|
+
const meta = await readRunMeta(assembled.store, runId);
|
|
1114
|
+
if (meta === void 0) throw new ConfigError(`run '${runId}' not found in the store`);
|
|
1115
|
+
const invoice = invoiceFromJournal(await assembled.store.load(runId), assembled.priceUsd);
|
|
1116
|
+
if (json) {
|
|
1117
|
+
context.io.out(JSON.stringify(invoice, null, 2));
|
|
1118
|
+
return 0;
|
|
1119
|
+
}
|
|
1120
|
+
context.io.out(`run ${meta.runId}: invoice (${meta.status})`);
|
|
1121
|
+
context.io.out(`gross: $${invoice.totalUsd.toFixed(4)} | net: $${invoice.netUsd.toFixed(4)} | abandoned: $${invoice.abandonedUsd.toFixed(4)}${invoice.usageApprox === true ? " (approx)" : ""}`);
|
|
1122
|
+
context.io.out(`rows: ${invoice.rows.length} (reconciliation failures: ${invoice.reconciliationFailures})`);
|
|
1123
|
+
for (const row of invoice.rows) {
|
|
1124
|
+
const usd = row.usd === void 0 ? "unpriced" : `$${row.usd.toFixed(4)}`;
|
|
1125
|
+
const tokens = row.usage.inputTokens + row.usage.outputTokens;
|
|
1126
|
+
const id = row.responseId ?? "no-id";
|
|
1127
|
+
const flags = `${row.usageApprox === true ? " approx" : ""}${row.abandoned === true ? " abandoned" : ""}`;
|
|
1128
|
+
context.io.out(`#${row.entrySeq}.${row.ordinal} ${row.servedBy}${row.role === void 0 ? "" : ` ${row.role}`}${row.attempt === void 0 ? "" : ` attempt=${row.attempt}`} ${row.outcome} ${id} ${tokens} tok ${usd}${flags} [${row.reconciliation}]`);
|
|
1129
|
+
}
|
|
1130
|
+
for (const item of invoice.unpriced) context.io.out(`unpriced: ${item.model} (${item.usage.inputTokens + item.usage.outputTokens} tok)`);
|
|
1131
|
+
return 0;
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1087
1134
|
* rulvar plan (M6-T11; grammar in grammar.ts): plans a workflow script
|
|
1088
1135
|
* through @rulvar/planner (loaded dynamically: the CLI's static
|
|
1089
1136
|
* dependency stays @rulvar/core only), prints the accepted script and
|
|
@@ -1546,6 +1593,11 @@ accounting, localized determinism warnings, and the output digest;
|
|
|
1546
1593
|
--assert-no-live exits 1 unless the replay is pure, and
|
|
1547
1594
|
--compare-output-hash exits 1 unless the replayed result's digest
|
|
1548
1595
|
equals the journaled one.
|
|
1596
|
+
invoice prints the per-dispatch reconciliation export: one row per
|
|
1597
|
+
billable provider call (failed and retried attempts included) with the
|
|
1598
|
+
provider's response id when the adapter surfaced one, plus the
|
|
1599
|
+
gross/net ledger totals (gross includes abandoned subtrees, exactly
|
|
1600
|
+
what the provider bills); --json emits the machine-readable form.
|
|
1549
1601
|
plan asks the planner model (role plan) to write a workflow script,
|
|
1550
1602
|
lints and self-repairs it, then runs it in the worker sandbox; --dry-run
|
|
1551
1603
|
prints the accepted script without running. Both stages are paid runs
|
|
@@ -1582,6 +1634,7 @@ async function runCli(argv, options) {
|
|
|
1582
1634
|
throw new ConfigError(RUNS_FAMILY_USAGE);
|
|
1583
1635
|
}
|
|
1584
1636
|
case "inspect": return await inspectCommand(rest, context);
|
|
1637
|
+
case "invoice": return await invoiceCommand(rest, context);
|
|
1585
1638
|
case "plan": return await planCommand(rest, context);
|
|
1586
1639
|
case "kb": return await kbCommand(rest, context);
|
|
1587
1640
|
case void 0:
|
|
@@ -1632,4 +1685,4 @@ function processIo() {
|
|
|
1632
1685
|
};
|
|
1633
1686
|
}
|
|
1634
1687
|
//#endregion
|
|
1635
|
-
export {
|
|
1688
|
+
export { loadWorkflowModule as _, invoiceCommand as a, runsLsCommand as c, strictExitCode as d, attachProgress as f, loadCliConfig as g, assembleEngine as h, inspectCommand as i, driveRun as l, DEFAULT_STORE_DIR as m, HELP as n, resumeCommand as o, renderEventLine as p, runCli as r, runCommand as s, processIo as t, reportOutcome as u, looksLikeFile as v };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.61.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.61.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^22.20.0",
|
|
29
29
|
"tsdown": "^0.22.3",
|
|
30
30
|
"typescript": "~6.0.3",
|
|
31
|
-
"@rulvar/
|
|
32
|
-
"@rulvar/
|
|
33
|
-
"@rulvar/
|
|
34
|
-
"@rulvar/
|
|
35
|
-
"@rulvar/
|
|
31
|
+
"@rulvar/testing": "1.61.0",
|
|
32
|
+
"@rulvar/planner": "1.61.0",
|
|
33
|
+
"@rulvar/store-sqlite": "1.61.0",
|
|
34
|
+
"@rulvar/plan": "1.61.0",
|
|
35
|
+
"@rulvar/evals": "1.61.0"
|
|
36
36
|
},
|
|
37
37
|
"bin": {
|
|
38
38
|
"rulvar": "./dist/cli.js"
|