fix(acp): Use ACP schema types for session/list (#7409)

Signed-off-by: rabi <ramishra@redhat.com>
This commit is contained in:
Rabi Mishra
2026-02-27 01:08:05 +05:30
committed by GitHub
parent 2f643091b7
commit 7240341974
3 changed files with 23 additions and 18 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ goose = { path = "../goose" }
goose-mcp = { path = "../goose-mcp" } goose-mcp = { path = "../goose-mcp" }
rmcp = { workspace = true } rmcp = { workspace = true }
sacp = "10.1.0" sacp = "10.1.0"
agent-client-protocol-schema = { version = "0.10", features = ["unstable_session_model"] } agent-client-protocol-schema = { version = "0.10", features = ["unstable_session_model", "unstable_session_list"] }
anyhow = { workspace = true } anyhow = { workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
tokio-util = { workspace = true, features = ["compat", "rt"] } tokio-util = { workspace = true, features = ["compat", "rt"] }
-6
View File
@@ -82,12 +82,6 @@ pub struct GetSessionResponse {
pub session: serde_json::Value, pub session: serde_json::Value,
} }
/// List all sessions.
#[derive(Debug, Serialize, JsonSchema)]
pub struct ListSessionsResponse {
pub sessions: Vec<serde_json::Value>,
}
/// Delete a session. /// Delete a session.
#[derive(Debug, Deserialize, JsonSchema)] #[derive(Debug, Deserialize, JsonSchema)]
pub struct DeleteSessionRequest { pub struct DeleteSessionRequest {
+22 -11
View File
@@ -24,10 +24,11 @@ use sacp::schema::{
AgentCapabilities, AuthMethod, AuthenticateRequest, AuthenticateResponse, BlobResourceContents, AgentCapabilities, AuthMethod, AuthenticateRequest, AuthenticateResponse, BlobResourceContents,
CancelNotification, Content, ContentBlock, ContentChunk, EmbeddedResource, CancelNotification, Content, ContentBlock, ContentChunk, EmbeddedResource,
EmbeddedResourceResource, ImageContent, InitializeRequest, InitializeResponse, EmbeddedResourceResource, ImageContent, InitializeRequest, InitializeResponse,
LoadSessionRequest, LoadSessionResponse, McpCapabilities, McpServer, ModelId, ModelInfo, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, McpCapabilities, McpServer,
NewSessionRequest, NewSessionResponse, PermissionOption, PermissionOptionKind, ModelId, ModelInfo, NewSessionRequest, NewSessionResponse, PermissionOption,
PromptCapabilities, PromptRequest, PromptResponse, RequestPermissionOutcome, PermissionOptionKind, PromptCapabilities, PromptRequest, PromptResponse,
RequestPermissionRequest, ResourceLink, SessionId, SessionModelState, SessionNotification, RequestPermissionOutcome, RequestPermissionRequest, ResourceLink, SessionCapabilities,
SessionId, SessionInfo, SessionListCapabilities, SessionModelState, SessionNotification,
SessionUpdate, SetSessionModelRequest, SetSessionModelResponse, StopReason, TextContent, SessionUpdate, SetSessionModelRequest, SetSessionModelResponse, StopReason, TextContent,
TextResourceContents, ToolCall, ToolCallContent, ToolCallId, ToolCallLocation, ToolCallStatus, TextResourceContents, ToolCall, ToolCallContent, ToolCallId, ToolCallLocation, ToolCallStatus,
ToolCallUpdate, ToolCallUpdateFields, ToolKind, ToolCallUpdate, ToolCallUpdateFields, ToolKind,
@@ -664,6 +665,7 @@ impl GooseAcpAgent {
let capabilities = AgentCapabilities::new() let capabilities = AgentCapabilities::new()
.load_session(true) .load_session(true)
.session_capabilities(SessionCapabilities::new().list(SessionListCapabilities::new()))
.prompt_capabilities( .prompt_capabilities(
PromptCapabilities::new() PromptCapabilities::new()
.image(true) .image(true)
@@ -1097,14 +1099,15 @@ impl GooseAcpAgent {
.list_sessions() .list_sessions()
.await .await
.map_err(|e| sacp::Error::internal_error().data(e.to_string()))?; .map_err(|e| sacp::Error::internal_error().data(e.to_string()))?;
let sessions_json = sessions let session_infos: Vec<SessionInfo> = sessions
.into_iter() .into_iter()
.map(|s| serde_json::to_value(&s)) .map(|s| {
.collect::<Result<Vec<_>, _>>() SessionInfo::new(SessionId::new(s.id), s.working_dir)
.map_err(|e| sacp::Error::internal_error().data(e.to_string()))?; .title(s.name)
Ok(ListSessionsResponse { .updated_at(s.updated_at.to_rfc3339())
sessions: sessions_json, })
}) .collect();
Ok(ListSessionsResponse::new(session_infos))
} }
#[custom_method("session/get")] #[custom_method("session/get")]
@@ -1286,6 +1289,14 @@ impl JrMessageHandler for GooseAcpHandler {
request_cx.respond(json)?; request_cx.respond(json)?;
Ok(()) Ok(())
} }
MessageCx::Request(req, request_cx) if req.method == "session/list" => {
let resp = agent.on_list_sessions().await?;
let json = serde_json::to_value(resp).map_err(|e| {
sacp::Error::internal_error().data(e.to_string())
})?;
request_cx.respond(json)?;
Ok(())
}
MessageCx::Request(req, request_cx) if req.method.starts_with('_') => { MessageCx::Request(req, request_cx) if req.method.starts_with('_') => {
match agent.handle_custom_request(&req.method, req.params).await { match agent.handle_custom_request(&req.method, req.params).await {
Ok(json) => request_cx.respond(json)?, Ok(json) => request_cx.respond(json)?,