All plugins

tokstat

Live token usage in the Hermes Desktop status bar: cumulative total, a real-time this-turn counter, last-turn delta, context occupancy, and prompt-cache hit rate. Event-driven (no polling, no RPC); English and Chinese, follows the app locale.

heerey525Desktopv1.0.1Updated 27 days ago

About

Live token usage in the Hermes Desktop status bar: cumulative total, a real-time this-turn counter, last-turn delta, context occupancy, and prompt-cache hit rate. Event-driven (no polling, no RPC); English and Chinese, follows the app locale.

tokstat

A Hermes Desktop plugin: live token usage for the focused session, pinned to the
right of the status bar.

Language: English · 中文

Total 1.1M · Turn 32K · Last 31K · Context 97% · Cache 56%
  • Total — cumulative tokens for the session (compact).
  • Turn — the reply currently generating, counting up in real time.
  • Last — the previous completed turn (appears when the live counter settles).
  • Context — context-window occupancy.
  • Cache — prompt-cache hit rate.

Hover for the exact figures (input / output / total, plus model name).

Labels and tooltips ship in English and Chinese — the readout follows the
Hermes Desktop locale (Settings → Language); English is the default.

How it works

No polling, no RPC. The plugin listens to three gateway events:

EventRole
session.usagemid-turn ticker (~1/s), carries the session-cumulative usage dict
message.startturn boundary — snapshots the cumulative total as the turn baseline
message.completeturn boundary — finalizes Turn − baseline as the last turn

Both payload.usage (gateway ticker) and top-level total_tokens /
context_tokens (local viewer) payload shapes are normalized, so the plugin
works on either gateway flavor. If a message.complete carries no usage, the
last ticker snapshot is used instead.

After a plugin hot-reload (or a brand-new session) the baseline is unknown, so
the first ticker snapshot of that turn becomes the baseline — "Turn" counts
up from that point rather than mirroring "Total".

Install

From the catalog (once listed):

hermes plugins install tokstat

From Git (in the meantime): Settings → Plugins → Install from Git, or:

mkdir -p ~/.hermes/desktop-plugins/tokstat
cp desktop/plugin.js ~/.hermes/desktop-plugins/tokstat/plugin.js

Then ⌘K → Reload desktop plugins (or just wait — the directory is watched).

Disclosure

  • Desktop-only, single-file plugin. No gateway-side code, no network calls of
    its own, no requires_env.
  • Reads usage figures that the gateway already reports; does not re-measure.
  • Per-turn numbers are cumulative-diff snapshots, not provider metering.
  • On builds where the session.usage ticker is absent the chip stays on its
    idle placeholder ("no usage reported yet") instead of showing stale data.

Tests

node --test tests/plugin.test.mjs

Tests import the real desktop/plugin.js with stubbed SDK (the official
single-file desktop-plugin test pattern); no build step. The usePluginI18n
stub mirrors the HOST (dotted-path walk over the registered bundle, en
fallback, then the key) instead of returning friendly strings — that is what
keeps the two i18n rules below honest.

i18n contract (learned the hard way)

ctx.i18n.register / usePluginI18n follow the host's catalog rules, and two
of them bite silently:

  1. Bundles must be nested trees. A key is resolved by walking the tree on
    ., so a flat 'label.total': '总量' entry is never found — the lookup
    returns the raw key, in every locale. Write label: { total: '总量' } and
    keep calling t('label.total').
  2. Interpolated messages must be functions. A plain string is returned
    verbatim; {0} / {1} are not substituted (that convenience exists only
    for app-level language packs registered through registerAppLocale). Use
    total: (n, i, o) => \总量:累计 ${n}…``.

The component translates through usePluginI18n('tokstat'), not ctx.i18n.t:
the latter samples the locale but never re-renders, so a live language switch
would leave the chip stranded in the old language until the next usage event.

README from the reviewed commit 5c11db1; 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