statusline

package
v1.261029.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MPL-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Name string `json:"name" example:"claude-opus-4-6"`
}

Agent represents agent information

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache() *Cache

func (*Cache) Get

func (c *Cache) Get(input *StatusInput) *StatusInput

func (*Cache) Update

func (c *Cache) Update(input *StatusInput)

type CombinedStatus

type CombinedStatus struct {
	Success bool                `json:"success"`
	Data    *CombinedStatusData `json:"data"`
}

CombinedStatus represents combined status from Claude Code and Tingly Box

type CombinedStatusData

type CombinedStatusData struct {
	// Claude Code info
	CCModel             string  `json:"cc_model" example:"Claude Sonnet 4.6"`
	CCUsedPct           int     `json:"cc_used_pct" example:"7"`
	CCUsedTokens        int     `json:"cc_used_tokens" example:"15000"`
	CCMaxTokens         int     `json:"cc_max_tokens" example:"200000"`
	CCCost              float64 `json:"cc_cost" example:"0.05"`
	CCDurationMs        int64   `json:"cc_duration_ms" example:"120000"`
	CCAPIDurationMs     int64   `json:"cc_api_duration_ms" example:"30000"`
	CCLinesAdded        int     `json:"cc_lines_added" example:"150"`
	CCLinesRemoved      int     `json:"cc_lines_removed" example:"50"`
	CCSessionID         string  `json:"cc_session_id" example:"session-123"`
	CCExceeds200kTokens bool    `json:"cc_exceeds_200k_tokens"`
	CCCacheReadTokens   int     `json:"cc_cache_read_tokens,omitempty" example:"10000"`
	CCCacheWriteTokens  int     `json:"cc_cache_write_tokens,omitempty" example:"2000"`
	CCCacheHitPct       int     `json:"cc_cache_hit_pct,omitempty" example:"87"`
	// Tingly Box model mapping info
	TBProviderName string `json:"tb_provider_name,omitempty" example:"openai"`
	TBProviderUUID string `json:"tb_provider_uuid,omitempty" example:"uuid-1234"`
	TBModel        string `json:"tb_model,omitempty" example:"gpt-4"`
	TBRequestModel string `json:"tb_request_model,omitempty" example:"gpt-4"`
	TBScenario     string `json:"tb_scenario,omitempty" example:"openai"`
	// Provider quota information
	TBQuotaAvailable bool   `json:"tb_quota_available" example:"true"`                           // Whether quota is available
	TBQuotaUsed      int    `json:"tb_quota_used,omitempty" example:"40000"`                     // Quota used
	TBQuotaLimit     int    `json:"tb_quota_limit,omitempty" example:"100000"`                   // Quota limit
	TBQuotaPercent   int    `json:"tb_quota_percent,omitempty" example:"40"`                     // Quota percentage
	TBQuotaWindow    string `json:"tb_quota_window,omitempty" example:"daily"`                   // Window type
	TBQuotaUnit      string `json:"tb_quota_unit,omitempty" example:"tokens"`                    // Unit
	TBQuotaResetsAt  string `json:"tb_quota_resets_at,omitempty" example:"2026-04-03T00:00:00Z"` // ISO 8601 reset time
}

CombinedStatusData represents the combined status data

type ContextWindow

type ContextWindow struct {
	TotalInputTokens    int          `json:"total_input_tokens" example:"15000"`
	TotalOutputTokens   int          `json:"total_output_tokens" example:"5000"`
	ContextWindowSize   int          `json:"context_window_size" example:"200000"`
	UsedPercentage      float64      `json:"used_percentage" example:"7.5"`
	RemainingPercentage float64      `json:"remaining_percentage" example:"92.5"`
	CurrentUsage        CurrentUsage `json:"current_usage"`
}

ContextWindow represents context window information

type Cost

type Cost struct {
	TotalCostUSD       float64 `json:"total_cost_usd" example:"0.05"`
	TotalDurationMs    int64   `json:"total_duration_ms" example:"120000"`
	TotalAPIDurationMs int64   `json:"total_api_duration_ms" example:"30000"`
	TotalLinesAdded    int     `json:"total_lines_added" example:"150"`
	TotalLinesRemoved  int     `json:"total_lines_removed" example:"50"`
}

Cost represents cost information

type CurrentUsage

type CurrentUsage struct {
	InputTokens  int `json:"input_tokens" example:"1500"`
	OutputTokens int `json:"output_tokens" example:"500"`
	CacheRead    int `json:"cache_read_input_tokens" example:"10000"`
	CacheWrite   int `json:"cache_creation_input_tokens" example:"2000"`
}

CurrentUsage represents token counts from the last API call

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles Claude Code status HTTP requests

func NewHandler

func NewHandler(cfg *config.Config, lb LoadBalancer, cache *Cache, quotaMgr QuotaManager) *Handler

NewHandler creates a new Claude Code handler

func (*Handler) GetClaudeCodeStatus

func (h *Handler) GetClaudeCodeStatus(c *gin.Context)

GetClaudeCodeStatus returns combined status from Claude Code input and Tingly Box This endpoint receives Claude Code status JSON and combines it with Tingly Box model mapping POST /tingly/:scenario/status

func (*Handler) GetClaudeCodeStatusLine

func (h *Handler) GetClaudeCodeStatusLine(c *gin.Context)

GetClaudeCodeStatusLine returns rendered status line text for Claude Code This endpoint receives Claude Code status JSON and returns a pre-rendered status line string POST /tingly/:scenario/statusline ref: https://code.claude.com/docs/en/statusline

func (*Handler) PreviewRoute added in v1.261001.1

func (h *Handler) PreviewRoute(scenario, modelID string) *Route

PreviewRoute is ResolveRoute without the quota lookup, for listing several routes at once. It returns nil when no rule matches the model.

func (*Handler) RegisterRoutes added in v1.261002.1

func (h *Handler) RegisterRoutes(rt *module.Routes)

RegisterRoutes registers Claude Code status routes

func (*Handler) ResolveRoute added in v1.261001.1

func (h *Handler) ResolveRoute(ctx context.Context, scenario, modelID string) *Route

ResolveRoute resolves the route the way the terminal status line does. It returns nil when no rule matches the model in the scenario.

type LoadBalancer

type LoadBalancer interface {
	PreviewService(rule *typ.Rule) (*loadbalance.Service, error)
}

LoadBalancer interface defines the load balancer operations we need. The status line only displays the pick, never dispatches to it, so it uses the side-effect-free PreviewService: SelectService would claim a half-open breaker's probe slot on every status poll.

type Model

type Model struct {
	ID           string `json:"id" example:"claude-sonnet-4-6"`
	DisplayName  string `json:"display_name" example:"Claude Sonnet 4.6"`
	ProviderName string `json:"provider_name" example:"anthropic"`
}

Model represents model information from Claude Code

type OutputStyle

type OutputStyle struct {
	Name string `json:"name" example:"default"`
}

OutputStyle represents output style information

type QuotaManager added in v0.260409.1540

type QuotaManager interface {
	GetQuota(ctx context.Context, providerUUID string) (*quota.ProviderUsage, error)
}

QuotaManager defines the quota manager interface

type QuotaSegment added in v1.261001.1

type QuotaSegment struct {
	Type    string // window type: session, daily, weekly, balance, ...
	Balance bool   // a balance ("$12.40"), not a used/limit window
	// Text is the rendered value, the same string the terminal status line
	// prints: "60% left", "12K/100K left", "$12.40".
	Text         string
	UsedPercent  float64
	ResetsAt     *time.Time
	LimitReached bool
}

QuotaSegment is one quota window as the status line shows it.

func QuotaSegments added in v1.261001.1

func QuotaSegments(usage *quota.ProviderUsage) []QuotaSegment

QuotaSegments lists a provider's windows that have something to show, in the provider's order. The terminal status line and a folder session's line both render from this, so the two never disagree.

type Route added in v1.261001.1

type Route struct {
	ProviderName string
	Model        string
	Quota        []QuotaSegment
}

Route is where a request for a model is routed in a scenario, and the quota of the provider it lands on: the tingly-box half of the status line.

type StatusInput

type StatusInput struct {
	Model         Model         `json:"model"`
	CWD           string        `json:"cwd"`
	Workspace     Workspace     `json:"workspace"`
	Cost          Cost          `json:"cost"`
	ContextWindow ContextWindow `json:"context_window"`
	// Additional fields
	Exceeds200kTokens bool        `json:"exceeds_200k_tokens"`
	SessionID         string      `json:"session_id"`
	SessionName       string      `json:"session_name"` // human-readable session title; resumeable via `claude --resume <title>`
	TranscriptPath    string      `json:"transcript_path"`
	Version           string      `json:"version"`
	OutputStyle       OutputStyle `json:"output_style"`
	Vim               Vim         `json:"vim"`
	Agent             Agent       `json:"agent"`
	Worktree          Worktree    `json:"worktree"` // present only in a Claude Code worktree session
}

StatusInput represents the input from Claude Code status line Ref: https://code.claude.com/docs/en/statusline.md

type Vim

type Vim struct {
	Mode string `json:"mode" example:"NORMAL"`
}

Vim represents vim mode information

type Workspace

type Workspace struct {
	CurrentDir string `json:"current_dir" example:"/Users/user/project"`
	ProjectDir string `json:"project_dir" example:"/Users/user/project"`
}

Workspace represents workspace information

type Worktree added in v1.261001.1

type Worktree struct {
	Name   string `json:"name" example:"my-feature"`
	Path   string `json:"path" example:"/path/to/.claude/worktrees/my-feature"`
	Branch string `json:"branch" example:"worktree-my-feature"`
}

Worktree represents an active Claude Code worktree session

Jump to

Keyboard shortcuts

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