Documentation
¶
Index ¶
- func BuildStubCommandArgv(env *agentexec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
- func FetchScrollbackSnapshot(listenAddr, sessionID string) []byte
- func IDs() []string
- func InjectInput(listenAddr, sessionID string, input []byte) error
- func IsTTYRunner(id string) bool
- func MarkTTYDead(home, runner, agentSessionID string)
- func PatchRunWithDualWrite(home, runnerID, agentSessionID string, onID func(string)) func(string)
- func Register(p Provider) error
- func Run(ctx context.Context, opts RunOptions) (captured, runnerSessionID string, err error)
- func RunStubTTYMain() error
- func WriteTTYJSON(home string, snap TTYSnapshot) error
- func WriteTTYJSONOnStart(home, runnerID, agentSessionID string, entry RegistryEntry) error
- type BuildArgvFunc
- type Provider
- type RegistryEntry
- type RunOptions
- type StubEvent
- type StubFrame
- type StubScenario
- type TTYSession
- type TTYSnapshot
- type TailContext
- type WSAttachClient
- type WritableStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildStubCommandArgv ¶
func BuildStubCommandArgv(env *agentexec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
BuildStubCommandArgv returns argv for the stub TTY process inside the PTY.
func FetchScrollbackSnapshot ¶
FetchScrollbackSnapshot reads scrollback via attach_mode=snapshot WebSocket probe.
func InjectInput ¶
InjectInput writes input to a live session via server-side HTTP inject API.
func IsTTYRunner ¶
IsTTYRunner reports whether id is a registered TTY runner.
func MarkTTYDead ¶
func MarkTTYDead(home, runner, agentSessionID string)
MarkTTYDead sets alive=false on tty.json (best-effort).
func PatchRunWithDualWrite ¶
PatchRunWithDualWrite wraps agentui callback to dual-write tty.json at terminal id assignment.
func Run ¶
func Run(ctx context.Context, opts RunOptions) (captured, runnerSessionID string, err error)
Run starts a TTY session via groktty engine with provider hooks and tty.json dual-write.
func RunStubTTYMain ¶
func RunStubTTYMain() error
RunStubTTYMain runs the test-only stub TTY alt-screen mock (invoked via __stub-tty).
func WriteTTYJSON ¶
func WriteTTYJSON(home string, snap TTYSnapshot) error
WriteTTYJSON dual-writes the denormalized TTY snapshot.
func WriteTTYJSONOnStart ¶
func WriteTTYJSONOnStart(home, runnerID, agentSessionID string, entry RegistryEntry) error
WriteTTYJSONOnStart writes tty.json when registry entry is known (called from run hook).
Types ¶
type BuildArgvFunc ¶
type BuildArgvFunc func(env *agentexec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
BuildArgvFunc builds the argv for a TTY runner command inside the PTY.
type Provider ¶
type Provider struct {
ID string
RegistryDir string
BannerProvider string
BannerMarkers []string
DisableTail bool
BuildArgv BuildArgvFunc
StartEventTail func(ctx TailContext) (runnerSessionID string, err error) // optional stub tail
DetectScreenStatus func(scrollback []byte) string
CheckWritable func(scrollback []byte) WritableStatus
}
Provider describes a pluggable TTY runner.
func ProviderListSorted ¶
func ProviderListSorted() []Provider
ProviderListSorted returns providers in registration order.
type RegistryEntry ¶
type RegistryEntry = groktty.RegistryEntry
RegistryEntry is the live TTY process index entry (alias of groktty.RegistryEntry).
func LookupSession ¶
func LookupSession(home, terminalSessionID string) (*RegistryEntry, string, error)
LookupSession searches registered providers' registry dirs in registration order and returns the first reachable live entry. Stale unreachable entries are removed.
type RunOptions ¶
type RunOptions struct {
Home string
Workspace string
Prompt string
Model string
ResumeSessionID string
RunnerID string
AgentSessionID string
SettingsPath string
AgentPath string
KeepTerminalAlive bool
Stderr io.Writer
Emit func(types.AgentEvent) error
OnTerminalSessionID func(string)
}
RunOptions configures a unified TTY runner invocation.
type StubScenario ¶
type StubScenario struct {
BannerDelayMs int `json:"banner_delay_ms"`
BannerText string `json:"banner_text"`
PromptLatencyMs int `json:"prompt_latency_ms"`
ResponseText string `json:"response_text"`
ScreenStatus string `json:"screen_status"`
ScreenFrames []StubFrame `json:"screen_frames"`
LLMEvents []StubEvent `json:"llm_events"`
RunnerSessionID string `json:"runner_session_id"`
TurnCompleteDelayMs int `json:"turn_complete_delay_ms"`
ExitAfterTurn bool `json:"exit_after_turn"`
WritableReason string `json:"writable_reason"`
}
StubScenario configures the test-only stub TTY mock process.
type TTYSession ¶
type TTYSession struct {
RunnerID string
AgentSessionID string
TerminalSessionID string
Registry RegistryEntry
Meta *agentstorage.SessionMeta
TTY *TTYSnapshot
TCPReachable bool
ScreenStatus string
}
TTYSession is the unified resolver result for status, attach, and send.
func ResolveByAgentSession ¶
func ResolveByAgentSession(store agentstorage.Store, runner, agentSessionID string) (*TTYSession, error)
ResolveByAgentSession resolves via meta.terminal_session_id then live registry.
func ResolveByTerminalID ¶
func ResolveByTerminalID(home, terminalSessionID string) (*TTYSession, error)
ResolveByTerminalID resolves a terminal-session-id across registered providers. Unlike LookupSession, stale entries are retained for status probes (TCPReachable=false).
type TTYSnapshot ¶
type TTYSnapshot struct {
RunnerID string `json:"runner_id"`
AgentSessionID string `json:"agent_session_id"`
TerminalSessionID string `json:"terminal_session_id"`
ListenAddr string `json:"listen_addr"`
PID int `json:"pid"`
CreatedAt string `json:"created_at"`
ScreenStatus string `json:"screen_status,omitempty"`
Alive bool `json:"alive"`
}
TTYSnapshot is the denormalized TTY cross-ref written to sessions/.../tty.json.
type TailContext ¶
type TailContext struct {
ScenarioPath string
Emit func(types.AgentEvent) error
}
TailContext carries dependencies for provider event tail hooks.
type WSAttachClient ¶
type WSAttachClient struct {
Conn *websocket.Conn
Role string
// contains filtered or unexported fields
}
WSAttachClient is a lightweight WebSocket attach helper for doctest harnesses.
func DialPTYAttach ¶
func DialPTYAttach(listenAddr, sessionID, attachMode string) (*WSAttachClient, error)
DialPTYAttach connects to a ptywrap session with the given attach mode.
func (*WSAttachClient) Close ¶
func (c *WSAttachClient) Close()
Close closes the WebSocket connection.
func (*WSAttachClient) Output ¶
func (c *WSAttachClient) Output() string
Output returns accumulated PTY output from the attach client.
func (*WSAttachClient) TryResize ¶
func (c *WSAttachClient) TryResize(cols, rows int) error
TryResize sends a resize control message.
func (*WSAttachClient) TryWriteInput ¶
func (c *WSAttachClient) TryWriteInput(data []byte) error
TryWriteInput sends binary input when the attach role allows writing.
type WritableStatus ¶
WritableStatus reports whether a TTY session is ready to receive injected input.
func WaitUntilWritable ¶
func WaitUntilWritable(provider Provider, listenAddr, sessionID string, timeout time.Duration) WritableStatus
WaitUntilWritable polls CheckWritable until ready or timeout.