Skip to main content

agent_client_protocol_schema/v2/
mod.rs

1//! Agent Client Protocol version 2 draft types.
2//!
3//! **EXPERIMENTAL.** This module is gated behind the `unstable_protocol_v2`
4//! feature, is not part of the [`unstable`] umbrella, and is **not**
5//! advertised by [`crate::ProtocolVersion::LATEST`]. The wire format is
6//! currently identical to v1 (the default crate-root types) and the types
7//! here exist only as a place to evolve v2 without disturbing the stable v1
8//! API. The wire format intentionally diverges from v1 as draft v2 RFDs land.
9//! Both the type definitions and the [`conversion`] helpers may change at any
10//! time.
11//!
12//! [`unstable`]: https://docs.rs/crate/agent-client-protocol-schema/latest/features
13
14mod agent;
15mod client;
16mod content;
17pub mod conversion;
18#[cfg(feature = "unstable_elicitation")]
19mod elicitation;
20mod error;
21mod ext;
22#[cfg(feature = "unstable_mcp_over_acp")]
23mod mcp;
24#[cfg(feature = "unstable_nes")]
25mod nes;
26mod plan;
27#[cfg(feature = "unstable_cancel_request")]
28mod protocol_level;
29pub(crate) mod schema_util;
30mod tool_call;
31
32pub use crate::rpc::{JsonRpcBatch, JsonRpcMessage, Notification, Request, RequestId};
33pub use agent::*;
34pub use client::*;
35pub use content::*;
36use derive_more::{Display, From};
37#[cfg(feature = "unstable_elicitation")]
38pub use elicitation::*;
39pub use error::*;
40pub use ext::*;
41#[cfg(feature = "unstable_mcp_over_acp")]
42pub use mcp::*;
43#[cfg(feature = "unstable_nes")]
44pub use nes::*;
45pub use plan::*;
46#[cfg(feature = "unstable_cancel_request")]
47pub use protocol_level::*;
48pub use serde_json::value::RawValue;
49pub use tool_call::*;
50
51pub type Response<Result> = crate::rpc::Response<Result, Error>;
52
53use schemars::JsonSchema;
54use serde::{Deserialize, Serialize};
55use std::sync::Arc;
56
57/// A unique identifier for a conversation session between a client and agent.
58///
59/// Sessions maintain their own context, conversation history, and state,
60/// allowing multiple independent interactions with the same agent.
61///
62/// See protocol docs: [Session ID](https://agentclientprotocol.com/protocol/session-setup#session-id)
63#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Hash, Display, From)]
64#[serde(transparent)]
65#[from(Arc<str>, String, &'static str)]
66#[non_exhaustive]
67pub struct SessionId(pub Arc<str>);
68
69impl SessionId {
70    #[must_use]
71    pub fn new(id: impl Into<Arc<str>>) -> Self {
72        Self(id.into())
73    }
74}