• Joined on 2025-08-09

@ndjoe/omp-stats (14.5.7)

Published 2026-04-29 03:36:32 +00:00 by ndjoe

Installation

@ndjoe:registry=https://git.tpk.fun/api/packages/ndjoe/npm/
npm install @ndjoe/omp-stats@14.5.7
"@ndjoe/omp-stats": "14.5.7"

About this package

@ndjoe/omp-stats

Local observability dashboard for AI usage statistics.

Features

  • Session log parsing: Reads JSONL session logs from ~/.omp/agent/sessions/
  • SQLite aggregation: Efficient stats storage and querying using bun:sqlite
  • Web dashboard: Real-time metrics visualization with Chart.js
  • Incremental sync: Only processes new/modified log entries

Metrics Tracked

Metric Calculation
Tokens/s output_tokens / (duration / 1000)
Cache Rate cache_read / (input + cache_read) * 100
Error Rate count(stopReason=error) / total_calls * 100
Total Cost Sum of usage.cost.total
Avg Latency Mean of duration
TTFT Mean of ttft (time to first token)

Usage

Via CLI

# Start dashboard server (default: http://localhost:3847)
omp stats

# Custom port
omp stats --port 8080

# Print summary to console
omp stats --summary

# Output as JSON (for scripting)
omp stats --json

Programmatic

import { getDashboardStats, syncAllSessions } from "@ndjoe/omp-stats";

// Sync session logs to database
const { processed, files } = await syncAllSessions();

// Get aggregated stats
const stats = await getDashboardStats();
console.log(stats.overall.totalCost);
console.log(stats.byModel[0].avgTokensPerSecond);

API Endpoints

Endpoint Description
GET /api/stats Overall stats with all breakdowns
GET /api/stats/models Per-model statistics
GET /api/stats/folders Per-folder/project statistics
GET /api/stats/timeseries Hourly time series data
GET /api/sync Trigger sync and return counts

Data Storage

  • Session logs: ~/.omp/agent/sessions/ (JSONL files)
  • Stats database: ~/.omp/stats.db (SQLite)

Dashboard

The web dashboard provides:

  • Overall metrics cards (requests, cost, cache rate, error rate, duration, tokens/s)
  • Time series chart showing requests and errors over time
  • Per-model breakdown table
  • Per-folder breakdown table
  • Auto-refresh every 30 seconds

License

MIT

Dependencies

Dependencies

ID Version
@ndjoe/pi-ai 14.5.5
@ndjoe/pi-utils 14.5.5
@tailwindcss/node ^4.2.4
chart.js ^4.5.1
date-fns ^4.1.0
lucide-react ^1.11.0
react ^19.2.5
react-chartjs-2 ^5.3.1
react-dom ^19.2.5

Development Dependencies

ID Version
@types/bun ^1.3
@types/react ^19.2.14
@types/react-dom ^19.2.3
postcss ^8.5.10
tailwindcss ^4.2.4

Keywords

ai observability metrics dashboard llm statistics
Details
npm
2026-04-29 03:36:32 +00:00
2
Can Boluk
MIT
27 KiB
Assets (1)
Versions (5) View all
14.5.10 2026-04-29
14.5.9 2026-04-29
14.5.7 2026-04-29
14.5.6 2026-04-29
14.5.4 2026-04-29