Skip to main content

Overview

The Runtime interface defines how and where agent sessions execute. Runtimes provide isolated execution environments and handle process lifecycle, I/O, and resource management. Plugin Slot: runtime
Default Plugin: tmux

Interface Definition

Methods

string
required
Plugin name identifier (e.g. "tmux", "docker", "kubernetes").
(config: RuntimeCreateConfig) => Promise<RuntimeHandle>
required
Create a new session environment and return a handle for communication.Parameters:
  • config.sessionId - Unique session identifier
  • config.workspacePath - Path to workspace directory
  • config.launchCommand - Shell command to launch the agent
  • config.environment - Environment variables for the agent process
Returns: RuntimeHandle for the created environment
(handle: RuntimeHandle) => Promise<void>
required
Destroy a session environment and clean up resources.Parameters:
  • handle - Runtime handle from create()
(handle: RuntimeHandle, message: string) => Promise<void>
required
Send a text message/prompt to the running agent.Parameters:
  • handle - Runtime handle
  • message - Text to send to the agent
(handle: RuntimeHandle, lines?: number) => Promise<string>
required
Capture recent output from the session.Parameters:
  • handle - Runtime handle
  • lines - Optional: number of recent lines to return
Returns: String containing session output
(handle: RuntimeHandle) => Promise<boolean>
required
Check if the session environment is still alive.Parameters:
  • handle - Runtime handle
Returns: true if environment is running, false otherwise
(handle: RuntimeHandle) => Promise<RuntimeMetrics>
Optional: Get resource metrics (uptime, memory, CPU usage).Parameters:
  • handle - Runtime handle
Returns: RuntimeMetrics with resource usage data
(handle: RuntimeHandle) => Promise<AttachInfo>
Optional: Get info needed to attach a human to this session (for Terminal plugin).Parameters:
  • handle - Runtime handle
Returns: AttachInfo with connection details

RuntimeCreateConfig

Configuration passed to create() when spawning a new runtime environment.
SessionId
required
Unique session identifier
string
required
Absolute path to workspace directory where agent will execute
string
required
Shell command to launch the agent (from Agent.getLaunchCommand())
Record<string, string>
required
Environment variables for the agent process (from Agent.getEnvironment())

RuntimeHandle

Opaque handle returned by create(), used for all subsequent operations.
string
required
Runtime-specific identifier (tmux session name, container ID, pod name, etc.)
string
required
Which runtime created this handle (matches Runtime.name)
Record<string, unknown>
required
Runtime-specific data (ports, connection strings, etc.)

RuntimeMetrics

number
required
How long the environment has been running (milliseconds)
number
Memory usage in megabytes
number
CPU usage percentage (0-100)

AttachInfo

string
required
How to connect: "tmux", "docker", "ssh", "web", or "process"
string
required
Connection target:
  • For tmux: session name
  • For docker: container ID
  • For web: URL
  • For SSH: host string
string
Optional command to run to attach (e.g. tmux attach -t session-name)

Usage Examples

Implementing a Runtime Plugin

Using Runtime in Session Manager

Implementation Notes

Security Considerations

  • Always use execFile instead of exec to prevent shell injection
  • Validate all handle IDs before using in shell commands
  • Set timeouts on all external command executions
  • Sanitize environment variables to prevent code injection

Error Handling

  • Throw errors if runtime operations fail (creation, destruction, messaging)
  • Return false from isAlive() for dead environments (don’t throw)
  • Handle network errors gracefully for remote runtimes (docker, k8s, SSH)

Built-in Plugins

  • tmux - Local tmux sessions (default)
  • process - Direct Node.js child processes
Future plugins could support Docker, Kubernetes, AWS ECS, SSH remote hosts, cloud sandboxes, etc.

See Also

  • Agent - Agent plugin interface
  • Session - Session interface
  • Terminal - Terminal UI plugin interface