@oh-my-pi/omp-stats 16.4.1 → 16.4.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [16.4.2] - 2026-07-10
6
+
7
+ ### Fixed
8
+
9
+ - Fixed a crash during stats synchronization on legacy session entries that lack a cost breakdown by falling back to catalog pricing when available.
10
+
5
11
  ## [16.3.9] - 2026-07-06
6
12
 
7
13
  ### Changed
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/omp-stats",
4
- "version": "16.4.1",
4
+ "version": "16.4.3",
5
5
  "description": "Local observability dashboard for pi AI usage statistics",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
@@ -39,9 +39,9 @@
39
39
  "fmt": "biome format --write ."
40
40
  },
41
41
  "dependencies": {
42
- "@oh-my-pi/pi-ai": "16.4.1",
43
- "@oh-my-pi/pi-catalog": "16.4.1",
44
- "@oh-my-pi/pi-utils": "16.4.1",
42
+ "@oh-my-pi/pi-ai": "16.4.3",
43
+ "@oh-my-pi/pi-catalog": "16.4.3",
44
+ "@oh-my-pi/pi-utils": "16.4.3",
45
45
  "@tailwindcss/node": "^4.3.0",
46
46
  "chart.js": "^4.5.1",
47
47
  "date-fns": "^4.4.0",
package/src/db.ts CHANGED
@@ -32,6 +32,14 @@ type ModelCost = { input: number; output: number; cacheRead: number; cacheWrite:
32
32
  type UsageCost = Usage["cost"];
33
33
  type CostTokens = Pick<Usage, "input" | "output" | "cacheRead" | "cacheWrite">;
34
34
 
35
+ const ZERO_USAGE_COST: UsageCost = {
36
+ input: 0,
37
+ output: 0,
38
+ cacheRead: 0,
39
+ cacheWrite: 0,
40
+ total: 0,
41
+ };
42
+
35
43
  interface CostBackfillRow {
36
44
  id: number;
37
45
  provider: string;
@@ -302,11 +310,14 @@ function calculateCatalogCost(provider: string, modelId: string, tokens: CostTok
302
310
  }
303
311
 
304
312
  function resolveStoredCost(stats: MessageStats): UsageCost {
305
- if (stats.usage.cost.total !== 0) {
306
- return stats.usage.cost;
313
+ // `usage.cost` was optional in older session files. Although current
314
+ // MessageStats requires it, parsed JSONL can still carry that legacy shape.
315
+ const storedCost: UsageCost | undefined = stats.usage.cost;
316
+ if (storedCost && storedCost.total !== 0) {
317
+ return storedCost;
307
318
  }
308
319
 
309
- return calculateCatalogCost(stats.provider, stats.model, stats.usage) ?? stats.usage.cost;
320
+ return calculateCatalogCost(stats.provider, stats.model, stats.usage) ?? storedCost ?? ZERO_USAGE_COST;
310
321
  }
311
322
 
312
323
  function backfillMissingCatalogCosts(database: Database): void {