omp packages

@hanmo5888/toktaken0.1.0

Report token usage from Claude Code, Codex, Pi, and OpenCode to TokTaken.

hanmo5888 Published 18 days ago ~269 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

TokTaken reporters

One npm package contains the reporters for Claude Code, Codex, Pi, and OpenCode. It requires Node.js 22.13 or later and has no package dependencies. Install it once on each machine:

npm install -g @hanmo5888/toktaken
TOKTAKEN_PLUGIN_DIR="$(npm root -g)/@hanmo5888/toktaken"

Create a reporting key in My dashboard → Reporting keys on your TokTaken site, then set:

export TOKTAKEN_URL='https://usage.example.com'
export TOKTAKEN_API_KEY='tt_…'

TOKTAKEN_URL is the site URL, without /api/v1. Loopback HTTP works for local development. Export these two variables where all your harness processes will inherit them (for GUI apps, use the launcher's environment). Configure one key per machine; multiple harnesses on the machine share that key.

Enable the harnesses you use. In config files, replace /path/to/toktaken with the value of TOKTAKEN_PLUGIN_DIR.

Harness Setup When it reports
Claude Code Start claude --plugin-dir "$TOKTAKEN_PLUGIN_DIR". When a turn or subagent stops.
Codex Merge codex/hooks.example.json from the package into ~/.codex/hooks.json (or the hooks file under your custom Codex home). Approve the hook in /hooks. If Codex cannot find toktaken on its PATH, use node "/path/to/toktaken/cli.mjs" hook codex as the hook command. When a turn stops. The existing notify setting is independent.
Pi Add /path/to/toktaken/pi-extension.mjs to extensions in ~/.pi/agent/settings.json, or start with pi -e "$TOKTAKEN_PLUGIN_DIR/pi-extension.mjs". After an assistant turn.
OpenCode Add file:///path/to/toktaken/opencode-plugin.mjs to plugin in ~/.config/opencode/opencode.json. On completed assistant messages.

If you only use Pi or OpenCode, you can let the harness install the same npm package instead: run pi install npm:@hanmo5888/toktaken, or add "@hanmo5888/toktaken" to OpenCode's plugin array. Use one loading method per harness.

When running from a source checkout, set TOKTAKEN_PLUGIN_DIR to its packages/reporter directory and use node "$TOKTAKEN_PLUGIN_DIR/cli.mjs" in place of the installed toktaken command.

Configurations were developed against Claude Code 2.1, Codex 0.169, Pi 1.3, and OpenCode 1.19. Restart the harnesses after configuring them. Make a model call, then check My dashboard for the harness and model totals.

Retry or import selected history

Pending batches stay under ${XDG_STATE_HOME:-~/.local/state}/toktaken and are retried on the next reporting activity. Run this to send them immediately:

toktaken flush

To import an existing transcript or OpenCode database, select the file explicitly:

toktaken sync codex /path/to/rollout.jsonl
toktaken sync claudecode /path/to/transcript.jsonl
toktaken sync pi /path/to/session.jsonl
toktaken sync opencode /path/to/opencode.db

The reporters send only model usage metadata, never prompts, responses, or local paths. Transcript hooks read new records in the active session and checkpoint after queuing. The queue is bound to the server and key to keep accounts separate. If you have pending events, flush them before revoking a key; selected history can also be reimported with a replacement key. Invalid batches stay on disk with a .rejected suffix so they don't block later reports.