@@ -45,48 +45,46 @@ struct ElicitationDefaultsClientHandler;
4545impl ClientHandler for ElicitationDefaultsClientHandler {
4646 fn get_info ( & self ) -> ClientInfo {
4747 let mut info = ClientInfo :: default ( ) ;
48- info. capabilities . elicitation = Some ( ElicitationCapability {
49- form : Some ( FormElicitationCapability {
50- schema_validation : Some ( true ) ,
51- } ) ,
52- url : None ,
53- } ) ;
48+ info. capabilities . elicitation = Some (
49+ ElicitationCapability :: new ( )
50+ . with_form ( FormElicitationCapability :: new ( ) . with_schema_validation ( true ) ) ,
51+ ) ;
5452 info
5553 }
5654
5755 async fn create_elicitation (
5856 & self ,
59- request : CreateElicitationRequestParams ,
57+ request : ElicitRequestParams ,
6058 _cx : RequestContext < RoleClient > ,
61- ) -> Result < CreateElicitationResult , ErrorData > {
59+ ) -> Result < ElicitResult , ErrorData > {
6260 let content = match & request {
63- CreateElicitationRequestParams :: FormElicitationParams {
61+ ElicitRequestParams :: FormElicitationParams {
6462 requested_schema, ..
6563 } => {
6664 let mut defaults = serde_json:: Map :: new ( ) ;
6765 for ( name, prop) in & requested_schema. properties {
6866 match prop {
69- PrimitiveSchema :: String ( s) => {
67+ PrimitiveSchemaDefinition :: String ( s) => {
7068 if let Some ( d) = & s. default {
7169 defaults. insert ( name. clone ( ) , Value :: String ( d. clone ( ) ) ) ;
7270 }
7371 }
74- PrimitiveSchema :: Number ( n) => {
72+ PrimitiveSchemaDefinition :: Number ( n) => {
7573 if let Some ( d) = n. default {
7674 defaults. insert ( name. clone ( ) , json ! ( d) ) ;
7775 }
7876 }
79- PrimitiveSchema :: Integer ( i) => {
77+ PrimitiveSchemaDefinition :: Integer ( i) => {
8078 if let Some ( d) = i. default {
8179 defaults. insert ( name. clone ( ) , json ! ( d) ) ;
8280 }
8381 }
84- PrimitiveSchema :: Boolean ( b) => {
82+ PrimitiveSchemaDefinition :: Boolean ( b) => {
8583 if let Some ( d) = b. default {
8684 defaults. insert ( name. clone ( ) , Value :: Bool ( d) ) ;
8785 }
8886 }
89- PrimitiveSchema :: Enum ( e) => {
87+ PrimitiveSchemaDefinition :: Enum ( e) => {
9088 let val = match e {
9189 EnumSchema :: Single ( SingleSelectEnumSchema :: Untitled ( u) ) => {
9290 u. default . as_ref ( ) . map ( |d| Value :: String ( d. clone ( ) ) )
@@ -109,22 +107,24 @@ impl ClientHandler for ElicitationDefaultsClientHandler {
109107 } )
110108 }
111109 EnumSchema :: Legacy ( _) => None ,
110+ _ => None ,
112111 } ;
113112 if let Some ( v) = val {
114113 defaults. insert ( name. clone ( ) , v) ;
115114 }
116115 }
116+ _ => { }
117117 }
118118 }
119119 Some ( Value :: Object ( defaults) )
120120 }
121121 _ => Some ( json ! ( { } ) ) ,
122122 } ;
123- Ok ( CreateElicitationResult {
124- action : ElicitationAction :: Accept ,
125- content ,
126- meta : None ,
127- } )
123+ let mut result = ElicitResult :: new ( ElicitationAction :: Accept ) ;
124+ if let Some ( c ) = content {
125+ result = result . with_content ( c ) ;
126+ }
127+ Ok ( result )
128128 }
129129}
130130
@@ -134,12 +134,10 @@ struct FullClientHandler;
134134impl ClientHandler for FullClientHandler {
135135 fn get_info ( & self ) -> ClientInfo {
136136 let mut info = ClientInfo :: default ( ) ;
137- info. capabilities . elicitation = Some ( ElicitationCapability {
138- form : Some ( FormElicitationCapability {
139- schema_validation : Some ( true ) ,
140- } ) ,
141- url : None ,
142- } ) ;
137+ info. capabilities . elicitation = Some (
138+ ElicitationCapability :: new ( )
139+ . with_form ( FormElicitationCapability :: new ( ) . with_schema_validation ( true ) ) ,
140+ ) ;
143141 info
144142 }
145143
@@ -158,7 +156,7 @@ impl ClientHandler for FullClientHandler {
158156 Ok ( CreateMessageResult :: new (
159157 SamplingMessage :: new (
160158 Role :: Assistant ,
161- SamplingMessageContent :: text ( format ! (
159+ SamplingMessageContentBlock :: text ( format ! (
162160 "This is a mock LLM response to: {}" ,
163161 prompt_text
164162 ) ) ,
@@ -170,14 +168,11 @@ impl ClientHandler for FullClientHandler {
170168
171169 async fn create_elicitation (
172170 & self ,
173- _request : CreateElicitationRequestParams ,
171+ _request : ElicitRequestParams ,
174172 _cx : RequestContext < RoleClient > ,
175- ) -> Result < CreateElicitationResult , ErrorData > {
176- Ok ( CreateElicitationResult {
177- action : ElicitationAction :: Accept ,
178- content : Some ( json ! ( { "username" : "testuser" , "email" : "test@example.com" } ) ) ,
179- meta : None ,
180- } )
173+ ) -> Result < ElicitResult , ErrorData > {
174+ Ok ( ElicitResult :: new ( ElicitationAction :: Accept )
175+ . with_content ( json ! ( { "username" : "testuser" , "email" : "test@example.com" } ) ) )
181176 }
182177}
183178
0 commit comments