session

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2026 License: MIT Imports: 46 Imported by: 0

Documentation

Overview

Package session runs the local interactive Lingon terminal session.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSessionIdentity

func DefaultSessionIdentity() (string, string)

DefaultSessionIdentity returns the standard default session id/name pair.

Types

type Options

type Options struct {
	Endpoint         string
	Token            string
	AuthFile         string
	SessionID        string
	SessionName      string
	Cols             int
	Rows             int
	Shell            string
	Term             string
	Respawn          bool
	Offline          bool
	Theme            string
	Publish          bool
	PublishControl   bool
	HostnameOnly     bool
	ScrollbackLines  int
	MaxReplayScreens int
	TLSDir           string
	Insecure         bool
	Stdin            *os.File
	Stdout           *os.File
	DisableRaw       bool
	Logger           pslog.Logger
	// Clock controls time-based behavior (reconnects, overlays).
	Clock           clock.Clock
	OnPTYRead       func([]byte)
	OnPublishFrame  func(*protocolpb.Frame)
	OnPublishStatus func(PublishStatus)
	OnPublishWall   func(*protocolpb.Wall)
	OnStatus        func(StatusUpdate)
	// DisableDesktopNotifications suppresses best-effort desktop notifications for inactivity walls.
	DisableDesktopNotifications bool
	DesktopNotifier             desktopnotify.Notifier
	// AllowRemoteResize permits relay- or attach-driven resize frames to resize
	// the underlying local PTY. This must remain false for normal host sessions
	// and only be enabled for headless Lingon-owned PTYs.
	AllowRemoteResize bool
	// ToggleWallInactivityFallback handles local-only wall inactivity cycling
	// when relay-backed toggle is unavailable.
	ToggleWallInactivityFallback func(context.Context, string) (WallInactivityToggleResult, error)
	OnSnapshot                   func(terminal.Snapshot)
	Trace                        *trace.Writer
	ResizeEvents                 <-chan struct{}
	// DisableSignalResize suppresses process-global SIGWINCH handling and relies
	// only on explicit ResizeEvents.
	DisableSignalResize bool
}

Options configures a local interactive session.

type PublishStatus

type PublishStatus struct {
	SessionID string
	Kind      PublishStatusKind
	Message   string
	Endpoint  string
	Remaining time.Duration
}

PublishStatus describes a host publish connectivity state change.

type PublishStatusKind

type PublishStatusKind string

PublishStatusKind identifies host publish connectivity transitions.

const (
	// PublishStatusConnected indicates relay connectivity was restored.
	PublishStatusConnected PublishStatusKind = "connected"
	// PublishStatusConnectionLost indicates relay connectivity was lost.
	PublishStatusConnectionLost PublishStatusKind = "connection_lost"
	// PublishStatusConnectionBackoff indicates reconnect backoff countdown is active.
	PublishStatusConnectionBackoff PublishStatusKind = "connection_backoff"
)

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner executes a local interactive session with optional relay publishing.

func New

func New(opts Options) *Runner

New constructs a Runner.

func (*Runner) HandleSessionCommand

func (r *Runner) HandleSessionCommand(ctx context.Context, sessionID string, kind protocolpb.CommandKind)

HandleSessionCommand applies a protocol command to the target local session.

func (*Runner) HandleSessionInput

func (r *Runner) HandleSessionInput(sessionID string, data []byte)

HandleSessionInput writes raw input to the target local PTY session.

func (*Runner) ResizeActive

func (r *Runner) ResizeActive(cols, rows int)

ResizeActive applies a size update to the current active session.

func (*Runner) ResizeActiveIfChanged

func (r *Runner) ResizeActiveIfChanged(cols, rows int) bool

ResizeActiveIfChanged applies a size update only when the active session has not already observed the requested dimensions.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

Run starts the local terminal session and blocks until exit.

func (*Runner) SendCtrlDActive

func (r *Runner) SendCtrlDActive()

SendCtrlDActive delivers an explicit EOF to the active local PTY session.

func (*Runner) SessionID

func (r *Runner) SessionID() string

SessionID returns the active session ID.

func (*Runner) SessionOffline

func (r *Runner) SessionOffline(sessionID string) (bool, bool)

SessionOffline reports the offline flag for a local session.

func (*Runner) StopSession

func (r *Runner) StopSession(sessionID, reason string)

StopSession force-stops the target local PTY session and publishes an explicit session-closed reason before shutting it down.

type StatusKind

type StatusKind string

StatusKind identifies generic status banner kinds.

const (
	// StatusKindInfo maps to a non-error status banner.
	StatusKindInfo StatusKind = "info"
	// StatusKindError maps to an error status banner.
	StatusKindError StatusKind = "error"
)

type StatusUpdate

type StatusUpdate struct {
	SessionID string
	Kind      StatusKind
	Message   string
	Duration  time.Duration
}

StatusUpdate describes a transient status banner update.

type WallInactivityToggleResult

type WallInactivityToggleResult struct {
	Enabled       bool
	InactiveAfter string
}

WallInactivityToggleResult describes post-toggle wall inactivity state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL