defineTypedTool
Register a SWAIG tool with a typed handler that receives named parameters instead of
the standard (args, rawData) convention. The SDK wraps the handler to unpack the
args object into positional params.
If no parameters schema is provided, one is inferred from the handler’s source
code (parameter names and default values).
Use defineTypedTool() when you want cleaner handler signatures with named
parameters. Use defineTool() when you need full control over
the args object.
Parameters
opts
Tool definition object.
opts.name
Tool name. Must be unique within the agent.
opts.description
Human-readable description. The AI reads this to decide when to call the tool.
opts.parameters
JSON Schema describing the tool’s parameters. If omitted, the schema is inferred from the handler’s parameter names and default values.
opts.handler
Typed handler that receives named parameters extracted from the args object. Parameter names must match the JSON Schema property names.
opts.secure
Whether to require token validation on tool calls.
opts.fillers
Language-specific filler phrases spoken while the tool executes.
opts.waitFile
URL of an audio file to play while the tool executes.
opts.waitFileLoops
Number of times to loop the wait file.
opts.required
List of required parameter names from the JSON Schema.
Returns
AgentBase — Returns this for method chaining.