Skip to main content

AcpHostHandler

Trait AcpHostHandler 

Source
pub trait AcpHostHandler: Send + Sync {
    // Provided methods
    fn fs_read_text_file(&self, path: &str) -> Result<String, String> { ... }
    fn terminal_create(
        &self,
        _cwd: Option<&str>,
        _env: Option<&HashMap<String, String>>,
    ) -> Result<String, String> { ... }
    fn terminal_write(
        &self,
        terminal_id: &str,
        input: &str,
    ) -> Result<String, String> { ... }
    fn request_permission(
        &self,
        _tool_name: &str,
        _description: &str,
        _session_id: &str,
    ) -> Result<bool, String> { ... }
}
Expand description

Typed handler for agent → host ACP requests.

All methods have default implementations that return safe denials, so callers only need to override the operations they actually support.

Implementations must be Send + Sync because the handler is called from the reader loop’s blocking thread.

Provided Methods§

Source

fn fs_read_text_file(&self, path: &str) -> Result<String, String>

Agent wants to read a file from the host filesystem.

Return Ok(content) or Err(human-readable message).

Source

fn terminal_create( &self, _cwd: Option<&str>, _env: Option<&HashMap<String, String>>, ) -> Result<String, String>

Agent wants to create a terminal session on the host.

Return Ok(terminal_id) or Err(human-readable message).

Source

fn terminal_write( &self, terminal_id: &str, input: &str, ) -> Result<String, String>

Agent wants to write input to an existing terminal session.

Return Ok(output) or Err(human-readable message).

Source

fn request_permission( &self, _tool_name: &str, _description: &str, _session_id: &str, ) -> Result<bool, String>

Agent is requesting permission to run a tool.

Return Ok(true) to allow, Ok(false) to deny, Err for error. Default: deny all requests (safe default).

Implementors§