iconsulting/packages/services
hailin 849a4a3099 feat(conversation): add token usage tracking for API cost analysis
- Add TokenUsageEntity to store per-request token consumption
- Add TokenUsageService with cost calculation and statistics APIs
  - Record input/output/cache tokens per API call
  - Calculate estimated cost based on Claude pricing
  - Provide user/conversation/global stats aggregation
  - Support daily stats and top users ranking
- Integrate token tracking in ClaudeAgentService
  - Track latency, tool calls, response length
  - Accumulate tokens across tool loop iterations
- Add token_usages table to init-db.sql with proper indexes

This enables:
- Per-user token consumption tracking
- Cost analysis and optimization
- Future billing/quota features

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 08:23:58 -08:00
..
conversation-service feat(conversation): add token usage tracking for API cost analysis 2026-01-23 08:23:58 -08:00
evolution-service fix(schema): sync ORM entities with database schema 2026-01-23 05:00:38 -08:00
file-service fix(file-service): specify explicit column types for TypeORM entities 2026-01-10 06:05:36 -08:00
knowledge-service fix(knowledge): add pgvector transformer for TypeORM embedding columns 2026-01-23 07:12:28 -08:00
payment-service fix(payment): use PORT env variable instead of PAYMENT_SERVICE_PORT 2026-01-10 02:48:44 -08:00
user-service fix(health): exclude /health endpoint from API prefix 2026-01-10 02:30:24 -08:00