@@ -186,15 +186,18 @@ export default class Tool<T = Record<string, string>> {
186186 handler_or_options : SimpleToolHandler | ToolOptions < T >
187187 ) {
188188 this . name = name ;
189-
190- const is_simple = typeof handler_or_options === "function" ;
191- this . description = is_simple ? name : handler_or_options . description ;
192- this . parameters = is_simple
193- ? { input : "Entrada para la herramienta" }
194- : handler_or_options . parameters || {
195- input : "Entrada para la herramienta" ,
196- } ;
197- this . func = is_simple ? handler_or_options : handler_or_options . func ;
189+ const options = {
190+ ...( typeof handler_or_options === "function"
191+ ? {
192+ description : name ,
193+ parameters : { input : "<tool-input>" } ,
194+ func : handler_or_options ,
195+ }
196+ : handler_or_options ) ,
197+ } ;
198+ this . description = options . description || this . name ;
199+ this . parameters = options . parameters ! ;
200+ this . func = options . func ! ;
198201 }
199202
200203 /**
@@ -213,14 +216,22 @@ export default class Tool<T = Record<string, string>> {
213216 * ```
214217 */
215218 toJSON ( ) : {
219+ type : "function" ;
216220 name : string ;
217221 description : string ;
218- parameters : T | { input : string } ;
222+ parameters : {
223+ type : "object" ;
224+ properties : T | { input : string } ;
225+ } ;
219226 } {
220227 return {
228+ type : "function" ,
221229 name : this . name ,
222230 description : this . description ,
223- parameters : this . parameters ,
231+ parameters : {
232+ type : "object" ,
233+ properties : this . parameters ,
234+ } ,
224235 } ;
225236 }
226237
0 commit comments