Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 63 additions & 64 deletions agent-client-protocol-schema/src/v2/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ use super::{
pub struct InitializeRequest {
/// The latest protocol version supported by the client.
pub protocol_version: ProtocolVersion,
/// Information about the implementation sending this initialize request.
pub info: Implementation,
/// Capabilities supported by the client.
#[serde_as(deserialize_as = "DefaultOnError")]
#[schemars(extend("x-deserialize-default-on-error" = true))]
#[serde(default)]
pub capabilities: ClientCapabilities,
/// Information about the implementation sending this initialize request.
pub info: Implementation,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
Expand Down Expand Up @@ -124,6 +124,8 @@ pub struct InitializeResponse {
///
/// The client should disconnect, if it doesn't support this version.
pub protocol_version: ProtocolVersion,
/// Information about the implementation sending this initialize response.
pub info: Implementation,
/// Capabilities supported by the agent.
#[serde_as(deserialize_as = "DefaultOnError")]
#[schemars(extend("x-deserialize-default-on-error" = true))]
Expand All @@ -134,8 +136,6 @@ pub struct InitializeResponse {
#[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))]
#[serde(default)]
pub auth_methods: Vec<AuthMethod>,
/// Information about the implementation sending this initialize response.
pub info: Implementation,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
Expand Down Expand Up @@ -1231,10 +1231,8 @@ impl NewSessionResponse {
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct LoadSessionRequest {
/// List of MCP servers to connect to for this session.
#[serde_as(deserialize_as = "DefaultOnError<VecSkipError<_, SkipListener>>")]
#[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))]
pub mcp_servers: Vec<McpServer>,
/// The ID of the session to load.
pub session_id: SessionId,
/// The working directory for this session.
pub cwd: PathBuf,
/// Additional workspace roots to activate for this session. Each path must be absolute.
Expand All @@ -1247,8 +1245,10 @@ pub struct LoadSessionRequest {
#[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub additional_directories: Vec<PathBuf>,
/// The ID of the session to load.
pub session_id: SessionId,
/// List of MCP servers to connect to for this session.
#[serde_as(deserialize_as = "DefaultOnError<VecSkipError<_, SkipListener>>")]
#[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))]
pub mcp_servers: Vec<McpServer>,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
Expand Down Expand Up @@ -3902,7 +3902,7 @@ pub struct AgentCapabilities {
#[serde_as(deserialize_as = "DefaultOnError")]
#[schemars(extend("x-deserialize-default-on-error" = true))]
#[serde(default)]
pub auth: AgentAuthCapabilities,
pub auth: Option<AgentAuthCapabilities>,
/// **UNSTABLE**
///
/// This capability is not part of the spec yet, and may be removed or changed at any point.
Expand Down Expand Up @@ -3968,8 +3968,8 @@ impl AgentCapabilities {

/// Authentication-related capabilities supported by the agent.
#[must_use]
pub fn auth(mut self, auth: AgentAuthCapabilities) -> Self {
self.auth = auth;
pub fn auth(mut self, auth: impl IntoOption<AgentAuthCapabilities>) -> Self {
self.auth = auth.into_option();
self
}

Expand Down Expand Up @@ -4804,10 +4804,10 @@ pub struct McpCapabilities {
/// This capability is not part of the spec yet, and may be removed or changed at any point.
///
/// Agent supports [`McpServer::Acp`].
#[cfg(feature = "unstable_mcp_over_acp")]
///
/// Optional. Omitted or `null` both mean the agent does not advertise support.
/// Supplying `{}` means the agent supports ACP MCP server transports.
#[cfg(feature = "unstable_mcp_over_acp")]
#[serde_as(deserialize_as = "DefaultOnError")]
#[schemars(extend("x-deserialize-default-on-error" = true))]
#[serde(default)]
Expand Down Expand Up @@ -5001,6 +5001,52 @@ impl McpAcpCapabilities {
}
}

/// Notification to cancel ongoing operations for a session.
///
/// See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-lifecycle#cancellation)
#[serde_as]
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[schemars(extend("x-side" = "agent", "x-method" = SESSION_CANCEL_METHOD_NAME))]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct CancelSessionNotification {
/// The ID of the session to cancel operations for.
pub session_id: SessionId,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
///
/// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
#[serde_as(deserialize_as = "DefaultOnError")]
#[schemars(extend("x-deserialize-default-on-error" = true))]
#[serde(default)]
#[serde(rename = "_meta")]
pub meta: Option<Meta>,
}

impl CancelSessionNotification {
/// Builds [`CancelSessionNotification`] with the required notification fields set; optional fields start unset or empty.
#[must_use]
pub fn new(session_id: impl Into<SessionId>) -> Self {
Self {
session_id: session_id.into(),
meta: None,
}
}

/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
///
/// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
#[must_use]
pub fn meta(mut self, meta: impl IntoOption<Meta>) -> Self {
self.meta = meta.into_option();
self
}
}

// Method schema

/// Names of all methods that agents handle.
Expand Down Expand Up @@ -5458,7 +5504,7 @@ pub enum ClientNotification {
/// cancellation succeeds
///
/// See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-lifecycle#cancellation)
CancelNotification(CancelNotification),
CancelSessionNotification(CancelSessionNotification),
#[cfg(feature = "unstable_nes")]
/// **UNSTABLE**
///
Expand Down Expand Up @@ -5515,7 +5561,7 @@ impl ClientNotification {
#[must_use]
pub fn method(&self) -> &str {
match self {
Self::CancelNotification(_) => AGENT_METHOD_NAMES.session_cancel,
Self::CancelSessionNotification(_) => AGENT_METHOD_NAMES.session_cancel,
#[cfg(feature = "unstable_nes")]
Self::DidOpenDocumentNotification(_) => AGENT_METHOD_NAMES.document_did_open,
#[cfg(feature = "unstable_nes")]
Expand All @@ -5537,52 +5583,6 @@ impl ClientNotification {
}
}

/// Notification to cancel ongoing operations for a session.
///
/// See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-lifecycle#cancellation)
#[serde_as]
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[schemars(extend("x-side" = "agent", "x-method" = SESSION_CANCEL_METHOD_NAME))]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct CancelNotification {
/// The ID of the session to cancel operations for.
pub session_id: SessionId,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
///
/// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
#[serde_as(deserialize_as = "DefaultOnError")]
#[schemars(extend("x-deserialize-default-on-error" = true))]
#[serde(default)]
#[serde(rename = "_meta")]
pub meta: Option<Meta>,
}

impl CancelNotification {
/// Builds [`CancelNotification`] with the required notification fields set; optional fields start unset or empty.
#[must_use]
pub fn new(session_id: impl Into<SessionId>) -> Self {
Self {
session_id: session_id.into(),
meta: None,
}
}

/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
///
/// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
#[must_use]
pub fn meta(mut self, meta: impl IntoOption<Meta>) -> Self {
self.meta = meta.into_option();
self
}
}

#[cfg(test)]
mod test_serialization {
use super::*;
Expand Down Expand Up @@ -5633,7 +5633,7 @@ mod test_serialization {
.unwrap();

assert!(capabilities.session.is_none());
assert_eq!(capabilities.auth, AgentAuthCapabilities::default());
assert_eq!(capabilities.auth, None);
}

#[test]
Expand Down Expand Up @@ -6923,7 +6923,6 @@ mod test_serialization {
assert_eq!(
serde_json::to_value(&caps).unwrap(),
json!({
"auth": {},
"session": {
"prompt": {
"image": {}
Expand Down
14 changes: 7 additions & 7 deletions agent-client-protocol-schema/src/v2/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4767,7 +4767,7 @@ impl IntoV1 for super::AgentCapabilities {
prompt_capabilities,
mcp_capabilities,
session_capabilities,
auth: auth.into_v1()?,
auth: auth.map(IntoV1::into_v1).transpose()?.unwrap_or_default(),
#[cfg(feature = "unstable_llm_providers")]
providers: into_v1_default_on_error(providers),
#[cfg(feature = "unstable_nes")]
Expand Down Expand Up @@ -4806,7 +4806,7 @@ impl IntoV2 for crate::v1::AgentCapabilities {

Ok(super::AgentCapabilities {
session: Some(session),
auth: auth.into_v2()?,
auth: Some(auth.into_v2()?),
#[cfg(feature = "unstable_llm_providers")]
providers: into_v2_default_on_error(providers),
#[cfg(feature = "unstable_nes")]
Expand Down Expand Up @@ -5458,7 +5458,7 @@ impl IntoV1 for super::ClientNotification {

fn into_v1(self) -> Result<Self::Output> {
Ok(match self {
Self::CancelNotification(value) => {
Self::CancelSessionNotification(value) => {
crate::v1::ClientNotification::CancelNotification(value.into_v1()?)
}
#[cfg(feature = "unstable_nes")]
Expand Down Expand Up @@ -5506,7 +5506,7 @@ impl IntoV2 for crate::v1::ClientNotification {
fn into_v2(self) -> Result<Self::Output> {
Ok(match self {
Self::CancelNotification(value) => {
super::ClientNotification::CancelNotification(value.into_v2()?)
super::ClientNotification::CancelSessionNotification(value.into_v2()?)
}
#[cfg(feature = "unstable_nes")]
Self::DidOpenDocumentNotification(value) => {
Expand Down Expand Up @@ -5547,7 +5547,7 @@ impl IntoV2 for crate::v1::ClientNotification {
}
}

impl IntoV1 for super::CancelNotification {
impl IntoV1 for super::CancelSessionNotification {
type Output = crate::v1::CancelNotification;

fn into_v1(self) -> Result<Self::Output> {
Expand All @@ -5560,11 +5560,11 @@ impl IntoV1 for super::CancelNotification {
}

impl IntoV2 for crate::v1::CancelNotification {
type Output = super::CancelNotification;
type Output = super::CancelSessionNotification;

fn into_v2(self) -> Result<Self::Output> {
let Self { session_id, meta } = self;
Ok(super::CancelNotification {
Ok(super::CancelSessionNotification {
session_id: session_id.into_v2()?,
meta: meta.into_v2()?,
})
Expand Down
9 changes: 3 additions & 6 deletions docs/protocol/v2/draft/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/d
<ResponseField name="capabilities" type={<a href="#agentcapabilities">AgentCapabilities</a>} >
Capabilities supported by the agent.

- Default: `{"auth":{}}`
- Default: `{}`

</ResponseField>
<ResponseField name="info" type={<a href="#implementation">Implementation</a>} required>
Expand Down Expand Up @@ -894,7 +894,7 @@ Upon receiving this notification, the Agent SHOULD:

See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/v2/draft/prompt-lifecycle#cancellation)

#### <span class="font-mono">CancelNotification</span>
#### <span class="font-mono">CancelSessionNotification</span>

Notification to cancel ongoing operations for a session.

Expand Down Expand Up @@ -2130,11 +2130,8 @@ these keys.
See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/draft/extensibility)

</ResponseField>
<ResponseField name="auth" type={<a href="#agentauthcapabilities">AgentAuthCapabilities</a>} >
<ResponseField name="auth" type={<><span><a href="#agentauthcapabilities">AgentAuthCapabilities</a></span><span> | null</span></>} >
Authentication-related capabilities supported by the agent.

- Default: `{}`

</ResponseField>
<ResponseField name="nes" type={<><span><a href="#nescapabilities">NesCapabilities</a></span><span> | null</span></>} >
**UNSTABLE**
Expand Down
9 changes: 3 additions & 6 deletions docs/protocol/v2/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/e
<ResponseField name="capabilities" type={<a href="#agentcapabilities">AgentCapabilities</a>} >
Capabilities supported by the agent.

- Default: `{"auth":{}}`
- Default: `{}`

</ResponseField>
<ResponseField name="info" type={<a href="#implementation">Implementation</a>} required>
Expand Down Expand Up @@ -221,7 +221,7 @@ Upon receiving this notification, the Agent SHOULD:

See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/v2/prompt-lifecycle#cancellation)

#### <span class="font-mono">CancelNotification</span>
#### <span class="font-mono">CancelSessionNotification</span>

Notification to cancel ongoing operations for a session.

Expand Down Expand Up @@ -904,11 +904,8 @@ these keys.
See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility)

</ResponseField>
<ResponseField name="auth" type={<a href="#agentauthcapabilities">AgentAuthCapabilities</a>} >
<ResponseField name="auth" type={<><span><a href="#agentauthcapabilities">AgentAuthCapabilities</a></span><span> | null</span></>} >
Authentication-related capabilities supported by the agent.

- Default: `{}`

</ResponseField>
<ResponseField name="session" type={<><span><a href="#sessioncapabilities">SessionCapabilities</a></span><span> | null</span></>} >
Session capabilities supported by the agent.
Expand Down
6 changes: 5 additions & 1 deletion schema-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,11 @@ starting with '$/' it is free to ignore the notification."
self.agent.get("SetSessionConfigOptionRequest").unwrap()
}
"session/prompt" => self.agent.get("PromptRequest").unwrap(),
"session/cancel" => self.agent.get("CancelNotification").unwrap(),
"session/cancel" => self
.agent
.get("CancelSessionNotification")
.or_else(|| self.agent.get("CancelNotification"))
.unwrap(),
"session/close" => self.agent.get("CloseSessionRequest").unwrap(),
"logout" => self.agent.get("LogoutRequest").unwrap(),
"auth/logout" => self.agent.get("LogoutAuthRequest").unwrap(),
Expand Down
Loading