@rulvar/cli 1.140.0 → 1.142.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/index.d.ts CHANGED
@@ -436,11 +436,13 @@ interface ToOtelOptions {
436
436
  patterns?: ReadonlyArray<RegExp | string>;
437
437
  }
438
438
  /**
439
- * Exports one settled run's event stream onto a tracer. The run's
440
- * events are consumed in seq order; span openers start spans, the
441
- * matching closers end them, and payload-only events attach as span
442
- * events on the innermost open span. Returns the number of spans
443
- * created.
439
+ * Exports one run's event stream onto a tracer. The run's events are
440
+ * consumed in seq order; span openers start spans, the matching
441
+ * closers end them, and payload-only events attach as span events on
442
+ * the innermost open span. Returns the number of spans created. Every
443
+ * terminal path exports, the unsettled ones included (RV1106): a
444
+ * rejecting `result` never fails an export the stream already
445
+ * completed, it only marks any leftover span with the refusal.
444
446
  */
445
447
  declare function toOtel(run: {
446
448
  runId: string;
package/dist/index.js CHANGED
@@ -291,7 +291,8 @@ function createServer(options) {
291
291
  ...outcome.error === void 0 ? {} : { error: outcome.error },
292
292
  pending: outcome.pending,
293
293
  dropped: outcome.dropped.length,
294
- usage: outcome.usage
294
+ usage: outcome.usage,
295
+ envelope: outcome.envelope
295
296
  });
296
297
  }
297
298
  const meta = await metaOf(runId);
@@ -927,11 +928,13 @@ function openAttributes(event, runId, maskText) {
927
928
  return attrs;
928
929
  }
929
930
  /**
930
- * Exports one settled run's event stream onto a tracer. The run's
931
- * events are consumed in seq order; span openers start spans, the
932
- * matching closers end them, and payload-only events attach as span
933
- * events on the innermost open span. Returns the number of spans
934
- * created.
931
+ * Exports one run's event stream onto a tracer. The run's events are
932
+ * consumed in seq order; span openers start spans, the matching
933
+ * closers end them, and payload-only events attach as span events on
934
+ * the innermost open span. Returns the number of spans created. Every
935
+ * terminal path exports, the unsettled ones included (RV1106): a
936
+ * rejecting `result` never fails an export the stream already
937
+ * completed, it only marks any leftover span with the refusal.
935
938
  */
936
939
  async function toOtel(run, tracer, options = {}) {
937
940
  const openBySpanId = /* @__PURE__ */ new Map();
@@ -997,6 +1000,11 @@ async function toOtel(run, tracer, options = {}) {
997
1000
  runOpen.span.setAttribute("rulvar.run.settled", false);
998
1001
  if (event.settledReason !== void 0) runOpen.span.setAttribute("rulvar.run.settled_reason", event.settledReason);
999
1002
  }
1003
+ const envelope = event.envelope;
1004
+ if (runOpen !== void 0 && envelope !== void 0) {
1005
+ runOpen.span.setAttribute("rulvar.run.total_usd", envelope.totalUsd);
1006
+ runOpen.span.setAttribute("rulvar.run.agents_spawned", envelope.agentsSpawned);
1007
+ }
1000
1008
  endSpan(event.spanId, event.ts, event.status, event.settled === false ? event.settledReason === "superseded" ? "superseded: a successor owns settlement; this stale terminal is withheld" : "settlement failed: nothing durable records this terminal; resume re-settles" : void 0, event.settled === false);
1001
1009
  break;
1002
1010
  }
@@ -1067,9 +1075,9 @@ async function toOtel(run, tracer, options = {}) {
1067
1075
  default: (openBySpanId.get(event.spanId) ?? stack[stack.length - 1])?.span.addEvent(event.type, { "rulvar.entry_seq": event.seq });
1068
1076
  }
1069
1077
  }
1070
- const outcome = await run.result;
1078
+ const settledOk = await run.result.then((outcome) => outcome.status === "ok", () => false);
1071
1079
  for (const open of [...openBySpanId.values()]) {
1072
- open.span.setStatus({ code: outcome.status === "ok" ? STATUS_OK : STATUS_ERROR });
1080
+ open.span.setStatus({ code: settledOk ? STATUS_OK : STATUS_ERROR });
1073
1081
  open.span.end();
1074
1082
  openBySpanId.delete(open.spanId);
1075
1083
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/cli",
3
- "version": "1.140.0",
3
+ "version": "1.142.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.140.0"
25
+ "@rulvar/core": "1.142.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.140.0",
32
- "@rulvar/store-sqlite": "1.140.0",
33
- "@rulvar/planner": "1.140.0",
34
- "@rulvar/evals": "1.140.0",
35
- "@rulvar/plan": "1.140.0"
31
+ "@rulvar/testing": "1.142.0",
32
+ "@rulvar/planner": "1.142.0",
33
+ "@rulvar/plan": "1.142.0",
34
+ "@rulvar/evals": "1.142.0",
35
+ "@rulvar/store-sqlite": "1.142.0"
36
36
  },
37
37
  "bin": {
38
38
  "rulvar": "./dist/cli.js"