Summary of Changes (6 files, +36/-19 lines)
Root Cause
The token-economics commit (00969cf) correctly added subagent token aggregation to the DB write path (drone-session.ts), but the in-memory and frontend paths only used master-only values. This meant:
- 
During a session: UI showed lower token counts than reality
- 
After page refresh: numbers jumped up (DB values loaded)
- 
Session toolCallCount missed subagent tool calls entirely
Fixes
1. packages/api/src/messages/drone.ts — Extended IWorkOrderCompleteStats with optional aggregate fields (totalInputTokens?, totalOutputTokens?, totalToolCallCount?)
2. gadget-code/src/lib/drone-session.ts — Now computes totalToolCallCount (master + subagent tool calls) alongside existing token aggregates, passes enrichedStats (with aggregate fields populated) to codeSession.onWorkOrderComplete()
3. gadget-code/src/lib/code-session.ts — In-memory session stats use stats.totalInputTokens ?? stats.masterInputTokens (aggregate when available, master fallback)
4. gadget-code/frontend/src/lib/api.ts — Frontend type matches the shared interface
5. gadget-code/frontend/src/pages/ChatSessionView.tsx — Frontend session stats update uses aggregate values; also now correctly increments toolCallCount (was previously missing)
6. gadget-drone/src/services/agent.ts — Three fixes:
- 
Removed local IWorkOrderCompleteStats redefinition, now imports from @gadget/api
- 
Master loop token accumulation uses optional chaining (response.stats?.tokenCounts?.input ?? 0) matching the subagent loop
- 
agent:complete emit now includes stats field from subagent data
