import type { Tool } from "ai"; export interface ToolMiddleware { /** Called before tool execution. Can modify params or throw to block. */ beforeExecute?: (context: ToolCallContext) => Promise | void; /** Called after successful execution. */ afterExecute?: (context: ToolCallContext & { result: unknown; durationMs: number; }) => Promise | void; /** Called on execution error. Return a value to use as fallback result, or rethrow. */ onError?: (context: ToolCallContext & { error: unknown; }) => Promise | unknown; } export interface ToolCallContext { toolName: string; params: unknown; timestamp: number; } /** * Wrap a set of tools with middleware hooks. * Returns a new tools object with the same keys but wrapped execute functions. */ export declare function withMiddleware>(tools: T, middleware: ToolMiddleware): T; //# sourceMappingURL=middleware.d.ts.map