diff --git a/crates/goose-acp/Cargo.toml b/crates/goose-acp/Cargo.toml index 69be0e5af957..4f0d0c635fe7 100644 --- a/crates/goose-acp/Cargo.toml +++ b/crates/goose-acp/Cargo.toml @@ -23,7 +23,7 @@ goose = { path = "../goose" } goose-mcp = { path = "../goose-mcp" } rmcp = { workspace = true } 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 } tokio = { workspace = true } tokio-util = { workspace = true, features = ["compat", "rt"] } diff --git a/crates/goose-acp/src/custom_requests.rs b/crates/goose-acp/src/custom_requests.rs index 04025a4353fd..816d7bac9e86 100644 --- a/crates/goose-acp/src/custom_requests.rs +++ b/crates/goose-acp/src/custom_requests.rs @@ -82,12 +82,6 @@ pub struct GetSessionResponse { pub session: serde_json::Value, } -/// List all sessions. -#[derive(Debug, Serialize, JsonSchema)] -pub struct ListSessionsResponse { - pub sessions: Vec, -} - /// Delete a session. #[derive(Debug, Deserialize, JsonSchema)] pub struct DeleteSessionRequest { diff --git a/crates/goose-acp/src/server.rs b/crates/goose-acp/src/server.rs index 3f953ab6adea..22ee87005b06 100644 --- a/crates/goose-acp/src/server.rs +++ b/crates/goose-acp/src/server.rs @@ -24,10 +24,11 @@ use sacp::schema::{ AgentCapabilities, AuthMethod, AuthenticateRequest, AuthenticateResponse, BlobResourceContents, CancelNotification, Content, ContentBlock, ContentChunk, EmbeddedResource, EmbeddedResourceResource, ImageContent, InitializeRequest, InitializeResponse, - LoadSessionRequest, LoadSessionResponse, McpCapabilities, McpServer, ModelId, ModelInfo, - NewSessionRequest, NewSessionResponse, PermissionOption, PermissionOptionKind, - PromptCapabilities, PromptRequest, PromptResponse, RequestPermissionOutcome, - RequestPermissionRequest, ResourceLink, SessionId, SessionModelState, SessionNotification, + ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, McpCapabilities, McpServer, + ModelId, ModelInfo, NewSessionRequest, NewSessionResponse, PermissionOption, + PermissionOptionKind, PromptCapabilities, PromptRequest, PromptResponse, + RequestPermissionOutcome, RequestPermissionRequest, ResourceLink, SessionCapabilities, + SessionId, SessionInfo, SessionListCapabilities, SessionModelState, SessionNotification, SessionUpdate, SetSessionModelRequest, SetSessionModelResponse, StopReason, TextContent, TextResourceContents, ToolCall, ToolCallContent, ToolCallId, ToolCallLocation, ToolCallStatus, ToolCallUpdate, ToolCallUpdateFields, ToolKind, @@ -653,6 +654,7 @@ impl GooseAcpAgent { let capabilities = AgentCapabilities::new() .load_session(true) + .session_capabilities(SessionCapabilities::new().list(SessionListCapabilities::new())) .prompt_capabilities( PromptCapabilities::new() .image(true) @@ -1086,14 +1088,15 @@ impl GooseAcpAgent { .list_sessions() .await .map_err(|e| sacp::Error::internal_error().data(e.to_string()))?; - let sessions_json = sessions + let session_infos: Vec = sessions .into_iter() - .map(|s| serde_json::to_value(&s)) - .collect::, _>>() - .map_err(|e| sacp::Error::internal_error().data(e.to_string()))?; - Ok(ListSessionsResponse { - sessions: sessions_json, - }) + .map(|s| { + SessionInfo::new(SessionId::new(s.id), s.working_dir) + .title(s.name) + .updated_at(s.updated_at.to_rfc3339()) + }) + .collect(); + Ok(ListSessionsResponse::new(session_infos)) } #[custom_method("session/get")] @@ -1275,6 +1278,14 @@ impl JrMessageHandler for GooseAcpHandler { request_cx.respond(json)?; 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('_') => { match agent.handle_custom_request(&req.method, req.params).await { Ok(json) => request_cx.respond(json)?,