Documentation
¶
Index ¶
- func BuildCodexCommandArgv(env *exec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
- func BuildCommandArgv(env *exec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
- func BuildGrokCommandArgv(env *exec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
- func CodexHome() string
- func DiscoverActiveCodexTranscript(ctx context.Context, codexHome, workspace string, runStart time.Time) (sessionID, path string, err error)
- func DiscoverCodexTranscript(ctx context.Context, codexHome, sessionID string) (string, error)
- func DiscoverSession(ctx context.Context, grokHome, workspace, prompt string, runStart time.Time) (sessionID string, updatesPath string, err error)
- func EncodedCwd(workspace string) (string, error)
- func FindCodexResumeSessionID(text string) string
- func GrokHome() string
- func ParseShellWords(line string) ([]string, error)
- func RemoveRegistry(home, sessionID string)
- func RemoveRegistryFor(home, dirName, sessionID string)
- func RenderTerminalText(scrollback []byte) []byte
- func ReserveRegistrySessionID(home, dirName string) (string, func(), error)
- func Run(ctx context.Context, opts RunOptions) (captured string, grokSessionID string, err error)
- func StripANSI(data []byte) string
- func TailCodexTranscriptFromOffset(ctx context.Context, path string, startOffset int64, ...) error
- func TailUpdates(ctx context.Context, updatesPath string, emit func(types.AgentEvent) error) error
- func TailUpdatesFromOffset(ctx context.Context, updatesPath string, startOffset int64, ...) error
- func WriteRegistry(home string, entry RegistryEntry) error
- func WriteRegistryFor(home, dirName string, entry RegistryEntry) error
- type ACPConverter
- type RegistryEntry
- type RunOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCodexCommandArgv ¶
func BuildCodexCommandArgv(env *exec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
BuildCodexCommandArgv returns argv for the interactive Codex TUI inside the PTY.
func BuildCommandArgv ¶
func BuildCommandArgv(env *exec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
BuildCommandArgv returns argv for the interactive grok TUI inside the PTY.
func BuildGrokCommandArgv ¶
func BuildGrokCommandArgv(env *exec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
BuildGrokCommandArgv returns argv for the interactive grok TUI inside the PTY.
func DiscoverCodexTranscript ¶
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. When AGENT_RUN_GROK_TTY_GROK_SESSION_ID is set, discovery is skipped.
func EncodedCwd ¶
EncodedCwd returns url.PathEscape(absWorkspace) matching grok session layout.
func GrokHome ¶
func GrokHome() string
GrokHome returns the grok data directory ($GROK_HOME or $HOME/.grok).
func ParseShellWords ¶
ParseShellWords splits a shell-style command line into argv words.
func RemoveRegistry ¶
func RemoveRegistry(home, sessionID string)
RemoveRegistry deletes the registry file for a session.
func RemoveRegistryFor ¶
func RemoveRegistryFor(home, dirName, sessionID string)
RemoveRegistryFor deletes the registry file for a provider-specific session.
func RenderTerminalText ¶
RenderTerminalText renders PTY scrollback into a plain terminal screen snapshot.
func ReserveRegistrySessionID ¶
ReserveRegistrySessionID returns the next session-N id for a registry dir. The returned release function must be called after the registry entry is written, so concurrent processes cannot choose the same id.
func Run ¶
Run starts an adhoc ptywrap server, runs interactive grok in a PTY, injects the prompt after the TUI banner, tails the matching grok session updates.jsonl when found, and blocks until the session exits.
func TailUpdates ¶
TailUpdates polls updates.jsonl and emits AgentEvents for new lines until ctx is done.
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. Use updatesTailStartOffset at discovery time to skip bytes already on disk.
func WriteRegistry ¶
func WriteRegistry(home string, entry RegistryEntry) error
WriteRegistry creates the registry file for a live grok-tty session.
func WriteRegistryFor ¶
func WriteRegistryFor(home, dirName string, entry RegistryEntry) error
WriteRegistryFor creates a live TTY registry file in a provider-specific registry dir.
Types ¶
type ACPConverter ¶
type ACPConverter struct {
// contains filtered or unexported fields
}
ACPConverter converts ACP session updates to AgentEvents with chunk coalescing.
func NewACPConverter ¶
func NewACPConverter() *ACPConverter
NewACPConverter creates a converter for one grok session tail.
func (*ACPConverter) Flush ¶
func (c *ACPConverter) Flush() []types.AgentEvent
Flush emits any buffered chunk coalescence at end of tail.
func (*ACPConverter) ProcessLine ¶
func (c *ACPConverter) ProcessLine(line string) []types.AgentEvent
ProcessLine parses one updates.jsonl line and returns AgentEvents to emit.
type RegistryEntry ¶
type RegistryEntry struct {
SessionID string `json:"session_id"`
ListenAddr string `json:"listen_addr"`
PID int `json:"pid"`
CreatedAt string `json:"created_at"`
}
RegistryEntry maps a grok-tty session id to the adhoc ptywrap listen address.
func ReadRegistry ¶
func ReadRegistry(home, sessionID string) (*RegistryEntry, error)
ReadRegistry loads a grok-tty session registry entry.
func ReadRegistryFor ¶
func ReadRegistryFor(home, dirName, sessionID, label string) (*RegistryEntry, error)
ReadRegistryFor loads a provider-specific TTY session registry entry.
func ReadSupportedRegistry ¶
func ReadSupportedRegistry(home, sessionID string) (*RegistryEntry, string, error)
ReadSupportedRegistry searches known TTY registry dirs deterministically and returns the first reachable live entry.
type RunOptions ¶
type RunOptions struct {
Home string
Workspace string
Prompt string
Model string
ResumeSessionID string
SettingsPath string
AgentPath string
RunnerID string
StderrPrefix string
RegistryDir string
BannerProvider string
BannerMarkers []string
DisableTail bool
KeepTerminalAlive bool
KeepTerminalBlocking bool // block after prompt inject to keep ptywrap server alive
BuildArgv func(env *agentexec.Env, settingsPath, agentPath, model, resumeSession string) ([]string, error)
Stderr io.Writer
Emit func(types.AgentEvent) error
OnTerminalSessionID func(string)
}
RunOptions configures a grok-tty headless invocation.