How mizcausevic-dev/agent-trace-normalizer works
agent-trace-normalizer is a small TypeScript library and CLI that turns raw OpenAI, Anthropic, Bedrock, and Gemini responses into a canonical usage record. The main workflow parses a single response or batch, selects or forces a provider adapter, extracts token and model data—including cache and reasoning details—and returns records for metering or tracing. The CLI adds file input/output and per-record errors. Adapter behavior and CLI flow are evidenced in sampled source; other README-described integrations are represented only where documented.
Main entry points: types.ts Usage record · normalize.ts Adapter selection · cli.ts CLI · index.ts Public API
Components 15
Interfaces
- CLI
src/cli.ts - Public API
src/index.ts
Normalization
- Batch normalization
src/normalize.ts - Single normalization
src/normalize.ts - Usage record
src/types.ts - Adapter selection
src/normalize.ts
Provider adapters
- OpenAI adapter
src/adapters.ts - Anthropic adapter
src/adapters.ts - Bedrock adapter
src/adapters.ts - Gemini adapter
src/adapters.ts
Other components
- CLI user
- Library caller
- Raw responses
- Cost and tracing
- Output file
Connections 21
- CLI user → CLI: invokes
- Raw responses → CLI: reads
- CLI → Batch normalization: normalizes batch
- CLI → Output file: writes
- CLI → Cost and tracing: emits records
- Library caller → Public API: calls
- Public API → Batch normalization: exports batch API
- Public API → Single normalization: exports single API
- Batch normalization → Single normalization: normalizes each
- Single normalization → Adapter selection: selects adapter
- Adapter selection → OpenAI adapter: detects or extracts
- Adapter selection → Anthropic adapter: detects or extracts
- Adapter selection → Bedrock adapter: detects or extracts
- Adapter selection → Gemini adapter: detects or extracts
- OpenAI adapter → Usage record: builds record
- Anthropic adapter → Usage record: builds record
- Bedrock adapter → Usage record: builds record
- Gemini adapter → Usage record: builds record
- Single normalization → Usage record: returns
- Usage record → Library caller: returns
- Usage record → Cost and tracing: feeds