feat(dashboard): show Claude usage (tokens + requests) since server start

ClaudeBrain now returns per-reply token usage (Reply.usage from the API
response), the dashboard accumulates it (monitor.add_claude_usage), and the
header shows a "클로드 토큰" stat (input+output total, with a tooltip breaking
down input/output tokens and request count).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-08-22 16:40:25 +09:00
parent 5d9161982f
commit f1f059a018
4 changed files with 28 additions and 1 deletions

View File

@@ -176,4 +176,9 @@ class ClaudeBrain:
messages=msgs,
)
text = "".join(b.text for b in resp.content if b.type == "text")
return Reply(text=text.strip(), ts=time.monotonic())
usage = None
u = getattr(resp, "usage", None)
if u is not None:
usage = {"input": getattr(u, "input_tokens", 0) or 0,
"output": getattr(u, "output_tokens", 0) or 0}
return Reply(text=text.strip(), ts=time.monotonic(), usage=usage)