Skip to main content

functionTool

Create a callable FunctionTool the agent can expose to its model. Pass a ToolDefinition describing the tool; name is required. The argument schema can be a Zod schema (input, which takes precedence, or parameters directly) or a plain JSON Schema (parameters); Zod schemas are converted to JSON Schema.
def
ToolDefinition<P>
required
returns
FunctionTool<P>

isFunctionTool

Type guard: whether obj is a FunctionTool (has valid _toolInfo).
obj
any
required
returns
obj is FunctionTool

getToolInfo

Return the FunctionToolInfoLike metadata attached to a tool.
tool
FunctionTool | any
required
returns
FunctionToolInfoLike

FunctionTool

A callable tool: a function that runs the tool, with its FunctionToolInfoLike metadata attached as _toolInfo. Create one with functionTool.

FunctionToolInfo

Concrete carrier for tool metadata; see FunctionToolInfoLike.

Constructor

info
FunctionToolInfoLike
required

ToolChoice

How the model is allowed to use tools on a turn.

buildOpenaiSchema

Convert a tool to the OpenAI function-calling schema.
tool
FunctionTool | any
required
returns
{ type: 'function'; function: { name: string; description: string; parameters: object }; }

buildGeminiSchema

Convert a tool to the Gemini function-declaration schema (simplified parameters).
tool
FunctionTool | any
required
returns
{ name: string; description: string; parameters: object; }

buildNovaSonicSchema

Convert a tool to the Nova Sonic schema (identical to OpenAI’s).
tool
FunctionTool | any
required
returns
{ type: 'function'; function: { name: string; description: string; parameters: object }; }

MCPServerStdio

Describe an MCP server run as a local subprocess communicating over stdio.

Constructor

command
string
required
Executable to launch.
args
string[] | null
Command-line arguments passed to the MCP server process. Default: [].
env
Record<string, string> | null
Environment variables for the MCP server process. Default: {}.

MCPServerHTTP

Describe an MCP server reached over HTTP.

Constructor

url
string
required
Base URL of the MCP server.
headers
Record<string, string> | null
HTTP headers sent with each request to the MCP server. Default: {}.

DTMFHandler

Create a DTMFHandler.

Constructor

_opts
Record<string, any>
default:"{}"

onDigit

Register callback to fire each time the given single digit is received.
digit
string
required
callback
DTMFCallback
required

onSequence

Register callback to fire when the recent digit stream ends with sequence.
sequence
string
required
callback
DTMFCallback
required

VoiceMailDetector

Create a VoiceMailDetector.

Constructor

llm
any
LLM used for classification. Default: null.
callback
VoiceMailCallback | null
Callback fired on detection. Default: null.
duration
number
Detection window in seconds. Default: 2.0. Overridden by VoiceMailDetectorOptions.maxDetectionSeconds when set.
customPrompt
string | null
Custom classifier prompt; falls back to the built-in prompt when empty. Default: ''.
autoHangup
boolean
Hang up automatically when voicemail is detected. Default: false.
detectionThreshold
number
Confidence threshold (0-1) required to count as a detection. Default: 1.0.
maxDetectionSeconds
number | null
Maximum detection window in seconds; takes precedence over VoiceMailDetectorOptions.duration. Default: null.