pub struct AcpClientV2 { /* private fields */ }Expand description
ACP Client V2 with full protocol compliance
This client implements the complete ACP session lifecycle:
initialize()- Negotiate protocol version and capabilitiesauthenticate()- Optional authentication (if required by agent)session_new()- Create a new conversation sessionsession_prompt()- Send prompts and receive responsessession_cancel()- Cancel ongoing operations
Streaming updates are delivered via SSE and can be subscribed to
using subscribe_updates().
Implementations§
Source§impl AcpClientV2
impl AcpClientV2
Sourcepub fn new(base_url: impl Into<String>) -> AcpResult<Self>
pub fn new(base_url: impl Into<String>) -> AcpResult<Self>
Create a new client with default settings
Sourcepub async fn is_initialized(&self) -> bool
pub async fn is_initialized(&self) -> bool
Check if client has been initialized
Sourcepub async fn protocol_version(&self) -> Option<String>
pub async fn protocol_version(&self) -> Option<String>
Get negotiated protocol version
Sourcepub async fn agent_capabilities(&self) -> Option<AgentCapabilities>
pub async fn agent_capabilities(&self) -> Option<AgentCapabilities>
Get agent capabilities (after initialization)
Sourcepub async fn initialize(&self) -> AcpResult<InitializeResult>
pub async fn initialize(&self) -> AcpResult<InitializeResult>
Initialize the connection with the agent
This must be called before any other method. It negotiates:
- Protocol version
- Client and agent capabilities
- Authentication requirements
Sourcepub async fn authenticate(
&self,
params: AuthenticateParams,
) -> AcpResult<AuthenticateResult>
pub async fn authenticate( &self, params: AuthenticateParams, ) -> AcpResult<AuthenticateResult>
Authenticate with the agent (if required)
Sourcepub async fn session_new(
&self,
params: SessionNewParams,
) -> AcpResult<SessionNewResult>
pub async fn session_new( &self, params: SessionNewParams, ) -> AcpResult<SessionNewResult>
Create a new session
Sourcepub async fn session_load(
&self,
session_id: &str,
) -> AcpResult<SessionLoadResult>
pub async fn session_load( &self, session_id: &str, ) -> AcpResult<SessionLoadResult>
Load an existing session
Sourcepub async fn session_prompt(
&self,
params: SessionPromptParams,
) -> AcpResult<SessionPromptResult>
pub async fn session_prompt( &self, params: SessionPromptParams, ) -> AcpResult<SessionPromptResult>
Send a prompt to the session
Returns the turn result. For streaming responses, use subscribe_updates()
before calling this method.
Sourcepub async fn session_prompt_with_timeout(
&self,
params: SessionPromptParams,
timeout: Option<Duration>,
) -> AcpResult<SessionPromptResult>
pub async fn session_prompt_with_timeout( &self, params: SessionPromptParams, timeout: Option<Duration>, ) -> AcpResult<SessionPromptResult>
Send a prompt with a custom timeout
Sourcepub async fn session_cancel(
&self,
session_id: &str,
turn_id: Option<&str>,
) -> AcpResult<()>
pub async fn session_cancel( &self, session_id: &str, turn_id: Option<&str>, ) -> AcpResult<()>
Cancel an ongoing operation
Sourcepub async fn get_session(&self, session_id: &str) -> Option<AcpSession>
pub async fn get_session(&self, session_id: &str) -> Option<AcpSession>
Get a session by ID
Sourcepub async fn list_sessions(&self) -> Vec<AcpSession>
pub async fn list_sessions(&self) -> Vec<AcpSession>
List all active sessions
Sourcepub async fn subscribe_updates(
&self,
session_id: &str,
) -> AcpResult<Receiver<SessionUpdateNotification>>
pub async fn subscribe_updates( &self, session_id: &str, ) -> AcpResult<Receiver<SessionUpdateNotification>>
Subscribe to session updates via Server-Sent Events
Returns a receiver channel that will receive update notifications. The connection will remain open until the receiver is dropped.