driver

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package driver exposes TUICast through a language-neutral JSON-RPC protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionOptions

type ConnectionOptions struct {
	Protocol                   string `json:"protocol"`
	Address                    string `json:"address"`
	Username                   string `json:"username,omitempty"`
	Password                   string `json:"password,omitempty"`
	PrivateKey                 string `json:"privateKey,omitempty"`
	PrivateKeyPassphrase       string `json:"privateKeyPassphrase,omitempty"`
	KnownHostsFile             string `json:"knownHostsFile,omitempty"`
	HostKeyFingerprint         string `json:"hostKeyFingerprint,omitempty"`
	InsecureSkipHostKeyCheck   bool   `json:"insecureSkipHostKeyCheck,omitempty"`
	ConnectTimeoutMilliseconds int64  `json:"connectTimeoutMilliseconds,omitempty"`
}

ConnectionOptions describes a transport connection requested through the driver. SSH host-key verification must use either KnownHostsFile, HostKeyFingerprint, or the explicit insecure option.

type ConnectionSnapshot

type ConnectionSnapshot struct {
	ID       uint64 `json:"id"`
	Protocol string `json:"protocol"`
	Address  string `json:"address"`
}

ConnectionSnapshot contains non-sensitive connection metadata.

type ConnectorFactory

type ConnectorFactory func(ConnectionOptions) (tuicast.Connector, error)

ConnectorFactory creates concrete transport connectors at the driver composition boundary.

type CursorMatcher

type CursorMatcher = tuicast.CursorMatcherSpec

CursorMatcher describes an expected cursor position.

type LineMatcher

type LineMatcher = tuicast.LineMatcherSpec

LineMatcher describes an exact screen-row expectation.

type Matcher

type Matcher = tuicast.MatcherSpec

Matcher describes a serializable screen expectation. Exactly one field must be set.

type Option added in v0.2.0

type Option func(*Server)

Option configures a driver server.

func WithDumpDirectory added in v0.2.0

func WithDumpDirectory(directory string) Option

WithDumpDirectory writes the flight-recorder dump of each failed wait to a file in directory and returns its path in the wait error data. Wait errors include the dump inline whether or not a directory is configured.

type Server

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

Server owns the JSON-RPC object registry and delegates terminal behavior to the TUICast library.

func New

func New(logger *slog.Logger, connectors ConnectorFactory, terminals TerminalFactory, options ...Option) (*Server, error)

New creates a driver server using injected concrete factories.

func (*Server) AcquireSessionControl

func (s *Server) AcquireSessionControl(id uint64) (*SessionControl, error)

AcquireSessionControl acquires exclusive input control for a session.

func (*Server) Close

func (s *Server) Close() error

Close closes subscriptions, sessions, and connections. It is idempotent.

func (*Server) DriverSnapshot

func (s *Server) DriverSnapshot() Snapshot

DriverSnapshot returns a detached view that never contains connection credentials or terminal screen contents.

func (*Server) Run

func (s *Server) Run(input io.Reader, output io.Writer) error

Run serves JSON-RPC 2.0 objects from input and writes responses and notifications to output. Requests may complete out of order.

func (*Server) SessionScreens

func (s *Server) SessionScreens(ctx context.Context, id uint64) (<-chan tuicast.Screen, error)

SessionScreens observes detached snapshots for a registered session.

type SessionControl

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

SessionControl grants one caller exclusive input control over a registered driver session. Release returns input control to JSON-RPC clients.

func (*SessionControl) Press

func (c *SessionControl) Press(key tuicast.Key, modifiers ...tuicast.KeyModifier) error

Press sends a named key through the controlled session.

func (*SessionControl) Release

func (c *SessionControl) Release()

Release relinquishes exclusive control. It is idempotent.

func (*SessionControl) Screen

func (c *SessionControl) Screen() tuicast.Screen

Screen returns the controlled session's current detached screen.

func (*SessionControl) Send

func (c *SessionControl) Send(data []byte) error

Send writes terminal input through the controlled session.

func (*SessionControl) WaitFor

func (c *SessionControl) WaitFor(ctx context.Context, matcher tuicast.ScreenMatcher) (tuicast.Screen, error)

WaitFor waits for a screen condition on the controlled session.

type SessionSnapshot

type SessionSnapshot struct {
	ID           uint64 `json:"id"`
	ConnectionID uint64 `json:"connectionId"`
	Terminal     string `json:"terminal"`
	Width        int    `json:"width"`
	Height       int    `json:"height"`
	Revision     uint64 `json:"revision"`
	State        string `json:"state"`
	Error        string `json:"error,omitempty"`
	// Unsupported counts the sequences the terminal ignored, in the order they
	// first appeared. Sequences are named in notation such as "CSI ? 2004 h"
	// and never include control-string content.
	Unsupported []UnsupportedSnapshot `json:"unsupported"`
}

SessionSnapshot describes one registered terminal session.

type Snapshot

type Snapshot struct {
	State       string               `json:"state"`
	Connections []ConnectionSnapshot `json:"connections"`
	Sessions    []SessionSnapshot    `json:"sessions"`
}

Snapshot is a detached, UI-safe view of the driver's current object graph.

type TerminalFactory

type TerminalFactory func(profile string, width, height int) (tuicast.Terminal, error)

TerminalFactory creates a terminal profile at the driver composition boundary.

type UnsupportedSnapshot added in v0.2.0

type UnsupportedSnapshot struct {
	Sequence string `json:"sequence"`
	Count    uint64 `json:"count"`
}

UnsupportedSnapshot counts one sequence the session's terminal ignored.

Jump to

Keyboard shortcuts

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