@@ -328,10 +328,91 @@ export const GetToolInputSchema = z.object({
328
328
toolId : z . string ( ) . describe ( 'ID of the tool to get' ) ,
329
329
} ) ;
330
330
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
+ // Base tool configuration schema (reusable for both create and update)
367
+ const BaseToolConfigSchema = z . object ( {
368
+ // Common fields for all tools
369
+ name : z . string ( ) . optional ( ) . describe ( 'Name of the function/tool' ) ,
370
+ description : z . string ( ) . optional ( ) . describe ( 'Description of what the function/tool does' ) ,
371
+
372
+ // SMS tool configuration
373
+ sms : z . object ( {
374
+ metadata : z . object ( {
375
+ from : z . string ( ) . describe ( 'Phone number to send SMS from (e.g., "+15551234567"). It must be a twilio number in E.164 format.' ) ,
376
+ } ) . describe ( 'SMS configuration metadata' ) ,
377
+ } ) . optional ( ) . describe ( 'SMS tool configuration - to send text messages' ) ,
378
+
379
+ // Transfer call tool configuration
380
+ transferCall : z . object ( {
381
+ destinations : z . array ( TransferCallDestinationSchema ) . describe ( 'Array of possible transfer destinations' ) ,
382
+ } ) . optional ( ) . describe ( 'Transfer call tool configuration - to transfer calls to destinations' ) ,
383
+
384
+ // Function tool configuration (custom functions with parameters)
385
+ function : z . object ( {
386
+ parameters : JsonSchema . describe ( 'JSON schema for function parameters' ) ,
387
+ server : ServerSchema . describe ( 'Server configuration with URL where the function will be called' ) ,
388
+ } ) . optional ( ) . describe ( 'Custom function tool configuration - for custom server-side functions' ) ,
389
+
390
+ // API Request tool configuration
391
+ apiRequest : z . object ( {
392
+ url : z . string ( ) . url ( ) . describe ( 'URL to make the API request to' ) ,
393
+ method : z . enum ( [ 'GET' , 'POST' ] ) . default ( 'POST' ) . describe ( 'HTTP method for the API request' ) ,
394
+ headers : z . record ( z . string ( ) ) . optional ( ) . describe ( 'Headers to send with the request (key-value pairs)' ) ,
395
+ body : JsonSchema . optional ( ) . describe ( 'Body schema for the API request in JSON Schema format' ) ,
396
+ backoffPlan : BackoffPlanSchema . optional ( ) . describe ( 'Retry configuration for failed API requests' ) ,
397
+ timeoutSeconds : z . number ( ) . default ( 20 ) . describe ( 'Request timeout in seconds' ) ,
398
+ } ) . optional ( ) . describe ( 'API Request tool configuration - for HTTP API integration' ) ,
399
+ } ) ;
400
+
401
+ export const CreateToolInputSchema = BaseToolConfigSchema . extend ( {
402
+ type : z . enum ( [ 'sms' , 'transferCall' , 'function' , 'apiRequest' ] )
403
+ . describe ( 'Type of the tool to create' ) ,
404
+ } ) ;
405
+
406
+ export const UpdateToolInputSchema = BaseToolConfigSchema . extend ( {
407
+ toolId : z . string ( ) . describe ( 'ID of the tool to update' ) ,
408
+ } ) ;
409
+
331
410
export const ToolOutputSchema = BaseResponseSchema . extend ( {
332
411
type : z
333
412
. string ( )
334
413
. describe ( 'Type of the tool (dtmf, function, mcp, query, etc.)' ) ,
335
414
name : z . string ( ) . describe ( 'Name of the tool' ) ,
336
415
description : z . string ( ) . describe ( 'Description of the tool' ) ,
416
+ parameters : z . record ( z . any ( ) ) . describe ( 'Parameters of the tool' ) ,
417
+ server : ServerSchema . describe ( 'Server of the tool' ) ,
337
418
} ) ;
0 commit comments