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
2 changes: 1 addition & 1 deletion crates/goose-acp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
6 changes: 0 additions & 6 deletions crates/goose-acp/src/custom_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<serde_json::Value>,
}

/// Delete a session.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct DeleteSessionRequest {
Expand Down
33 changes: 22 additions & 11 deletions crates/goose-acp/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<SessionInfo> = sessions
.into_iter()
.map(|s| serde_json::to_value(&s))
.collect::<Result<Vec<_>, _>>()
.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")]
Expand Down Expand Up @@ -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)?,
Expand Down