pub trait RuntimeAdapter: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn has_shell_access(&self) -> bool;
fn has_filesystem_access(&self) -> bool;
fn storage_path(&self) -> PathBuf;
fn supports_long_running(&self) -> bool;
fn build_shell_command(
&self,
command: &str,
workspace_dir: &Path,
) -> Result<Command>;
// Provided method
fn memory_budget(&self) -> u64 { ... }
}Expand description
Runtime adapter that abstracts platform differences for the agent.
Implement this trait to port the agent to a new execution environment. The adapter declares platform capabilities (shell access, filesystem, long-running processes) and provides platform-specific implementations for operations like spawning shell commands. The orchestration loop queries these capabilities to adapt its behavior—for example, disabling tool execution on runtimes without shell access.
Implementations must be Send + Sync because the adapter is shared
across async tasks on the Tokio runtime.
Required Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Return the human-readable name of this runtime environment.
Used in logs and diagnostics (e.g., "native", "docker",
"cloudflare-workers").
Sourcefn has_shell_access(&self) -> bool
fn has_shell_access(&self) -> bool
Report whether this runtime supports shell command execution.
When false, the agent disables shell-based tools. Serverless and
edge runtimes typically return false.
Sourcefn has_filesystem_access(&self) -> bool
fn has_filesystem_access(&self) -> bool
Report whether this runtime supports filesystem read/write.
When false, the agent disables file-based tools and falls back to
in-memory storage.
Sourcefn storage_path(&self) -> PathBuf
fn storage_path(&self) -> PathBuf
Return the base directory for persistent storage on this runtime.
Memory backends, logs, and other artifacts are stored under this path. Implementations should return a platform-appropriate writable directory.
Sourcefn supports_long_running(&self) -> bool
fn supports_long_running(&self) -> bool
Report whether this runtime supports long-running background processes.
When true, the agent may start the gateway server, heartbeat loop,
and other persistent tasks. Serverless runtimes with short execution
limits should return false.
Sourcefn build_shell_command(
&self,
command: &str,
workspace_dir: &Path,
) -> Result<Command>
fn build_shell_command( &self, command: &str, workspace_dir: &Path, ) -> Result<Command>
Build a shell command process configured for this runtime.
Constructs a tokio::process::Command that will execute command
with workspace_dir as the working directory. Implementations may
prepend sandbox wrappers, set environment variables, or redirect
I/O as appropriate for the platform.
§Errors
Returns an error if the runtime does not support shell access or if the command cannot be constructed (e.g., missing shell binary).
Provided Methods§
Sourcefn memory_budget(&self) -> u64
fn memory_budget(&self) -> u64
Return the maximum memory budget in bytes for this runtime.
A value of 0 (the default) indicates no limit. Constrained
environments (embedded, serverless) should return their actual
memory ceiling so the agent can adapt buffer sizes and caching.