sentinelayer-cli 0.18.0 → 0.18.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sentinelayer-cli",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "Scaffold Sentinelayer spec/prompt/guide artifacts with secure browser auth and token bootstrap.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -6,6 +6,14 @@ import {
6
6
  } from "../cost/tracker.js";
7
7
 
8
8
  const SESSION_USAGE_EVENT = "session_usage";
9
+ export const BILLING_SESSION_USAGE_SCHEMA = "billing/v1";
10
+ export const LOCAL_SESSION_USAGE_SCHEMA = "session_usage/local-v1";
11
+ const LEGACY_SESSION_USAGE_SCHEMAS = new Set(["", "session_usage/v0"]);
12
+ const SUPPORTED_SESSION_USAGE_SCHEMAS = new Set([
13
+ BILLING_SESSION_USAGE_SCHEMA,
14
+ LOCAL_SESSION_USAGE_SCHEMA,
15
+ ...LEGACY_SESSION_USAGE_SCHEMAS,
16
+ ]);
9
17
 
10
18
  function n(value) {
11
19
  return String(value == null ? "" : value).trim();
@@ -104,6 +112,9 @@ export function buildUsageLedgerEntry(
104
112
  if (kind !== SESSION_USAGE_EVENT) return null;
105
113
 
106
114
  const payload = object(event?.payload);
115
+ const schema = n(payload.schema);
116
+ if (!SUPPORTED_SESSION_USAGE_SCHEMAS.has(schema)) return null;
117
+
107
118
  const usage = object(payload.usage);
108
119
  const prompt = object(payload.prompt);
109
120
  const response = object(payload.response);
@@ -157,6 +168,7 @@ export function buildUsageLedgerEntry(
157
168
  return {
158
169
  ledgerEntryId,
159
170
  idempotencyKey,
171
+ schema: schema || "legacy",
160
172
  sessionId: n(sessionId),
161
173
  agentId,
162
174
  action,
@@ -1,13 +1,20 @@
1
1
  /**
2
- * Session usage emitter — records every LLM interaction inside a session
3
- * as a `session_usage` event so consumers (web dashboard, transcript
4
- * download, telemetry sync) can surface live, accurate token + cost
5
- * counters per-agent + session-wide.
2
+ * Session usage emitter — records local transcript/live-stats LLM
3
+ * interactions inside a session as `session_usage` events so consumers
4
+ * (web dashboard, transcript download, local recap) can surface live token
5
+ * + cost counters per-agent + session-wide.
6
6
  *
7
7
  * Senti orchestrator philosophy: "tokens on point every time any LLM
8
8
  * interacts." Every persona / Jules / Codex / Claude call inside a
9
9
  * session should land here so the running tally is authoritative.
10
10
  *
11
+ * Important contract split: this module is NOT the API billing ledger.
12
+ * API-durable billable rows must go through `src/billing/session-usage.js`
13
+ * and emit `payload.schema = "billing/v1"` with the API-supported price
14
+ * book. This module emits `session_usage/local-v1`, which is intentionally
15
+ * ignored by API quota/billing projection while still remaining visible in
16
+ * transcripts and local aggregate counters.
17
+ *
11
18
  * Event shape:
12
19
  *
13
20
  * {
@@ -44,6 +51,7 @@ import { createAgentEvent } from "../events/schema.js";
44
51
  import { estimateModelCost } from "../cost/tracker.js";
45
52
  import {
46
53
  DEFAULT_PRICE_BOOK_VERSION,
54
+ LOCAL_SESSION_USAGE_SCHEMA,
47
55
  buildSessionUsageLedger,
48
56
  createSessionUsageLedgerId,
49
57
  } from "./pricing-ledger.js";
@@ -158,6 +166,7 @@ export async function emitLLMInteraction(
158
166
  const responseText = clipText(response);
159
167
 
160
168
  const payload = {
169
+ schema: LOCAL_SESSION_USAGE_SCHEMA,
161
170
  interactionId: id,
162
171
  idempotencyKey: id,
163
172
  ledgerEntryId,