Documentation
¶
Overview ¶
Package token reads Claude Code session JSONL files from agent volume mounts and aggregates token usage per agent. It is independent of the cost package — no pricing, no USD, just raw token counts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Timestamp time.Time
AgentName string
SessionID string
Model string
InputTokens int64
OutputTokens int64
CacheRead int64
CacheCreate int64
}
Entry represents a single token usage event from a JSONL session file.
func CollectAgent ¶
CollectAgent returns token entries for a single agent, useful for timeseries recording where individual timestamps matter.
type Usage ¶
type Usage struct {
AgentName string `json:"agent_name"`
Model string `json:"model"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CacheRead int64 `json:"cache_read"`
CacheCreate int64 `json:"cache_create"`
TotalTokens int64 `json:"total_tokens"`
Entries int `json:"entries"`
}
Usage represents aggregated token usage for a single agent.
func CollectAll ¶
CollectAll scans all agent directories under agentsDir and returns aggregated token usage per agent. The expected layout is:
agentsDir/<agent>/claude/projects/*/*.jsonl
Click to show internal directories.
Click to hide internal directories.