Documentation
¶
Overview ¶
Package terminal runs the person's shell in a pseudo-terminal for the window's terminal tab (spec_062_terminal): one Manager a workspace, each Terminal keeping its recent output as scrollback that a watcher replays from an offset, so a window that reloads picks a terminal up as it was.
A terminal is the person's, not the agent's: it runs outside the agent's sandbox and nothing of its text reaches a model or the logs (TRM-02).
Index ¶
Constants ¶
const ( // DefaultMax is how many terminals a workspace keeps at once. DefaultMax = 10 // DefaultScrollback is how many bytes of output a terminal keeps. DefaultScrollback = 2 << 20 // MaxWrite is the most input one write takes. MaxWrite = 64 << 10 )
Limits (TRM-05).
Variables ¶
var ( // ErrUnknown is a terminal that isn't there (or was closed). ErrUnknown = errors.New("no such terminal") // ErrTooMany is a terminal past the workspace's limit. ErrTooMany = errors.New("too many terminals") // ErrUnsupported is a platform without pseudo-terminals. ErrUnsupported = errors.New("terminals aren't supported on this system yet") // ErrClosed is a manager whose workspace has closed. ErrClosed = errors.New("the workspace's terminals are closed") // ErrNotReading is input the shell hasn't taken for WriteTimeout: what // runs in it isn't reading (a hung program, an ssh whose network went), // so its input is full (TRM-13a). ErrNotReading = errors.New("the terminal isn't taking input: what runs in it isn't reading") // ErrExited is input for a shell that has exited. ErrExited = errors.New("the terminal's shell has exited") )
Errors a caller tells apart.
var WriteTimeout = 5 * time.Second
WriteTimeout is how long input waits for room in the shell's input before the write fails with ErrNotReading (TRM-13a); a variable for tests.
Functions ¶
func Environment ¶
Environment is env (the service's when nil) with what a terminal adds (TRM-01): its type and colours, Blitz as its program, and a UTF-8 locale when none is set.
func LoginShell ¶
func LoginShell() string
LoginShell is the person's shell: $SHELL, else zsh on macOS and bash elsewhere (TRM-01).
Types ¶
type Chunk ¶
Chunk is output a watcher is sent: Data ends at Offset (counted from the terminal's start); Skipped is output before Data that was no longer in the scrollback (older than it, or come and gone while the watcher was behind); Exited ends the stream with the shell's exit code.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager keeps a workspace's terminals.
func NewManager ¶
NewManager is a manager keeping at most max terminals, each with scrollback bytes of output (0 for each's default).
func (*Manager) CloseAll ¶
func (m *Manager) CloseAll()
CloseAll ends every terminal; none opens after it (the workspace closed).
type Options ¶
type Options struct {
// Dir is the folder it starts in (absolute).
Dir string
// Shell is the program to run; "" for the person's login shell.
Shell string
// Args are the shell's arguments; nil for a login shell's ("-l").
Args []string
// Env is its environment; nil for the service's (TRM-01's additions
// are made either way).
Env []string
// Cols and Rows are its size; 0 for 80×24.
Cols, Rows uint16
// Version is Blitz's, as TERM_PROGRAM_VERSION.
Version string
}
Options are how a terminal starts.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal is one shell in a pseudo-terminal.
func (*Terminal) Done ¶
func (t *Terminal) Done() <-chan struct{}
Done is closed when the shell has exited and its output is read.