Documentation
¶
Overview ¶
Package agentactivity classifies live agent terminal observations without depending on tmux, Bubble Tea, or persistent conversation storage.
Where the rules live ¶
Not here. Every provider is classified by Herdr's vendored detection manifest for it, executed by internal/agentactivity/manifest; anything Sidecar knows that upstream does not is a data overlay under manifests/sidecar/. This package owns what surrounds that: a stricter-than-Herdr process gate per provider, the identity resolver, the two evidence strings no manifest can produce, the low-evidence fallback policy, and Tracker, which turns a stream of verdicts into transitions. See docs/reference/herdr-detection-parity.md.
Spinner glyph sets are provider-owned, and are upstream's problem now ¶
The rule tables that used to live here shared this failure mode, and it is worth remembering because it is what the cutover bought. A spinner set that is too narrow does not merely miss activity, it inverts the verdict: Claude shared one eleven-glyph braille pattern with Codex, 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 Tracker turned that working→idle transition into a completed turn. Sessions reported "done" with work in flight. Claude Code 2.1.228 then switched to half-circle frames (U+25D0–U+25D3), which Sidecar's hand-written pattern never learned and upstream's `osc_title_working` already covered.
If a spinner is missed today, the fix is a fixture and either an overlay rule or a pull request to Herdr — never a regex added back into this package.
Index ¶
- Constants
- func ExplainManifest(ob Observation) *manifest.Explain
- func ExplainVendoredManifest(agentID string, ob Observation) (*manifest.Explain, bool)
- func ForegroundShellReady(panePID int, currentCommand string) bool
- func HasProcessIdentity() bool
- func HasVendoredManifest(agentID string) bool
- func HerdrAgentLabel(agent string) string
- func Identify(ob Observation) string
- func ManifestAgentID(agent string) string
- func NeedsProcessIdentity(command string) bool
- func ResolveForegroundAgent(panePID int) string
- func ResolveForegroundProcess(panePID int) string
- func Supports(agent string) bool
- type Observation
- 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 DetectManifest(ob Observation) (Result, *manifest.Explain)
- func DetectManifestResult(ob Observation) Result
- func DetectMuse(ob Observation) Result
- func DetectOpenCode(ob Observation) Result
- func DetectPi(ob Observation) Result
- 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 ExplainManifest ¶ added in v1.12.0
func ExplainManifest(ob Observation) *manifest.Explain
ExplainManifest is DetectManifest for a caller that only wants the record, such as `sidecar agent explain --file`.
func ExplainVendoredManifest ¶ added in v1.12.0
func ExplainVendoredManifest(agentID string, ob Observation) (*manifest.Explain, bool)
ExplainVendoredManifest evaluates a screen against the vendored manifest for a Herdr agent id, with no provider gate and no Result.
It exists for the agents Sidecar vendors a manifest for and does not claim as providers. Since Phase 4 registered the ten detection-only families that is `gemini` alone (Decision 4 of the plan), but the reason it was written has not gone away, and it is why the entry point stays: when it was added, `kiro` and `qodercli` were outside Supports and carried two of the four `\p{Alphabetic}` overlay rewrites between them, so those rewrites had no fixture, no census row and no differential-harness row, and a dead rule in either file would have gone on being dead until someone read the TOML. Both are providers now and reach the live path, but the next agent synced in and not yet registered will be in exactly the position they were, and `sidecar agent explain --file` is what covers it. It is a debugging surface for a manifest rather than a verdict for a pane, so refusing an id the binary carries the bytes for was an arbitrary limit.
It is deliberately not a second Detect: there is no Sidecar provider here, so there is no process gate to apply, no evidence string to mint and no fallback policy to choose. A caller that wants a verdict wants Detect and a supported agent. The bool reports whether a manifest for the id exists at all.
func ForegroundShellReady ¶ added in v1.11.0
ForegroundShellReady is the strict launch gate for a managed tmux pane. It accepts only the pane shell's own process group with exactly one member, and that member must resolve to a known interactive shell. Unknown helpers are busy, not ignorable.
func HasProcessIdentity ¶ added in v1.11.0
func HasProcessIdentity() bool
HasProcessIdentity reports whether this platform can disambiguate a pane's foreground job by argv[0].
It exists so the answer is read from the build rather than restated as a GOOS list somewhere else — the host protocol's hello carries this bit, and a second copy of "which platforms are implemented" would be wrong the moment a third one is added.
func HasVendoredManifest ¶ added in v1.12.0
HasVendoredManifest reports whether a Herdr agent id has a vendored manifest that compiles, whether or not Sidecar claims it as a provider.
func HerdrAgentLabel ¶ added in v1.12.0
HerdrAgentLabel maps a Sidecar provider family to Herdr's *label* for it — the string `agent_label` returns (src/detect/mod.rs:121 at e2b85c7), which is what `herdr agent explain --agent` takes, what keys its alias table, and what names Herdr's own local override file.
It does not name Sidecar's: a local override under ~/.config/sidecar/agent-detection is named after the vendored manifest file it replaces (manifests.OverridePath), so `agy` is Herdr's override name and `antigravity.toml` is Sidecar's. This label is for talking to Herdr.
It is a second, different mapping from ManifestAgentID, and the difference is not tidy: Herdr's Antigravity manifest lives in antigravity.toml but its label is "agy", and its Copilot manifest lives in github-copilot.toml but its label is "copilot". Conflating the two silently reads the wrong file for one of the two providers, so both mappings are spelled out rather than derived.
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 ManifestAgentID ¶ added in v1.12.0
ManifestAgentID maps a Sidecar provider family to the Herdr agent id whose manifest classifies it.
One mapping is not the identity: Sidecar's family is `copilot` and Herdr's manifest is `github-copilot.toml`. Everything else Sidecar claims shares Herdr's spelling, including `antigravity` (whose *manifest id* is "agy" while its file is antigravity.toml — the file name is what the loader keys on). Keeping the whole mapping in one function is what stops a second, subtly different copy appearing next to a new call site.
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.
func ResolveForegroundProcess ¶ added in v1.11.0
ResolveForegroundProcess identifies the known program in the pane's actual foreground process group, including "shell" when the group belongs to an interactive shell. Unlike pane_current_command, this is process ownership evidence and is therefore safe for agent-control's shell-ready gate.
func Supports ¶ added in v0.94.0
Supports reports whether Sidecar has provider-owned activity evidence rules.
Since Phase 4 it answers true for twenty agents, not ten: the launchable ten, and the ten detection-only families below. What the second group has is exactly what the first group has for detection purposes — a vendored Herdr manifest and a process gate — and nothing else, which is the point. Supports is a statement about the screen lane, not about launch, resume, or a conversation adapter; agentcatalog.Families and agentcatalog.DetectionOnly are what answer those.
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
// PaneHeight is the pane's own row count (tmux #{pane_height}). It is the
// manifest engine's read window: Herdr reads the tail of the buffer N rows
// deep where N is the pane's height, so a capture carrying scrollback has to
// be bounded to the same N or a resolved historical prompt wins a rule it
// should never have seen. Zero means the height was not available and the
// engine falls back to 24, Herdr's own DEFAULT_DETECTION_ROWS. See
// docs/reference/herdr-detection-parity.md ("Read window").
PaneHeight int
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 vendored Herdr manifest for its provider. Keeping dispatch here lets the workspace poll remain product-neutral while each provider file owns only its process gate.
There is one lane. Every provider Sidecar claims was cut over in Phase 2 of docs/plans/active/herdr-detection-parity.md, so the Go rule tables, the selector that used to choose between the two lanes, and the shadow mode that compared them are all gone. What is left of each `<provider>.go` is the process gate, plus an identity pattern for cursor and grok; Claude's and Codex's identity patterns sit beside Identify above, because that is the only thing that reads them.
func DetectAmp ¶
func DetectAmp(ob Observation) Result
DetectAmp classifies an Amp pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's.
func DetectAntigravity ¶
func DetectAntigravity(ob Observation) Result
DetectAntigravity classifies an Antigravity pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's, plus the three overlay rules.
func DetectClaude ¶
func DetectClaude(ob Observation) Result
DetectClaude classifies a Claude Code pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's.
func DetectCodex ¶
func DetectCodex(ob Observation) Result
DetectCodex classifies a Codex pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's. tmux commonly reports "node" for the npm-installed Codex launcher, which is why the gate is a set rather than an equality.
func DetectCopilot ¶
func DetectCopilot(ob Observation) Result
DetectCopilot classifies a Copilot pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's.
func DetectCursor ¶
func DetectCursor(ob Observation) Result
DetectCursor classifies a Cursor pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's, plus the three overlay rules.
func DetectGrok ¶
func DetectGrok(ob Observation) Result
DetectGrok classifies a Grok pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's, plus the four overlay rules.
func DetectManifest ¶ added in v1.12.0
func DetectManifest(ob Observation) (Result, *manifest.Explain)
DetectManifest is DetectManifestResult with the explain record beside the verdict, for a caller that wants to show its reasoning: `sidecar agent explain`, the census, the differential harness.
The Explain is nil when the process gate refused or the manifest could not be loaded: there is nothing to explain about rules that were never evaluated.
func DetectManifestResult ¶ added in v1.12.0
func DetectManifestResult(ob Observation) Result
DetectManifestResult classifies an observation through the vendored Herdr manifest for its agent and returns the verdict alone.
This is the live path, and it is separate from DetectManifest for one reason: building an explain record costs an EvaluatedRule struct and a 240-character region preview per rule — around eighteen of each for Codex — and the poller runs every 200ms per visible pane and throws all of it away. Evaluate does the same work and allocates none of it.
func DetectMuse ¶ added in v1.12.0
func DetectMuse(ob Observation) Result
DetectMuse classifies a Muse pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's.
func DetectOpenCode ¶
func DetectOpenCode(ob Observation) Result
DetectOpenCode classifies an OpenCode pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's.
func DetectPi ¶
func DetectPi(ob Observation) Result
DetectPi classifies a Pi pane. The process gate runs first and refuses before any manifest is evaluated; everything after it is upstream's.
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 classification 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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package manifest implements Herdr's agent-detection manifest grammar in Go.
|
Package manifest implements Herdr's agent-detection manifest grammar in Go. |
|
Package manifests holds Sidecar's vendored copy of Herdr's agent-detection manifests, the lock that pins them, and the extracted alias and authority tables that go with them.
|
Package manifests holds Sidecar's vendored copy of Herdr's agent-detection manifests, the lock that pins them, and the extracted alias and authority tables that go with them. |