Expand description
par-term-acp: Agent Communication Protocol (ACP) implementation.
This crate provides the core ACP protocol implementation for communicating with AI coding agents (Claude Code, Codex CLI, Gemini CLI, etc.) via JSON-RPC.
§Architecture
The crate is organized into several modules:
agent- Agent lifecycle management (spawn, handshake, message routing dispatch)agents- Agent discovery and configuration loadingmessage_handler- Background async task that routes incoming JSON-RPC messages to the UIprotocol- ACP message types (initialize, session, permission, etc.)jsonrpc- JSON-RPC 2.0 client implementationfs_ops- Low-level filesystem operations (read, write, list, find)fs_tools- RPC handler functions forfs/*tool calls from the agentpermissions- Permission request dispatch, auto-approval logic,SafePaths, andis_safe_write_pathsession- Session-new parameter builders (MCP server descriptor, Claude wrapper metadata)
§Example
ⓘ
use par_term_acp::{Agent, AgentConfig, AgentMessage, SafePaths, discover_agents};
use tokio::sync::mpsc;
// Discover available agents
let agents = discover_agents(&config_dir);
let config = agents.into_iter().next().unwrap();
// Create agent manager
let (tx, mut rx) = mpsc::unbounded_channel();
let safe_paths = SafePaths {
config_dir: PathBuf::from("/path/to/config"),
shaders_dir: PathBuf::from("/path/to/shaders"),
};
let mut agent = Agent::new(config, tx, safe_paths, PathBuf::from("par-term"));
// Connect and handle messages
agent.connect("/working/dir", capabilities, &[]).await?;
while let Some(msg) = rx.recv().await {
match msg {
AgentMessage::SessionUpdate(update) => { /* handle */ }
AgentMessage::PermissionRequest { .. } => { /* handle */ }
_ => {}
}
}Re-exports§
pub use agent::Agent;pub use agent::AgentMessage;pub use agent::AgentStatus;pub use agents::AgentConfig;pub use agents::discover_agents;pub use jsonrpc::IncomingMessage;pub use jsonrpc::JsonRpcClient;pub use jsonrpc::Request;pub use jsonrpc::Response;pub use jsonrpc::RpcError;pub use permissions::SafePaths;pub use protocol::ClientCapabilities;pub use protocol::ClientInfo;pub use protocol::ContentBlock;pub use protocol::FsCapabilities;pub use protocol::FsFindParams;pub use protocol::FsListDirectoryParams;pub use protocol::FsReadParams;pub use protocol::FsWriteParams;pub use protocol::InitializeParams;pub use protocol::InitializeResult;pub use protocol::PermissionOption;pub use protocol::PermissionOutcome;pub use protocol::RequestPermissionParams;pub use protocol::RequestPermissionResponse;pub use protocol::SessionNewParams;pub use protocol::SessionPromptParams;pub use protocol::SessionResult;pub use protocol::SessionUpdate;pub use protocol::SessionUpdateParams;pub use protocol::ToolCallInfo;pub use protocol::ToolCallUpdateInfo;
Modules§
- agent
- Agent lifecycle manager for ACP (Agent Communication Protocol).
- agents
- fs_ops
- Filesystem operations for ACP agent requests.
- fs_
tools - File-system tool handlers for ACP RPC calls.
- harness
- Reusable helpers for the
par-term-acp-harnessbinary. - jsonrpc
- message_
handler - Background message handler for incoming JSON-RPC messages from the agent.
- permissions
- Permission request dispatch and approval logic for ACP.
- protocol
- ACP (Agent Communication Protocol) message type definitions.
- session
- ACP session lifecycle helpers.