shared

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

View Source
var ErrHookUnsupported = errors.New("hook parsing not supported")

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 CollectFilesByExt

func CollectFilesByExt(roots []string, exts map[string]bool) []string

func CreateStandardRequest

func CreateStandardRequest(ctx context.Context, baseURL, endpoint, apiKey string, headers map[string]string) (*http.Request, error)

func DefaultCodeStatsConfig added in v0.5.8

func DefaultCodeStatsConfig() core.CodeStatsConfig

DefaultCodeStatsConfig returns the standard CodeStatsConfig used by coding-tool providers.

func ExpandHome

func ExpandHome(path string) string

func FinalizeStatus

func FinalizeStatus(snap *core.UsageSnapshot)

func FirstNonEmpty

func FirstNonEmpty(values ...string) string

func FlexParseTime

func FlexParseTime(value string) time.Time

func Float64Ptr

func Float64Ptr(v float64) *float64

func Int64Ptr

func Int64Ptr(v int64) *int64

func ParseFlexibleTimestamp

func ParseFlexibleTimestamp(value string) (int64, bool)

func ParseTimestampString

func ParseTimestampString(value string) (time.Time, error)

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

func SanitizeWorkspace(cwd string) string

func UnixAuto

func UnixAuto(ts int64) time.Time

Types

type TelemetryChannel

type TelemetryChannel string
const (
	TelemetryChannelHook   TelemetryChannel = "hook"
	TelemetryChannelSSE    TelemetryChannel = "sse"
	TelemetryChannelJSONL  TelemetryChannel = "jsonl"
	TelemetryChannelAPI    TelemetryChannel = "api"
	TelemetryChannelSQLite TelemetryChannel = "sqlite"
)

type TelemetryCollectOptions

type TelemetryCollectOptions struct {
	Paths     map[string]string
	PathLists map[string][]string
}

func (TelemetryCollectOptions) Path

func (o TelemetryCollectOptions) Path(key string, fallback string) string

func (TelemetryCollectOptions) PathsFor

func (o TelemetryCollectOptions) PathsFor(key string, fallback []string) []string

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"
)

Jump to

Keyboard shortcuts

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