feat: emit usage_updated events for real-time token usage updates

This commit is contained in:
Mohamed Boudra
2026-04-08 08:59:02 +07:00
parent 5ac7b3f7c7
commit 5c93fbc955
8 changed files with 498 additions and 7 deletions
@@ -2124,6 +2124,10 @@ export class AgentManager {
void this.refreshRuntimeInfo(agent);
}
break;
case "usage_updated":
agent.lastUsage = event.usage;
this.emitState(agent);
break;
case "timeline":
// Skip provider-replayed user_message items during history hydration.
if (options?.fromHistory && event.item.type === "user_message") {