Documentation
¶
Overview ¶
Terminal sanitization matches terminal-bash: strip ANSI CSI/OSC escape sequences from raw PTY output and normalize line endings into displayable plain text.
Package terminal provides persistent terminal sessions (S10), matching shell/terminal. This cross-platform backend uses subprocesses and pipes for spawn/send/read/signal/close, bounded scrollback, wait reasons, and one active session per agent. A native PTY backend can replace it without changing the interface.
Index ¶
- func NormalizeText(s string) string
- func Sanitize(s string) string
- func ShellCommand(script string) (name string, args []string)
- func StripANSI(s string) string
- type Session
- func (s *Session) Close() error
- func (s *Session) Contains(sub string) bool
- func (s *Session) Read() []string
- func (s *Session) ReadString() string
- func (s *Session) Send(data string) error
- func (s *Session) SendLine(line string) error
- func (s *Session) Signal() error
- func (s *Session) Wait() WaitReason
- type TerminalBackend
- type TerminalConfig
- type WaitReason
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeText ¶
NormalizeText converts CRLF and lone CR to LF and removes BEL.
func ShellCommand ¶
ShellCommand returns the platform shell and one-command execution arguments, allowing tests such as echo to run under Windows cmd or Unix sh.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a persistent subprocess-and-pipe terminal with bounded scrollback.
func (*Session) Contains ¶
Contains checks scrollback for a substring, useful for polling assertions.
func (*Session) ReadString ¶
ReadString joins current scrollback into text.
func (*Session) Wait ¶
func (s *Session) Wait() WaitReason
Wait blocks until termination and returns its reason.
type TerminalBackend ¶
type TerminalBackend struct {
// contains filtered or unexported fields
}
TerminalBackend owns terminal sessions and permits one active session per agent.
func NewBackend ¶
func NewBackend(cfg TerminalConfig) *TerminalBackend
NewBackend creates a terminal backend.
func (*TerminalBackend) Active ¶
func (b *TerminalBackend) Active() *Session
Active returns the active session, or nil.
type TerminalConfig ¶
type TerminalConfig struct {
Command string // Executable name, such as bash, cmd, or sh.
Args []string // Arguments.
MaxLines int // Scrollback line limit; nonpositive defaults to 1000.
ReadLineMax int // Maximum bytes per line.
}
TerminalConfig configures a terminal session.
type WaitReason ¶
type WaitReason string
WaitReason identifies why a session ended.
const ( WaitExited WaitReason = "exited" // Normal process exit. WaitSignalled WaitReason = "signalled" // Signal termination. WaitClosed WaitReason = "closed" // Explicitly closed. WaitError WaitReason = "error" // Startup or execution error. )
Session termination reasons.