vtcode_acp_client/
lib.rs

1//! ACP (Agent Communication Protocol) client for inter-agent communication
2//!
3//! This module provides:
4//! - HTTP-based communication with remote agents
5//! - Agent discovery (online and offline)
6//! - Request/response message handling
7//! - Async-first design with optional sync support
8
9pub mod client;
10pub mod discovery;
11pub mod error;
12pub mod messages;
13
14pub use client::{AcpClient, AcpClientBuilder};
15pub use discovery::{AgentInfo, AgentRegistry};
16pub use error::{AcpError, AcpResult};
17pub use messages::{AcpMessage, AcpRequest, AcpResponse};
18
19use agent_client_protocol::AgentSideConnection;
20use std::sync::{Arc, OnceLock};
21
22static ACP_CONNECTION: OnceLock<Arc<AgentSideConnection>> = OnceLock::new();
23
24/// Register the global ACP connection from the host protocol.
25///
26/// Returns `Err` with the provided connection if one has already been
27/// registered. Callers may drop the returned connection or reuse it as needed.
28pub fn register_acp_connection(
29    connection: Arc<AgentSideConnection>,
30) -> Result<(), Arc<AgentSideConnection>> {
31    ACP_CONNECTION.set(connection)
32}
33
34/// Retrieve the registered ACP connection, if available.
35pub fn acp_connection() -> Option<Arc<AgentSideConnection>> {
36    ACP_CONNECTION.get().cloned()
37}