Skip to main content

ShellBackend

Trait ShellBackend 

Source
pub trait ShellBackend: Send + Sync {
    // Required methods
    fn create(
        &self,
        command: String,
        cwd: PathBuf,
    ) -> BoxFuture<'_, Result<TerminalId, ShellError>>;
    fn output(
        &self,
        id: &TerminalId,
    ) -> BoxFuture<'_, Result<ShellOutput, ShellError>>;
    fn wait_for_exit(
        &self,
        id: &TerminalId,
    ) -> BoxFuture<'_, Result<TerminalExitStatus, ShellError>>;
    fn release(&self, id: &TerminalId) -> BoxFuture<'_, Result<(), ShellError>>;
    fn kill(&self, id: &TerminalId) -> BoxFuture<'_, Result<(), ShellError>>;
}
Expand description

Shell backend trait.

Current semantics: each command gets an independent terminal — create → run → wait_for_exit for the exit status → output for the full output → release to free resources. Persistent terminals reused across turns are not exposed; interactive terminal tooling is left for future evolution.

Parameters use owned String / PathBuf to confine the future’s lifetime to &'_ self, avoiding explicit lifetime parameters — the same trade-off as crate::fs::FsBackend.

Required Methods§

Source

fn create( &self, command: String, cwd: PathBuf, ) -> BoxFuture<'_, Result<TerminalId, ShellError>>

Creates a terminal and starts the command.

command is a full shell command line (currently run via sh -c on the backend). cwd must be an absolute path already validated to be inside the workspace — the agent tool layer enforces this boundary; the backend does not perform business validation.

Source

fn output( &self, id: &TerminalId, ) -> BoxFuture<'_, Result<ShellOutput, ShellError>>

Take a snapshot of the terminal’s current accumulated output.

Idempotent and safe to call repeatedly — the backend does not drain the buffer here. exit_status = Some(_) indicates the process has exited, but output itself does not block waiting for exit (use ShellBackend::wait_for_exit for blocking).

Source

fn wait_for_exit( &self, id: &TerminalId, ) -> BoxFuture<'_, Result<TerminalExitStatus, ShellError>>

Blocks until the terminal process exits.

Source

fn release(&self, id: &TerminalId) -> BoxFuture<'_, Result<(), ShellError>>

Release terminal resources (close file descriptors / remove internal bookkeeping).

Idempotent: releasing the same id multiple times does not return an error (silently succeeds if already released).

Source

fn kill(&self, id: &TerminalId) -> BoxFuture<'_, Result<(), ShellError>>

Forcefully kill the terminal process. Does not release resources — subsequent calls to ShellBackend::output / ShellBackend::wait_for_exit are still valid; releasing is handled by ShellBackend::release.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§