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 ¶
- func LoginShellCommand(shell string) (string, error)
- func LoginShellCommandFromEnv() (string, error)
- func WinsizeFromInts(rows, cols int) (uint16, uint16, bool)
- type Agent
- type AgentManager
- func (m *AgentManager) CloseAgent(agent *Agent) error
- func (m *AgentManager) CloseAll()
- func (m *AgentManager) CloseWorkspaceAgents(ws *data.Workspace)
- func (m *AgentManager) CreateAgent(ws *data.Workspace, agentType AgentType, sessionName string, rows, cols uint16) (*Agent, error)
- func (m *AgentManager) CreateAgentWithTags(ws *data.Workspace, agentType AgentType, sessionName string, rows, cols uint16, ...) (*Agent, error)
- func (m *AgentManager) CreateViewer(ws *data.Workspace, command, sessionName string, rows, cols uint16) (*Agent, error)
- func (m *AgentManager) CreateViewerWithTags(ws *data.Workspace, command, sessionName string, rows, cols uint16, ...) (*Agent, error)
- func (m *AgentManager) SendInterrupt(agent *Agent) error
- func (m *AgentManager) SetTmuxOptions(opts tmux.Options)
- type AgentType
- type Terminal
- func (t *Terminal) Close() error
- func (t *Terminal) File() *os.File
- func (t *Terminal) IsClosed() bool
- func (t *Terminal) Read(p []byte) (int, error)
- func (t *Terminal) Running() bool
- func (t *Terminal) SendInterrupt() error
- func (t *Terminal) SendString(s string) error
- func (t *Terminal) SetReadDeadline(deadline time.Time) error
- func (t *Terminal) SetSize(rows, cols uint16) error
- func (t *Terminal) Write(p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoginShellCommand ¶ added in v0.0.20
LoginShellCommand validates and quotes shell for use in a sh -c command.
func LoginShellCommandFromEnv ¶ added in v0.0.20
LoginShellCommandFromEnv builds a safe login-shell exec command from SHELL.
func WinsizeFromInts ¶ added in v0.0.20
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) 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 NewWithSize ¶
NewWithSize creates a new terminal with an initial size, if provided.
func (*Terminal) Read ¶
Read reads output from the terminal Note: This does NOT hold the mutex during the blocking read to avoid deadlock
func (*Terminal) SendInterrupt ¶
SendInterrupt sends Ctrl+C to the terminal
func (*Terminal) SendString ¶
SendString sends a string to the terminal
func (*Terminal) SetReadDeadline ¶ added in v0.0.20
SetReadDeadline sets the deadline for future Read calls.