clawdesk-acp
Implementation of the Agent Communication Protocol (ACP) for inter-agent communication. Enables ClawDesk agents to communicate with external agents and services using a standardized protocol.
Dependencies
Internal: clawdesk-types, clawdesk-domain
External: reqwest, tokio, serde, tracing, thiserror, async-trait
Modules
| Module | Description |
|---|---|
client | ACP client for sending messages to external agents |
server | ACP server endpoint handling incoming agent requests |
protocol | Wire protocol types and serialization |
discovery | Agent discovery via ACP directory |
auth | ACP authentication and authorization |
Key Types
/// ACP message envelope
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AcpMessage {
pub id: String,
pub from: AgentId,
pub to: AgentId,
pub content: AcpContent,
pub timestamp: chrono::DateTime<chrono::Utc>,
pub metadata: HashMap<String, serde_json::Value>,
}
/// Agent identifier in the ACP network
#[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq)]
pub struct AgentId {
pub name: String,
pub endpoint: String,
}
/// ACP content types
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AcpContent {
TextMessage(String),
TaskRequest(TaskRequest),
TaskResponse(TaskResponse),
StatusUpdate(StatusUpdate),
}
/// ACP client for inter-agent communication
pub struct AcpClient {
client: reqwest::Client,
agent_id: AgentId,
}
impl AcpClient {
pub async fn send(&self, to: &AgentId, content: AcpContent) -> Result<AcpMessage, AcpError> {
// ...
}
pub async fn discover(&self, directory_url: &str) -> Result<Vec<AgentId>, AcpError> {
// ...
}
}
/// ACP server for receiving messages
pub struct AcpServer {
handler: Box<dyn AcpHandler>,
agent_id: AgentId,
}
#[async_trait]
pub trait AcpHandler: Send + Sync {
async fn handle(&self, message: AcpMessage) -> Result<AcpMessage, AcpError>;
}
Example Usage
use clawdesk_acp::{AcpClient, AcpContent, AgentId};
let client = AcpClient::new(AgentId {
name: "clawdesk-main".into(),
endpoint: "http://localhost:1420/acp".into(),
});
// Send a task to another agent
let response = client.send(
&AgentId {
name: "research-agent".into(),
endpoint: "http://research:8080/acp".into(),
},
AcpContent::TaskRequest(TaskRequest {
task: "Summarize the latest Rust release notes".into(),
context: Default::default(),
}),
).await?;
info
ACP enables building multi-agent workflows where specialized agents collaborate on complex tasks.