8000 feat(collector): read Codex and OpenCode usage in the single collector by InfinityPacer · Pull Request #59 · InfinityPacer/meterleaf · GitHub
[go: up one dir, main page]

Skip to content

feat(collector): read Codex and OpenCode usage in the single collector - #59

Merged
InfinityPacer merged 5 commits into
mainfrom
feat/single-collector-local-agents
Oct 30, 2026
Merged

InfinityPacer merged 5 commits into
mainfrom
feat/single-collector-local-agents

Conversation

@InfinityPacer
Copy link
Copy Markdown
Owner

问题

  • 本机 Codex 用量只能靠一个从未安装的独立采集程序上传,OpenCode 的用量没有接入。
  • OpenCode Go 的七天和月度额度按写死的单模型月上限推算,同一周期混用或换模型(DeepSeek → GLM)时必然算错。
  • 价目表缺少 GLM-5.3 Flash、GPT-6.1 Sol/Terra 和 codex-auto-review。

结果

  • 单一采集器:主采集器每轮依次读取 Claude Code、Codex(含 .jsonl.zst 压缩会话)和 OpenCode 本地数据库,共用一个状态库和上传路径;独立 Codex 采集器及其文档删除。
  • 按通道归账:新增 channelAccounts 配置。内置默认把 Codex 的 openai 通道记到 Codex 账户(套餐与五小时、七天额度来自会话记录),Codex go 通道和 OpenCode opencode-go 通道记到 OpenCode Go;其他通道(如经网关的 bo、OpenCode 免费通道)跳过并计数。默认规则沿用 modelAccounts 中同一账户的资料。
  • 历史起点:两个新来源只上传 2026-09-20 之后的记录。
  • 读取可靠性:每个文件的用量、额度、套餐与读取进度同一事务提交;额度与套餐按采样时间取最新;超出单轮预算的压缩文件顺延并在下一轮优先读取。
  • Go 额度:删除按模型固定月上限的推算,七天与月度窗口按上游百分比外推。
  • 价目表 2026-10-30.1:GLM-5.3 Flash(与智谱官方价一致,无高低峰)、GPT-6.1 Sol/Terra(官方公布价,Terra 缓存写入取 Codex 使用的默认 30 分钟档)、codex-auto-review 按 gpt-6-luna 计价(Codex 自动评审在 luna 上执行)。
  • 缓存写入:缺少 1 小时拆分时,已知 5 分钟部分按 5 分钟价,其余按 1 小时价,不再未计价。现有账本中没有此类记录。
  • 浏览器冒烟测试补上对 /api/accounts/archive 的模拟,原先在没有本地后端时必然失败(main 上同样失败)。

验证

  • bun run typecheck 通过;bun test tests 586 pass / 0 fail;bun run build、bun run build:collector 通过;bun run test:browser 在 1440×1000 与 390×844 全部检查通过。
  • 用构建出的采集器对本机真实数据做不上传的演练:Codex openai 用量入队到 codex(套餐 plus,五小时与七天额度各一条),opencode-go 收到 OpenCode 与 Codex go 两处用量,免费通道被跳过,最早记录不早于 2026-09-20。
  • 数据库结构版本未变,升级与回滚只需更换镜像。

🤖 Generated with Claude Code

InfinityPacer and others added 5 commits October 30, 2026 15:53
- Codex sessions (including compressed .jsonl.zst) and OpenCode messages are
  read by the main collector into one state store and one upload path.
- Accounts are routed by source and channel through channelAccounts; built-in
  defaults send Codex/openai to Codex and Go channels to OpenCode Go, and skip
  everything else.
- OpenCode Go quotas no longer use fixed per-model monthly limits; seven-day
  and monthly windows extrapolate from upstream percentages.
- Price book 2026-10-30.1 adds GLM-5.3 Flash, GPT-6.1 Sol/Terra and prices
  codex-auto-review as gpt-6-luna.
- The standalone Codex collector is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oversized archives

- Quota samples and plan observations are committed in the same transaction as
  the file progress, so an interrupted round no longer loses them.
- The newest sample wins by sample time across files, independent of file
  modification order; the latest plan persists across rounds.
- A session that only carries quota still creates its account.
- A compressed file that does not fit the remaining budget waits for the next
  round unless it is the first file of the round.
- Clarify that OpenCode message content is parsed in memory but never stored
  or uploaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude Code writes 1-hour cache by default and the 1-hour rate is the higher
one, so an unsplit record is valued instead of left unpriced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…plans

- A file deferred for budget is read first in the next round, so a newer file
  that never finishes cannot starve it.
- A plan stored as a bare name stays until a newer observation replaces it.
- An unsplit cache write keeps the known 5-minute part at its own rate and
  prices only the remainder at the 1-hour rate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@InfinityPacer
InfinityPacer merged commit 5588863 into main Oct 30, 2026
2 checks passed
@InfinityPacer
InfinityPacer deleted the feat/single-collector-local-agents branch October 30, 2026 08:27
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