import { z } from "zod"; export interface ToolCall { id: string; type: "function"; function: { name: string; arguments: string; }; } export interface ToolDefinition { type: "function"; function: { name: string; description?: string; strict?: boolean; parameters: Record; }; handler?: (args: unknown) => Promise; } /** * Stops the agentic tool execution loop and returns the content as the final response. * Return this from a tool's execute() method to immediately end the conversation turn. * * @example * ```typescript * class PaymentTool extends Tool { * async execute({ amount }) { * if (amount > 10000) { * return this.halt("Payment requires manager approval. Please contact support."); * } * return processPayment(amount); * } * } * ``` */ export declare class ToolHalt { readonly content: string; constructor(content: string); toString(): string; toJSON(): { halt: true; content: string; }; } /** * Anything that can be resolved into a ToolDefinition. */ export type ToolResolvable = Tool | { new (): Tool; } | ToolDefinition; /** * Subclass this to create tools with auto-generated schemas and type safety. */ export declare abstract class Tool> { /** * The name of the tool (must match [a-zA-Z0-9_-]+). */ abstract name: string; /** * A clear description of what the tool does, used by the LLM to decide when to call it. */ abstract description: string; /** * Parameters the tool accepts. * Can be a Zod object (for auto-schema + type safety) or a raw JSON Schema. */ abstract schema: z.ZodObject | Record; /** * Whether to enforce strict JSON schema constraints for OpenAI and similar providers. * When true, additionalProperties: false and full required arrays are automatically applied. */ strict?: boolean; /** * The core logic for the tool. * 'args' will be parsed and validated based on 'schema'. */ abstract execute(args: T): Promise; /** * Stop the agentic loop and return this message as the final tool result. * Use this when you want to end the conversation turn immediately. * * @example * ```typescript * async execute({ amount }) { * if (amount > 10000) { * return this.halt("Payment requires manager approval."); * } * return processPayment(amount); * } * ``` */ protected halt(message: string): ToolHalt; /** * Internal handler to bridge with LLM providers. * Converts any result to a string (usually JSON). * Preserves ToolHalt instances for the execution loop to detect. */ handler(args: T): Promise; /** * Converts the tool definition and logic into a standard ToolDefinition interface. * This is called automatically by NodeLLM when registering tools. */ toLLMTool(): ToolDefinition; } //# sourceMappingURL=Tool.d.ts.map