@@ -8,6 +8,7 @@ use std::{path::PathBuf, sync::Arc};
88use derive_more:: { Display , From } ;
99use schemars:: JsonSchema ;
1010use serde:: { Deserialize , Serialize } ;
11+ use serde_with:: { DefaultOnError , VecSkipError , serde_as} ;
1112
1213#[ cfg( feature = "unstable_elicitation" ) ]
1314use crate :: elicitation:: {
@@ -152,11 +153,13 @@ impl CurrentModeUpdate {
152153}
153154
154155/// Session configuration options have been updated.
156+ #[ serde_as]
155157#[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema , PartialEq , Eq ) ]
156158#[ serde( rename_all = "camelCase" ) ]
157159#[ non_exhaustive]
158160pub struct ConfigOptionUpdate {
159161 /// The full set of configuration options and their current values.
162+ #[ serde_as( deserialize_as = "VecSkipError<_>" ) ]
160163 pub config_options : Vec < SessionConfigOption > ,
161164 /// The _meta property is reserved by ACP to allow clients and agents to attach additional
162165 /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
@@ -249,6 +252,7 @@ impl SessionInfoUpdate {
249252///
250253/// Context window and cost update for a session.
251254#[ cfg( feature = "unstable_session_usage" ) ]
255+ #[ serde_as]
252256#[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema , PartialEq ) ]
253257#[ serde( rename_all = "camelCase" ) ]
254258#[ non_exhaustive]
@@ -258,7 +262,8 @@ pub struct UsageUpdate {
258262 /// Total context window size in tokens.
259263 pub size : u64 ,
260264 /// Cumulative session cost (optional).
261- #[ serde( skip_serializing_if = "Option::is_none" ) ]
265+ #[ serde_as( deserialize_as = "DefaultOnError" ) ]
266+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
262267 pub cost : Option < Cost > ,
263268 /// The _meta property is reserved by ACP to allow clients and agents to attach additional
264269 /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
@@ -395,11 +400,13 @@ impl ContentChunk {
395400}
396401
397402/// Available commands are ready or have changed
403+ #[ serde_as]
398404#[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema , PartialEq , Eq ) ]
399405#[ serde( rename_all = "camelCase" ) ]
400406#[ non_exhaustive]
401407pub struct AvailableCommandsUpdate {
402408 /// Commands the agent can execute
409+ #[ serde_as( deserialize_as = "VecSkipError<_>" ) ]
403410 pub available_commands : Vec < AvailableCommand > ,
404411 /// The _meta property is reserved by ACP to allow clients and agents to attach additional
405412 /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
@@ -432,6 +439,7 @@ impl AvailableCommandsUpdate {
432439}
433440
434441/// Information about a command.
442+ #[ serde_as]
435443#[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema , PartialEq , Eq ) ]
436444#[ serde( rename_all = "camelCase" ) ]
437445#[ non_exhaustive]
@@ -441,6 +449,8 @@ pub struct AvailableCommand {
441449 /// Human-readable description of what the command does.
442450 pub description : String ,
443451 /// Input for the command if required
452+ #[ serde_as( deserialize_as = "DefaultOnError" ) ]
453+ #[ serde( default ) ]
444454 pub input : Option < AvailableCommandInput > ,
445455 /// The _meta property is reserved by ACP to allow clients and agents to attach additional
446456 /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
@@ -1473,6 +1483,7 @@ impl TerminalExitStatus {
14731483/// available features and methods.
14741484///
14751485/// See protocol docs: [Client Capabilities](https://agentclientprotocol.com/protocol/initialization#client-capabilities)
1486+ #[ serde_as]
14761487#[ derive( Default , Debug , Clone , Serialize , Deserialize , JsonSchema , PartialEq , Eq ) ]
14771488#[ serde( rename_all = "camelCase" ) ]
14781489#[ non_exhaustive]
@@ -1501,6 +1512,7 @@ pub struct ClientCapabilities {
15011512 /// Elicitation capabilities supported by the client.
15021513 /// Determines which elicitation modes the agent may use.
15031514 #[ cfg( feature = "unstable_elicitation" ) ]
1515+ #[ serde_as( deserialize_as = "DefaultOnError" ) ]
15041516 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
15051517 pub elicitation : Option < ElicitationCapabilities > ,
15061518 /// **UNSTABLE**
@@ -1509,14 +1521,16 @@ pub struct ClientCapabilities {
15091521 ///
15101522 /// NES (Next Edit Suggestions) capabilities supported by the client.
15111523 #[ cfg( feature = "unstable_nes" ) ]
1512- #[ serde( skip_serializing_if = "Option::is_none" ) ]
1524+ #[ serde_as( deserialize_as = "DefaultOnError" ) ]
1525+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
15131526 pub nes : Option < ClientNesCapabilities > ,
15141527 /// **UNSTABLE**
15151528 ///
15161529 /// This capability is not part of the spec yet, and may be removed or changed at any point.
15171530 ///
15181531 /// The position encodings supported by the client, in order of preference.
15191532 #[ cfg( feature = "unstable_nes" ) ]
1533+ #[ serde_as( deserialize_as = "VecSkipError<_>" ) ]
15201534 #[ serde( default , skip_serializing_if = "Vec::is_empty" ) ]
15211535 pub position_encodings : Vec < PositionEncodingKind > ,
15221536
0 commit comments