Documentation
¶
Overview ¶
Package harness provides a PTY-based TUI for embedding Claude Code.
The harness creates a "window-in-window" interface where Claude Code runs interactively via PTY, with a status bar showing connection state, job info, and queue metrics.
This implementation uses ANSI scroll regions (DECSTBM) to reserve the top lines for status while giving Claude Code full control of the remaining terminal space.
Package harness provides a PTY-based TUI for embedding Claude Code.
Index ¶
Constants ¶
const DefaultExecutionTimeout = 10 * time.Minute
DefaultExecutionTimeout is the fallback when no execution timeout is set on the job.
const PTYChunkDelay = 10 * time.Millisecond
PTYChunkDelay is the delay between writing chunks to the PTY.
const PTYPasteSettleDelay = 500 * time.Millisecond
PTYPasteSettleDelay is the delay after bulk-pasting content, allowing the application to process the pasted text before we send Enter.
const PTYPostWriteDelay = 50 * time.Millisecond
PTYPostWriteDelay is the delay after writing all content before sending Enter.
const PTYWriteChunkSize = 4096
PTYWriteChunkSize is the max bytes to write to the PTY at once.
const PromptDebounceTime = 1 * time.Second
PromptDebounceTime is how long to wait after seeing the prompt before declaring Claude is ready. Used only for initial startup detection.
const SignalFileName = "complete"
SignalFileName is the marker file created by the Stop hook.
const SignalPollInterval = 200 * time.Millisecond
SignalPollInterval is how often to check for completion signal files.
const StatusBarHeight = 2
StatusBarHeight is the number of lines reserved for the status bar
Variables ¶
var PromptDetectionBytes = []byte{0xe2, 0x9d, 0xaf, 0x20} // "❯ " in UTF-8
PromptDetectionBytes contains the bytes to detect Claude's input prompt. We look for "❯ " (U+276F HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT + space) to know Claude is ready for input (used for initial ready state).
Functions ¶
func LoadedMCPServers ¶ added in v1.2.0
func LoadedMCPServers(cfg *client.RunnerConfigResponse, now time.Time) []string
LoadedMCPServers returns the names of MCP providers that are effectively loaded.
Types ¶
type Config ¶
type Config struct {
Client *client.Client
HabitatID string
QueueID string
SupportedAgents []string
InstanceID string
RunnerConfig *client.RunnerConfigResponse
}
Config holds configuration for the harness.
type ConnectionStatus ¶
type ConnectionStatus int
ConnectionStatus represents the connection state.
const ( StatusDisconnected ConnectionStatus = iota StatusConnecting StatusConnected StatusProcessing StatusError )
ConnectionStatus values.
func (ConnectionStatus) String ¶
func (s ConnectionStatus) String() string
String returns a human-readable status.
type RootModel ¶
type RootModel struct {
// contains filtered or unexported fields
}
RootModel manages the harness state with scroll region approach.
func NewRootModel ¶
NewRootModel creates a new root model with the given configuration.