pub struct Connection { /* private fields */ }Expand description
Owned ACP JSON-RPC 2.0 stdio client with strict FIFO stdout reader barrier.
Implementations§
Source§impl Connection
impl Connection
pub fn new( agent_name: impl Into<String>, auth_hint: impl Into<String>, stdout: ChildStdout, stdin: ChildStdin, hide_always_options: bool, known_secrets: Vec<String>, ) -> Self
pub fn connection_id(&self) -> u64
pub fn capabilities(&self) -> Option<&AgentCapabilities>
pub async fn initialize(&mut self) -> Result<Initialized, Problem>
pub async fn session_new( &mut self, cwd: &Path, mcp_servers: &[McpServer], system_append: Option<&str>, ) -> Result<OpenedSession, Problem>
Sourcepub async fn session_load(
&mut self,
remote_session_id: &str,
cwd: &Path,
mcp_servers: &[McpServer],
) -> Result<OpenedSession, Problem>
pub async fn session_load( &mut self, remote_session_id: &str, cwd: &Path, mcp_servers: &[McpServer], ) -> Result<OpenedSession, Problem>
Call session/load with replay suppression bound to (connection_id, load_request_id, remote_session_id).
pub async fn set_config_option( &mut self, session_id: &str, config_id: &str, value: &str, ) -> Result<Vec<ConfigOption>, Problem>
pub async fn set_legacy_model( &mut self, session_id: &str, model_id: &str, ) -> Result<(), Problem>
pub async fn set_legacy_mode( &mut self, session_id: &str, mode_id: &str, ) -> Result<Option<String>, Problem>
Sourcepub async fn apply_config_options(
&mut self,
session: &OpenedSession,
requested: &[ConfigSelection],
) -> Result<AppliedConfig, Problem>
pub async fn apply_config_options( &mut self, session: &OpenedSession, requested: &[ConfigSelection], ) -> Result<AppliedConfig, Problem>
Apply user-selected configOptions in dependency order:
model -> refresh live options -> mode -> thought_level -> rest.
Falls back with a Notice only when a previously saved model or thought_level
disappeared from the live list; aborts with Problem::ModeMismatch if a user-selected
mode is missing or mismatched (never silently downgrades approval level).
Sourcepub async fn inspect_models(
&mut self,
cwd: &Path,
) -> Result<(Vec<ListedModel>, Vec<ConfigOption>), Problem>
pub async fn inspect_models( &mut self, cwd: &Path, ) -> Result<(Vec<ListedModel>, Vec<ConfigOption>), Problem>
Inspect advertised models (and per-model thought levels when supported) for probes/CLI.
pub async fn logout(&mut self) -> Result<(), Problem>
pub async fn start_prompt( &mut self, session_id: &str, text: &str, ) -> Result<u64, Problem>
Sourcepub async fn next_prompt_frame(
&mut self,
prompt_request_id: u64,
session_id: &str,
) -> Result<PromptFrame, Problem>
pub async fn next_prompt_frame( &mut self, prompt_request_id: u64, session_id: &str, ) -> Result<PromptFrame, Problem>
Receive the next FIFO frame while a prompt is active. Automatically answers unknown
server requests with -32601 so the caller only sees updates, permissions, and prompt end.
Sourcepub async fn send_permission_selected(
&mut self,
rpc_id: RpcId,
option_id: &str,
) -> Result<(), Problem>
pub async fn send_permission_selected( &mut self, rpc_id: RpcId, option_id: &str, ) -> Result<(), Problem>
Send ACP session/request_permission selected outcome on the wire.
Sourcepub async fn send_permission_cancelled(
&mut self,
rpc_id: RpcId,
) -> Result<(), Problem>
pub async fn send_permission_cancelled( &mut self, rpc_id: RpcId, ) -> Result<(), Problem>
Send ACP session/request_permission cancelled outcome per ACP v1 spec.
Sourcepub async fn send_cancel(&mut self, session_id: &str)
pub async fn send_cancel(&mut self, session_id: &str)
Send session/cancel notification with bounded write timeout.
Sourcepub async fn drain_after_cancel(
&mut self,
prompt_request_id: u64,
session_id: &str,
) -> bool
pub async fn drain_after_cancel( &mut self, prompt_request_id: u64, session_id: &str, ) -> bool
Drain stdout up to PROMPT_CANCEL_GRACE after session/cancel so a warm child can
return to quiescence with StopReason::Cancelled instead of needing process termination.