99 ToolOutputSchema ,
1010 UpdateAssistantInputSchema ,
1111 CreateToolInputSchema ,
12+ UpdateToolInputSchema ,
1213} from '../schemas/index.js' ;
1314
1415// ===== Assistant Transformers =====
@@ -310,8 +311,61 @@ export function transformToolInput(
310311 return toolDto ;
311312}
312313
314+ export function transformUpdateToolInput (
315+ input : z . infer < typeof UpdateToolInputSchema >
316+ ) : any {
317+ let updateDto : any = { } ;
318+
319+ // Add function definition if name and description are provided
320+ if ( input . name || input . description ) {
321+ updateDto . function = {
322+ ...( input . name && { name : input . name } ) ,
323+ ...( input . description && { description : input . description } ) ,
324+ } ;
325+ }
326+
327+ // Handle SMS tool configuration
328+ if ( input . sms ?. metadata ) {
329+ updateDto . metadata = input . sms . metadata ;
330+ }
331+
332+ // Handle Transfer call tool configuration
333+ if ( input . transferCall ?. destinations ) {
334+ updateDto . destinations = input . transferCall . destinations ;
335+ }
336+
337+ // Handle Function tool configuration
338+ if ( input . function ?. parameters && input . function ?. server ) {
339+ // For function tools, add parameters to the existing function object
340+ if ( updateDto . function ) {
341+ updateDto . function . parameters = input . function . parameters ;
342+ } else {
343+ updateDto . function = {
344+ parameters : input . function . parameters ,
345+ } ;
346+ }
347+
348+ updateDto . server = {
349+ url : input . function . server . url ,
350+ ...( input . function . server . headers && { headers : input . function . server . headers } ) ,
351+ } ;
352+ }
353+
354+ // Handle API Request tool configuration
355+ if ( input . apiRequest ) {
356+ if ( input . apiRequest . url ) updateDto . url = input . apiRequest . url ;
357+ if ( input . apiRequest . method ) updateDto . method = input . apiRequest . method ;
358+ if ( input . apiRequest . headers ) updateDto . headers = input . apiRequest . headers ;
359+ if ( input . apiRequest . body ) updateDto . body = input . apiRequest . body ;
360+ if ( input . apiRequest . backoffPlan ) updateDto . backoffPlan = input . apiRequest . backoffPlan ;
361+ if ( input . apiRequest . timeoutSeconds ) updateDto . timeoutSeconds = input . apiRequest . timeoutSeconds ;
362+ }
363+
364+ return updateDto ;
365+ }
366+
313367export function transformToolOutput (
314- tool : any
368+ tool : Vapi . ToolsGetResponse
315369) : z . infer < typeof ToolOutputSchema > {
316370 return {
317371 id : tool . id ,
@@ -320,5 +374,10 @@ export function transformToolOutput(
320374 type : tool . type || '' ,
321375 name : tool . function ?. name || '' ,
322376 description : tool . function ?. description || '' ,
377+ parameters : tool . function ?. parameters || { } ,
378+ server : {
379+ url : tool . server ?. url || '' ,
380+ headers : tool . server ?. headers as Record < string , string > || { } ,
381+ }
323382 } ;
324383}
0 commit comments