Skip to content

feat(usage): pure usage normalizer + accumulators (Task #5)#21

Open
lubobill1990 wants to merge 1 commit into
feat/04-with-account-wrapperfrom
feat/05-usage-normalizer
Open

feat(usage): pure usage normalizer + accumulators (Task #5)#21
lubobill1990 wants to merge 1 commit into
feat/04-with-account-wrapperfrom
feat/05-usage-normalizer

Conversation

@lubobill1990
Copy link
Copy Markdown
Collaborator

Summary

  • Pure module src/lib/usage-normalizer.ts (no DB / network / state)
  • OpenAI / Anthropic / embeddings normalizers
  • Streaming accumulators for both formats

Test plan

  • 9 new tests; 71 total pass
  • typecheck clean

Refs #5

🤖 Generated with Claude Code

- src/lib/usage-normalizer.ts: NormalizedUsage shape + helpers for OpenAI / Anthropic / embeddings, plus streaming accumulators that watch for include_usage / message_start+message_delta and finalize to NormalizedUsage. UsageMissingError raised if OpenAI stream finishes without usage.

Tests: OpenAI/Anthropic/embeddings normalize, OpenAI accumulator capture + missing-usage error, Anthropic accumulator aggregation + sane zeros.

Refs #5

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant