Documentation
¶
Index ¶
- Constants
- func AutoProvisionGrokConfigHome(runnerID, agentRunnerBinary, configHome string) (string, error)
- func BuildCodexCommandArgv(env *exec.Env, settingsPath, agentRunnerBinary, model, resumeSession string) ([]string, error)
- func BuildGrokCommandArgv(env *exec.Env, settingsPath, agentRunnerBinary, model, resumeSession string) ([]string, error)
- func BuildStubCommandArgv(env *agentexec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
- func CodexHome() string
- func CodexHomeForRunner(configHome string) string
- func DiscoverSession(ctx context.Context, grokHome, workspace, prompt string, runStart time.Time) (sessionID string, updatesPath string, err error)
- func ExtractAssistantTextFromSnapshot(runner string, scrollback []byte, prompt string) string
- func FindCodexResumeSessionID(text string) string
- func GrokHome() string
- func GrokHomeForRunner(configHome string) string
- func IDs() []string
- func IsTTYRunner(id string) bool
- func LookupSession(home, terminalSessionID string) (*ttywatch.RegistryEntry, string, error)
- func ParseShellWords(line string) ([]string, error)
- func PrependCommandEnv(argv []string, runnerID, configHome string) []string
- func ProviderRegistrySubdirs() []string
- func Register(p Provider) error
- func ResolveAgentRunnerConfigHome(flagValue string) string
- func RunHeadless(ctx context.Context, opts RunOptions) (runnerSessionID, terminalSessionID string, err error)
- func RunStubTTYMain() error
- func RunnerConfigHomeEnv(runnerID, configHome string) []string
- func StripANSI(data []byte) string
- func TailCodexTranscriptFromOffset(ctx context.Context, path string, startOffset int64, ...) error
- func TailUpdatesFromOffset(ctx context.Context, updatesPath string, startOffset int64, ...) error
- func WriteTTYJSON(home string, snap TTYSnapshot) error
- type BuildArgvFunc
- type Provider
- type RunOptions
- type StubEvent
- type StubFrame
- type StubScenario
- type TTYSession
- type TTYSnapshot
- type TailContext
- type WritableStatus
Constants ¶
const EnvAgentRunnerConfigHome = "AGENT_RUNNER_CONFIG_HOME"
Variables ¶
This section is empty.
Functions ¶
func AutoProvisionGrokConfigHome ¶
AutoProvisionGrokConfigHome creates a temp grok home when using llm-mock-run-grok without an explicit config home so agent-run discovery matches the child process.
func BuildCodexCommandArgv ¶
func BuildCodexCommandArgv(env *exec.Env, settingsPath, agentRunnerBinary, model, resumeSession string) ([]string, error)
BuildCodexCommandArgv returns argv for the interactive Codex TUI inside the PTY.
func BuildGrokCommandArgv ¶
func BuildGrokCommandArgv(env *exec.Env, settingsPath, agentRunnerBinary, model, resumeSession string) ([]string, error)
BuildGrokCommandArgv returns argv for the interactive grok TUI inside the PTY.
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 CodexHomeForRunner ¶
CodexHomeForRunner returns the codex data directory for session discovery.
func DiscoverSession ¶
func DiscoverSession(ctx context.Context, grokHome, workspace, prompt string, runStart time.Time) (sessionID string, updatesPath string, err error)
DiscoverSession locates the grok on-disk session matching workspace cwd and prompt.
func ExtractAssistantTextFromSnapshot ¶
ExtractAssistantTextFromSnapshot extracts assistant response text from terminal scrollback.
func FindCodexResumeSessionID ¶
FindCodexResumeSessionID extracts a codex resume session id from terminal text.
func GrokHome ¶
func GrokHome() string
GrokHome returns the grok data directory ($GROK_HOME or $HOME/.grok).
func GrokHomeForRunner ¶
GrokHomeForRunner returns the grok data directory for session discovery.
func IsTTYRunner ¶
IsTTYRunner reports whether id is a registered TTY runner.
func LookupSession ¶
func LookupSession(home, terminalSessionID string) (*ttywatch.RegistryEntry, string, error)
LookupSession searches registered providers' registry dirs in registration order and returns the first reachable live entry. Stale unreachable entries are removed.
func ParseShellWords ¶
ParseShellWords splits a shell-style command line into argv words.
func PrependCommandEnv ¶
PrependCommandEnv prefixes argv with env(1) assignments for the PTY child process.
func ProviderRegistrySubdirs ¶
func ProviderRegistrySubdirs() []string
ProviderRegistrySubdirs returns registry subdir names for all registered providers.
func ResolveAgentRunnerConfigHome ¶
ResolveAgentRunnerConfigHome returns the flag value or AGENT_RUNNER_CONFIG_HOME env.
func RunHeadless ¶
func RunHeadless(ctx context.Context, opts RunOptions) (runnerSessionID, terminalSessionID string, err error)
RunHeadless starts a detached ttywatch serve session, injects the prompt, tails agent events, and waits for the child to exit unless KeepTerminalAlive is set.
func RunStubTTYMain ¶
func RunStubTTYMain() error
RunStubTTYMain runs the test-only stub TTY alt-screen mock (invoked via __stub-tty).
func RunnerConfigHomeEnv ¶
RunnerConfigHomeEnv returns runner-specific env assignments for a PTY child.
func TailCodexTranscriptFromOffset ¶
func TailCodexTranscriptFromOffset(ctx context.Context, path string, startOffset int64, emit func(types.AgentEvent) error) error
TailCodexTranscriptFromOffset tails a codex transcript jsonl from offset.
func TailUpdatesFromOffset ¶
func TailUpdatesFromOffset(ctx context.Context, updatesPath string, startOffset int64, emit func(types.AgentEvent) error) error
TailUpdatesFromOffset tails updates.jsonl starting at the given byte offset.
func WriteTTYJSON ¶
func WriteTTYJSON(home string, snap TTYSnapshot) error
WriteTTYJSON dual-writes the denormalized TTY snapshot.
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)
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 RunOptions ¶
type RunOptions struct {
Home string
Workspace string
Prompt string
Model string
ResumeSessionID string
RunnerID string
AgentSessionID string
SettingsPath string
AgentPath string
AgentRunnerConfigHome string
BinaryPath string
KeepTerminalAlive bool
Stderr io.Writer
Emit func(types.AgentEvent) error
OnTerminalSessionID func(string)
}
RunOptions configures a headless TTY runner invocation via detached serve.
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 ttywatch.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 WritableStatus ¶
type WritableStatus = ttywatch.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.