mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-06 18:39:47 +00:00
The live pipeline records only the final model step of an OpenCode turn, so the usage dashboard showed roughly 42% of OpenCode's own totals. Add an offline reconciliation ledger instead of touching the streaming path (a previous attempt that fed cumulative counters into the live pipeline made the chat/status UI numbers jump): - shared: read and aggregate `~/.local/share/opencode/opencode.db` per (day, model), exposed as `@hapi/protocol/opencodeUsage` - hub: additive `usage_reconciliation` table (no schema bump, safe to roll back), local scan at startup and every 30 minutes, and the usage summary prefers snapshots over live events for reconciled sessions - cli: each runner scans its machine's store every 30 minutes and reports snapshots over the new `opencode-usage-report` socket event, covering remote machines and sessions whose process already exited - the hub-local scan skips sessions whose store lives on another machine, so it can never wipe remotely reported rows