@rulvar/cli 1.107.0 → 1.108.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { r as runCli, t as processIo } from "./io-B4I9hIzW.js";
2
+ import { r as runCli, t as processIo } from "./io-eA5_NvlK.js";
3
3
  import { sanitizeTerminalText } from "@rulvar/core";
4
4
  import { inspect } from "node:util";
5
5
  //#region src/cli.ts
package/dist/index.d.ts CHANGED
@@ -43,8 +43,9 @@ declare function inspectCommand(argv: string[], context: CommandContext): Promis
43
43
  * request and the rows sum to gross; an aggregate-priced remainder or
44
44
  * legacy entry makes the export say `row usd is non-additive`, and
45
45
  * `allocatedUsd` is the additive column that sums to gross in every
46
- * case. Pricing folds at read time from the assembled price table, the
47
- * same numbers rulvar inspect reports.
46
+ * case. Pricing folds at read time from the run's settle pins composed
47
+ * with the assembled price table (RV611), the same numbers rulvar
48
+ * inspect reports and the engine's own settle mirrors.
48
49
  */
49
50
  declare function invoiceCommand(argv: string[], context: CommandContext): Promise<number>;
50
51
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as loadCliConfig, a as invoiceCommand, c as runCommand, d as reportOutcome, f as strictExitCode, g as assembleEngine, h as DEFAULT_STORE_DIR, i as inspectCommand, l as runsLsCommand, m as renderEventLine, n as HELP, o as preflightCommand, p as attachProgress, r as runCli, s as resumeCommand, t as processIo, u as driveRun, v as loadWorkflowModule, y as looksLikeFile } from "./io-B4I9hIzW.js";
1
+ import { _ as loadCliConfig, a as invoiceCommand, c as runCommand, d as reportOutcome, f as strictExitCode, g as assembleEngine, h as DEFAULT_STORE_DIR, i as inspectCommand, l as runsLsCommand, m as renderEventLine, n as HELP, o as preflightCommand, p as attachProgress, r as runCli, s as resumeCommand, t as processIo, u as driveRun, v as loadWorkflowModule, y as looksLikeFile } from "./io-eA5_NvlK.js";
2
2
  import { ConfigError, InvalidResolutionError, JournalCompatibilityError, LeaseHeldError, Replayer, RulvarError, buildDeriverRegistry, compileSecretMasker, costReportFromJournal, journalPricingSnapshot, maskSecrets, normalizeEntry, readRunMeta, scanJournalCompatibility, validateSchemaSpec } from "@rulvar/core";
3
3
  //#region src/server.ts
4
4
  /**
@@ -526,7 +526,9 @@ function createServer(options) {
526
526
  message: `run '${runId}' not found`
527
527
  } });
528
528
  const entries = (await journal.load(runId)).map((raw) => normalizeEntry(raw));
529
- return json(200, costReportFromJournal(entries, journalPricingSnapshot(entries)?.priceUsd ?? options.priceUsd ?? (() => void 0)));
529
+ const settleSnapshot = journalPricingSnapshot(entries);
530
+ const currentPriceUsd = options.priceUsd ?? (() => void 0);
531
+ return json(200, costReportFromJournal(entries, settleSnapshot === void 0 ? currentPriceUsd : settleSnapshot.composedPriceUsd(currentPriceUsd)));
530
532
  }
531
533
  async function route(req) {
532
534
  const path = new URL(req.url).pathname;
@@ -1101,9 +1101,9 @@ async function inspectCommand(argv, context) {
1101
1101
  for (const [kind, count] of [...byKind.entries()].sort((a, b) => a[0].localeCompare(b[0]))) context.io.out(` ${kind}: ${count}`);
1102
1102
  context.io.out(`open suspensions: ${openSuspensions}`);
1103
1103
  const inspectSnapshot = journalPricingSnapshot(entries);
1104
- const cost = costReportFromJournal(entries, inspectSnapshot?.priceUsd ?? assembled.priceUsd);
1104
+ const cost = costReportFromJournal(entries, inspectSnapshot === void 0 ? assembled.priceUsd : inspectSnapshot.composedPriceUsd(assembled.priceUsd));
1105
1105
  context.io.out(`cost: $${cost.totalUsd.toFixed(4)}`);
1106
- if (inspectSnapshot !== void 0) context.io.out("pricing: run-settle snapshot" + (inspectSnapshot.pricingVersion === void 0 ? "" : ` (${inspectSnapshot.pricingVersion})`));
1106
+ if (inspectSnapshot !== void 0) context.io.out(`pricing: run-settle pins composed with the current table${pinVersionsSuffix(inspectSnapshot)}`);
1107
1107
  if (cost.abandoned.usd > 0) context.io.out(`gross: $${cost.grossUsd.toFixed(4)} (abandoned: $${cost.abandoned.usd.toFixed(4)}; see rulvar invoice)`);
1108
1108
  for (const [model, usd] of Object.entries(cost.byModel)) context.io.out(` ${model}: $${usd.toFixed(4)}`);
1109
1109
  for (const item of cost.unpriced) context.io.out(` unpriced: ${item.model} (${item.usage.inputTokens + item.usage.outputTokens} tok)`);
@@ -1126,8 +1126,9 @@ async function inspectCommand(argv, context) {
1126
1126
  * request and the rows sum to gross; an aggregate-priced remainder or
1127
1127
  * legacy entry makes the export say `row usd is non-additive`, and
1128
1128
  * `allocatedUsd` is the additive column that sums to gross in every
1129
- * case. Pricing folds at read time from the assembled price table, the
1130
- * same numbers rulvar inspect reports.
1129
+ * case. Pricing folds at read time from the run's settle pins composed
1130
+ * with the assembled price table (RV611), the same numbers rulvar
1131
+ * inspect reports and the engine's own settle mirrors.
1131
1132
  */
1132
1133
  async function invoiceCommand(argv, context) {
1133
1134
  const parsed = parseCommand(GRAMMAR.invoice, argv);
@@ -1143,10 +1144,12 @@ async function invoiceCommand(argv, context) {
1143
1144
  if (meta === void 0) throw new ConfigError(`run '${runId}' not found in the store`);
1144
1145
  const entries = await assembled.store.load(runId);
1145
1146
  const snapshot = journalPricingSnapshot(entries);
1146
- const invoice = invoiceFromJournal(entries, snapshot?.priceUsd ?? assembled.priceUsd, { pricing: snapshot === void 0 ? { source: "current-table" } : {
1147
- source: "snapshot",
1147
+ const invoice = invoiceFromJournal(entries, snapshot === void 0 ? assembled.priceUsd : snapshot.composedPriceUsd(assembled.priceUsd), { pricing: snapshot === void 0 ? { source: "current-table" } : {
1148
+ source: "composed",
1148
1149
  ...snapshot.pricingVersion === void 0 ? {} : { pricingVersion: snapshot.pricingVersion },
1149
- rows: snapshot.rows
1150
+ rows: snapshot.rows,
1151
+ segments: snapshot.segments,
1152
+ pinnedThroughSeq: snapshot.pinnedThroughSeq
1150
1153
  } });
1151
1154
  if (json) {
1152
1155
  context.io.out(JSON.stringify(invoice, null, 2));
@@ -1156,7 +1159,7 @@ async function invoiceCommand(argv, context) {
1156
1159
  context.io.out(`gross: $${invoice.totalUsd.toFixed(4)} | net: $${invoice.netUsd.toFixed(4)} | abandoned: $${invoice.abandonedUsd.toFixed(4)}${invoice.usageApprox === true ? " (approx)" : ""}`);
1157
1160
  context.io.out(`rows: ${invoice.rows.length} (reconciliation failures: ${invoice.reconciliationFailures}${invoice.usageUnknownRows === void 0 ? "" : `; usage unknown: ${invoice.usageUnknownRows}`})`);
1158
1161
  context.io.out(`pricing basis: ${invoice.pricingBasis} ` + (invoice.rowUsdNonAdditive ? "(row usd is non-additive: an aggregate-priced remainder or legacy entry is in the fold; allocatedUsd sums to gross)" : "(rows are additive: every provider call priced per request; allocatedUsd agrees and sums to gross)"));
1159
- context.io.out(invoice.pricing?.source === "snapshot" ? "pricing rates: run-settle snapshot" + (invoice.pricing.pricingVersion === void 0 ? "" : ` (${invoice.pricing.pricingVersion})`) : "pricing rates: current table (no snapshot in the journal)");
1162
+ context.io.out(snapshot === void 0 ? "pricing rates: current table (no snapshot in the journal)" : `pricing rates: run-settle pins composed with the current table${pinVersionsSuffix(snapshot)}`);
1160
1163
  for (const row of invoice.rows) {
1161
1164
  const usd = row.usd === void 0 ? "unpriced" : `$${row.usd.toFixed(4)}`;
1162
1165
  const tokens = row.usage.inputTokens + row.usage.outputTokens;
@@ -1171,6 +1174,16 @@ async function invoiceCommand(argv, context) {
1171
1174
  function usdOf(value) {
1172
1175
  return value === void 0 ? "n/a" : `$${value.toFixed(4)}`;
1173
1176
  }
1177
+ /**
1178
+ * ` (v-a, v-b)` across the pins in journal order, deduplicated (RV611):
1179
+ * one version per rotation, so the inspect and invoice text forms name
1180
+ * every table that priced the fold, not only the last. Empty when no
1181
+ * pin carried a version.
1182
+ */
1183
+ function pinVersionsSuffix(snapshot) {
1184
+ const versions = [...new Set(snapshot.segments.map((segment) => segment.pricingVersion).filter((version) => version !== void 0))];
1185
+ return versions.length === 0 ? "" : ` (${versions.join(", ")})`;
1186
+ }
1174
1187
  function renderPreflight(report, io) {
1175
1188
  io.out("preflight: effective limits and admission projection (zero provider dispatches)");
1176
1189
  const perProvider = report.concurrency.perProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/cli",
3
- "version": "1.107.0",
3
+ "version": "1.108.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.107.0"
25
+ "@rulvar/core": "1.108.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/testing": "1.107.0",
32
- "@rulvar/store-sqlite": "1.107.0",
33
- "@rulvar/plan": "1.107.0",
34
- "@rulvar/planner": "1.107.0",
35
- "@rulvar/evals": "1.107.0"
31
+ "@rulvar/testing": "1.108.0",
32
+ "@rulvar/planner": "1.108.0",
33
+ "@rulvar/store-sqlite": "1.108.0",
34
+ "@rulvar/plan": "1.108.0",
35
+ "@rulvar/evals": "1.108.0"
36
36
  },
37
37
  "bin": {
38
38
  "rulvar": "./dist/cli.js"