@oh-my-pi/omp-stats 16.2.6 → 16.2.8

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.2.7] - 2026-06-30
6
+
7
+ ### Fixed
8
+
9
+ - Improved premium request calculation accuracy by correctly accounting for specific model families.
10
+
5
11
  ## [16.2.6] - 2026-06-29
6
12
 
7
13
  ### Fixed
@@ -1,4 +1,4 @@
1
- import type { AssistantMessage, ServiceTier, StopReason, Usage } from "@oh-my-pi/pi-ai";
1
+ import type { AssistantMessage, ServiceTier, ServiceTierByFamily, StopReason, Usage } from "@oh-my-pi/pi-ai";
2
2
  import type { AgentType } from "./shared-types";
3
3
  export * from "./shared-types";
4
4
  /**
@@ -68,7 +68,7 @@ export interface SessionServiceTierChangeEntry {
68
68
  id: string;
69
69
  parentId?: string | null;
70
70
  timestamp: string;
71
- serviceTier: ServiceTier | null;
71
+ serviceTier: ServiceTierByFamily | ServiceTier | null;
72
72
  }
73
73
  export type SessionEntry = SessionHeader | SessionMessageEntry | SessionServiceTierChangeEntry | {
74
74
  type: string;
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.2.6",
4
+ "version": "16.2.8",
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.2.6",
43
- "@oh-my-pi/pi-catalog": "16.2.6",
44
- "@oh-my-pi/pi-utils": "16.2.6",
42
+ "@oh-my-pi/pi-ai": "16.2.8",
43
+ "@oh-my-pi/pi-catalog": "16.2.8",
44
+ "@oh-my-pi/pi-utils": "16.2.8",
45
45
  "@tailwindcss/node": "^4.3.0",
46
46
  "chart.js": "^4.5.1",
47
47
  "date-fns": "^4.4.0",
package/src/parser.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import * as fs from "node:fs/promises";
2
2
  import * as path from "node:path";
3
- import { type AssistantMessage, getPriorityPremiumRequests, type ServiceTier } from "@oh-my-pi/pi-ai";
3
+ import {
4
+ type AssistantMessage,
5
+ coerceServiceTierByFamily,
6
+ getPriorityPremiumRequests,
7
+ resolveModelServiceTier,
8
+ type ServiceTierByFamily,
9
+ } from "@oh-my-pi/pi-ai";
4
10
  import { getSessionsDir, isEnoent } from "@oh-my-pi/pi-utils";
5
11
  import type {
6
12
  AgentType,
@@ -130,7 +136,7 @@ function extractStats(
130
136
  sessionFile: string,
131
137
  folder: string,
132
138
  entry: SessionMessageEntry,
133
- currentServiceTier: ServiceTier | undefined,
139
+ currentServiceTier: ServiceTierByFamily | undefined,
134
140
  agentType: AgentType,
135
141
  ): MessageStats | null {
136
142
  const msg = entry.message as AssistantMessage;
@@ -143,7 +149,9 @@ function extractStats(
143
149
  // non-zero value already in `usage.premiumRequests` (Copilot multipliers or
144
150
  // the new AI code path) and only synthesise when the field is missing/zero.
145
151
  const recorded = msg.usage.premiumRequests ?? 0;
146
- const derived = recorded > 0 ? recorded : getPriorityPremiumRequests(currentServiceTier, msg.provider);
152
+ const model = { provider: msg.provider, api: msg.api, id: msg.model };
153
+ const tier = resolveModelServiceTier(currentServiceTier, model);
154
+ const derived = recorded > 0 ? recorded : getPriorityPremiumRequests(tier, model);
147
155
  const usage = derived === recorded ? msg.usage : { ...msg.usage, premiumRequests: derived };
148
156
 
149
157
  return {
@@ -206,10 +214,10 @@ function parseSessionEntriesLenient(bytes: Uint8Array): { entries: SessionEntry[
206
214
  return { entries, read };
207
215
  }
208
216
 
209
- function scanLastServiceTier(bytes: Uint8Array): ServiceTier | undefined {
210
- let currentServiceTier: ServiceTier | undefined;
217
+ function scanLastServiceTier(bytes: Uint8Array): ServiceTierByFamily | undefined {
218
+ let currentServiceTier: ServiceTierByFamily | undefined;
211
219
  visitSessionEntriesLenient(bytes, entry => {
212
- if (isServiceTierChange(entry)) currentServiceTier = entry.serviceTier ?? undefined;
220
+ if (isServiceTierChange(entry)) currentServiceTier = coerceServiceTierByFamily(entry.serviceTier);
213
221
  });
214
222
  return currentServiceTier;
215
223
  }
@@ -253,13 +261,13 @@ export async function parseSessionFile(sessionPath: string, fromOffset = 0): Pro
253
261
  const start = Math.max(0, Math.min(fromOffset, bytes.length));
254
262
  const unprocessed = bytes.subarray(start);
255
263
  const { entries, read } = parseSessionEntriesLenient(unprocessed);
256
- let currentServiceTier: ServiceTier | undefined;
264
+ let currentServiceTier: ServiceTierByFamily | undefined;
257
265
  if (start > 0) {
258
266
  currentServiceTier = scanLastServiceTier(bytes.subarray(0, start));
259
267
  }
260
268
  for (const entry of entries) {
261
269
  if (isServiceTierChange(entry)) {
262
- currentServiceTier = entry.serviceTier ?? undefined;
270
+ currentServiceTier = coerceServiceTierByFamily(entry.serviceTier);
263
271
  continue;
264
272
  }
265
273
  if (isUserMessage(entry)) {
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AssistantMessage, ServiceTier, StopReason, Usage } from "@oh-my-pi/pi-ai";
1
+ import type { AssistantMessage, ServiceTier, ServiceTierByFamily, StopReason, Usage } from "@oh-my-pi/pi-ai";
2
2
  import type { AgentType } from "./shared-types";
3
3
 
4
4
  export * from "./shared-types";
@@ -72,7 +72,7 @@ export interface SessionServiceTierChangeEntry {
72
72
  id: string;
73
73
  parentId?: string | null;
74
74
  timestamp: string;
75
- serviceTier: ServiceTier | null;
75
+ serviceTier: ServiceTierByFamily | ServiceTier | null;
76
76
  }
77
77
 
78
78
  export type SessionEntry = SessionHeader | SessionMessageEntry | SessionServiceTierChangeEntry | { type: string };