Skip to content

Commit 54394f3

Browse files
authored
Update to agent-client-protocol-schema v0.8.0 (#17)
1 parent e8bda82 commit 54394f3

File tree

20 files changed

+116
-97
lines changed

20 files changed

+116
-97
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tokio = { version = "1.48", features = ["full"] }
2727
tokio-util = { version = "0.7", features = ["compat"] }
2828

2929
# Protocol
30-
agent-client-protocol-schema = "0.7.0"
30+
agent-client-protocol-schema = { version = "0.8.0" }
3131

3232
# Serialization
3333
serde = { version = "1.0", features = ["derive", "rc"] }

examples/migration/agent_legacy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl Agent for MyAgent {
3232

3333
async fn new_session(&self, _args: NewSessionRequest) -> Result<NewSessionResponse> {
3434
eprintln!("[{}] Creating session", self.name);
35-
Ok(NewSessionResponse::new("session-1".into()))
35+
Ok(NewSessionResponse::new("session-1"))
3636
}
3737

3838
async fn prompt(&self, _args: PromptRequest) -> Result<PromptResponse> {

examples/migration/agent_sacp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async fn main() -> Result<(), sacp::Error> {
2525
// ANCHOR: handler_new_session
2626
.on_receive_request(async move |_req: NewSessionRequest, cx| {
2727
eprintln!("[{}] Creating session", agent_name);
28-
cx.respond(NewSessionResponse::new("session-1".into()))
28+
cx.respond(NewSessionResponse::new("session-1"))
2929
})
3030
// ANCHOR_END: handler_new_session
3131
// ANCHOR: handler_prompt

examples/migration/agent_with_callbacks_sacp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async fn main() -> Result<(), sacp::Error> {
1818
cx.respond(InitializeResponse::new(req.protocol_version))
1919
})
2020
.on_receive_request(async move |_req: NewSessionRequest, cx| {
21-
cx.respond(NewSessionResponse::new("session-1".into()))
21+
cx.respond(NewSessionResponse::new("session-1"))
2222
})
2323
// ANCHOR: blocking_risk
2424
.on_receive_request(async move |_req: PromptRequest, cx| {

examples/migration/client_legacy.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use agent_client_protocol::{
66
Agent, Client, ClientSideConnection, CreateTerminalRequest, CreateTerminalResponse, Error,
77
ExtNotification, ExtRequest, ExtResponse, InitializeRequest, KillTerminalCommandRequest,
8-
KillTerminalCommandResponse, NewSessionRequest, PromptRequest, ReadTextFileRequest,
9-
ReadTextFileResponse, ReleaseTerminalRequest, ReleaseTerminalResponse,
8+
KillTerminalCommandResponse, NewSessionRequest, PromptRequest, ProtocolVersion,
9+
ReadTextFileRequest, ReadTextFileResponse, ReleaseTerminalRequest, ReleaseTerminalResponse,
1010
RequestPermissionRequest, RequestPermissionResponse, Result, SessionNotification,
11-
TerminalOutputRequest, TerminalOutputResponse, V1, WaitForTerminalExitRequest,
11+
TerminalOutputRequest, TerminalOutputResponse, WaitForTerminalExitRequest,
1212
WaitForTerminalExitResponse, WriteTextFileRequest, WriteTextFileResponse,
1313
};
1414
use futures::FutureExt;
@@ -125,7 +125,9 @@ async fn main() -> Result<()> {
125125
// Now we can send requests using the connection
126126
// ANCHOR: send_requests
127127
// Initialize the agent
128-
let init_response = connection.initialize(InitializeRequest::new(V1)).await?;
128+
let init_response = connection
129+
.initialize(InitializeRequest::new(ProtocolVersion::LATEST))
130+
.await?;
129131

130132
eprintln!("Agent initialized: {:?}", init_response.agent_info);
131133

examples/migration/client_sacp.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
//!
33
//! This example shows how to connect to an agent and send requests using the handler chain API.
44
5+
use agent_client_protocol::ProtocolVersion;
56
use sacp::JrHandlerChain;
67
use sacp::schema::{
78
InitializeRequest, NewSessionRequest, PromptRequest, ReadTextFileRequest,
8-
RequestPermissionRequest, SessionNotification, VERSION, WriteTextFileRequest,
9+
RequestPermissionRequest, SessionNotification, WriteTextFileRequest,
910
};
1011
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};
1112

@@ -48,7 +49,7 @@ async fn main() -> Result<(), sacp::Error> {
4849
// ANCHOR: send_requests
4950
// Initialize the agent
5051
let init_response = cx
51-
.send_request(InitializeRequest::new(VERSION))
52+
.send_request(InitializeRequest::new(ProtocolVersion::LATEST))
5253
.block_task()
5354
.await?;
5455

src/agent-client-protocol/src/agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub trait Agent {
133133
///
134134
/// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
135135
async fn ext_method(&self, _args: ExtRequest) -> Result<ExtResponse> {
136-
Ok(RawValue::NULL.to_owned().into())
136+
Ok(ExtResponse::new(RawValue::NULL.to_owned().into()))
137137
}
138138

139139
/// Handles extension notifications from the client.

src/agent-client-protocol/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub trait Client {
155155
///
156156
/// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
157157
async fn ext_method(&self, _args: ExtRequest) -> Result<ExtResponse> {
158-
Ok(RawValue::NULL.to_owned().into())
158+
Ok(ExtResponse::new(RawValue::NULL.to_owned().into()))
159159
}
160160

161161
/// Handles extension notifications from the agent.

src/agent-client-protocol/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl Side for ClientSide {
222222
if let Some(custom_method) = method.strip_prefix('_') {
223223
Ok(AgentRequest::ExtMethodRequest(ExtRequest::new(
224224
custom_method,
225-
params.to_owned(),
225+
params.to_owned().into(),
226226
)))
227227
} else {
228228
Err(Error::method_not_found())
@@ -242,7 +242,7 @@ impl Side for ClientSide {
242242
if let Some(custom_method) = method.strip_prefix('_') {
243243
Ok(AgentNotification::ExtNotification(ExtNotification::new(
244244
custom_method,
245-
RawValue::from_string(params.get().to_string())?,
245+
RawValue::from_string(params.get().to_string())?.into(),
246246
)))
247247
} else {
248248
Err(Error::method_not_found())
@@ -525,7 +525,7 @@ impl Side for AgentSide {
525525
if let Some(custom_method) = method.strip_prefix('_') {
526526
Ok(ClientRequest::ExtMethodRequest(ExtRequest::new(
527527
custom_method,
528-
params.to_owned(),
528+
params.to_owned().into(),
529529
)))
530530
} else {
531531
Err(Error::method_not_found())
@@ -545,7 +545,7 @@ impl Side for AgentSide {
545545
if let Some(custom_method) = method.strip_prefix('_') {
546546
Ok(ClientNotification::ExtNotification(ExtNotification::new(
547547
custom_method,
548-
RawValue::from_string(params.get().to_string())?,
548+
RawValue::from_string(params.get().to_string())?.into(),
549549
)))
550550
} else {
551551
Err(Error::method_not_found())

0 commit comments

Comments
 (0)