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
impl AcpBridge
Sourcepub async fn start(
command: String,
args: Vec<String>,
cwd: PathBuf,
) -> Result<Self>
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.
Sourcepub fn cancel_handle(&self) -> BridgeCancelHandle
pub fn cancel_handle(&self) -> BridgeCancelHandle
Obtain a lightweight cancel handle that can be used while evt_rx is
borrowed mutably.
Sourcepub async fn prompt(&self, messages: Vec<String>) -> Result<PromptResult>
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.
Sourcepub async fn send_prompt(
&self,
messages: Vec<String>,
) -> Result<Receiver<Result<PromptResult>>>
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.
Sourcepub async fn cancel(&self) -> Result<()>
pub async fn cancel(&self) -> Result<()>
Request cancellation of the current prompt (best-effort).
Sourcepub async fn set_mode(&self, mode: String) -> Result<()>
pub async fn set_mode(&self, mode: String) -> Result<()>
Set the session mode on the ACP connection.