@oh-my-pi/omp-stats 15.10.10 → 15.10.12
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 +4 -3
- package/src/aggregator.ts +15 -19
- package/src/db.ts +3 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/omp-stats",
|
|
4
|
-
"version": "15.10.
|
|
4
|
+
"version": "15.10.12",
|
|
5
5
|
"description": "Local observability dashboard for pi AI usage statistics",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -37,8 +37,9 @@
|
|
|
37
37
|
"fmt": "biome format --write ."
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@oh-my-pi/pi-ai": "15.10.
|
|
41
|
-
"@oh-my-pi/pi-
|
|
40
|
+
"@oh-my-pi/pi-ai": "15.10.12",
|
|
41
|
+
"@oh-my-pi/pi-catalog": "15.10.12",
|
|
42
|
+
"@oh-my-pi/pi-utils": "15.10.12",
|
|
42
43
|
"@tailwindcss/node": "^4.3.0",
|
|
43
44
|
"chart.js": "^4.5.1",
|
|
44
45
|
"date-fns": "^4.3.0",
|
package/src/aggregator.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import { workerHostEntry } from "@oh-my-pi/pi-utils";
|
|
3
3
|
import {
|
|
4
4
|
getRecentErrors as dbGetRecentErrors,
|
|
5
5
|
getRecentRequests as dbGetRecentRequests,
|
|
@@ -24,15 +24,10 @@ import {
|
|
|
24
24
|
} from "./db";
|
|
25
25
|
import { getSessionEntry, listAllSessionFiles, type ParseSessionResult } from "./parser";
|
|
26
26
|
import type { SyncWorkerRequest, SyncWorkerResponse } from "./sync-worker";
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
// the same source file through `import.meta.url`, so the literal only has to
|
|
32
|
-
// be valid relative to the `--root` directory (repo root). Importing the
|
|
33
|
-
// source as `with { type: "file" }` is NOT sufficient — that copies the file
|
|
34
|
-
// as a raw asset and does not bundle the worker's relative imports, so the
|
|
35
|
-
// worker would crash on first `import` (issue #1011, PR #1027).
|
|
27
|
+
// Coding-agent binary/bundle workers route through the CLI entrypoint with a
|
|
28
|
+
// hidden argv mode, so the compiled binary and npm bundle only need one
|
|
29
|
+
// JavaScript entry. Standalone source `omp-stats` keeps using this package's
|
|
30
|
+
// own sync-worker source file.
|
|
36
31
|
import type { BehaviorDashboardStats, DashboardStats, MessageStats, RequestDetails } from "./types";
|
|
37
32
|
|
|
38
33
|
/**
|
|
@@ -89,17 +84,18 @@ interface WorkerHandle {
|
|
|
89
84
|
}
|
|
90
85
|
|
|
91
86
|
/**
|
|
92
|
-
* Create a fresh sync worker.
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* by callers.
|
|
87
|
+
* Create a fresh sync worker. When the process was started from a
|
|
88
|
+
* self-dispatching CLI entry (omp in source, npm-bundle, or compiled form),
|
|
89
|
+
* re-enter that entry with a worker argv selector; otherwise (standalone
|
|
90
|
+
* omp-stats, bun test, SDK embedding) load the worker module directly, so this
|
|
91
|
+
* package keeps zero runtime dependency on `@oh-my-pi/pi-coding-agent`.
|
|
98
92
|
*/
|
|
99
93
|
function createSyncWorker(): Worker {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
const hostEntry = workerHostEntry();
|
|
95
|
+
if (hostEntry) {
|
|
96
|
+
return new Worker(hostEntry, { type: "module", argv: ["__omp_stats_sync_worker"] });
|
|
97
|
+
}
|
|
98
|
+
return new Worker(new URL("./sync-worker.ts", import.meta.url).href, { type: "module" });
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
function spawnWorker(): WorkerHandle {
|
package/src/db.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Database } from "bun:sqlite";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
|
-
import
|
|
3
|
+
import type { Usage } from "@oh-my-pi/pi-ai";
|
|
4
|
+
import type { GeneratedProvider } from "@oh-my-pi/pi-catalog/models";
|
|
5
|
+
import { getBundledModel } from "@oh-my-pi/pi-catalog/models";
|
|
4
6
|
import { getConfigRootDir, getStatsDbPath } from "@oh-my-pi/pi-utils";
|
|
5
7
|
import type {
|
|
6
8
|
AggregatedStats,
|