Documentation
¶
Index ¶
- Variables
- func ApplyStandardRateLimits(resp *http.Response, snap *core.UsageSnapshot)
- func CodingToolHidePrefixes() []string
- func CodingToolSectionOrder() []core.DashboardStandardSection
- func CollectFilesByExt(roots []string, exts map[string]bool) []string
- func CreateStandardRequest(ctx context.Context, baseURL, endpoint, apiKey string, ...) (*http.Request, error)
- func DefaultCodeStatsConfig() core.CodeStatsConfig
- func ExpandHome(path string) string
- func ExtractFilePathsFromPayload(input any) []string
- func FinalizeStatus(snap *core.UsageSnapshot)
- func FirstPathNumber(root map[string]any, paths ...[]string) *float64
- func FirstPathString(root map[string]any, paths ...[]string) string
- func FlexParseTime(value string) time.Time
- func FormatTokenCount(value int) string
- func FormatTokenCountF(value float64) string
- func HasHookUsage(u HookUsage) bool
- func Int64Ptr(v int64) *int64
- func NumberFromAny(value any) (float64, bool)
- func NumberToFloat64Ptr(v *float64) *float64
- func NumberToInt64Ptr(v *float64) *int64
- func ParseFlexibleTimestamp(value string) (int64, bool)
- func ParseTimestampString(value string) (time.Time, error)
- func PathMap(root map[string]any, path ...string) (map[string]any, bool)
- func PathSlice(root map[string]any, path ...string) ([]any, bool)
- func PathValue(root map[string]any, path ...string) (any, bool)
- func ProbeRateLimits(ctx context.Context, url, apiKey string, snap *core.UsageSnapshot) error
- func ProcessStandardResponse(resp *http.Response, acct core.AccountConfig, providerID string) (core.UsageSnapshot, error)
- func RequireAPIKey(acct core.AccountConfig, providerID string) (string, *core.UsageSnapshot)
- func ResolveBaseURL(acct core.AccountConfig, defaultURL string) string
- func SanitizeWorkspace(cwd string) string
- func Truncate(s string, maxLen int) string
- func UnixAuto(ts int64) time.Time
- type HookUsage
- type TelemetryChannel
- type TelemetryCollectOptions
- type TelemetryEvent
- type TelemetryEventType
- type TelemetrySource
- type TelemetryStatus
Constants ¶
This section is empty.
Variables ¶
var CodeStatsCompactLabels = map[string]string{
"composer_lines_added": "added",
"composer_lines_removed": "removed",
"composer_files_changed": "files",
"scored_commits": "commits",
"total_prompts": "prompts",
"ai_code_percentage": "ai %",
}
CodeStatsCompactLabels are compact (tile pill) labels for code stats metrics.
var CodeStatsMetricLabels = map[string]string{
"composer_lines_added": "Lines Added",
"composer_lines_removed": "Lines Removed",
"composer_files_changed": "Files Changed",
"scored_commits": "Commits",
"total_prompts": "Prompts",
"ai_code_percentage": "AI Code",
}
CodeStatsMetricLabels are display labels shared across coding-tool providers.
var ErrHookUnsupported = errors.New("hook parsing not supported")
var FirstNonEmpty = core.FirstNonEmpty
FirstNonEmpty delegates to core.FirstNonEmpty for backwards compatibility.
var Float64Ptr = core.Float64Ptr
Float64Ptr delegates to core.Float64Ptr for backwards compatibility.
Functions ¶
func ApplyStandardRateLimits ¶
func ApplyStandardRateLimits(resp *http.Response, snap *core.UsageSnapshot)
func CodingToolHidePrefixes ¶ added in v0.5.8
func CodingToolHidePrefixes() []string
CodingToolHidePrefixes returns the set of metric prefixes hidden by most coding-tool providers.
func CodingToolSectionOrder ¶ added in v0.5.8
func CodingToolSectionOrder() []core.DashboardStandardSection
CodingToolSectionOrder returns the standard section order used by coding-tool providers.
func CreateStandardRequest ¶
func DefaultCodeStatsConfig ¶ added in v0.5.8
func DefaultCodeStatsConfig() core.CodeStatsConfig
DefaultCodeStatsConfig returns the standard CodeStatsConfig used by coding-tool providers.
func ExpandHome ¶
func ExtractFilePathsFromPayload ¶ added in v0.6.3
ExtractFilePathsFromPayload walks a JSON-like structure and extracts file path candidates from values stored under path-related keys. This is used by telemetry adapters to extract tool target file paths for language inference.
func FinalizeStatus ¶
func FinalizeStatus(snap *core.UsageSnapshot)
func FirstPathNumber ¶ added in v0.6.7
FirstPathNumber tries multiple JSON paths and returns the first numeric value found (supports float64, float32, int, int64, int32, json.Number, string).
func FirstPathString ¶ added in v0.6.7
FirstPathString tries multiple JSON paths and returns the first non-empty string value found (supports string and json.Number types).
func FlexParseTime ¶
func FormatTokenCount ¶ added in v0.6.3
FormatTokenCount returns a human-readable string for a token count (e.g. "1.5K", "2.3M", "1.0B").
func FormatTokenCountF ¶ added in v0.6.3
FormatTokenCountF is like FormatTokenCount but takes a float64.
func HasHookUsage ¶ added in v0.6.7
HasHookUsage returns true if the usage contains any non-zero token or cost data.
func NumberFromAny ¶ added in v0.6.7
NumberFromAny converts various numeric types to float64.
func NumberToFloat64Ptr ¶ added in v0.6.7
NumberToFloat64Ptr returns nil for nil input, otherwise a copy of the value.
func NumberToInt64Ptr ¶ added in v0.6.7
NumberToInt64Ptr converts *float64 to *int64, returning nil for nil input.
func ParseFlexibleTimestamp ¶
func PathValue ¶ added in v0.6.7
PathValue traverses a nested map[string]any by the given path segments, returning the value at the final key or (nil, false) if any step is missing.
func ProbeRateLimits ¶ added in v0.6.7
ProbeRateLimits performs a GET request to the given URL with Bearer auth, copies redacted headers to snap.Raw, applies standard status code handling (401/403 → StatusAuth, 429 → StatusLimited), and parses standard RPM/TPM rate-limit headers. This replaces the identical fetchRateLimits pattern used across deepseek, xai, and similar providers.
func ProcessStandardResponse ¶
func ProcessStandardResponse(resp *http.Response, acct core.AccountConfig, providerID string) (core.UsageSnapshot, error)
func RequireAPIKey ¶
func RequireAPIKey(acct core.AccountConfig, providerID string) (string, *core.UsageSnapshot)
func ResolveBaseURL ¶
func ResolveBaseURL(acct core.AccountConfig, defaultURL string) string
func SanitizeWorkspace ¶
Types ¶
type HookUsage ¶ added in v0.6.7
type HookUsage struct {
InputTokens *int64
OutputTokens *int64
ReasoningTokens *int64
CacheReadTokens *int64
CacheWriteTokens *int64
TotalTokens *int64
CostUSD *float64
}
HookUsage holds token and cost data extracted from webhook/hook payloads. Used by claude_code, codex, and other telemetry providers.
func (*HookUsage) SumTotalTokens ¶ added in v0.6.7
func (u *HookUsage) SumTotalTokens()
SumTotalTokens computes TotalTokens from parts if it's nil.
type TelemetryChannel ¶
type TelemetryChannel string
const ( TelemetryChannelHook TelemetryChannel = "hook" TelemetryChannelSSE TelemetryChannel = "sse" TelemetryChannelJSONL TelemetryChannel = "jsonl" TelemetryChannelAPI TelemetryChannel = "api" TelemetryChannelSQLite TelemetryChannel = "sqlite" )
type TelemetryCollectOptions ¶
type TelemetryEvent ¶
type TelemetryEvent struct {
SchemaVersion string
Channel TelemetryChannel
OccurredAt time.Time
AccountID string
WorkspaceID string
SessionID string
TurnID string
MessageID string
ToolCallID string
ProviderID string
AgentName string
EventType TelemetryEventType
ModelRaw string
InputTokens *int64
OutputTokens *int64
ReasoningTokens *int64
CacheReadTokens *int64
CacheWriteTokens *int64
TotalTokens *int64
CostUSD *float64
Requests *int64
ToolName string
Status TelemetryStatus
Payload map[string]any
}
type TelemetryEventType ¶
type TelemetryEventType string
const ( TelemetryEventTypeTurnCompleted TelemetryEventType = "turn_completed" TelemetryEventTypeMessageUsage TelemetryEventType = "message_usage" TelemetryEventTypeToolUsage TelemetryEventType = "tool_usage" TelemetryEventTypeRawEnvelope TelemetryEventType = "raw_envelope" )
type TelemetrySource ¶
type TelemetrySource interface {
System() string
Collect(ctx context.Context, opts TelemetryCollectOptions) ([]TelemetryEvent, error)
ParseHookPayload(raw []byte, opts TelemetryCollectOptions) ([]TelemetryEvent, error)
}
type TelemetryStatus ¶
type TelemetryStatus string
const ( TelemetryStatusOK TelemetryStatus = "ok" TelemetryStatusError TelemetryStatus = "error" TelemetryStatusAborted TelemetryStatus = "aborted" TelemetryStatusUnknown TelemetryStatus = "unknown" )