Documentation
¶
Overview ¶
Package statusline defines the display-only, dependency-leaf protocol shared by mecatui composition and UI status-line renderers.
Index ¶
- Constants
- type Clock
- type Command
- type Context
- type ContextAtom
- type Delegation
- type DelegationStateCounts
- type DelegationSummary
- type Document
- type Input
- type LinkPalette
- type LiveTeam
- type MainAgent
- type Model
- type Palette
- type PassthroughEnvError
- type Result
- type ServerTarget
- type Session
- type Source
- type Span
- type Surface
- type SurfaceTemplates
- type TemplateSet
- type Terminal
- type Token
- type Usage
- type UsageAtom
- type Workspace
Constants ¶
const ( // ProtocolVersion is the current Input wire-independent contract version. ProtocolVersion uint8 = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
Clock is the raw source-owned time fact. A submitted value is preserved until the source refreshes it; templates and future commands observe the same value.
type Command ¶
type Command struct {
Path string
Args []string
// PassthroughEnv names additional parent environment variables explicitly
// allowed into the command's otherwise fixed environment.
PassthroughEnv []string
LaunchDir string
// RefreshInterval optionally refreshes an otherwise idle command. Values below
// one second are disabled; input changes still use the command debounce.
RefreshInterval time.Duration
}
Command is a validated local status command. Path is an absolute executable and Args are passed literally. LaunchDir remains private command-runner state and is never projected into Input.
func (Command) Valid ¶
Valid reports whether command specifies an absolute executable and literal args.
func (Command) ValidatePassthroughEnv ¶ added in v0.0.23
ValidatePassthroughEnv reports whether PassthroughEnv has valid names that do not override values owned by the status-command environment.
type Context ¶
type Context struct {
Used ContextAtom
Window ContextAtom
Percent int
}
Context describes current context-window consumption. Percent is Used.Raw as an integer percentage of Window.Raw, or zero when the window is unknown. The visual bar is renderer-owned because its glyphs and semantic style depend on the active theme and available surface width.
type ContextAtom ¶
ContextAtom carries an exact token count and its standard compact display notation. It is separate from UsageAtom to make the context-window contract explicit at call sites.
type Delegation ¶
type Delegation struct {
Total DelegationStateCounts
DirectSubagent DelegationStateCounts
TeamMember DelegationStateCounts
ParallelBranch DelegationStateCounts
Subagents DelegationSummary
Parallel DelegationSummary
Team LiveTeam
}
Delegation groups the uniform state counts by flat leaf unit. Total is the component-wise sum of direct subagent, team member, and parallel branch.
func (Delegation) Valid ¶
func (d Delegation) Valid() bool
Valid reports whether Total is exactly the sum of the leaf units.
type DelegationStateCounts ¶
type DelegationStateCounts struct {
Running int
AwaitingApproval int
Completed int
Failed int
Cancelled int
Stopped int
}
DelegationStateCounts classifies delegated leaf work into mutually exclusive terminal and live states.
type DelegationSummary ¶
DelegationSummary is the display-oriented running/finished projection of one leaf family. Finished deliberately collapses the detailed terminal states; raw DelegationStateCounts remains available for command handlers.
type Document ¶
type Document struct {
Header Surface
}
Document is a parsed StatusML document. Header and Footer are independently optional through their Present fields.
type Input ¶
type Input struct {
Version uint8
Server ServerTarget
Session Session
Model Model
Usage Usage
Context Context
Workspace Workspace
Terminal Terminal
MainAgent MainAgent
Delegation Delegation
Clock Clock
}
Input is the canonical, raw snapshot supplied to status handlers. It is intentionally a small allowlist: it carries display-safe session facts, never prompts, transcript/tool content, credentials, authentication metadata, diagnostics, or raw command output.
Commands receive this exact data as JSON. Template rendering receives a private, StatusML-escaped projection so template interpolation cannot create markup or terminal controls. The raw input remains available to commands for ordinary data use such as querying Git from Workspace.Path.
Renderer policy—clipping, safety/activity lanes, and context-bar glyph/style selection—does not belong here. Header and footer available widths are facts computed after those renderer reservations.
type LinkPalette ¶
LinkPalette is an optional theme extension for StatusML links. Render never emits OSC 8; consumers decide how to display the validated destination.
type LiveTeam ¶
LiveTeam is present only while a team is active. Completed teams intentionally disappear from the footer, unlike parallel and direct-subagent summaries.
type MainAgent ¶
MainAgent carries the main agent's display-safe activity. State is one of "connecting", "idle", "thinking", "running_tool", "awaiting_approval", "completed", "failed", or "cancelled". Activity is a bounded display label. Approval is "none" or "awaiting" and reflects whether a human verdict is pending.
type Model ¶
type Model struct {
ProviderID string
ID string
DisplayName string
Route string
ContextWindow ContextAtom
}
Model carries the provider-independent model facts selected for the session. ProviderID and ID are opaque routing identifiers; DisplayName is the operator- facing label. ContextWindow is the resolved model context capacity, not current session consumption.
type Palette ¶
Palette resolves a StatusML semantic token through the active theme. It returns descriptive style data, never terminal control sequences.
type PassthroughEnvError ¶ added in v0.0.23
type PassthroughEnvError struct {
ReservedName string
}
PassthroughEnvError reports an invalid passthrough environment name. ReservedName is empty when the value does not match the supported environment-name grammar.
func (*PassthroughEnvError) Error ¶ added in v0.0.23
func (e *PassthroughEnvError) Error() string
type Result ¶
type Result struct {
Header Surface
}
Result holds independently selected semantic surfaces. It never contains terminal rendering or control sequences.
type ServerTarget ¶
type ServerTarget struct {
// DisplayTarget is the credential-free connection target shown in chrome.
DisplayTarget string
ConnectionMode string
}
ServerTarget identifies the display target and connection mode, without any authentication or endpoint credential data. ConnectionMode is one of "embedded" (the local in-process server) or "connect" (an explicitly dialed server); an empty value means the mode is not yet known.
type Session ¶
Session carries optional user-facing session facts. Title is empty when no custom or generated title exists. Handle is the fixed, terminal-safe escaped session prefix used by ordinary mecatui presentation. Mode is the active permission mode. ReasoningEffort is either empty (unset or unsupported) or one of "low", "medium", "high", "xhigh", or "max".
type Source ¶
type Source interface {
Submit(Input)
Changed() <-chan struct{}
Latest() Result
Close(context.Context) error
}
Source produces the latest semantic status-line surfaces from raw display facts. It is UI-agnostic: Changed is a wake-up edge, never a queue.
func NewCommandSource ¶
NewCommandSource creates a local command-backed source. It passes complete raw Input JSON on stdin and never exposes command failures or captured output to the generated status line.
func NewDefaultSource ¶
NewDefaultSource creates the shipped source. It owns all default variants, including initial and partial-surface degradation.
func NewTemplateSource ¶
func NewTemplateSource(templates TemplateSet, interval time.Duration) Source
NewTemplateSource creates a template source whose missing surfaces and variants use the shipped defaults.
type Span ¶
Span is one terminal-safe text run resolved through a Palette. Href is a separately validated link destination and is never included in Text.
type Surface ¶
Surface is an optional header or footer. Present distinguishes an absent surface from a present empty one. The renderer determines alignment by surface: headers are left-aligned and footers are right-aligned.
type SurfaceTemplates ¶
type SurfaceTemplates struct{ Full, Compact, Minimal string }
SurfaceTemplates contains the three independently selected variants for one surface. Empty variants fall back to the corresponding shipped variant.
type Terminal ¶
Terminal provides measured dimensions and independently reserved columns for status surfaces. Cols is the full terminal width. HeaderAvailCols and FooterAvailCols are the widths remaining after the renderer reserves mandatory header safety/navigation and footer activity lanes, respectively.
type Token ¶
type Token string
Token is a closed semantic style vocabulary for StatusML text.
const ( TokenText Token = "text" TokenMuted Token = "muted" TokenPrimary Token = "primary" TokenSecondary Token = "secondary" TokenAccent Token = "accent" TokenSuccess Token = "success" TokenWarning Token = "warning" TokenError Token = "error" TokenInfo Token = "info" )
Token values are the only semantic styles StatusML accepts.
type Usage ¶
type Usage struct {
Input UsageAtom
Output UsageAtom
CacheRead UsageAtom
CacheWrite UsageAtom
CacheReadPercent int
}
Usage is the cumulative session usage summary. CacheRead is input served from the prompt cache (a subset of Input); CacheWrite is input written to the prompt cache. CacheReadPercent is the integer percentage CacheRead.Raw/Input.Raw, or zero when the input count is zero.
type UsageAtom ¶
UsageAtom carries an exact non-negative token count and the same count rendered with the standard compact display notation (for example, "1.1M"). Raw is for arithmetic or command handlers; Human is a display-ready atom.