import { ExecutionContext } from "./ExecutionContext"; import { ClassificationTypeConfig } from "./IClassifier"; import { z } from "zod"; import { EventEmitter } from "events"; import { InferClassificationUnion } from "./TypeInference"; export type ToolInput = InferClassificationUnion; export declare abstract class ToolOutput { abstract getContent(): string; } export declare class StringOutput extends ToolOutput { private content; metadata?: Record | undefined; constructor(content: string, metadata?: Record | undefined); getContent(): string; } export declare class JSONOutput extends ToolOutput { private content; metadata?: Record | undefined; constructor(content: T, metadata?: Record | undefined); getContent(): string; getTypedContent(): T; } export declare class ToolError extends Error { context: Record; constructor(message: string, context?: Record); } export declare class ValidationError extends ToolError { errors: Array; constructor(message: string, errors: Array); } export interface ToolOptions { cache?: boolean; maxRetries?: number; retryDelay?: number; timeout?: number; } export interface RunOptions { signal?: AbortSignal; context?: Record; } export interface ToolEvents { onStart?: (input: TInput, context: ExecutionContext, options: RunOptions) => Promise; onSuccess?: (output: TOutput, input: TInput, context: ExecutionContext, options: RunOptions) => Promise; onError?: (error: ToolError, input: TInput, context: ExecutionContext, options: RunOptions) => Promise; onRetry?: (error: ToolError, attempt: number, input: TInput, context: ExecutionContext, options: RunOptions) => Promise; } export declare abstract class Tool { readonly name: string; readonly description: string; protected readonly events?: ToolEvents | undefined; protected readonly emitter: EventEmitter; protected readonly options: TOptions; protected context: ExecutionContext; constructor(name: string, description: string, options?: TOptions, events?: ToolEvents | undefined); setContext(context: ExecutionContext): void; abstract schema(): z.ZodSchema; protected abstract execute(input: ToolInput, context: ExecutionContext, options: RunOptions): Promise; private validateInput; protected withRetry(operation: () => Promise, input: ToolInput, options: RunOptions): Promise; run(input: ToolInput, options?: RunOptions): Promise; /** * Generates an OpenAI-compatible function description for this tool */ getFunctionDescription(): { type: 'function'; function: { name: string; description: string; parameters: { type: 'object'; properties: Record; required: string[]; }; }; }; private extractSchemaProperties; private extractRequiredFields; private zodTypeToJsonSchema; } export declare class ToolBuilder extends Tool { private fields; constructor(fields: { name: string; description: string; inputSchema: z.ZodSchema; handler: (input: TInput, context: ExecutionContext, options: RunOptions, runContext?: { tool: ToolBuilder; }) => Promise; options?: ToolOptions; events?: ToolEvents; }); schema(): z.ZodSchema; protected execute(input: TInput, context: ExecutionContext, options: RunOptions): Promise; }