Skip to content

Commit 6ffca65

Browse files
authored
feat(rust-only): Remove unused RPC message schema types (schema.json unchanged) (#1009)
* feat(rust-only): Remove unused RPC message schema types (schema unchanged) These were items that mostly moved to the SDK anyway, and are more of an SDK concern, not a schema one. This simplifies the schema generation with less generic message wrappers and side decoding types, instead using explicit agent/client request, response, and notification enums in schema generation. The schema itself is completely unchanged, it is a Rust only change. * Update agents.md
1 parent 6f5465a commit 6ffca65

File tree

3 files changed

+69
-617
lines changed

3 files changed

+69
-617
lines changed

AGENTS.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ All paths in the protocol should be absolute
1919

2020
- Add constants for the method names
2121
- Add variants to {Agent|Client}{Request|Response} enums
22-
- Handle the new method in the `Side::decode_request`/`Side::decode_notification` implementation
2322
- Add the method to markdown_generator.rs SideDocs functions
2423
- Run `npm run generate` and fix any issues that appear
2524
- Run `npm run check`

src/bin/generate.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use agent_client_protocol_schema::{
2-
AGENT_METHOD_NAMES, AgentSide, CLIENT_METHOD_NAMES, ClientSide, JsonRpcMessage,
3-
OutgoingMessage, ProtocolVersion,
2+
AGENT_METHOD_NAMES, AgentNotification, AgentRequest, AgentResponse, CLIENT_METHOD_NAMES,
3+
ClientNotification, ClientRequest, ClientResponse, JsonRpcMessage, Notification,
4+
ProtocolVersion, Request, Response,
45
};
56
#[cfg(feature = "unstable_cancel_request")]
67
use agent_client_protocol_schema::{PROTOCOL_LEVEL_METHOD_NAMES, ProtocolLevelNotification};
@@ -9,28 +10,41 @@ use schemars::{
910
generate::SchemaSettings,
1011
transform::{RemoveRefSiblings, ReplaceBoolSchemas},
1112
};
13+
use serde::{Deserialize, Serialize};
1214
use std::{env, fs, path::Path};
1315

1416
use markdown_generator::MarkdownGenerator;
1517

16-
#[expect(dead_code)]
17-
#[derive(JsonSchema)]
18+
/// All messages that an agent can send to a client.
19+
#[derive(Serialize, Deserialize, JsonSchema)]
20+
#[serde(untagged)]
1821
#[schemars(inline)]
19-
struct AgentOutgoingMessage(JsonRpcMessage<OutgoingMessage<AgentSide, ClientSide>>);
22+
#[allow(clippy::large_enum_variant)]
23+
enum AgentOutgoingMessage {
24+
Request(Request<AgentRequest>),
25+
Response(Response<AgentResponse>),
26+
Notification(Notification<AgentNotification>),
27+
}
2028

21-
#[expect(dead_code)]
22-
#[derive(JsonSchema)]
29+
/// All messages that a client can send to an agent.
30+
#[derive(Serialize, Deserialize, JsonSchema)]
31+
#[serde(untagged)]
2332
#[schemars(inline)]
24-
struct ClientOutgoingMessage(JsonRpcMessage<OutgoingMessage<ClientSide, AgentSide>>);
33+
#[allow(clippy::large_enum_variant)]
34+
enum ClientOutgoingMessage {
35+
Request(Request<ClientRequest>),
36+
Response(Response<ClientResponse>),
37+
Notification(Notification<ClientNotification>),
38+
}
2539

2640
#[expect(dead_code)]
2741
#[derive(JsonSchema)]
2842
#[serde(untagged)]
2943
#[schemars(title = "Agent Client Protocol")]
3044
#[allow(clippy::large_enum_variant)]
3145
enum AcpTypes {
32-
Agent(AgentOutgoingMessage),
33-
Client(ClientOutgoingMessage),
46+
Agent(JsonRpcMessage<AgentOutgoingMessage>),
47+
Client(JsonRpcMessage<ClientOutgoingMessage>),
3448
#[cfg(feature = "unstable_cancel_request")]
3549
ProtocolLevel(ProtocolLevelNotification),
3650
}

0 commit comments

Comments
 (0)