runtime

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

func ExtractOptions(prompt string) []string

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

func IsSeparatorLine(line string) bool

IsSeparatorLine returns true if the line is entirely separator characters.

func OptionLineNumber

func OptionLineNumber(line string) string

OptionLineNumber extracts a numbered option prefix (e.g. "1" from "1. Yes").

func ShellQuote

func ShellQuote(s string) string

ShellQuote returns a shell-safe single-quoted string.

Types

type ConfirmFunc

type ConfirmFunc func(prompt string) []string

ConfirmFunc decides which keys to send for a given interactive prompt. Returns nil to skip (do not confirm this prompt).

type LineFilter

type LineFilter func(line string) (keep bool, interactive bool)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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