agentctl

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 9 Imported by: 0

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

View Source
const DefaultKind = "claude"

DefaultKind is the kind a profile has when no layer names one.

Variables

View Source
var ErrAgentNotFound = errors.New("agent not found")

ErrAgentNotFound matches, under errors.Is, a backend's answer that no live agent goes by that name.

View Source
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

func AgentName(id, suffix, path string) string

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

func BareAgentName(id, suffix string) string

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.

func KindNames added in v0.48.0

func KindNames() []string

KindNames lists the registered kinds for messages.

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
	// 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 Occupancy

type Occupancy int

An Occupancy is what holds a workspace's agent slot.

const (
	AgentPresent Occupancy = iota // an agent runs there, whatever its name
	Free                          // nothing runs there: an agent can start
	Busy                          // something other than an agent runs there
)

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

type Profile struct {
	Kind   string
	Model  string
	Effort string
}

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

func ParseProfile(raw string) (Profile, error)

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

func ParseRecorded(s string) Profile

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

func (p Profile) Args() []string

Args is the command line p puts on the agent's start, through its kind.

func (Profile) IsDefault added in v0.48.0

func (p Profile) IsDefault() bool

IsDefault reports a profile that passes nothing: the kind's own default.

func (Profile) Over added in v0.48.0

func (p Profile) Over(under Profile) Profile

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) Resolve added in v0.48.0

func (p Profile) Resolve() (Profile, string, bool)

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

func (p Profile) Short() string

Short is the profile as a person types it: a default kind and empty segments dropped, `opus:high`, `opus`, `high`; "" for the default.

func (Profile) String added in v0.48.0

func (p Profile) String() string

String is the profile in full, the kind always named: `claude:opus:high`, `claude::high` for an effort alone.

func (Profile) Tool added in v0.48.0

func (p Profile) Tool() (string, string)

Tool is p as the Agent tool takes it: the model's family and the effort word, either "" when the profile leaves it to the tool.

type Status

type Status string

A Status is a workspace's agent as the backend reports it; the constants are the values f10 acts on, and any other word passes through for a reader to show.

const (
	StatusWorking Status = "working"
	StatusIdle    Status = "idle"
	StatusDone    Status = "done" // idle since a turn nobody has looked at yet
)

type Workspace

type Workspace struct {
	ID      string
	Label   string
	Path    string
	Focused bool
	Status  Status
}

A Workspace is one as a listing reports it; Path is "" with no checkout.

Jump to

Keyboard shortcuts

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