Documentation
¶
Overview ¶
Package session owns PTY-backed process lifecycles and exposes neutral, typed events. It deliberately has no dependency on Bubble Tea.
Index ¶
- Variables
- type AdapterEvent
- type Error
- type Event
- type Exited
- type Info
- type Manager
- func (m *Manager) BeginShutdown()
- func (m *Manager) Close()
- func (m *Manager) Context() context.Context
- func (m *Manager) Done(sessionID string) (<-chan struct{}, error)
- func (m *Manager) Name() string
- func (m *Manager) Output(sessionID string) (string, error)
- func (m *Manager) PendingEvent(sessionID string) (*adapters.Event, error)
- func (m *Manager) Resize(sessionID string, columns, rows int) error
- func (m *Manager) Result(sessionID string) (exited bool, waitErr error, exitCode *int, err error)
- func (m *Manager) Revision(sessionID string) (uint64, error)
- func (m *Manager) SendData(sessionID string, data []byte) error
- func (m *Manager) SendDataForEvent(sessionID, eventID string, data []byte) error
- func (m *Manager) SendInput(sessionID string, value string) error
- func (m *Manager) SendLine(ctx context.Context, sessionID, line string) error
- func (m *Manager) Start(spec agent.Spec, columns, rows int) (Info, error)
- func (m *Manager) Stop(sessionID string) error
- type OutputAvailable
Constants ¶
This section is empty.
Variables ¶
var ( ErrClosed = errors.New("PTY session closed") // ErrStopUncertain means Relayer requested termination but could not confirm // that both the command leader and its PTY process group disappeared. A // caller must not start a replacement process while this error is present. ErrStopUncertain = errors.New("PTY session stop not confirmed") )
ErrClosed is returned when an operation targets a PTY that has already been closed or a manager that no longer accepts sessions.
Functions ¶
This section is empty.
Types ¶
type AdapterEvent ¶
AdapterEvent carries the single backend-neutral semantic representation produced by an adapter or by a real session lifecycle transition.
type Event ¶
type Event interface {
// contains filtered or unexported methods
}
Event is emitted by Manager for asynchronous session state changes. The unexported marker keeps the event set closed while allowing consumers to use type switches over the exported concrete types.
type Exited ¶
Exited is retained for source compatibility. Managers now publish a real AdapterEvent with type process_exit instead of emitting this legacy value.
type Info ¶
Info remains an alias for compatibility with the original PTY API while every backend now shares terminal.Info.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the sole owner of process lifecycles and PTY descriptors.
func NewManager ¶
func NewManager( parent context.Context, events chan<- Event, patterns []intercept.Pattern, ringCapacity int, ) (*Manager, error)
NewManager validates every prompt pattern before any process can start.
func NewManagerWithRegistry ¶
func NewManagerWithRegistry( parent context.Context, events chan<- Event, registry *adapters.Registry, ringCapacity int, ) (*Manager, error)
NewManagerWithRegistry creates a PTY owner around the application adapter registry. The registry is validated before any process can start and creates independent adapter state for every session.
func (*Manager) BeginShutdown ¶
func (m *Manager) BeginShutdown()
BeginShutdown immediately unblocks essential event senders. Close performs descriptor/process cleanup and joins every owned goroutine.
func (*Manager) Done ¶
Done exposes lifecycle completion without leaking the underlying process or PTY descriptor. The channel is closed before the corresponding process_exit AdapterEvent is emitted.
func (*Manager) Name ¶
Name identifies the concrete backend without exposing PTY implementation details to the application or TUI.
func (*Manager) PendingEvent ¶
PendingEvent returns an independent copy of the actionable occurrence still awaiting a decision, if any.
func (*Manager) Revision ¶
Revision is the latest semantic event occurrence sequence for the session.
func (*Manager) SendData ¶
SendData is the compatibility path for callers that do not yet retain the actionable event ID. It still uses Processor.Resolve so acknowledgement only happens after the exact bytes have been delivered successfully.
func (*Manager) SendDataForEvent ¶
SendDataForEvent atomically validates the pending occurrence, delivers the exact bytes and acknowledges only after a successful write.
func (*Manager) SendLine ¶
SendLine is the ordinary-input path. Processor.SendLine atomically confirms that the process is live and no actionable event is pending, then appends exactly one carriage return without acknowledging semantic state.
type OutputAvailable ¶
type OutputAvailable struct {
SessionID string
}
OutputAvailable invalidates a consumer's cached output snapshot. The latest bounded snapshot is retrieved with Manager.Output.