mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-05 23:19:43 +02:00
feat: persistent token tracking with global stats aggregation
- Add restoreTokens() method to Session class for recovery after restart - Add GlobalStats type for cumulative usage tracking across all sessions - Accumulate tokens from deleted sessions into global stats - Track lifetime session count with incrementSessionsCreated() - Add /api/stats endpoint for global stats - Include globalStats in /api/status response - Frontend shows aggregate tokens + cost in header - Fix respawn controller config to filter undefined values - Add 7 new tests for global stats functionality (v0.1343) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -571,6 +571,16 @@ export class Session extends EventEmitter {
|
||||
return this._totalOutputTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore token and cost values from saved state.
|
||||
* Called when recovering sessions after server restart.
|
||||
*/
|
||||
restoreTokens(inputTokens: number, outputTokens: number, totalCost: number): void {
|
||||
this._totalInputTokens = inputTokens;
|
||||
this._totalOutputTokens = outputTokens;
|
||||
this._totalCost = totalCost;
|
||||
}
|
||||
|
||||
get autoClearThreshold(): number {
|
||||
return this._autoClearThreshold;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user