/** * BaseTool - Abstract base class for creating custom tools (plugins) * * This provides the same extensibility pattern as Python's BaseTool. * External developers can create plugins by extending BaseTool. * * Usage: * import { BaseTool } from 'praisonai'; * * class MyTool extends BaseTool { * name = 'my_tool'; * description = 'Does something useful'; * * async run(params: { query: string }): Promise { * return `Result for ${params.query}`; * } * } */ export interface ToolResult { output: T; success: boolean; error?: string; metadata?: Record; } export declare class ToolValidationError extends Error { constructor(message: string); } export interface ToolParameters { type: 'object'; properties: Record; required?: string[]; } /** * Abstract base class for all PraisonAI tools. * * Subclass this to create custom tools that can be: * - Used directly by agents * - Distributed as npm packages (plugins) * - Auto-discovered via package.json */ export declare abstract class BaseTool { /** Unique identifier for the tool */ abstract name: string; /** Human-readable description (used by LLM) */ abstract description: string; /** Tool version string */ version: string; /** JSON Schema for parameters */ parameters?: ToolParameters; /** * Execute the tool with given arguments. * This method must be implemented by subclasses. */ abstract run(params: TParams): Promise | TResult; /** * Allow tool to be called directly like a function. */ execute(params: TParams): Promise; /** * Execute tool with error handling, returning ToolResult. */ safeRun(params: TParams): Promise>; /** * Get OpenAI-compatible function schema for this tool. */ getSchema(): { type: 'function'; function: { name: string; description: string; parameters: any; }; }; /** * Validate the tool configuration. */ validate(): boolean; toString(): string; } /** * Validate any tool-like object. */ export declare function validateTool(tool: any): boolean; /** * Create a simple tool from a function (alternative to class-based approach) */ export declare function createTool(config: { name: string; description: string; parameters?: ToolParameters; run: (params: TParams) => Promise | TResult; }): BaseTool;