agent

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckTmux

func CheckTmux() error

CheckTmux verifies tmux is installed and available on PATH.

func CurrentTmuxSessionName added in v0.6.1

func CurrentTmuxSessionName() string

CurrentTmuxSessionName returns the tmux session name for the current pane, or empty string when not running inside tmux or when it cannot be resolved.

func ProbeSession added in v0.4.0

func ProbeSession(sessionName string) (status string, active bool)

ProbeSession checks whether a tmux session exists and determines its status without instantiating a full Agent. Returns the status string and whether the session is active. This is used by the `canopy status --json` subcommand.

func SessionNameFor added in v0.4.0

func SessionNameFor(repoRoot, branch, worktreePath string) string

SessionNameFor derives a deterministic, tmux-safe session name. A repo-root hash prefix prevents collisions across repos with the same branch name. Exported for use by the status subcommand and nvim plugin.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

Agent manages an AI coding process via a dedicated tmux session.

func New

func New() *Agent

func (*Agent) Kill

func (a *Agent) Kill()

Kill terminates the tmux session and stops polling.

func (*Agent) Reconnect

func (a *Agent) Reconnect(workdir, branch, repoRoot, tmuxPrefix string) bool

Reconnect checks whether a tmux session for this worktree already exists (e.g. from a previous canopy instance) and resumes polling if so. Returns true if an existing session was found.

func (*Agent) Reset

func (a *Agent) Reset()

Reset clears state and kills any existing session.

func (*Agent) Send

func (a *Agent) Send(text string)

Send writes text to the agent's tmux session as literal keystrokes.

func (*Agent) SessionName

func (a *Agent) SessionName() string

SessionName returns the active tmux session name, or empty string when idle.

func (*Agent) SetIdleTimeout

func (a *Agent) SetIdleTimeout(secs int)

SetIdleTimeout configures the agent-agnostic idle timeout. When the tmux pane snapshot has not changed for secs seconds, a Running status is overridden to Waiting. Set to 0 to disable.

func (*Agent) SetOnChange added in v0.3.0

func (a *Agent) SetOnChange(cb func())

SetOnChange registers a callback fired when status or snapshot changes.

func (*Agent) Snapshot

func (a *Agent) Snapshot() string

Snapshot returns the most recent trimmed capture-pane output.

func (*Agent) Start

func (a *Agent) Start(workdir, command, branch, repoRoot, tmuxPrefix string) error

Start creates a tmux session and launches the agent command inside it.

func (*Agent) Status

func (a *Agent) Status() Status

type Status

type Status int
const (
	StatusIdle Status = iota
	StatusRunning
	StatusWaiting // agent is asking for input
	StatusDone
	StatusError
)

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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