tokend-cli
v2.1.1
Published
AI 编程成本监控 — 扫描本地日志,同步至云端面板
Readme
Tokend
Tokend is a local single-user cost monitoring cockpit for OpenClaw.
It reads historical usage primarily from local OpenClaw session files, stores normalized events in SQLite, and shows breakdowns by:
- day
- model
- channel
- session
It also supports estimated cost tracking via an editable model price table.
What works now
- Dashboard with today totals, model mix, channel mix, top sessions, and trends
- Models / Channels / Sessions / Session detail pages
- SQLite-backed ingestion from local OpenClaw session files
- Manual re-sync and full re-index
- Source health view
- Editable model price table
Current limitations
- Cost is only as good as the configured or inferred price table
- Some models may show
$0.00until you add prices manually - Realtime activity is limited; Tokend is strongest on historical accounting
- No file watcher / auto-refresh loop yet
- Single-user local app only
Requirements
- Node.js 24+
- npm
Install
cd /Users/xinzechao/.openclaw/workspace/Tokend
npm installDevelopment
This starts:
- API server on
127.0.0.1:3001 - frontend dev server on
127.0.0.1:4173
cd /Users/xinzechao/.openclaw/workspace/Tokend
npm run devOpen:
http://127.0.0.1:4173Important
Tokend now uses frontend port 4173 by default instead of 5173, to avoid common Vite port collisions.
If 4173 is already occupied, Vite is configured with strictPort: true, so startup should fail loudly instead of silently hopping to another port.
Production-ish local run
Build frontend and serve it from the backend on port 3001:
cd /Users/xinzechao/.openclaw/workspace/Tokend
npm run build
npm run prodOpen:
http://127.0.0.1:3001Useful commands
Incremental ingestion
npm run ingestInstall Project Hooks
This project can auto-update the Feishu 版本记录 sheet before git push.
npm run setup-hooksAfter that, each push will run:
npm run update-version-recordRelease content is read from:
release/current-version.jsonBefore publishing a new version:
- Update
package.jsonversion - Update
release/current-version.json - Run
git push
The hook currently writes to:
- spreadsheet:
ICA2s2tgGhonFjtLblRctv8AnGc - sheet:
版本记录(cVwJUD)
Rebuild frontend
npm run buildData sources
Primary historical sources:
~/.openclaw/agents/*/sessions/*.jsonl- session metadata from nearby
sessions.jsonindexes
Troubleshooting
Frontend won't open
- Make sure
npm run devis still running - Open
http://127.0.0.1:4173 - If startup fails, another process is likely already using 4173
- Either stop that process or run with a different port:
FRONTEND_PORT=4273 npm run devThen open:
http://127.0.0.1:4273Backend API fails
Default backend port is:
127.0.0.1:3001To change it:
PORT=3011 npm run devCosts look wrong
Go to Settings and update the model price table.
Some providers/models do not currently have trustworthy built-in pricing, so Tokend may need manual price inputs.
Notes
- Tokend does not modify core OpenClaw config
- It is intended as a local observability tool, not a billing source of truth
