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