terminalservice

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 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 terminalservice manages local PTY-backed shell sessions.

Index

Constants

View Source
const (
	DefaultIdleTimeout = 30 * time.Minute
	DefaultMaxSessions = 8
)

Variables

View Source
var (
	// ErrDisabled is returned when the terminal feature is off.
	ErrDisabled = errors.New("terminal: disabled")
	// ErrNotImplemented is returned on platforms without PTY support.
	ErrNotImplemented = errors.New("terminal: not implemented on this platform")
	// ErrSessionNotFound is returned for unknown session IDs.
	ErrSessionNotFound = errors.New("terminal: session not found")
	// ErrTooManySessions is returned when the per-process session slot is occupied.
	ErrTooManySessions = errors.New("terminal: too many concurrent sessions")
)

Functions

func CwdUnderRoot

func CwdUnderRoot(allowedRoot, cwd string) error

CwdUnderRoot ensures cwd is the same as allowedRoot or a subdirectory.

func IsEnabled

func IsEnabled(v string) bool

IsEnabled returns true for accepted truthy terminal feature flag values.

func ResolveCwdUnderRoot

func ResolveCwdUnderRoot(allowedRoot, cwd string) (string, error)

ResolveCwdUnderRoot returns a cleaned, real cwd after validating it is inside allowedRoot.

func ValidateShell

func ValidateShell(shell string) error

Types

type Config

type Config struct {
	Enabled      bool
	AllowedRoot  string
	DefaultShell string
	// IdleTimeout is the maximum time a detached session is kept alive.
	// Zero disables idle reaping.
	IdleTimeout time.Duration
	// MaxSessions is the maximum number of concurrent live PTY sessions.
	// Zero means unlimited.
	MaxSessions int
}

Config holds terminal service settings.

func ParseEnv

func ParseEnv(terminalEnabled, terminalAllowedRoot, terminalShell, terminalIdleTimeout, terminalMaxSessions string) (Config, error)

ParseEnv builds a Config from raw env-backed string fields.

type CreateRequest

type CreateRequest struct {
	CWD   string
	Cols  int
	Rows  int
	Shell string
}

type CreateResponse

type CreateResponse struct {
	ID string
}

type ResizeMsg

type ResizeMsg struct {
	Cols int
	Rows int
}

type Service

type Service interface {
	Create(ctx context.Context, principal string, req CreateRequest) (*CreateResponse, error)
	Close(ctx context.Context, principal, id string) error
	CloseAll(ctx context.Context) error
	Attach(ctx context.Context, principal, id string, conn io.ReadWriteCloser, resizeCh <-chan ResizeMsg) error
	Get(ctx context.Context, principal, id string) (*SessionInfo, error)
	List(ctx context.Context, principal string, createdAtCursor *time.Time, limit int) ([]*SessionInfo, error)
	UpdateGeometry(ctx context.Context, principal, id string, cols, rows int) error
	ReapIdle(ctx context.Context) error
}

func New

func New(cfg Config, db libdb.DBManager, nodeInstanceID string, workspaceID string) (Service, error)

func NewDisabled

func NewDisabled() Service

func WithActivityTracker

func WithActivityTracker(svc Service, tracker libtracker.ActivityTracker) Service

type SessionInfo

type SessionInfo = terminalstore.Session

Jump to

Keyboard shortcuts

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