8000 feat(collector): split non-Claude models into their own accounts and track OpenCode Go for 0.11.0 by InfinityPacer · Pull Request #45 · InfinityPacer/meterleaf · GitHub
[go: up one dir, main page]

Skip to content

feat(collector): split non-Claude models into their own accounts and track OpenCode Go for 0.11.0 - #45

Merged
InfinityPacer merged 6 commits into
mainfrom
feat/opencode-go-accounts
Oct 22, 2026
Merged

InfinityPacer merged 6 commits into
mainfrom
feat/opencode-go-accounts

Conversation

@InfinityPacer
@InfinityPacer InfinityPacer commented Oct 22, 2026 •
Copy link
Copy Markdown
Owner

问题

  • Claude Code 经 OpenCode Go 使用 DeepSeek 时,会话记录和 Claude 订阅写在同一个目录,记录里没有账户和请求地址。采集器按登录时间把这些用量全部记到当前 Claude 账户,Claude 账户的用量和额度预估被虚高。
  • 价格表没有 DeepSeek V4.1 Flash,这些请求显示为未计价;Go 在工作日高峰时段价格翻倍,价格表也没有按时段计价的规则。
  • Meterleaf 看不到 Go 的 5 小时、每周和每月额度。

改动

  • 按模型名分账户(src/collector/model-accounts.ts、src/collector/state.ts、src/collector/collect.ts、src/collector/config.ts)
    • 只有 claude- 开头的模型按登录时间线归属;其他模型默认归到「其他模型」账户。
    • 采集器 config.json 新增可选 modelAccounts,按模型名匹配式把用量映射到独立账户(例如 deepseek-* → OpenCode Go),换模型或加供应商只改配置。
    • 归属规则版本升到 3,并与映射摘要一起记录。升级或修改映射后,已推送的事件按新规则重新归属并补推一次,服务端按 (sourceId, externalId) 更新账户,历史上记错的用量随之改归。
  • DeepSeek V4.1 Flash 计价(src/domain/pricing.ts、prices/meterleaf-2026-09-25.json)
    • 规则新增可选 peak,按 UTC 星期和时段使用显式峰时费率;不能与 longContext、imageRates 同时配置。
    • 按 Go 公布价格加入两个 USD 分支,工作日 UTC 01:00–04:00、06:00–10:00 使用峰时价。价格表版本 2026-09-25.5。
  • Go 额度(src/server/opencode-go.ts、src/server/config.ts、src/server/snapshot.ts)
    • 服务端配置 METERLEAF_OPENCODE_GO_KEY(可选 METERLEAF_OPENCODE_GO_ACCOUNT),只在有页面在线时读取 Go 用量接口,最多每 2 分钟一次;采集器不经手这把 Key。
    • 额度保存为 5 小时、每周和新增的 monthly 快照;失败只记录状态码,不记录 Key。
  • 界面(src/web/lib/quota-display.ts、src/web/App.tsx 等):账户卡片和详情在周额度之后显示「月」窗口及其重置时间、周期费用与预估。
  • 文档(docs/collector.md、docs/deployment.md、docs/pricing.md)、.env.example、compose.yaml 与 CHANGELOG 已更新,版本升到 0.11.0。数据库结构未变。

验证

  • bun run typecheck、bun test tests(488 通过)、bun run build、bun run build:collector、所改文件 Prettier 检查与 git diff --check 通过。
  • 新增测试覆盖:模型匹配与顺序、未配置时归入其他模型、映射账户随用量推送、升级和修改映射各只重新归属一次、配置校验、bind-history 不会把映射账户的用量改归;峰时起点包含与终点不包含、周末不加价、非法时段被拒、内置表能为 DeepSeek 记录计价;Go 用量换算三个窗口、只在页面在线且间隔已到时读取、失败计入间隔且日志不含 Key、读数未变时少写快照、月周期跨月末、配置默认账户;月额度显示顺序和周额度用尽时让位。
  • 本机端到端升级演练(临时数据目录和临时服务端):
    • 用 main 上的旧采集器推送真实历史并绑定账户,复现 DeepSeek 用量记在 Claude 账户下(342 条)。
    • 换新采集器并配置映射后,一轮同步把 342 条全部改归 opencode-go,Claude 账户请求数相应减少,DeepSeek 显示金额。
    • 模拟页面在线后,服务端用真实 Go Key 读到 5 小时、每周、每月三个额度,页面账户卡片和详情在桌面与手机宽度显示「月」窗口。

已知限制

  • Go 用量接口不是公开文档化的接口,字段变化时额度读取会失败并记日志,用量与计价不受影响。
  • 估值按 Go 公布的按 token 价格计算,不是 Go 的月度账单。

🤖 Generated with Claude Code

InfinityPacer and others added 6 commits October 23, 2026 02:44
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o quota reads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@InfinityPacer
InfinityPacer merged commit 8f56f26 into main Oct 22, 2026
2 checks passed
@InfinityPacer
InfinityPacer deleted the feat/opencode-go-accounts branch October 22, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0