feat: add cache-aware token usage dashboard (#1338)

* feat: add cache-aware token usage dashboard

Track normalized Claude, Codex, and ACP usage with incremental SQLite backfill. Exclude imported transcript history, rebuild usage after history rewrites, and expose an owner-only dashboard with cache-aware totals and breakdowns.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>

* fix: preserve usage model and local dates

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>

* fix: normalize cached usage and timezone buckets

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>

---------

Co-authored-by: HAPI <noreply@hapi.run>
This commit is contained in:
2026-08-03 18:02:26 +08:00
committed by GitHub
co-authored by HAPI
parent 518bd7a9a9
commit 1761b696f7
49 changed files with 1904 additions and 46 deletions
+3 -3
View File
@@ -326,7 +326,7 @@ async function publishPiTurnUsage(
const usageMessage = convertPiTurnUsage(event, contextUsage);
if (!usageMessage) return;
const converted = convertAgentMessage(usageMessage);
const converted = convertAgentMessage(usageMessage, session.currentModel);
if (converted) session.sendAgentMessage(converted);
}
@@ -362,7 +362,7 @@ export function wireTransportEvents(
const accumulated = assistantMessageAccumulator.handleEvent(event);
if (accumulated.length > 0) {
for (const msg of accumulated) {
const converted = convertAgentMessage(msg);
const converted = convertAgentMessage(msg, session.currentModel);
if (converted) session.sendAgentMessage(converted);
}
}
@@ -371,7 +371,7 @@ export function wireTransportEvents(
if (event.type !== 'message_start' && event.type !== 'message_update' && event.type !== 'message_end') {
const messages = convertPiEvent(event);
for (const msg of messages) {
const converted = convertAgentMessage(msg);
const converted = convertAgentMessage(msg, session.currentModel);
if (converted) session.sendAgentMessage(converted);
}
}