acp_utils/client/
event.rs1use crate::notifications::{
2 AuthMethodsUpdatedParams, ContextClearedParams, GitDiffEventPayload, McpNotification, SubAgentProgressParams,
3};
4use agent_client_protocol::Responder;
5use agent_client_protocol::schema::v2::{
6 CreateElicitationRequest, CreateElicitationResponse, ElicitationScope, SessionId, UpdateSessionNotification,
7};
8
9pub enum AcpEvent {
11 SessionUpdate(Box<UpdateSessionNotification>),
12 ContextCleared(ContextClearedParams),
13 SubAgentProgress(SubAgentProgressParams),
14 AuthMethodsUpdated(AuthMethodsUpdatedParams),
15 McpNotification(McpNotification),
16 GitDiffEvent(GitDiffEventPayload),
17 ElicitationRequest { params: Box<CreateElicitationRequest>, responder: Responder<CreateElicitationResponse> },
18 ConnectionClosed,
19}
20
21impl AcpEvent {
22 pub fn session_id(&self) -> Option<&SessionId> {
23 match self {
24 Self::SessionUpdate(notification) => Some(¬ification.session_id),
25 Self::ContextCleared(params) => Some(¶ms.session_id),
26 Self::SubAgentProgress(params) => Some(¶ms.session_id),
27 Self::GitDiffEvent(params) => Some(¶ms.session_id),
28 Self::ElicitationRequest { params, .. } => match params.scope() {
29 ElicitationScope::Session(scope) => Some(&scope.session_id),
30 _ => None,
31 },
32 Self::AuthMethodsUpdated(_) | Self::McpNotification(_) | Self::ConnectionClosed => None,
33 }
34 }
35}
36
37impl From<UpdateSessionNotification> for AcpEvent {
38 fn from(notification: UpdateSessionNotification) -> Self {
39 Self::SessionUpdate(Box::new(notification))
40 }
41}