Files
Henry 4c0d92154b feat(backend): add per-run cost/token ledger for task usage (#2960)
Co-authored-by: nova28 <17953305+nova28@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
2026-08-23 22:15:19 +00:00

43 lines
1.1 KiB
Go

package models
import "time"
// TaskUsageEvent is one immutable row of internal/task/repository/sqlite's
// task_usage_events ledger (docs/specs/task-cost-ledger/spec.md). A pointer
// token/rate field means the value is *not recorded*, distinct from a
// measured zero (AC-4, AC-30); SessionID, TurnID, and PricingCatalogVersion
// use "" for SQL NULL since they are always either absent or a non-empty
// identifier.
type TaskUsageEvent struct {
ID int64
UsageEventID string
TaskID string
SessionID string
TurnID string
AgentProfileID string
AgentType string
Model string
Provider string
TokensIn int64
TokensCachedRead *int64
TokensCachedWrite *int64
TokensOut *int64
TokensThought *int64
TokensTotal int64
CostSubcents int64
CostSource string
Estimated bool
RateInputPerMillion *int64
RateCachedReadPerMillion *int64
RateCachedWritePerMillion *int64
RateOutputPerMillion *int64
PricingCatalogVersion string
ContractVersion int
OccurredAt time.Time
CreatedAt time.Time
}