@oh-my-pi/omp-stats 18.10.3 → 18.10.4
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 +6 -0
- package/dist/types/parser.d.ts +11 -1
- package/package.json +4 -4
- package/src/db.ts +11 -6
- package/src/frustration.ts +3 -2
- package/src/live.ts +2 -1
- package/src/parser.ts +23 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [18.10.4] - 2026-10-13
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Usage recorded at $0 for a model whose catalog price changes on a date (Gemini 4 Argon, Devin SWE-2) is now priced at the rate in force on the request's date, instead of staying $0 like peak/off-peak tariff usage ([#15620](https://github.com/can1357/oh-my-pi/pull/15620) by [@eggpeat](https://github.com/eggpeat))
|
|
10
|
+
|
|
5
11
|
## [18.9.0] - 2026-10-11
|
|
6
12
|
|
|
7
13
|
### Fixed
|
package/dist/types/parser.d.ts
CHANGED
|
@@ -75,7 +75,17 @@ export declare function parseSessionFile(sessionPath: string, fromOffset?: numbe
|
|
|
75
75
|
*/
|
|
76
76
|
export declare function listSessionFolders(): Promise<string[]>;
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
78
|
+
* Name prefix of the scratch directories `omp gc --compress` creates beside
|
|
79
|
+
* the files it copies on APFS. Their `.jsonl` files are transient copies of
|
|
80
|
+
* transcripts, never transcripts of their own; a killed run can leave one
|
|
81
|
+
* behind until the next `omp gc --compress --apply` removes it.
|
|
82
|
+
*/
|
|
83
|
+
export declare const COMPRESS_SCRATCH_PREFIX = ".omp-gc-compress-";
|
|
84
|
+
/** Whether `relativePath` (from any ancestor directory) lies inside a compress scratch directory. */
|
|
85
|
+
export declare function isCompressScratchPath(relativePath: string): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* List all session files in a folder, excluding copies inside
|
|
88
|
+
* `omp gc --compress` scratch directories.
|
|
79
89
|
*/
|
|
80
90
|
export declare function listSessionFiles(folderPath: string): Promise<string[]>;
|
|
81
91
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/omp-stats",
|
|
4
|
-
"version": "18.10.
|
|
4
|
+
"version": "18.10.4",
|
|
5
5
|
"description": "Local observability dashboard for omp AI usage statistics",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": {
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@oh-my-pi/pi-ai": "18.10.
|
|
46
|
-
"@oh-my-pi/pi-catalog": "18.10.
|
|
47
|
-
"@oh-my-pi/pi-utils": "18.10.
|
|
45
|
+
"@oh-my-pi/pi-ai": "18.10.4",
|
|
46
|
+
"@oh-my-pi/pi-catalog": "18.10.4",
|
|
47
|
+
"@oh-my-pi/pi-utils": "18.10.4",
|
|
48
48
|
"lucide-react": "^1.24.0",
|
|
49
49
|
"react": "19.2.7",
|
|
50
50
|
"react-dom": "19.2.7"
|
package/src/db.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
calculateUsageCost,
|
|
7
7
|
type GeneratedProvider,
|
|
8
8
|
getBundledModel,
|
|
9
|
+
hasRecurringTariff,
|
|
9
10
|
} from "@oh-my-pi/pi-catalog/models";
|
|
10
11
|
import type { ModelCost } from "@oh-my-pi/pi-catalog/types";
|
|
11
12
|
import { getConfigRootDir, getStatsDbPath, VERSION } from "@oh-my-pi/pi-utils";
|
|
@@ -463,9 +464,11 @@ function resolveStoredCost(stats: MessageStatsInput): ResolvedCost {
|
|
|
463
464
|
const storedCost = raw ? normalizeUsageCost(raw) : undefined;
|
|
464
465
|
const catalogCost = getCatalogCost(stats.provider, stats.model);
|
|
465
466
|
|
|
466
|
-
//
|
|
467
|
-
// Preserve legacy zero-cost subscription correction for
|
|
468
|
-
|
|
467
|
+
// Recurring-tariff prices are frozen per request, including explicitly free
|
|
468
|
+
// usage. Preserve legacy zero-cost subscription correction for other models;
|
|
469
|
+
// dated rate cards reprice it at the card for the request's timestamp.
|
|
470
|
+
const recurring = catalogCost?.timeBased !== undefined && hasRecurringTariff(catalogCost.timeBased);
|
|
471
|
+
if (storedCost && Number.isFinite(storedCost.total) && (storedCost.total !== 0 || recurring)) {
|
|
469
472
|
return { cost: storedCost, unpriced: false };
|
|
470
473
|
}
|
|
471
474
|
|
|
@@ -528,12 +531,14 @@ function backfillMissingCatalogCosts(database: Database): void {
|
|
|
528
531
|
const applyBackfill = database.transaction(() => {
|
|
529
532
|
for (const row of rows) {
|
|
530
533
|
// A stored zero cannot distinguish missing historical prices from an
|
|
531
|
-
// explicitly free request. Never reprice recorded
|
|
532
|
-
// zero ingested for a
|
|
534
|
+
// explicitly free request. Never reprice recorded recurring-tariff
|
|
535
|
+
// usage: a zero ingested for such a card is permanent, because this
|
|
533
536
|
// backfill skips those rows. Re-parsing the session file is the only
|
|
534
537
|
// repair, and it works only once the entry's absent `cost` reaches
|
|
535
538
|
// `resolveStoredCost` as absence rather than as a synthesized zero.
|
|
536
|
-
|
|
539
|
+
// Dated rate cards need the row's timestamp to pick their card.
|
|
540
|
+
const schedule = getCatalogCost(row.provider, row.model)?.timeBased;
|
|
541
|
+
if (schedule && (hasRecurringTariff(schedule) || !hasRequestTimestamp(row.timestamp))) continue;
|
|
537
542
|
const cost = calculateCatalogCost(
|
|
538
543
|
row.provider,
|
|
539
544
|
row.model,
|
package/src/frustration.ts
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { type Judge, judgeQuestions, type Model } from "@oh-my-pi/pi-ai";
|
|
20
20
|
import { compareRevision, parseRevision } from "@oh-my-pi/pi-catalog/compat/revision";
|
|
21
21
|
import { classifyModel } from "@oh-my-pi/pi-catalog/compat/taxonomy";
|
|
22
|
+
import { getEffectiveTokenCost } from "@oh-my-pi/pi-catalog/models";
|
|
22
23
|
import { logger } from "@oh-my-pi/pi-utils";
|
|
23
24
|
import { getTimeRangeConfig } from "./aggregator";
|
|
24
25
|
import {
|
|
@@ -214,8 +215,8 @@ export async function estimateFrustrationRun(range?: string | null): Promise<Fru
|
|
|
214
215
|
const { cutoff } = getTimeRangeConfig(range);
|
|
215
216
|
const { messages, chars } = getPendingFrustrationTotals(cutoff);
|
|
216
217
|
const inputTokens = messages * REQUEST_OVERHEAD_TOKENS + Math.ceil(chars / CHARS_PER_TOKEN);
|
|
217
|
-
const
|
|
218
|
-
|
|
218
|
+
const rates = getEffectiveTokenCost(model.cost);
|
|
219
|
+
const cost = (inputTokens * rates.input) / 1e6 + (messages * OUTPUT_TOKENS_PER_REQUEST * rates.output) / 1e6;
|
|
219
220
|
return { available: true, messages, chars, inputTokens, cost, judge: `${model.provider}/${model.id}` };
|
|
220
221
|
}
|
|
221
222
|
|
package/src/live.ts
CHANGED
|
@@ -15,6 +15,7 @@ import * as path from "node:path";
|
|
|
15
15
|
import { getSessionsDir, logger } from "@oh-my-pi/pi-utils";
|
|
16
16
|
import { syncAllSessions } from "./aggregator";
|
|
17
17
|
import { getDataVersion, initDb } from "./db";
|
|
18
|
+
import { isCompressScratchPath } from "./parser";
|
|
18
19
|
import { getRollupStatus, refreshRollups } from "./rollup";
|
|
19
20
|
import type { LiveStatus, LiveSyncStatus } from "./shared-types";
|
|
20
21
|
|
|
@@ -231,7 +232,7 @@ export class StatsLive {
|
|
|
231
232
|
const pending = new Set<string>();
|
|
232
233
|
try {
|
|
233
234
|
this.#watcher = fs.watch(root, { recursive: true }, (_event, filename) => {
|
|
234
|
-
if (!filename?.endsWith(".jsonl")) return;
|
|
235
|
+
if (!filename?.endsWith(".jsonl") || isCompressScratchPath(filename)) return;
|
|
235
236
|
pending.add(path.join(root, filename));
|
|
236
237
|
clearTimeout(this.#debounceTimer ?? undefined);
|
|
237
238
|
this.#debounceTimer = setTimeout(() => {
|
package/src/parser.ts
CHANGED
|
@@ -672,12 +672,33 @@ export async function listSessionFolders(): Promise<string[]> {
|
|
|
672
672
|
}
|
|
673
673
|
|
|
674
674
|
/**
|
|
675
|
-
*
|
|
675
|
+
* Name prefix of the scratch directories `omp gc --compress` creates beside
|
|
676
|
+
* the files it copies on APFS. Their `.jsonl` files are transient copies of
|
|
677
|
+
* transcripts, never transcripts of their own; a killed run can leave one
|
|
678
|
+
* behind until the next `omp gc --compress --apply` removes it.
|
|
679
|
+
*/
|
|
680
|
+
export const COMPRESS_SCRATCH_PREFIX = ".omp-gc-compress-";
|
|
681
|
+
|
|
682
|
+
/** Whether `relativePath` (from any ancestor directory) lies inside a compress scratch directory. */
|
|
683
|
+
export function isCompressScratchPath(relativePath: string): boolean {
|
|
684
|
+
return relativePath.split(/[\\/]/).some(part => part.startsWith(COMPRESS_SCRATCH_PREFIX));
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* List all session files in a folder, excluding copies inside
|
|
689
|
+
* `omp gc --compress` scratch directories.
|
|
676
690
|
*/
|
|
677
691
|
export async function listSessionFiles(folderPath: string): Promise<string[]> {
|
|
678
692
|
try {
|
|
679
693
|
const entries = await fs.readdir(folderPath, { recursive: true, withFileTypes: true });
|
|
680
|
-
return entries
|
|
694
|
+
return entries
|
|
695
|
+
.filter(
|
|
696
|
+
e =>
|
|
697
|
+
e.isFile() &&
|
|
698
|
+
e.name.endsWith(".jsonl") &&
|
|
699
|
+
!isCompressScratchPath(path.relative(folderPath, e.parentPath)),
|
|
700
|
+
)
|
|
701
|
+
.map(e => path.join(e.parentPath, e.name));
|
|
681
702
|
} catch {
|
|
682
703
|
return [];
|
|
683
704
|
}
|