runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package runtime provides a backend-agnostic interface for agent session management.

Agents can run in tmux sessions (default) or Docker containers. The Backend interface abstracts the session lifecycle so the agent package doesn't need to know which runtime is in use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// HasSession checks if a session exists.
	HasSession(ctx context.Context, name string) bool
	// CreateSession creates a new session.
	CreateSession(ctx context.Context, name, dir string) error
	// CreateSessionWithCommand creates a session and runs a command.
	CreateSessionWithCommand(ctx context.Context, name, dir, command string) error
	// CreateSessionWithEnv creates a session with env vars.
	CreateSessionWithEnv(ctx context.Context, name, dir, command string, env map[string]string) error
	// KillSession kills a session.
	KillSession(ctx context.Context, name string) error
	// RenameSession renames a session.
	RenameSession(ctx context.Context, oldName, newName string) error
	// SendKeys sends keys to a session with Enter as submit key.
	SendKeys(ctx context.Context, name, keys string) error
	// SendKeysWithSubmit sends keys to a session with a specified submit key.
	SendKeysWithSubmit(ctx context.Context, name, keys, submitKey string) error
	// Capture captures session output.
	Capture(ctx context.Context, name string, lines int) (string, error)
	// ListSessions lists all sessions managed by this backend.
	ListSessions(ctx context.Context) ([]Session, error)
	// AttachCmd returns an exec.Cmd to attach to a session.
	AttachCmd(ctx context.Context, name string) *exec.Cmd
	// IsRunning checks if the backend is running.
	IsRunning(ctx context.Context) bool
	// KillServer kills all sessions.
	KillServer(ctx context.Context) error
	// SetEnvironment sets an environment variable in a session.
	SetEnvironment(ctx context.Context, name, key, value string) error
	// SessionName returns the full session name with prefix.
	SessionName(name string) string
	// PipePane starts/stops streaming session output to a log file.
	PipePane(ctx context.Context, name, logPath string) error
}

Backend abstracts session management for agents. Implementations exist for tmux (default) and Docker containers.

type Session

type Session struct {
	Name      string
	Created   string
	Directory string
	Attached  bool
}

Session represents an agent session regardless of backend.

type TmuxBackend

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

TmuxBackend wraps a tmux.Manager to implement the Backend interface.

func NewTmuxBackend

func NewTmuxBackend(mgr *tmux.Manager) *TmuxBackend

NewTmuxBackend creates a Backend backed by a tmux.Manager.

func (*TmuxBackend) AttachCmd

func (t *TmuxBackend) AttachCmd(ctx context.Context, name string) *exec.Cmd

func (*TmuxBackend) Capture

func (t *TmuxBackend) Capture(ctx context.Context, name string, lines int) (string, error)

func (*TmuxBackend) CreateSession

func (t *TmuxBackend) CreateSession(ctx context.Context, name, dir string) error

func (*TmuxBackend) CreateSessionWithCommand

func (t *TmuxBackend) CreateSessionWithCommand(ctx context.Context, name, dir, command string) error

func (*TmuxBackend) CreateSessionWithEnv

func (t *TmuxBackend) CreateSessionWithEnv(ctx context.Context, name, dir, command string, env map[string]string) error

func (*TmuxBackend) HasSession

func (t *TmuxBackend) HasSession(ctx context.Context, name string) bool

func (*TmuxBackend) IsRunning

func (t *TmuxBackend) IsRunning(ctx context.Context) bool

func (*TmuxBackend) KillServer

func (t *TmuxBackend) KillServer(ctx context.Context) error

func (*TmuxBackend) KillSession

func (t *TmuxBackend) KillSession(ctx context.Context, name string) error

func (*TmuxBackend) ListSessions

func (t *TmuxBackend) ListSessions(ctx context.Context) ([]Session, error)

func (*TmuxBackend) PipePane

func (t *TmuxBackend) PipePane(ctx context.Context, name, logPath string) error

func (*TmuxBackend) RenameSession

func (t *TmuxBackend) RenameSession(ctx context.Context, oldName, newName string) error

func (*TmuxBackend) SendKeys

func (t *TmuxBackend) SendKeys(ctx context.Context, name, keys string) error

func (*TmuxBackend) SendKeysWithSubmit

func (t *TmuxBackend) SendKeysWithSubmit(ctx context.Context, name, keys, submitKey string) error

func (*TmuxBackend) SessionName

func (t *TmuxBackend) SessionName(name string) string

func (*TmuxBackend) SetEnvironment

func (t *TmuxBackend) SetEnvironment(ctx context.Context, name, key, value string) error

func (*TmuxBackend) TmuxManager

func (t *TmuxBackend) TmuxManager() *tmux.Manager

TmuxManager returns the underlying tmux.Manager. Use this when tmux-specific operations are needed.

Jump to

Keyboard shortcuts

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