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
Plugin name identifier (e.g.
"tmux", "docker", "kubernetes").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
Destroy a session environment and clean up resources.Parameters:
handle- Runtime handle from create()
Send a text message/prompt to the running agent.Parameters:
handle- Runtime handlemessage- Text to send to the agent
Capture recent output from the session.Parameters:
handle- Runtime handlelines- Optional: number of recent lines to return
Check if the session environment is still alive.Parameters:
handle- Runtime handle
Optional: Get resource metrics (uptime, memory, CPU usage).Parameters:
handle- Runtime handle
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.
Unique session identifier
Absolute path to workspace directory where agent will execute
Shell command to launch the agent (from Agent.getLaunchCommand())
Environment variables for the agent process (from Agent.getEnvironment())
RuntimeHandle
create(), used for all subsequent operations.
Runtime-specific identifier (tmux session name, container ID, pod name, etc.)
Which runtime created this handle (matches Runtime.name)
Runtime-specific data (ports, connection strings, etc.)
RuntimeMetrics
How long the environment has been running (milliseconds)
Memory usage in megabytes
CPU usage percentage (0-100)
AttachInfo
How to connect:
"tmux", "docker", "ssh", "web", or "process"Connection target:
- For tmux: session name
- For docker: container ID
- For web: URL
- For SSH: host 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
