@openduo/duoduo 0.5.0-rc.2.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -341,7 +341,7 @@ body{
341
341
  <div class="stats">
342
342
  <span id="stat-cost" class="val">--</span>
343
343
  <span id="stat-tokens" class="val">--</span>
344
- <span id="stat-cache" class="val" title="KV cache hit rate across drains that reported cache fields (providers that omit these fields, e.g. Codex, are excluded)">--</span>
344
+ <span id="stat-cache" class="val" title="Prompt-cache hit rate, blended across protocols. Anthropic-protocol drains use cache_read / (read + create + fresh_input). Codex drains use cached / input_tokens (cached is a subset of input on that protocol). Drains from anthropic-compat backends that omit cache_creation (e.g. GLM via z.ai) are excluded — they cannot be reliably classified. NOTE: only drains written by the protocol-tagged ledger contribute. Pre-fix historical drains (untagged) are intentionally not counted; '--' here means no tagged drains yet, not an error.">--</span>
345
345
  <span id="stat-tools" class="val">-- tools</span>
346
346
  <button class="cfg-btn" id="cfg-btn">CONFIG</button>
347
347
  <div id="health-dot" class="health-dot"></div>
@@ -784,7 +784,17 @@ body{
784
784
  var st=r[0].status==="fulfilled"?r[0].value:null;
785
785
  var us=r[1].status==="fulfilled"?r[1].value:null;
786
786
  var jr=r[2].status==="fulfilled"?r[2].value:null;
787
- if(us&&us.totals){var m=us.totals;costEl.textContent=fmtCost(m.total_cost_usd||0);tokensEl.textContent=fmtTokens((m.total_input_tokens||0)+(m.total_output_tokens||0)+(m.total_cache_read_tokens||0));var cacheRead=m.total_cache_read_tokens||0,cacheEligibleIn=m.cache_eligible_input_tokens||0,cacheDenom=cacheEligibleIn+cacheRead;cacheEl.textContent=cacheDenom>0?Math.round(cacheRead/cacheDenom*100)+"%\u2009cache":"--";toolsEl.textContent=fmtTools(m.total_tool_calls||0)}
787
+ if(us&&us.totals){var m=us.totals;costEl.textContent=fmtCost(m.total_cost_usd||0);tokensEl.textContent=fmtTokens((m.total_input_tokens||0)+(m.total_output_tokens||0)+(m.total_cache_read_tokens||0));
788
+ // Per-protocol blended cache hit rate. Anthropic and Codex use
789
+ // different formulas (see ledger.ts UsageSummary.cache docs).
790
+ // Combine: numerator = read tokens served from cache across both;
791
+ // denominator = total prompt tokens billed across both.
792
+ var cAnt=(m.cache&&m.cache.anthropic)||{},cCdx=(m.cache&&m.cache.codex)||{};
793
+ var antTotal=(cAnt.cache_read_tokens||0)+(cAnt.cache_create_tokens||0)+(cAnt.fresh_input_tokens||0);
794
+ var blendedSave=(cAnt.cache_read_tokens||0)+(cCdx.cached_tokens||0);
795
+ var blendedTotal=antTotal+(cCdx.input_tokens||0);
796
+ cacheEl.textContent=blendedTotal>0?Math.round(blendedSave/blendedTotal*100)+"%\u2009cache":"--";
797
+ toolsEl.textContent=fmtTools(m.total_tool_calls||0)}
788
798
  if(st){
789
799
  // Update session display_name lookup
790
800
  (st.sessions||[]).forEach(function(s){if(s.display_name)sessionDisplayNames.set(s.session_key,s.display_name)});