Define a tool with proper TypeScript types.
This is a type-safe helper for creating tools. The function preserves the input/output types from the config.
Input type for the tool
Output type for the tool
Tool configuration
A fully-typed Tool object
const myTool = defineTool({ name: 'summarize', input: {} as { text: string }, output: {} as { summary: string }, description: 'Summarize text', run: async (input) => { return { output: { summary: input.text.substring(0, 50) } }; }}); Copy
const myTool = defineTool({ name: 'summarize', input: {} as { text: string }, output: {} as { summary: string }, description: 'Summarize text', run: async (input) => { return { output: { summary: input.text.substring(0, 50) } }; }});
Define a tool with proper TypeScript types.
This is a type-safe helper for creating tools. The function preserves the input/output types from the config.