Documentation
¶
Overview ¶
Package agentctl is what start, drive, finish and forward ask of whatever hosts a task's agent. Herdr is the first backend; a backend owns its own layout (panes, sessions), so none of it shows here.
Index ¶
- Constants
- Variables
- func AgentName(id, suffix, path string) string
- func BareAgentName(id, suffix string) string
- func KindNames() []string
- type Backend
- type Kind
- type Occupancy
- type Opened
- type Profile
- func (p Profile) Args() []string
- func (p Profile) IsDefault() bool
- func (p Profile) Over(under Profile) Profile
- func (p Profile) PromptArgs(text string) ([]string, bool)
- func (p Profile) Resolve() (Profile, string, bool)
- func (p Profile) Short() string
- func (p Profile) String() string
- func (p Profile) Tool() (string, string)
- type Status
- type Workspace
Constants ¶
const DefaultKind = "claude"
DefaultKind is the kind a profile has when no layer names one.
Variables ¶
var ErrAgentNotFound = errors.New("agent not found")
ErrAgentNotFound matches, under errors.Is, a backend's answer that no live agent goes by that name.
var Kinds = map[string]Kind{ DefaultKind: { Efforts: []string{"low", "medium", "high", "xhigh", "max"}, // contains filtered or unexported fields }, }
Kinds is every backend kind a profile may name.
Functions ¶
func AgentName ¶
AgentName cuts the bare name to leave room for a short hash of the worktree path: Herdr's live agent names share one namespace across every project, capped at 32 characters, and the same id in two checkouts must not collide.
func BareAgentName ¶
BareAgentName takes the suffix so two attempts on one task can both run; an agent started before names carried the path hash still answers to it.
Types ¶
type Backend ¶
type Backend interface {
// Name names the backend in messages.
Name() string
// Available is nil when this process can reach the backend, else the
// refusal to print.
Available() error
// Workspaces lists every workspace the backend shows.
Workspaces(ctx context.Context) ([]Workspace, error)
// Open opens a workspace labelled label on the checkout at path, or
// adopts one already showing it; notes name what it left alone.
Open(ctx context.Context, path, label string) (Opened, []string, error)
// Occupancy says what holds ws's agent slot.
Occupancy(ctx context.Context, ws Opened) (Occupancy, error)
// StartAgent launches an agent of kind under name in ws's slot, with
// args on its command line. While it waits for the slot, waiting (when
// not nil) hears how long it has waited and the most it will.
StartAgent(
ctx context.Context,
ws Opened,
name, kind string,
args []string,
waiting func(waited, limit time.Duration),
) error
// Prompt submits text to the named agent and returns once submitted.
Prompt(ctx context.Context, name, text string) error
// Screen is the named agent's visible screen as text.
Screen(ctx context.Context, name string) (string, error)
// SendEnter presses Enter alone in the named agent's terminal.
SendEnter(ctx context.Context, name string) error
// Focus brings the workspace to the front.
Focus(ctx context.Context, id string) error
// Close closes the workspace and whatever agent ran in it.
Close(ctx context.Context, id string) error
}
A Backend hosts task agents. Every method answers from the directory the backend was made for.
type Kind ¶ added in v0.48.0
type Kind struct {
Efforts []string
// contains filtered or unexported fields
}
A Kind is one agent backend's vocabulary: the models it takes, the effort words it knows, how a profile goes on its command line and how the same profile is handed to a subagent through the Agent tool.
type Opened ¶
type Opened struct {
ID string
Slot string
AlreadyOpen bool // the backend was showing this checkout before the call
}
Opened is the workspace a checkout was opened or adopted in, and the slot its agent runs in: an id only the backend reads (Herdr: a pane).
type Profile ¶ added in v0.48.0
A Profile is what one step's agent runs on, `claude:opus:high`. An empty segment is left to the layer below; one still empty when the agent starts is the kind's own default, no flag passed.
func ParseProfile ¶ added in v0.48.0
ParseProfile reads raw as typed: `kind:model:effort`, `model:effort`, or one segment, a model unless it is exactly one of the kind's effort words. The kind is checked against Kinds and the effort against that kind; the model stays as typed, since resolving it is the kind's (Resolve). An empty profile parses to the zero Profile: nothing chosen.
func ParseRecorded ¶ added in v0.48.0
ParseRecorded reads a profile String wrote back, every segment as it was; a bare model from before profiles (the old branch record) reads as a model-only profile.
func (Profile) Args ¶ added in v0.48.0
Args is the command line p puts on the agent's start, through its kind.
func (Profile) IsDefault ¶ added in v0.48.0
IsDefault reports a profile that passes nothing: the kind's own default.
func (Profile) Over ¶ added in v0.48.0
Over is p laid over under: each segment p names wins, the rest is under's. The result's kind is named, the default when neither names one.
func (Profile) PromptArgs ¶ added in v0.55.0
PromptArgs is text as a first prompt on p's command line, false when the kind takes none or text holds a control character, which herdr refuses in an argument: the caller then types it.
func (Profile) Resolve ¶ added in v0.48.0
Resolve reads p's model through its kind: the profile with the model as the kind takes it, a note when that differs from what was typed, and false when the model names none the kind knows, in which case the model is dropped so the kind's default runs instead. An empty model resolves to itself.
func (Profile) Short ¶ added in v0.48.0
Short is the profile as a person types it: a default kind and empty segments dropped, `opus:high`, `opus`, `high`; "" for the default.