agentsclimarketplace

Token reporter

Skill aAAaqwq/AGI-Super-Team/skills/token-reporter

每日自动统计 OpenClaw 实例 Token 消耗和工作产出,上报到飞书多维表格。扫描 JSONL 日志按模型聚合 token,收集各 agent 当日工作摘要,写入飞书 Bitable。触发:'token报告'、'token report'、'日报'、'每日汇报'、'飞书上报'。From its SKILL.md

Install
npx -y skills add aAAaqwq/AGI-Super-Team --skill token-reporter

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

4.7 KB, ~1.6k tokens by cl100k_base, as published. Nobody here has run it

Token Reporter — 每日 Token 消耗 + 产出上报

  • Author: Daniel Li
  • Copyright © Daniel Li. All rights reserved.

功能概述

每天自动统计本机 OpenClaw 实例的 Token 消耗和 Agent 工作产出,格式化后写入飞书多维表格。

实例对应关系

实例CEO Agent上报人
aa (本机)小a (main)Daniel
Peter Mini小兔 (xiaotu)Peter
小m小m bot小m

执行流程

Step 1: 扫描 JSONL 日志

扫描 ~/.openclaw/agents/*/sessions/*.jsonl 中当日增量数据。

每条 assistant 消息携带 usage 对象:

{
  "usage": {
    "input": 27813,
    "output": 246,
    "cacheRead": 6720,
    "cacheWrite": 0,
    "totalTokens": 34779,
    "cost": {
      "input": 0, "output": 0,
      "cacheRead": 0, "cacheWrite": 0,
      "total": 0
    }
  }
}

Step 2: 按 Agent + Model 聚合

重点追踪 4 个模型(其他模型归入"其他"):

模型匹配规则
opus4.6claude-opus-4-6 (xingsuancode, xingjiabiapi)
glm-5zai/glm-5
minimax-M2.5minimax/MiniMax-M2.5
gemini-3-progemini-3-pro (xingjiabiapi)

Step 3: 格式化 Token 明细

opus4.6: input 320K / output 18K / cache 82% / $4.2
glm-5: input 1.2M / output 85K / cache 78% / $0.3
minimax-M2.5: input 200K / output 12K / cache 0% / $0.1
gemini: — (当日未使用)

cache% = cacheRead / (input + cacheRead + cacheWrite) × 100

Step 4: 收集产出

汇总各 agent 当日工作摘要,格式:

code: KGKB工厂30/30完成, 5平台发布脚本 | content: 小红书×2, 选题推荐 | ops: cron改造, 服务器巡检

产出收集方式:

  1. 读取当日 memory 文件 ~/clawd/memory/$(date +%Y-%m-%d).md
  2. 解析 ## Agent名 段落或关键词匹配
  3. 如无 memory 文件,从 JSONL 最后一条 user/assistant 消息摘要推断

Step 5: 写入飞书多维表格

使用 lark-mcp 工具写入 Bitable:

字段类型填写者说明
员工名称文本configconfig.json 写死 person
Token明细文本脚本统计4模型格式化文本
产出文本脚本统计各agent当日工作摘要
个人总结文本人填员工手动填写(留空)
评分单选高层选优秀/良好/不及格(留空)
时间日期脚本自动当天日期

飞书 API

  • 参考 skill: ~/clawd/skills/feishu-automation/SKILL.md
  • 工具前缀: mcp__lark-mcp_*
  • 新增记录: mcp__lark-mcp_createRecord
  • 查询记录: mcp__lark-mcp_listRecords

脚本用法

# 统计当日 Token(只看数据,不上报)
python scripts/report.py --scan-only

# 统计 + 上报飞书
python scripts/report.py --report

# 指定日期
python scripts/report.py --date 2026-03-17 --scan-only

# 使用指定配置
python scripts/report.py --config /path/to/config.json --report

Cron 配置建议

{
  "name": "📊 每日 Token 报告 + 飞书上报",
  "schedule": { "kind": "cron", "expr": "0 23 * * *", "tz": "Asia/Shanghai" },
  "payload": {
    "kind": "agentTurn",
    "message": "执行每日 Token 报告任务:\n1. 运行 python3 ~/clawd/skills/token-reporter/scripts/report.py --scan-only\n2. 查看输出,确认数据合理\n3. 运行 python3 ~/clawd/skills/token-reporter/scripts/report.py --report\n4. 确认飞书写入成功后,用 message(action=send, channel=telegram, target=-1003890797239) 简要汇报\n5. 如果失败,报告错误原因"
  }
}

配置

安装时复制 config.example.json → config.json 并填写:

{
  "person": "Daniel",
  "instance": "aa",
  "lark_app_id": "REDACTED_LARK_APP_ID_1",
  "bitable_app_token": "your_bitable_token",
  "bitable_table_id": "your_table_id"
}

文件结构

token-reporter/
├── SKILL.md
├── config.example.json    # 配置模板(安装时复制为 config.json)
├── scripts/
│   └── report.py          # 核心统计脚本
└── references/
    └── jsonl-structure.md # JSONL 数据结构参考

错误处理

错误处理
JSONL 文件损坏跳过该行,记录警告
无当日数据报告"当日无数据"
飞书 API 失败重试3次,失败后本地缓存结果
config.json 不存在提示复制 config.example.json
Memory 文件不存在产出标记为"无记录"

What ships with it: 4 files

20.7 KB alongside SKILL.md, 1 of them executable

references/

scripts/

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.