pty

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package pty manages the pseudo-terminals that back hosted agents: it spawns agent processes (Agent) attached to a PTY (Terminal), sizes them, and streams their byte output to the UI for parsing by internal/vterm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginShellCommand added in v0.0.20

func LoginShellCommand(shell string) (string, error)

LoginShellCommand validates and quotes shell for use in a sh -c command.

func LoginShellCommandFromEnv added in v0.0.20

func LoginShellCommandFromEnv() (string, error)

LoginShellCommandFromEnv builds a safe login-shell exec command from SHELL.

func WinsizeFromInts added in v0.0.20

func WinsizeFromInts(rows, cols int) (uint16, uint16, bool)

WinsizeFromInts converts UI dimensions into PTY winsize dimensions. Non-positive pairs mean "use the platform/default size" and return ok=false. Oversized dimensions are clamped to the largest value the PTY API accepts.

Types

type Agent

type Agent struct {
	Type      AgentType
	Terminal  *Terminal
	Workspace *data.Workspace
	Config    config.AssistantConfig
	Session   string
}

Agent represents a running AI agent instance

type AgentManager

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

AgentManager manages agent instances

func NewAgentManager

func NewAgentManager(cfg *config.Config) *AgentManager

NewAgentManager creates a new agent manager

func (*AgentManager) CloseAgent

func (m *AgentManager) CloseAgent(agent *Agent) error

CloseAgent closes an agent

func (*AgentManager) CloseAll

func (m *AgentManager) CloseAll()

CloseAll closes all agents

func (*AgentManager) CloseWorkspaceAgents added in v0.0.5

func (m *AgentManager) CloseWorkspaceAgents(ws *data.Workspace)

CloseWorkspaceAgents closes and removes all agents for a specific workspace

func (*AgentManager) CreateAgent

func (m *AgentManager) CreateAgent(ws *data.Workspace, agentType AgentType, sessionName string, rows, cols uint16) (*Agent, error)

CreateAgent creates a new agent for the given workspace.

func (*AgentManager) CreateAgentWithTags added in v0.0.9

func (m *AgentManager) CreateAgentWithTags(ws *data.Workspace, agentType AgentType, sessionName string, rows, cols uint16, tags tmux.SessionTags) (*Agent, error)

CreateAgentWithTags creates a new agent for the given workspace with tmux tags.

func (*AgentManager) CreateViewer

func (m *AgentManager) CreateViewer(ws *data.Workspace, command, sessionName string, rows, cols uint16) (*Agent, error)

CreateViewer creates a new agent (viewer) for the given workspace and command.

func (*AgentManager) CreateViewerWithTags added in v0.0.9

func (m *AgentManager) CreateViewerWithTags(ws *data.Workspace, command, sessionName string, rows, cols uint16, tags tmux.SessionTags) (*Agent, error)

CreateViewerWithTags creates a new viewer for the given workspace with tmux tags.

func (*AgentManager) SendInterrupt

func (m *AgentManager) SendInterrupt(agent *Agent) error

SendInterrupt sends an interrupt to an agent

func (*AgentManager) SetTmuxOptions added in v0.0.14

func (m *AgentManager) SetTmuxOptions(opts tmux.Options)

SetTmuxOptions updates tmux options for future agent/viewer command construction.

type AgentType

type AgentType string

AgentType represents the type of AI agent. Concrete agent identifiers are not enumerated here: the canonical roster lives in the config.AgentRegistry, and the runtime resolves agents by their assistant-name string (see CreateAgentWithTags). Keeping the names in one place avoids hand-synced lists.

type Terminal

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

Terminal wraps a PTY with an associated command

func New

func New(command, dir string, env []string) (*Terminal, error)

New creates a new terminal with the given command.

func NewWithSize

func NewWithSize(command, dir string, env []string, rows, cols uint16) (*Terminal, error)

NewWithSize creates a new terminal with an initial size, if provided.

func (*Terminal) Close

func (t *Terminal) Close() error

Close closes the terminal

func (*Terminal) File

func (t *Terminal) File() *os.File

File returns the underlying PTY file

func (*Terminal) IsClosed

func (t *Terminal) IsClosed() bool

IsClosed returns whether the terminal has been closed

func (*Terminal) Read

func (t *Terminal) Read(p []byte) (int, error)

Read reads output from the terminal Note: This does NOT hold the mutex during the blocking read to avoid deadlock

func (*Terminal) Running

func (t *Terminal) Running() bool

Running returns whether the terminal is still running

func (*Terminal) SendInterrupt

func (t *Terminal) SendInterrupt() error

SendInterrupt sends Ctrl+C to the terminal

func (*Terminal) SendString

func (t *Terminal) SendString(s string) error

SendString sends a string to the terminal

func (*Terminal) SetReadDeadline added in v0.0.20

func (t *Terminal) SetReadDeadline(deadline time.Time) error

SetReadDeadline sets the deadline for future Read calls.

func (*Terminal) SetSize

func (t *Terminal) SetSize(rows, cols uint16) error

SetSize sets the terminal size

func (*Terminal) Write

func (t *Terminal) Write(p []byte) (int, error)

Write sends input to the terminal

Jump to

Keyboard shortcuts

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