@@ -328,6 +328,78 @@ export const GetToolInputSchema = z.object({
328328 toolId : z . string ( ) . describe ( 'ID of the tool to get' ) ,
329329} ) ;
330330
331+ const TransferCallDestinationSchema = z . object ( {
332+ type : z . literal ( 'number' ) ,
333+ number : z . string ( ) . describe ( 'Phone number to transfer to (e.g., "+16054440129"). It can be any phone number in E.164 format.' ) ,
334+ extension : z . string ( ) . optional ( ) . describe ( 'Extension number if applicable' ) ,
335+ callerId : z . string ( ) . optional ( ) . describe ( 'Caller ID to use for the transfer' ) ,
336+ description : z . string ( ) . optional ( ) . describe ( 'Description of the transfer destination' ) ,
337+ } ) ;
338+
339+ // Generic custom tool schemas
340+ const JsonSchemaProperty = z . object ( {
341+ type : z . string ( ) ,
342+ description : z . string ( ) . optional ( ) ,
343+ enum : z . array ( z . string ( ) ) . optional ( ) ,
344+ items : z . any ( ) . optional ( ) ,
345+ properties : z . record ( z . any ( ) ) . optional ( ) ,
346+ required : z . array ( z . string ( ) ) . optional ( ) ,
347+ } ) ;
348+
349+ const JsonSchema = z . object ( {
350+ type : z . literal ( 'object' ) ,
351+ properties : z . record ( JsonSchemaProperty ) ,
352+ required : z . array ( z . string ( ) ) . optional ( ) ,
353+ } ) ;
354+
355+ const ServerSchema = z . object ( {
356+ url : z . string ( ) . url ( ) . describe ( 'Server URL where the function will be called' ) ,
357+ headers : z . record ( z . string ( ) ) . optional ( ) . describe ( 'Headers to send with the request' ) ,
358+ } ) ;
359+
360+ const BackoffPlanSchema = z . object ( {
361+ type : z . enum ( [ 'fixed' , 'exponential' ] ) . default ( 'fixed' ) ,
362+ maxRetries : z . number ( ) . default ( 3 ) . describe ( 'Maximum number of retries' ) ,
363+ baseDelaySeconds : z . number ( ) . default ( 1 ) . describe ( 'Base delay between retries in seconds' ) ,
364+ } ) ;
365+
366+ export const CreateToolInputSchema = z . object ( {
367+ type : z . enum ( [ 'sms' , 'transferCall' , 'function' , 'apiRequest' ] )
368+ . describe ( 'Type of the tool to create' ) ,
369+
370+ // Common fields for all tools
371+ name : z . string ( ) . optional ( ) . describe ( 'Name of the function/tool' ) ,
372+ description : z . string ( ) . optional ( ) . describe ( 'Description of what the function/tool does' ) ,
373+
374+ // SMS tool configuration
375+ sms : z . object ( {
376+ metadata : z . object ( {
377+ from : z . string ( ) . describe ( 'Phone number to send SMS from (e.g., "+15551234567"). It must be a twilio number in E.164 format.' ) ,
378+ } ) . describe ( 'SMS configuration metadata' ) ,
379+ } ) . optional ( ) . describe ( 'SMS tool configuration - to send text messages' ) ,
380+
381+ // Transfer call tool configuration
382+ transferCall : z . object ( {
383+ destinations : z . array ( TransferCallDestinationSchema ) . describe ( 'Array of possible transfer destinations' ) ,
384+ } ) . optional ( ) . describe ( 'Transfer call tool configuration - to transfer calls to destinations' ) ,
385+
386+ // Function tool configuration (custom functions with parameters)
387+ function : z . object ( {
388+ parameters : JsonSchema . describe ( 'JSON schema for function parameters' ) ,
389+ server : ServerSchema . describe ( 'Server configuration with URL where the function will be called' ) ,
390+ } ) . optional ( ) . describe ( 'Custom function tool configuration - for custom server-side functions' ) ,
391+
392+ // API Request tool configuration
393+ apiRequest : z . object ( {
394+ url : z . string ( ) . url ( ) . describe ( 'URL to make the API request to' ) ,
395+ method : z . enum ( [ 'GET' , 'POST' ] ) . default ( 'POST' ) . describe ( 'HTTP method for the API request' ) ,
396+ headers : z . record ( z . string ( ) ) . optional ( ) . describe ( 'Headers to send with the request (key-value pairs)' ) ,
397+ body : JsonSchema . optional ( ) . describe ( 'Body schema for the API request in JSON Schema format' ) ,
398+ backoffPlan : BackoffPlanSchema . optional ( ) . describe ( 'Retry configuration for failed API requests' ) ,
399+ timeoutSeconds : z . number ( ) . default ( 20 ) . describe ( 'Request timeout in seconds' ) ,
400+ } ) . optional ( ) . describe ( 'API Request tool configuration - for HTTP API integration' ) ,
401+ } ) ;
402+
331403export const ToolOutputSchema = BaseResponseSchema . extend ( {
332404 type : z
333405 . string ( )
0 commit comments