Documentation
¶
Overview ¶
Package terminal defines the process-neutral contract implemented by every Relayer terminal backend. It deliberately contains no Bubble Tea, PTY, tmux command or interception code.
Index ¶
Constants ¶
const MaxLineBytes = adapters.MaxLineBytes
MaxLineBytes is the maximum line size before the core appends one carriage return. It aliases the Processor limit so transports cannot drift.
Variables ¶
var ( ErrClosed = errors.New("terminal backend closed") ErrSessionNotFound = errors.New("terminal session not found") ErrNotAttachable = errors.New("terminal session not attachable") ErrUnsupported = errors.New("terminal backend not supported") // ErrSessionRunning rejects releasing a session identity while its process // may still be alive. A replacement session must never be started under a // identity whose previous process has not been proven gone. ErrSessionRunning = errors.New("terminal session still running") // These aliases preserve one errors.Is identity from the Processor through // session, backend, router and presentation boundaries. ErrEventPending = adapters.ErrEventPending ErrInvalidLine = adapters.ErrInvalidLine ErrLineUnsupported = adapters.ErrLineUnsupported ErrLineDeliveryUncertain = adapters.ErrLineDeliveryUncertain )
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
Name() string
Start(context.Context, agent.Spec, Size) (Info, error)
Send(context.Context, SessionID, []byte) error
Resize(context.Context, SessionID, Size) error
Snapshot(context.Context, SessionID) (Snapshot, error)
AttachCommand(context.Context, SessionID) (*exec.Cmd, error)
Stop(context.Context, SessionID) error
Close(context.Context) error
}
Backend is the authoritative terminal boundary used by the application. Implementations own their processes and resources; all potentially blocking operations accept a context. Send transmits data exactly as supplied.
type EventSender ¶
EventSender atomically delivers a decision for the exact pending event. Implementations acknowledge eventID only after data is written successfully.
type Info ¶
type Info struct {
ID SessionID
Name string
DisplayCommand string
Backend string
Adapter string
Shell bool
}
Info is immutable, display-safe metadata returned after startup. Backend is always concrete (pty or tmux), never the auto selector.
type LineSender ¶
LineSender is the optional, atomic ordinary-input boundary. Implementations must reject input while an actionable event is pending and must append the line terminator in the core rather than accepting pre-encoded raw bytes.
type OperationError ¶
OperationError adds safe context to a backend failure without requiring an implementation to expose command arguments or environment values.
func (*OperationError) Error ¶
func (e *OperationError) Error() string
func (*OperationError) Unwrap ¶
func (e *OperationError) Unwrap() error
type PendingEventProvider ¶
type PendingEventProvider interface {
PendingEvent(context.Context, SessionID) (*adapters.Event, error)
}
PendingEventProvider returns only cached semantic state. Implementations must not query a process or spawn an external command; Bubble Tea uses this path while reducing an already-delivered event.
type RawSender ¶ added in v0.6.0
RawSender is an optional interface for backends supporting direct raw input streams (interactive terminal emulation, control signals like Ctrl+C, cursor navigation).
type Recorder ¶ added in v0.7.0
type Recorder interface {
StartSession(info Info, size Size, at time.Time)
RecordOutput(id SessionID, at time.Time, data []byte)
RecordInput(id SessionID, at time.Time, data []byte)
RecordResize(id SessionID, at time.Time, size Size)
FinishSession(id SessionID, at time.Time, exitCode *int)
}
Recorder receives a session transcript. Every method is fire-and-forget: an implementation must never block the caller, never return an error, and never panic. The PTY read loop calls RecordOutput.
type RecorderAware ¶ added in v0.7.0
type RecorderAware interface{ SetRecorder(Recorder) }
RecorderAware is implemented by backends that can stream a transcript.
type SessionRemover ¶ added in v0.4.0
SessionRemover is the optional per-agent lifecycle capability that releases a fully stopped session identity so a later Start may reuse it. Implementations must prove the previous process is gone before forgetting the session; when that proof is impossible they return ErrSessionRunning and keep the identity locked.
type Snapshot ¶
type Snapshot struct {
ID SessionID
Status Status
Running bool
Attached bool
ExitCode *int
Output string
Pending *adapters.Event
Revision uint64
}
Snapshot reconciles bounded output, process status and a possible prompt after asynchronous activity such as returning from an attached tmux client.