agent_client_protocol_schema/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! [](https://agentclientprotocol.com/)
4//!
5//! # Agent Client Protocol Schema
6//!
7//! Strongly-typed Rust definitions of the Agent Client Protocol (ACP) wire
8//! format. ACP is a JSON-RPC based protocol that standardizes communication
9//! between code editors (IDEs, text-editors, etc.) and coding agents
10//! (programs that use generative AI to autonomously modify code).
11//!
12//! This crate is **only** the schema: the request, response, and
13//! notification types, plus serde plumbing and JSON Schema generation. For
14//! the runtime pieces (transport, connection setup, the `Agent` / `Client`
15//! traits, etc.) use the higher-level [`agent-client-protocol`] crate, which
16//! builds on top of these types.
17//!
18//! [`agent-client-protocol`]: https://crates.io/crates/agent-client-protocol
19//!
20//! ## What's in this crate
21//!
22//! - Wire-format types for every ACP method: request, response, and
23//! notification structs grouped by which side handles them.
24//! - JSON-RPC envelope and routing types: [`JsonRpcMessage`],
25//! [`rpc::JsonRpcBatch`], [`Request`], [`Response`], [`Notification`],
26//! [`RequestId`], [`Error`].
27//! - Aggregated routing enums: [`AgentRequest`], [`AgentResponse`],
28//! [`AgentNotification`], and the matching client-side trio used by SDK
29//! crates to dispatch incoming JSON-RPC messages.
30//!
31//! ## Versioning
32//!
33//! The default surface re-exports the v1 (current stable) protocol types
34//! directly at the crate root, so most consumers can write
35//! `agent_client_protocol_schema::SessionId` (and so on) without thinking
36//! about versions.
37//!
38//! For the complete protocol specification and documentation, visit
39//! <https://agentclientprotocol.com>.
40
41pub mod rpc;
42mod serde_util;
43mod v1;
44#[cfg(feature = "unstable_protocol_v2")]
45pub mod v2;
46mod version;
47
48pub use serde_util::*;
49pub use v1::*;
50pub use version::*;
51
52#[cfg(test)]
53mod serde_json_feature_tests {
54 use serde_json::Value;
55
56 #[test]
57 fn serde_json_values_preserve_object_key_order() {
58 let Value::Object(object) =
59 serde_json::from_str::<Value>(r#"{"z":1,"a":2,"m":3}"#).unwrap()
60 else {
61 panic!("expected JSON object");
62 };
63
64 let keys = object.keys().map(String::as_str).collect::<Vec<_>>();
65 assert_eq!(keys, ["z", "a", "m"]);
66 }
67}