feat: add cache routing alignment and usage visibility for 2.5.0

This commit is contained in:
chenmingxuan committed 2026-11-02 17:15:59 +08:00
1 parent 7c0c2b59ca
commit 3dd96078db
15 files changed
+316 -15

No files matched your search

@@ -80,6 +80,14 @@ export function contextPercent(
return Math.min(100, Math.round(pct * 10) / 10);
}
/** Session-wide token-weighted cache share; cached input is part of total input. */
export function cachePercent(cachedTokens: number | null | undefined, promptTokens: number | null | undefined): number | null {
if (typeof cachedTokens !== 'number' || typeof promptTokens !== 'number' ||
!Number.isFinite(cachedTokens) || !Number.isFinite(promptTokens) ||
promptTokens <= 0 || cachedTokens < 0 || cachedTokens > promptTokens) return null;
return Math.round(cachedTokens / promptTokens * 1000) / 10;
}
/**
* Seconds a session has been (or was) running.
*