@chartgen.ai/claw-bi
v0.1.0
Published
OpenClaw usage cost analytics, output value assessment, and optimization suggestions.
Downloads
14
Readme
ClawBI
OpenClaw 用量成本分析插件。自动采集 agent 运行数据,生成交互式报告,帮你看清每天花了多少、花在哪里、效率如何。
功能
- 成本追踪:按 agent、模型、渠道、时间段统计 token 用量和费用
- 效率分析:缓存命中率、异常中断率、上下文长度趋势
- 互动分析:用户响应间隔、heartbeat/cron 任务占比
- 多格式输出:HTML(交互图表)、Markdown、文本简报、PDF
- AI 对话集成:直接问 AI「帮我分析费用」,自动调用分析工具
支持模型:Claude(全系列)、GPT-4.1/4o、Gemini 2.5/2.0/1.5、GLM-5/4
安装
前置条件:OpenClaw >= 2026.3.2
# 克隆到本地
git clone https://github.com/your-org/claw-bi.git
cd claw-bi
npm install
npm run build然后在 ~/.openclaw/openclaw.json 的 plugins.load.paths 中添加路径:
{
"plugins": {
"load": {
"paths": ["/path/to/claw-bi"]
},
"entries": {
"claw-bi": { "enabled": true }
}
}
}重启 OpenClaw 即可。
使用
命令行
/bi # 显示帮助
/bi 7d # 分析最近 7 天
/bi 30d # 分析最近 30 天
/bi all # 全量历史数据
/bi 7d markdown # 输出 Markdown 格式
/bi 7d pdf # 输出 PDF(需要 puppeteer)AI 对话
直接在对话中说,AI 会自动调用分析工具:
「帮我分析一下最近的费用」 「最近 7 天哪个 agent 花钱最多?」 「我的缓存命中率怎么样?」
配置
在 ~/.openclaw/openclaw.json 中配置插件选项:
{
"plugins": {
"entries": {
"claw-bi": {
"enabled": true,
"locale": "zh-CN",
"currency": "CNY",
"outputDir": "./reports"
}
}
}
}| 参数 | 默认值 | 说明 |
|------|--------|------|
| locale | zh-CN | 报告语言,支持 zh-CN / en-US |
| currency | CNY | 显示货币,支持 CNY / USD / EUR |
| outputDir | ./reports | 报告输出目录 |
报告格式
| 格式 | 命令 | 说明 |
|------|------|------|
| HTML | /bi 7d | 交互式,含图表、下钻、时间筛选 |
| Markdown | /bi 7d markdown | 适合 AI 对话展示或文档嵌入 |
| 文本简报 | /bi 7d text | 7 行摘要,适合通知推送 |
| PDF | /bi 7d pdf | 需要 npm install puppeteer |
修改代码后更新
claw-bi 加载的是编译后的 dist/,修改源码后需要重新 build:
npm run build
# 重启 OpenClaw插件扩展
可以通过 PluginRegistry 添加自定义分析 tab,详见 docs/plugin-development.md。
文档
License
MIT
