All plugins

token-usage

Token usage analytics from the local Hermes database (~/.hermes/state.db) — lifetime totals, per-model breakdown, per-session details, cache/reasoning tokens, API call counts and estimated cost. No network, no auth, no Hermes Desktop required. Fully config-driven. Disclosure — reads the Hermes session database (state.db) read-only for token counts and cost totals, and config.yaml for its own token_plugin settings; no network, no writes.

priyankarpalToolsv0.3.0Updated 5 days ago

About

Token usage analytics from the local Hermes database (~/.hermes/state.db) — lifetime totals, per-model breakdown, per-session details, cache/reasoning tokens, API call counts and estimated cost. No network, no auth, no Hermes Desktop required. Fully config-driven. Disclosure — reads the Hermes session database (state.db) read-only for token counts and cost totals, and config.yaml for its own token_plugin settings; no network, no writes.

Hermes Token Usage Plugin

Purpose

See your token usage from the local Hermes database in the terminal. Shows totals, per-model breakdown, and per-session breakdown — all filterable by time window, model, profile, and session.

Install

hermes plugins install priyankarpal/hermes-agent-token-usages --enable

Update to get new CLI flags:

hermes plugins update token-usage

Quick Start

hermes tokens                    # lifetime, daily heatmap, page 1 (10 sessions)
hermes tokens --by month         # 6-month bar chart instead of heatmap
hermes tokens --page 2 --page-size 20   # page 2, 20 sessions per page
hermes tokens --window 30d --by year    # last 3 years, 30-day window
hermes tokens --format json      # JSON output for scripts

CLI Flags

FlagValuesDefaultDescription
--windowlifetime, 7d, 30d, 90dlifetimeTime window
--modelmodel name—Filter to one model
--sessionsession ID—Drill down into one session
--profileprofile name—Filter to one profile
--formattable, jsontableOutput format
--byday, month, yeardayTimeline: heatmap / 6-month bars / 3-year bars
--pageinteger1Sessions page number
--page-sizeinteger10Sessions per page
--widthintegerterminalForce terminal width (min 60)

Invalid page, page-size, or width (< 60) → exit code 2 with one-line message.

What You See

1. Meta Panel

Database path, window, profile, format, and current session (most recent by last_activity_at).

2. Totals Panel

MetricMeaning
SessionsCount of sessions in window
Input / OutputTokens sent to / received from model
Cache ReadTokens served from cache
Cache Multipliercache_read / (input + output) × 100% — scale (often 1000%+)
Cache Hit Ratecache_read / (cache_read + input) × 100% — efficiency (0–100%)
Total Tokensinput + output only (excludes cache/read/write/reasoning)
Est. Cost— if no pricing configured for any model in window

3. Models Table

Per-model breakdown with share bars (██████░░░░ 64.8%). Columns drop responsively at narrow widths.

4. Timeline (--by)

ModeWhat you get
--by dayGitHub-style 12-week heatmap (Mon–Sun), 4 green levels, month labels, legend
--by monthLast 6 calendar months (incl. zeros) as horizontal share-bar chart
--by yearLast 3 calendar years (incl. zeros) as horizontal share-bar chart

5. Sessions Table (paginated)

  • Current session pinned at top of page 1 with ◂ current marker (never truncates)
  • Sorted by total tokens descending
  • Zero-token sessions hidden; counted in footer
  • Footer: Page N of M · rows a–b of T · next: --page N+1 · X with no activity hidden
  • Columns drop responsively: Current (never) → Model → Session ID → others

Cost Display: Why — (em dash)?

The DB stores only cost totals, not per-token rates. Without token_plugin.pricing config, the plugin shows — meaning "not configured" — not a bug. Add pricing for models you want cost estimates:

token_plugin:
  pricing:
    "nvidia/nemotron-3.5":
      input_per_1m: 0.15
      output_per_1m: 0.60

Cache Metrics Explained

MetricFormulaRangeMeaning
Cache Multipliercache_read / (input + output) × 100%0%–∞Scale — how many times larger cache reads are than fresh model tokens. Can exceed 100% (often 1000%+).
Cache Hit Ratecache_read / (cache_read + input) × 100%0%–100%Efficiency — what fraction of total token interactions (cache + input) were served from cache.

Total Tokens = input + output only (excludes cache/read/write/reasoning).

Configuration

All under token_plugin: in ~/.hermes/config.yaml (or TOKEN_PLUGIN_* env vars):

KeyEnv VarDefaultDescription
db_pathTOKEN_PLUGIN_DB_PATH~/.hermes/state.dbSQLite DB (read-only)
default_windowTOKEN_PLUGIN_DEFAULT_WINDOWlifetimeTime window
include_archivedTOKEN_PLUGIN_INCLUDE_ARCHIVEDfalseInclude archived sessions
output_formatTOKEN_PLUGIN_OUTPUT_FORMATtabletable or json
max_sessionsTOKEN_PLUGIN_MAX_SESSIONS50Max sessions in breakdown
profileTOKEN_PLUGIN_PROFILE—Profile filter
currency_labelTOKEN_PLUGIN_CURRENCY_LABELUSDCurrency label (no FX)

Labels are config-driven under token_plugin.labels:*; unset falls back to key name.

Safety

Two independent layers guarantee the Hermes DB is never modified:

  1. URI mode=ro — read-only file descriptor
  2. PRAGMA query_only = ON — SQLite rejects all writes at runtime

Only SELECT on sessions and session_model_usage tables.

Example

$ hermes tokens --page 1 --page-size 5 --width 120

Outputs: meta panel → totals panel → models table → 12-week heatmap → sessions table (page 1) with pagination footer.

README from the reviewed commit 365660e; it updates when the author re-pins.

Developer Mode

Explore built-in Hermes toolsets and actions.

HermesAgent

Developer?

Create a Hermes extension for Desktop or agent workflows.

Developer Section