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
10 changes: 5 additions & 5 deletions rust/acp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Agent for ClientSideConnection {
Some(ClientRequest::AuthenticateRequest(args)),
)
.await
.map(|value| value.unwrap_or_default())
.map(Option::unwrap_or_default)
}

async fn new_session(&self, args: NewSessionRequest) -> Result<NewSessionResponse, Error> {
Expand All @@ -203,7 +203,7 @@ impl Agent for ClientSideConnection {
Some(ClientRequest::LoadSessionRequest(args)),
)
.await
.map(|value| value.unwrap_or_default())
.map(Option::unwrap_or_default)
}

async fn set_session_mode(
Expand Down Expand Up @@ -466,7 +466,7 @@ impl Client for AgentSideConnection {
Some(AgentRequest::WriteTextFileRequest(args)),
)
.await
.map(|value| value.unwrap_or_default())
.map(Option::unwrap_or_default)
}

async fn read_text_file(
Expand Down Expand Up @@ -515,7 +515,7 @@ impl Client for AgentSideConnection {
Some(AgentRequest::ReleaseTerminalRequest(args)),
)
.await
.map(|value| value.unwrap_or_default())
.map(Option::unwrap_or_default)
}

async fn wait_for_terminal_exit(
Expand All @@ -540,7 +540,7 @@ impl Client for AgentSideConnection {
Some(AgentRequest::KillTerminalCommandRequest(args)),
)
.await
.map(|value| value.unwrap_or_default())
.map(Option::unwrap_or_default)
}

async fn session_notification(&self, args: SessionNotification) -> Result<(), Error> {
Expand Down
2 changes: 1 addition & 1 deletion rust/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ pub enum ClientRequest {
/// This enum is used internally for routing RPC responses. You typically won't need
/// to use this directly - the responses are handled automatically by the connection.
///
/// These are responses to the corresponding ClientRequest variants.
/// These are responses to the corresponding `ClientRequest` variants.
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
#[schemars(extend("x-docs-ignore" = true))]
Expand Down
6 changes: 3 additions & 3 deletions rust/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub enum SessionUpdate {
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct AvailableCommand {
/// Command name (e.g., "create_plan", "research_codebase").
/// Command name (e.g., `create_plan`, `research_codebase`).
pub name: String,
/// Human-readable description of what the command does.
pub description: String,
Expand Down Expand Up @@ -359,7 +359,7 @@ pub struct WriteTextFileRequest {
pub meta: Option<serde_json::Value>,
}

/// Response to fs/write_text_file
/// Response to `fs/write_text_file`
#[derive(Default, Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[schemars(extend("x-side" = "client", "x-method" = FS_WRITE_TEXT_FILE_METHOD_NAME))]
Expand Down Expand Up @@ -706,7 +706,7 @@ pub enum AgentRequest {
/// This enum is used internally for routing RPC responses. You typically won't need
/// to use this directly - the responses are handled automatically by the connection.
///
/// These are responses to the corresponding AgentRequest variants.
/// These are responses to the corresponding `AgentRequest` variants.
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
#[schemars(extend("x-docs-ignore" = true))]
Expand Down
11 changes: 9 additions & 2 deletions rust/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//!
//! See: [Error Handling](https://agentclientprotocol.com/protocol/overview#error-handling)

use std::{fmt::Display, ops::Deref as _};
use std::fmt::Display;

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -52,37 +52,44 @@ impl Error {
///
/// This method is chainable and allows attaching context-specific information
/// to help with debugging or provide more details about the error.
#[must_use]
pub fn with_data(mut self, data: impl Into<serde_json::Value>) -> Self {
self.data = Some(data.into());
self
}

/// Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.
#[must_use]
pub fn parse_error() -> Self {
Error::new(ErrorCode::PARSE_ERROR)
}

/// The JSON sent is not a valid Request object.
#[must_use]
pub fn invalid_request() -> Self {
Error::new(ErrorCode::INVALID_REQUEST)
}

/// The method does not exist / is not available.
#[must_use]
pub fn method_not_found() -> Self {
Error::new(ErrorCode::METHOD_NOT_FOUND)
}

/// Invalid method parameter(s).
#[must_use]
pub fn invalid_params() -> Self {
Error::new(ErrorCode::INVALID_PARAMS)
}

/// Internal JSON-RPC error.
#[must_use]
pub fn internal_error() -> Self {
Error::new(ErrorCode::INTERNAL_ERROR)
}

/// Authentication required.
#[must_use]
pub fn auth_required() -> Self {
Error::new(ErrorCode::AUTH_REQUIRED)
}
Expand Down Expand Up @@ -181,7 +188,7 @@ impl Display for Error {

impl From<anyhow::Error> for Error {
fn from(error: anyhow::Error) -> Self {
Error::into_internal_error(error.deref())
Error::into_internal_error(&*error)
}
}

Expand Down
6 changes: 3 additions & 3 deletions rust/example_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::cell::Cell;

use agent_client_protocol::{
self as acp, AuthenticateResponse, Client, ExtNotification, ExtRequest, ExtResponse,
SessionNotification,
SessionNotification, SetSessionModeResponse,
};
use serde_json::json;
use tokio::sync::{mpsc, oneshot};
Expand Down Expand Up @@ -58,7 +58,7 @@ impl acp::Agent for ExampleAgent {
arguments: acp::AuthenticateRequest,
) -> Result<AuthenticateResponse, acp::Error> {
log::info!("Received authenticate request {arguments:?}");
Ok(Default::default())
Ok(AuthenticateResponse::default())
}

async fn new_session(
Expand Down Expand Up @@ -121,7 +121,7 @@ impl acp::Agent for ExampleAgent {
args: acp::SetSessionModeRequest,
) -> Result<acp::SetSessionModeResponse, acp::Error> {
log::info!("Received set session mode request {args:?}");
Ok(Default::default())
Ok(SetSessionModeResponse::default())
}

async fn ext_method(&self, args: ExtRequest) -> Result<ExtResponse, acp::Error> {
Expand Down
Loading