Documentation
¶
Overview ¶
Package terminalaccess keeps GUI terminal permissions separate from both session labels and terminal contents. Only the operator-facing host grants access; model-supplied names are never credentials.
Index ¶
- Variables
- func UserShell() []string
- type Connection
- func (c *Connection) AgentWrite(agent string, b []byte) (int, error)
- func (c *Connection) AgentWriteChecked(agent string, b []byte, check func() error) (int, error)
- func (c *Connection) Barrier(ctx context.Context, send func([]byte)) error
- func (c *Connection) Close() error
- func (c *Connection) Observe(after uint64) (uint64, bool, <-chan struct{})
- func (c *Connection) Read(b []byte) (int, error)
- func (c *Connection) Resize(cols, rows int) error
- func (c *Connection) Revision() (uint64, bool)
- func (c *Connection) SetViewLocked(locked bool)
- func (c *Connection) ViewLocked() bool
- func (c *Connection) Wait(ctx context.Context, after uint64) (uint64, bool, error)
- func (c *Connection) Write(b []byte) (int, error)
- type Process
- type ProcessOptions
- type Registry
- func (r *Registry) Access(paneID, agentID string) (read, write bool, owner string)
- func (r *Registry) AddAgent(id, project string) error
- func (r *Registry) AddAgentPane(id, agentID, parentID string) error
- func (r *Registry) AddPane(id, project string) error
- func (r *Registry) CanClose(paneID, agentID string) bool
- func (r *Registry) Grant(paneID, agentID string, read, write, transfer bool) error
- func (r *Registry) MarkExited(paneID string)
- func (r *Registry) Owner(paneID string) string
- func (r *Registry) RemoveAgent(id string)
- func (r *Registry) RemoveAgentPane(paneID, agentID string) error
- func (r *Registry) RemovePane(id string)
- func (r *Registry) Revoke(paneID, agentID string)
- func (r *Registry) SystemInput(paneID string, fn func() error) error
- func (r *Registry) TakeBack(paneID string)
- func (r *Registry) Use(paneID, agentID string, write bool, fn func() error) error
- func (r *Registry) UserInput(paneID string, fn func() error) (string, error)
- func (r *Registry) WatchRead(paneID, agentID string) (<-chan struct{}, error)
Constants ¶
This section is empty.
Variables ¶
var ErrDenied = errors.New("terminal access denied")
Functions ¶
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is the MyGo terminal's Conn. Input from the terminal view and input from an Agent meet at the same lock before either reaches the PTY.
func NewConnection ¶
func NewConnection(registry *Registry, pane string, source io.ReadWriteCloser, onTakeover func(string)) (*Connection, error)
func (*Connection) AgentWrite ¶
func (c *Connection) AgentWrite(agent string, b []byte) (int, error)
AgentWrite must be called only after the tool's execution and host-control gates approve this exact input. Registry.Use rechecks the current lease.
func (*Connection) AgentWriteChecked ¶
AgentWriteChecked performs an additional live-policy check while the pane's input lease is held, directly before writing to the underlying PTY.
func (*Connection) Barrier ¶
func (c *Connection) Barrier(ctx context.Context, send func([]byte)) error
Barrier enqueues an unguessable marker into MyGo's input queue and consumes it here, never forwarding it to the PTY. A timed-out marker remains reserved until it arrives, so it cannot later leak into the person's shell.
func (*Connection) Close ¶
func (c *Connection) Close() error
func (*Connection) Observe ¶
func (c *Connection) Observe(after uint64) (uint64, bool, <-chan struct{})
Observe returns an event only when there is no newer output yet.
func (*Connection) Resize ¶
func (c *Connection) Resize(cols, rows int) error
func (*Connection) Revision ¶
func (c *Connection) Revision() (uint64, bool)
Revision and Wait provide event-driven output observation without polling. The caller must authorize reading before and after waiting.
func (*Connection) SetViewLocked ¶
func (c *Connection) SetViewLocked(locked bool)
SetViewLocked is set only after the UI disabled local input and Barrier drained already-queued keystrokes. The terminal can still emit protocol replies while locked; those must not steal an Agent's control lease.
func (*Connection) ViewLocked ¶
func (c *Connection) ViewLocked() bool
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process owns a cross-platform PTY and its child. It is intentionally separate from the terminal emulator, so local and authorized Agent writes go through Connection instead of being queued independently by MyGo.
func StartProcess ¶
func StartProcess(o ProcessOptions) (*Process, error)
StartProcess starts exactly argv in a PTY; it does not authorize a command or create a sandbox. Agent callers must supply a previously authorized envelope.
type ProcessOptions ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is owned by one GUI process. Agent and pane IDs must be unique for their lifetime and never reused after removal.
func (*Registry) Access ¶
Access reports an agent's current rights without exposing the identities of other readers. Callers still have to use Use immediately before an action.
func (*Registry) AddAgentPane ¶
AddAgentPane atomically validates the creator and, for a split, its current write lease on the exact parent. A created pane starts with that Agent's read and write access; no later focus or project switch can change its owner.
func (*Registry) Grant ¶
Grant is an operator action. Write access is exclusive: transfer must be explicitly approved when a different agent already holds it. Read and write are independent so granting input does not silently expose past output.
func (*Registry) MarkExited ¶
MarkExited revokes input while retaining explicit readers and the creator's ability to close its finished pane. It does not remove the displayed output.
func (*Registry) RemoveAgent ¶
func (*Registry) RemoveAgentPane ¶
RemoveAgentPane atomically checks the exact live writer before removing the pane. Closing its underlying process happens after the registry lock releases.
func (*Registry) RemovePane ¶
func (*Registry) SystemInput ¶
SystemInput serializes terminal-protocol replies while the view is locked to an Agent. The caller must ensure local user input is disabled first.
func (*Registry) TakeBack ¶
TakeBack revokes whichever Agent currently has write control without changing separately granted read access.
func (*Registry) Use ¶
Use serializes input and rechecks authority immediately before fn. Revocation stops future input; a write already dispatched may finish. The state mutex is not held during a potentially blocking PTY write, so the UI can revoke it.