Documentation
¶
Index ¶
- func AutoConfirmLoop(ctx context.Context, rt Runtime, proc *Process, ready <-chan struct{}, ...) error
- func CaptureInteractivePrompt(ctx context.Context, rt Runtime, proc *Process, filter LineFilter) (string, error)
- func CompactInteractivePrompt(pane string, filter LineFilter) string
- func ExtractOptions(prompt string) []string
- func IsSeparatorLine(line string) bool
- func OptionLineNumber(line string) string
- func ShellQuote(s string) string
- type ConfirmFunc
- type LineFilter
- type OutputHandler
- type Process
- type Runtime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoConfirmLoop ¶
func AutoConfirmLoop(ctx context.Context, rt Runtime, proc *Process, ready <-chan struct{}, filter LineFilter, confirm ConfirmFunc, interval, timeout time.Duration) error
AutoConfirmLoop polls a process for interactive prompts and auto-confirms them. confirm is an agent-specific function that decides how to respond to each prompt. filter is the agent-specific line filter for prompt detection. Stops when ready is closed, timeout fires, or ctx is canceled.
func CaptureInteractivePrompt ¶
func CaptureInteractivePrompt(ctx context.Context, rt Runtime, proc *Process, filter LineFilter) (string, error)
CaptureInteractivePrompt captures output and extracts any interactive prompt using the given line filter.
func CompactInteractivePrompt ¶
func CompactInteractivePrompt(pane string, filter LineFilter) string
CompactInteractivePrompt extracts interactive prompt content from terminal output. The filter decides which lines to keep/discard per agent.
func ExtractOptions ¶
ExtractOptions parses numbered options from a prompt (e.g. "1. Yes" → "1"). Agent-specific option formats should be handled in the agent's own code.
func IsSeparatorLine ¶
IsSeparatorLine returns true if the line is entirely separator characters.
func OptionLineNumber ¶
OptionLineNumber extracts a numbered option prefix (e.g. "1" from "1. Yes").
func ShellQuote ¶
ShellQuote returns a shell-safe single-quoted string.
Types ¶
type ConfirmFunc ¶
ConfirmFunc decides which keys to send for a given interactive prompt. Returns nil to skip (do not confirm this prompt).
type LineFilter ¶
LineFilter decides whether a terminal line should be kept and whether it indicates an interactive prompt. Implementations are agent-specific (e.g. Claude Code filters "Claude Code v" lines, Codex filters differently).
type OutputHandler ¶
type OutputHandler func(content string)
OutputHandler is called with the current sliding window content each time new output is detected from the process.
type Process ¶
type Process struct {
ID string // container process identifier (tmux: window_id)
PaneID string // interactive pane identifier (tmux: pane_id)
}
Process represents a running process inside the runtime container.
type Runtime ¶
type Runtime interface {
StartProcess(ctx context.Context, name, workDir, command string) (*Process, error)
CaptureOutput(ctx context.Context, proc *Process) (string, error)
SendInput(ctx context.Context, proc *Process, keys ...string) error
Kill(ctx context.Context, proc *Process) error
Respawn(ctx context.Context, proc *Process, command string) error
// Watch streams process output through a sliding window.
// The handler receives the latest ~1 screen of content on each update.
// Blocks until ctx is canceled.
Watch(ctx context.Context, proc *Process, handler OutputHandler) error
Close() error
}
Runtime is a frontend process container abstraction (tmux, screen, etc.). It manages long-running interactive processes that need a persistent terminal.