Appearance
Function: chatTool()
ts
function chatTool<TInput>(def: ChatToolDef<TInput>): ChatToolDef<TInput>;Defined in: packages/sdk/src/renderer/chat-driver.ts:120
Identity helper that infers a tool's TInput from its inputSchema (mirrors the Vercel AI SDK's tool()), so execute({input}) is fully typed. Optional — a plain object literal works too, defaulting to {prompt: string}.
Type Parameters
| Type Parameter | Default type |
|---|---|
TInput | { prompt: string; } |
Parameters
| Parameter | Type |
|---|---|
def | ChatToolDef<TInput> |
Returns
ChatToolDef<TInput>
Example
ts
tools: {
search: chatTool({
description: 'Search the catalog',
inputSchema: z.object({query: z.string(), limit: z.number().optional()}),
execute: ({input}) => ({reply: `Searched ${input.query}`}), // input is typed
}),
}