Documentation
¶
Overview ¶
Package agentactivity classifies live agent terminal observations without depending on tmux, Bubble Tea, or persistent conversation storage.
Spinner glyph sets are provider-owned ¶
Every provider file declares its own spinner pattern, even where two of them would look identical today. Sharing one is a standing bug: the sets are not the same and they drift independently as each CLI ships. Codex animates the classic ten braille dots frames; Claude, Grok and Cursor cycle the whole Braille block (U+2800–U+28FF).
A set that is too narrow does not merely miss activity, it inverts the verdict. Claude shares one shared eleven-glyph pattern with Codex until this was fixed, so the frames outside that set left the title rule unmatched; evaluation fell through to the prompt-box idle rule while subagents were still running, and the tracker turned that working→idle transition into a completed turn. Sessions reported "done" with work in flight.
When adding or revising a provider, harvest the real frames rather than assuming a set, and prefer anchoring the pattern to where the glyph actually appears — braille elsewhere in a title or task name is not a spinner.
Index ¶
- Constants
- func Identify(ob Observation) string
- func NeedsProcessIdentity(command string) bool
- func ResolveForegroundAgent(panePID int) string
- func Supports(agent string) bool
- type Observation
- type Region
- type Result
- func Detect(ob Observation) Result
- func DetectAmp(ob Observation) Result
- func DetectAntigravity(ob Observation) Result
- func DetectClaude(ob Observation) Result
- func DetectCodex(ob Observation) Result
- func DetectCopilot(ob Observation) Result
- func DetectCursor(ob Observation) Result
- func DetectGrok(ob Observation) Result
- func DetectOpenCode(ob Observation) Result
- func DetectPi(ob Observation) Result
- func Evaluate(ob Observation, rules []Rule) Result
- type Rule
- type Snapshot
- type State
- type Tracker
Constants ¶
const IdleDebounce = 400 * time.Millisecond
const SkipRetentionCap = 2 * time.Minute
SkipRetentionCap bounds how long an overlay rule may retain the prior state. Retention exists so a transcript or model picker does not erase a live turn, but an overlay left open — or a rule matching chrome that never clears — would otherwise hold a confident badge forever. Past the cap the tracker admits it no longer knows rather than continuing to assert stale evidence.
Variables ¶
This section is empty.
Functions ¶
func Identify ¶ added in v0.94.0
func Identify(ob Observation) string
Identify returns the live program owning an agent pane when the existing tmux metadata or current UI makes that identity unambiguous. It deliberately returns an empty string for shared runtimes such as node and bun unless the current screen distinguishes the provider. Callers can retain their prior identity in that case without paying for a process-tree scan.
func NeedsProcessIdentity ¶ added in v1.9.0
NeedsProcessIdentity reports whether tmux's command name is shared by multiple agent CLIs and therefore benefits from foreground argv[0].
func ResolveForegroundAgent ¶ added in v1.9.0
ResolveForegroundAgent identifies a pane's foreground job without shelling out. The platform adapter supplies process-group argv[0] values; this shared layer resolves symlinks and maps only exact known executable names. Results are briefly cached by pane PID and foreground group so active-agent polling does not scan the process table on every frame, while a new foreground job invalidates the cache immediately.
Types ¶
type Observation ¶
type Observation struct {
Agent string
Screen string
PaneTitle string
CurrentCommand string
// ProcessIdentity is a provider name resolved from the pane's foreground
// process group and argv[0]. It disambiguates shared runtimes such as Node
// without promoting phrases from another agent's transcript.
ProcessIdentity string
CapturedAt time.Time
}
type Result ¶
type Result struct {
State State
Evidence string
VisibleIdle bool
VisibleWorking bool
VisibleBlocker bool
SkipStateUpdate bool
// FallbackIdle distinguishes provider-owned explicit idle evidence from the
// conservative no-match policy for a positively identified live process.
// Fallback idle may establish/display idle, but cannot announce completion.
FallbackIdle bool
}
func Detect ¶
func Detect(ob Observation) Result
Detect dispatches an observation to the expected provider probe. Keeping dispatch here lets the workspace poll remain product-neutral while each provider owns its evidence table.
func DetectAmp ¶
func DetectAmp(ob Observation) Result
func DetectAntigravity ¶
func DetectAntigravity(ob Observation) Result
func DetectClaude ¶
func DetectClaude(ob Observation) Result
func DetectCodex ¶
func DetectCodex(ob Observation) Result
DetectCodex requires live process identity before evaluating Codex-owned UI. tmux commonly reports "node" for the npm-installed Codex launcher.
func DetectCopilot ¶
func DetectCopilot(ob Observation) Result
func DetectCursor ¶
func DetectCursor(ob Observation) Result
func DetectGrok ¶
func DetectGrok(ob Observation) Result
func DetectOpenCode ¶
func DetectOpenCode(ob Observation) Result
func DetectPi ¶
func DetectPi(ob Observation) Result
func Evaluate ¶
func Evaluate(ob Observation, rules []Rule) Result
Evaluate applies rules in caller-supplied priority order. Rules are kept deliberately small: provider files own their evidence and ordering.
type Rule ¶
type Rule struct {
ID string
State State
Region Region
Contains []string
// Any holds alternative corroborating groups: the rule matches when at
// least one group has all of its literals present. It exists so a retain
// rule can demand a distinctive phrase *and* surrounding chrome, rather
// than firing on a word the agent might merely be discussing. Compared
// case-insensitively, since these are rendered UI hints.
Any [][]string
Regexp *regexp.Regexp
Not []string
LastN int
Skip bool
}
type Snapshot ¶ added in v0.96.0
type Snapshot struct {
State string `json:"state"`
Evidence string `json:"evidence,omitempty"`
ChangedAt time.Time `json:"changedAt"`
Seen bool `json:"seen"`
IdleInferred bool `json:"idleInferred,omitempty"`
}
Snapshot is the persistable projection of a tracker. It carries only the fields that survive a restart meaningfully: transition policy timers are in-process concerns and are deliberately dropped.
type Tracker ¶
type Tracker struct {
State State
Evidence string
ChangedAt time.Time
Seen bool
VisibleBlocker bool
// IdleInferred records that the current idle state came from the absence
// of activity rather than an explicit completion marker. Providers without
// a completion signal can never assert "done", and views use this to say so
// instead of letting their absence from the done lane read as a bug.
IdleInferred bool
// contains filtered or unexported fields
}
Tracker owns transition policy while Evaluate remains state-free.
func Restore ¶ added in v0.96.0
Restore rebuilds a tracker from persisted state. A restored idle keeps its original ChangedAt, so a turn that finished before the restart still reads as recently finished rather than as "just observed".
func (*Tracker) Acknowledge ¶
func (t *Tracker) Acknowledge()
func (Tracker) DisplayState ¶
func (*Tracker) ResetForProcessChange ¶ added in v0.94.0
ResetForProcessChange clears semantic state from the prior pane owner while allowing a confirmed new process's first explicit idle observation to land immediately. That first idle is initialization, not a completion event.