Token Burn Monitor
Zero-dependency Node.js dashboard. Core API + swappable frontend themes.
Architecture
CODEBLOCK0
Quick Start
CODEBLOCK1
Configuration
Copy config.default.json to config.json:
CODEBLOCK2
- - theme: Directory name under
themes/. Default: INLINECODE3 - agents: Display names/icons. Auto-discovered; config only overrides display.
- port: Also settable via
PORT env var. - modelPricing: Override/add model pricing ($/1M tokens).
Set OPENCLAW_AGENTS_DIR to override agent directory (default: /home/node/.openclaw/agents).
Themes
Themes live in themes/<name>/. Minimum: one index.html that fetches data from the API.
To create a custom theme:
- 1. Read
API.md for all available endpoints - Create INLINECODE10
- Set
"theme": "my-theme" in config.json - Restart
The default theme (themes/default/) is a full reference implementation.
API Overview
All endpoints return JSON. GET-only. Server binds to localhost. Full docs in API.md.
| Endpoint | Description |
|---|
| INLINECODE14 | Agent names and icons |
| INLINECODE15 |
All agents aggregated |
|
GET /api/agent/:id?date= | Single agent with per-call breakdown |
|
GET /api/history?days= | 30-day cost history |
|
GET /api/pricing | Model pricing table |
|
GET /api/crons | Scheduled jobs (read from filesystem) |
|
GET /api/cron/:id/runs | Job run history |
Security
- - Server binds to
127.0.0.1 by default (localhost only) - No shell execution — all data read from filesystem
- No outbound network requests — default theme uses system fonts
- User prompts redacted by default (
[redacted]), opt-in via showPrompts: true in config - HTML responses include CSP: INLINECODE24
- GET-only — all other HTTP methods rejected
Troubleshooting
- - No data: Verify
OPENCLAW_AGENTS_DIR points to correct agents directory. - Port conflict: INLINECODE26
- Theme not loading: Check
themes/<name>/index.html exists.
Token Burn Monitor
零依赖的Node.js仪表盘。核心API + 可切换的前端主题。
架构
server.js → 核心API(稳定,请勿修改)
themes/default/ → 默认深色仪表盘主题
themes// → 用户/代理生成的主题
API.md → 面向主题开发者的API契约
config.json → 端口、主题、代理、定价覆盖配置
快速开始
bash
bash start.sh # 启动(默认端口3847)
bash start.sh status # 检查状态
bash start.sh restart # 配置更改后重启
bash start.sh stop # 停止
配置
复制config.default.json为config.json:
json
{
port: 3847,
theme: default,
agents: {
main: { name: Karl, icon: /assets/karl.png }
},
modelPricing: {}
}
- - theme: themes/目录下的子目录名称。默认值:default
- agents: 显示名称/图标。自动发现;配置仅覆盖显示内容。
- port: 也可通过PORT环境变量设置。
- modelPricing: 覆盖/添加模型定价($/百万Token)。
设置OPENCLAWAGENTSDIR以覆盖代理目录(默认:/home/node/.openclaw/agents)。
主题
主题位于themes//目录下。最低要求:一个从API获取数据的index.html文件。
创建自定义主题:
- 1. 阅读API.md了解所有可用端点
- 创建themes/my-theme/index.html
- 在config.json中设置theme: my-theme
- 重启
默认主题(themes/default/)是一个完整的参考实现。
API概览
所有端点返回JSON格式。仅支持GET请求。服务器绑定到localhost。完整文档见API.md。
| 端点 | 描述 |
|---|
| GET /api/config | 代理名称和图标 |
| GET /api/stats?date= |
所有代理汇总数据 |
| GET /api/agent/:id?date= | 单个代理及每次调用的详细数据 |
| GET /api/history?days= | 30天成本历史 |
| GET /api/pricing | 模型定价表 |
| GET /api/crons | 定时任务(从文件系统读取) |
| GET /api/cron/:id/runs | 任务运行历史 |
安全
- - 服务器默认绑定到127.0.0.1(仅限本地访问)
- 不执行shell命令——所有数据从文件系统读取
- 无出站网络请求——默认主题使用系统字体
- 用户提示默认被编辑([redacted]),可通过配置中的showPrompts: true选择显示
- HTML响应包含CSP:connect-src self; font-src self
- 仅支持GET——拒绝所有其他HTTP方法
故障排除
- - 无数据:验证OPENCLAWAGENTSDIR指向正确的代理目录。
- 端口冲突:PORT=4000 bash start.sh
- 主题未加载:检查themes//index.html是否存在。