@oh-my-pi/omp-stats 18.4.3 → 18.4.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/index.d.ts +5 -0
- package/package.json +4 -4
- package/src/index.ts +10 -12
package/CHANGELOG.md
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ export { getGainDashboardStats } from "./gain-aggregator.js";
|
|
|
7
7
|
export { formatStatsDashboardUrl, type StartServerOptions, startServer } from "./server.js";
|
|
8
8
|
export type { GainDashboardStats, GainSource, GainSourceTotals, GainTimeSeriesPoint } from "./shared-types.js";
|
|
9
9
|
export type { AggregatedStats, DashboardStats, FolderStats, MessageStats, ModelPerformancePoint, ModelStats, ModelTimeSeriesPoint, TimeSeriesPoint, ToolDashboardStats, ToolModelStats, ToolTimeSeriesPoint, ToolUsageStats, } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Print the dashboard summary to the console. Shared by `omp stats --summary`
|
|
12
|
+
* and the standalone `omp-stats --sync`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function printStatsSummary(): Promise<void>;
|
|
10
15
|
/** Parsed arguments for the standalone `omp-stats` entry point. */
|
|
11
16
|
export interface StandaloneStatsArgs {
|
|
12
17
|
port: number;
|
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.4.
|
|
4
|
+
"version": "18.4.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.4.
|
|
46
|
-
"@oh-my-pi/pi-catalog": "18.4.
|
|
47
|
-
"@oh-my-pi/pi-utils": "18.4.
|
|
45
|
+
"@oh-my-pi/pi-ai": "18.4.4",
|
|
46
|
+
"@oh-my-pi/pi-catalog": "18.4.4",
|
|
47
|
+
"@oh-my-pi/pi-utils": "18.4.4",
|
|
48
48
|
"lucide-react": "^1.24.0",
|
|
49
49
|
"react": "19.2.7",
|
|
50
50
|
"react-dom": "19.2.7"
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
|
-
import { formatDuration, formatNumber, formatPercent } from "@oh-my-pi/pi-utils";
|
|
4
|
+
import { formatDuration, formatNumber, formatPercent, normalizePremiumRequests } from "@oh-my-pi/pi-utils";
|
|
5
|
+
import chalk from "@oh-my-pi/pi-utils/chalk";
|
|
5
6
|
import { getDashboardStats, getTotalMessageCount, syncAllSessions } from "./aggregator";
|
|
6
7
|
import { closeDb } from "./db";
|
|
7
8
|
import { refreshRollups } from "./rollup";
|
|
@@ -45,20 +46,17 @@ function formatCost(n: number, unpricedRequests = 0): string {
|
|
|
45
46
|
return `$${n.toFixed(2)}`;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function normalizePremiumRequests(n: number): number {
|
|
49
|
-
return Math.round((n + Number.EPSILON) * 100) / 100;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
49
|
/**
|
|
53
|
-
* Print
|
|
50
|
+
* Print the dashboard summary to the console. Shared by `omp stats --summary`
|
|
51
|
+
* and the standalone `omp-stats --sync`.
|
|
54
52
|
*/
|
|
55
|
-
async function
|
|
53
|
+
export async function printStatsSummary(): Promise<void> {
|
|
56
54
|
const stats = await getDashboardStats();
|
|
57
55
|
const { overall, byModel, byFolder } = stats;
|
|
58
56
|
|
|
59
|
-
console.log("\n=== AI Usage Statistics ===\n");
|
|
57
|
+
console.log(chalk.bold("\n=== AI Usage Statistics ===\n"));
|
|
60
58
|
|
|
61
|
-
console.log("Overall:");
|
|
59
|
+
console.log(chalk.bold("Overall:"));
|
|
62
60
|
console.log(` Requests: ${formatNumber(overall.totalRequests)} (${formatNumber(overall.failedRequests)} errors)`);
|
|
63
61
|
console.log(` Error Rate: ${formatPercent(overall.errorRate)}`);
|
|
64
62
|
console.log(` Total Tokens: ${formatNumber(overall.totalInputTokens + overall.totalOutputTokens)}`);
|
|
@@ -75,7 +73,7 @@ async function printStats(): Promise<void> {
|
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
if (byModel.length > 0) {
|
|
78
|
-
console.log("\nBy Model (API-equivalent estimates):");
|
|
76
|
+
console.log(chalk.bold("\nBy Model (API-equivalent estimates):"));
|
|
79
77
|
for (const m of byModel.slice(0, 10)) {
|
|
80
78
|
console.log(
|
|
81
79
|
` ${m.model}: ${formatNumber(m.totalRequests)} reqs, ${formatCost(m.totalCost, m.unpricedRequests)}, ${formatPercent(m.cacheRate)} cache rate, ${formatPercent(m.cacheSavings)} cache savings`,
|
|
@@ -84,7 +82,7 @@ async function printStats(): Promise<void> {
|
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
if (byFolder.length > 0) {
|
|
87
|
-
console.log("\nBy Folder (API-equivalent estimates):");
|
|
85
|
+
console.log(chalk.bold("\nBy Folder (API-equivalent estimates):"));
|
|
88
86
|
for (const f of byFolder.slice(0, 10)) {
|
|
89
87
|
console.log(
|
|
90
88
|
` ${f.folder}: ${formatNumber(f.totalRequests)} reqs, ${formatCost(f.totalCost, f.unpricedRequests)}`,
|
|
@@ -199,7 +197,7 @@ Examples:
|
|
|
199
197
|
if (values.json) {
|
|
200
198
|
console.log(JSON.stringify(await getDashboardStats(), null, 2));
|
|
201
199
|
} else {
|
|
202
|
-
await
|
|
200
|
+
await printStatsSummary();
|
|
203
201
|
}
|
|
204
202
|
} catch (error) {
|
|
205
203
|
console.error("Error:", error);
|