usage

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRuntime

func AddRuntime(t *RuntimeTotals, u ledger.InvocationUsage)

func AggregateHooks

func AggregateHooks(recs []usage.HookInvocation) map[string]HookCounts

func AggregateRuntime

func AggregateRuntime(runs []ledger.Run) runtimeSummary

func Command

func Command(a *app.App) *cobra.Command

Command returns the usage command.

Types

type App

type App struct{ *app.App }

App carries the shared CLI state and helpers for usage commands.

func (*App) AllUsageRuns

func (a *App) AllUsageRuns() ([]ledger.Run, error)

func (*App) FillElapsedFromLogs

func (a *App) FillElapsedFromLogs(runs []ledger.Run)

FillElapsedFromLogs estimates the time of invocations recorded before it was tracked, from the start in their log metadata to their last logged line. Invocations whose logs were pruned stay unreported.

type HookCounts

type HookCounts struct {
	PreTool  int `json:"pre_tool"`
	PostTool int `json:"post_tool"`
	Other    int `json:"other"`
	NonOK    int `json:"non_ok"`
}

type RunTotals

type RunTotals struct {
	RunID     string `json:"run_id"`
	Task      string `json:"task,omitempty"`
	CreatedAt string `json:"created_at"`
	JevCalls  int    `json:"jev_calls"`
	RuntimeTotals
}

RunTotals is one SDLC run's usage, with its fan-out child runs folded in.

type RuntimeTotals

type RuntimeTotals struct {
	Invocations          int      `json:"invocations"`
	ElapsedMS            int64    `json:"elapsed_ms"`
	UnknownElapsed       int      `json:"unknown_elapsed"`
	ToolCalls            int64    `json:"tool_calls"`
	UnknownToolCalls     int      `json:"unknown_tool_calls"`
	InputTokens          int64    `json:"input_tokens"`
	OutputTokens         int64    `json:"output_tokens"`
	CacheReadTokens      int64    `json:"cache_read_tokens"`
	CacheCreationTokens  int64    `json:"cache_creation_tokens"`
	UnknownInput         int      `json:"unknown_input"`
	UnknownOutput        int      `json:"unknown_output"`
	UnknownCacheRead     int      `json:"unknown_cache_read"`
	UnknownCacheCreation int      `json:"unknown_cache_creation"`
	UnknownCost          int      `json:"unknown_cost"`
	SuppliedCostUSD      *float64 `json:"supplied_cost_usd,omitempty"`
	// ContextInputTokens is input including cached input, which runtimes
	// report differently: Codex counts cached reads inside input, the others
	// report them separately. It is comparable across runtimes.
	ContextInputTokens int64 `json:"context_input_tokens"`
	// contains filtered or unexported fields
}

type UsageReport

type UsageReport struct {
	Kind          string       `json:"kind"`
	SchemaVersion int          `json:"schema_version"`
	Calls         int          `json:"calls"`
	InputTokens   int          `json:"input_tokens"`
	OutputTokens  int          `json:"output_tokens"`
	Sources       usageSources `json:"sources"`
}

Top-level call totals are retained for readers of the v1 JSON shape; sources holds the authoritative, separate v2 accounting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL