import { Chat, s } from '@hashbrownai/core'; import { type DependencyList } from 'react'; /** * @public */ export interface ToolOptionsWithInput { /** * The name of the tool. */ name: Name; /** * The description of the tool. This helps the LLM understand its purpose. */ description: string; /** * The schema that describes the input for the tool. */ schema: Schema; /** * The handler of the tool. This is what the LLM agent will call * to execute the tool, passing in an input that adheres to the schema. */ handler: (input: s.Infer, abortSignal: AbortSignal) => Promise; /** * Dependencies that should trigger tool recreation. * The hook will automatically memoize the handler based on these dependencies, * so you can safely pass anonymous functions. */ deps: DependencyList; } /** * @public */ export interface ToolOptionsWithStandardSchema { /** * The name of the tool. */ name: Name; /** * The description of the tool. This helps the LLM understand its purpose. */ description: string; /** * The schema that describes the input for the tool. */ schema: Schema; /** * The handler of the tool. This is what the LLM agent will call * to execute the tool, passing in an input that adheres to the schema. */ handler: (input: s.StandardJSONSchemaV1.InferInput, abortSignal: AbortSignal) => Promise; /** * Dependencies that should trigger tool recreation. * The hook will automatically memoize the handler based on these dependencies, * so you can safely pass anonymous functions. */ deps: DependencyList; } /** * @public */ export interface ToolOptionsWithUnknownSchema { /** * The name of the tool. */ name: Name; /** * The description of the tool. This helps the LLM understand its purpose. */ description: string; /** * The unknown schema that describes the input for the tool. */ schema: object; /** * The handler of the tool. This is what the LLM agent will call * to execute the tool, passing in an input that adheres to the schema. */ handler: (input: any, abortSignal: AbortSignal) => Promise; /** * Dependencies that should trigger tool recreation. * The hook will automatically memoize the handler based on these dependencies, * so you can safely pass anonymous functions. */ deps: DependencyList; } /** * @public */ export interface ToolOptionsWithoutInput { /** * The name of the tool. */ name: Name; /** * The description of the tool. This helps the LLM understand its purpose. */ description: string; /** * The handler of the tool. This is what the LLM agent will call * to execute the tool. */ handler: (abortSignal: AbortSignal) => Promise; /** * Dependencies that should trigger tool recreation. * The hook will automatically memoize the handler based on these dependencies, * so you can safely pass anonymous functions. */ deps: DependencyList; } /** * @public */ export type ToolOptions = ToolOptionsWithInput | ToolOptionsWithStandardSchema | ToolOptionsWithUnknownSchema | ToolOptionsWithoutInput; /** * Creates a tool with a schema. * * @public * @typeParam Name - The name of the tool. * @typeParam Schema - The schema of the tool. * @typeParam Result - The result of the tool. * @param input - The input for the tool containing: * - `name`: The name of the tool * - `description`: The description of the tool * - `schema`: The schema of the tool * - `handler`: The handler of the tool * @param deps - Dependencies that should trigger tool recreation. * The hook will automatically memoize the handler based on these dependencies, * so you can safely pass anonymous functions. * @param Name - The name of the tool. * @param Schema - The schema of the tool. * @param Result - The result of the tool. * @returns The tool. */ export declare function useTool(input: ToolOptionsWithInput): Chat.Tool, Result>; /** * Creates a tool with a Standard JSON Schema. * * @public * @typeParam Name - The name of the tool. * @typeParam Schema - The schema of the tool. * @typeParam Result - The result of the tool. * @param input - The input for the tool containing: * - `name`: The name of the tool * - `description`: The description of the tool * - `schema`: The schema of the tool * - `handler`: The handler of the tool */ export declare function useTool(input: ToolOptionsWithStandardSchema): Chat.Tool, Result>; /** * Creates a tool with a unknown JSON schema. * * @public * @typeParam Name - The name of the tool. * @typeParam Result - The result of the tool. * @param input - The input for the tool containing: * - `name`: The name of the tool * - `description`: The description of the tool * - `schema`: The schema of the tool * - `handler`: The handler of the tool */ export declare function useTool(input: ToolOptionsWithUnknownSchema): Chat.Tool; /** * Creates a tool. * * @public * @typeParam Name - The name of the tool. * @typeParam Result - The result of the tool. * @param input - The input for the tool containing: * - `name`: The name of the tool * - `description`: The description of the tool * - `schema`: The schema of the tool * - `handler`: The handler of the tool * @param deps - Dependencies that should trigger tool recreation. * The hook will automatically memoize the handler based on these dependencies, * so you can safely pass anonymous functions. * @param Name - The name of the tool. * @param Schema - The schema of the tool. * @param Result - The result of the tool. * @returns The tool. */ export declare function useTool(input: ToolOptionsWithoutInput): Chat.Tool; //# sourceMappingURL=use-tool.d.ts.map