agentresolve

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 4 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

Overview

Package agentresolve is the one place Sidecar turns an observation of a pane into that pane's effective agent activity.

Before this package there were three copies of the same four lines — project worktree polling, project managed-shell polling, and workspaceinventory each built an agentactivity.Observation and called agentactivity.Detect on it. Three copies was survivable while screen detection was the only evidence. It stops being survivable the moment a second kind of evidence exists, because then each copy has to decide which one wins, and three independent answers to that question is exactly the split-brain the M6 plan forbids.

So the rule is: every surface builds its own observation — they genuinely differ in how they capture a screen and what they know about a pane — and then they all call Resolve. No surface holds a private opinion about authority.

The nil source is the important case

A nil Source, or a source with nothing to say about this pane, produces exactly what agentactivity.Detect produced before this package existed: same result, same evidence string, same flags. That is not a convenience, it is the safety property that made this extraction possible to verify. The Phase A compatibility fixtures pin the old behavior and were not modified; they pass because the no-evidence path through here is the identity function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resolve

Resolve produces the effective activity result for one observation.

The screen detectors always run. Arbitration chooses between evidence; it never decides whether to gather it, because a pane whose integration turns out to be stale needs a screen answer already in hand rather than a second capture round-trip.

An empty ref is treated as "no lifecycle evidence" rather than as an error: an unidentifiable pane is exactly the case where screen detection is the only honest answer.

func ResolveTarget added in v1.16.0

func ResolveTarget(q TargetQuery, lookup TargetLookup) (agentcontrol.Target, error)

ResolveTarget turns a caller's query into a managed agent identity before agentcontrol pins its physical pane. CLI, API and UI callers use the same omitted-target refusal and explicit-target scoping rule.

func Result

Result is the common case: callers that only need the lane and not the diagnostic. It exists so the three call sites read as a one-line swap for the Detect call they replaced rather than growing a decision-unpacking dance.

Types

type Evidence

type Evidence struct {
	// Live is the pane and run identity as the source currently understands it.
	Live agentlifecycle.Identity
	// ProcessAlive reports whether the matching provider process is running.
	ProcessAlive bool

	// Capability and Status describe the installed integration.
	Capability agentlifecycle.Capability
	Status     agentlifecycle.IntegrationStatus
	// ProviderInTestedRange reports whether the detected provider version falls
	// inside the range the capability's tier was proved against.
	ProviderInTestedRange bool

	// Latest is the newest valid report for the pane, or nil.
	Latest *agentlifecycle.Report

	// StoreUnavailable and InvalidReports withdraw authority without claiming
	// anything about the pane.
	StoreUnavailable bool
	InvalidReports   bool
}

Evidence is everything a lifecycle source knows about one pane.

It is deliberately the resolver's input shape rather than a smaller one: the arbitration in agentlifecycle.Resolve needs identity, capability, status, liveness, and the latest report together, and assembling that in two places would be a second chance to assemble it differently.

type PaneRef

type PaneRef struct {
	// PaneID is the tmux "%7"-shaped identifier, when the caller knows it.
	PaneID string
	// Session is the tmux session name, which every caller knows.
	Session string

	// Identity is what the caller already knows about the pane's machine, tmux
	// server, and provider, used only to fill in the explanation when no
	// lifecycle evidence applies.
	//
	// It exists because that path previously reported an identity consisting of
	// a pane id and nothing else, so `agent explain` on a pane with no
	// integration printed an empty server field — which reads as "Sidecar could
	// not determine the server" rather than "there was no report to check one
	// against". A caller that has already paid for the answer can supply it; a
	// polling caller leaves it zero and gets exactly the previous behavior.
	//
	// It is never consulted when a source does supply evidence: arbitration
	// builds the live identity from what the source observed, and letting a
	// caller inject one there would make every identity check compare a value
	// with itself.
	Identity agentlifecycle.Identity
}

PaneRef names the pane an observation is about.

Two fields rather than one because the three call sites genuinely know different things and neither can be derived from the other for free. workspaceinventory already holds the tmux %pane id; the two project polling paths hold only the session name, and the capture format strings that would have to carry a pane id are asserted by terminal tests and sit on the hot path. Rather than widen those, the reference carries whichever is available and a Source resolves the rest — once, and cached, because the mapping only changes when a pane is split or closed.

func (PaneRef) Empty

func (p PaneRef) Empty() bool

Empty reports whether the reference names nothing usable.

type Source

type Source interface {
	// Evidence returns what is known about a pane. The bool reports whether
	// any lifecycle evidence applies at all; false means pure screen fallback
	// and the Evidence value is ignored.
	Evidence(ref PaneRef) (Evidence, bool)
}

Source supplies lifecycle evidence for a pane.

Implementations must be safe to call from a polling command and must not block: a slow source would stall a surface's refresh, and the correct answer when evidence cannot be fetched quickly is "no evidence", which degrades to ordinary screen detection.

type TargetLookup added in v1.16.0

type TargetLookup func(target, shell, project string, globalExplicit bool) (agentcontrol.Target, error)

TargetLookup resolves a value within the caller's authorized universe. The globalExplicit argument requests a search across registered projects. A lookup may retain a scan for one operation (for example, prompt's two lookups), but must not cache it for the lifetime of a server.

Adapters return agentcontrol.Error for semantic refusals. Other failures are wrapped as transport failures by ResolveTarget.

type TargetQuery added in v1.16.0

type TargetQuery struct {
	Target   string
	Shell    string
	Project  string
	Explicit bool
}

TargetQuery describes how a caller addresses a managed agent. Target is the supplied name, or the caller's own shell for an omitted target. Callers supply that context explicitly; resolution never reads the environment or the focused UI row.

Jump to

Keyboard shortcuts

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