Skip to main content

AcpBridge

Struct AcpBridge 

Source
pub struct AcpBridge {
    pub evt_rx: UnboundedReceiver<BridgeEvent>,
    /* private fields */
}
Expand description

Core bridge that manages the ACP agent process lifecycle.

Spawns the agent in a dedicated blocking thread with a LocalSet (required because ACP futures are !Send), and exposes an async command/event API for the main thread to drive prompts and receive streamed output.

Fields§

§evt_rx: UnboundedReceiver<BridgeEvent>

Implementations§

Source§

impl AcpBridge

Source

pub async fn start( command: String, args: Vec<String>, cwd: PathBuf, ) -> Result<Self>

Start the ACP bridge by spawning the agent process in a background thread.

The agent is launched via command with the given args, and the working directory for the ACP session is set to cwd.

Source

pub fn cancel_handle(&self) -> BridgeCancelHandle

Obtain a lightweight cancel handle that can be used while evt_rx is borrowed mutably.

Source

pub async fn prompt(&self, messages: Vec<String>) -> Result<PromptResult>

Send a prompt to the agent and wait for the result.

Text content is streamed in real-time via BridgeEvent::TextChunk events on evt_rx. The returned PromptResult.content will be empty because the main thread is expected to collect content from those events.

Source

pub async fn send_prompt( &self, messages: Vec<String>, ) -> Result<Receiver<Result<PromptResult>>>

Send a prompt command without awaiting the reply.

Returns a oneshot receiver that will resolve when the prompt completes. This allows the caller to drive evt_rx concurrently with waiting for the prompt result, avoiding borrow conflicts on self.

Source

pub async fn cancel(&self) -> Result<()>

Request cancellation of the current prompt (best-effort).

Source

pub async fn set_mode(&self, mode: String) -> Result<()>

Set the session mode on the ACP connection.

Source

pub async fn set_config(&self, key: String, value: String) -> Result<()>

Set a session config option on the ACP connection.

Source

pub async fn shutdown(self) -> Result<()>

Gracefully shut down the bridge, killing the agent process and joining the background thread.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoMaybeUndefined<T> for T

Source§

impl<T> IntoOption<T> for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.