Overview
TheRuntime interface defines how and where agent sessions execute. Runtimes provide isolated execution environments and handle process lifecycle, I/O, and resource management.
Plugin Slot: runtimeDefault 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 identifierconfig.workspacePath- Path to workspace directoryconfig.launchCommand- Shell command to launch the agentconfig.environment- Environment variables for the agent process
(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 handlemessage- Text to send to the agent
(handle: RuntimeHandle, lines?: number) => Promise<string>
required
Capture recent output from the session.Parameters:
handle- Runtime handlelines- Optional: number of recent lines to return
(handle: RuntimeHandle) => Promise<boolean>
required
Check if the session environment is still alive.Parameters:
handle- Runtime handle
(handle: RuntimeHandle) => Promise<RuntimeMetrics>
Optional: Get resource metrics (uptime, memory, CPU usage).Parameters:
handle- Runtime handle
(handle: RuntimeHandle) => Promise<AttachInfo>
Optional: Get info needed to attach a human to this session (for Terminal plugin).Parameters:
handle- Runtime handle
Related Types
RuntimeCreateConfig
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
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
execFileinstead ofexecto 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
falsefromisAlive()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
