/** * Parameters for a tool execution request */ export interface ToolExecutionParams { /** The name of the tool to execute */ name: string; /** Parameters to pass to the tool */ parameters: Record; /** Optional execution context */ context?: ToolExecutionContext; } /** * Context for tool execution */ export interface ToolExecutionContext { /** Optional timeout in milliseconds */ timeout?: number; /** Whether to retry on failure */ retry?: boolean; /** Maximum number of retries */ maxRetries?: number; /** Whether to execute in background */ background?: boolean; } /** * Result of a tool execution */ export interface ToolExecutionResult { /** Whether the execution was successful */ success: boolean; /** The result data if successful */ data?: T; /** Error information if unsuccessful */ error?: ToolExecutionError; /** Execution metadata */ metadata: { /** Time taken in milliseconds */ duration: number; /** Server that executed the tool */ server: string; /** Number of retries if any */ retries?: number; }; } /** * Error information for failed tool executions */ export interface ToolExecutionError { /** Error code */ code: string; /** Error message */ message: string; /** Optional stack trace */ stack?: string; /** Additional error details */ details?: Record; } /** * Handler for tool execution */ export interface ToolExecutor { /** * Execute a tool * @param params Tool execution parameters * @returns Promise resolving to execution result * @throws If execution fails and cannot be recovered */ execute(params: ToolExecutionParams): Promise; /** * Cancel a running tool execution * @param name Tool name * @param server Optional server name (if known) * @returns Promise resolving when cancellation is complete */ cancel(name: string, server?: string): Promise; /** * Check if a tool is currently executing * @param name Tool name * @returns Whether the tool is executing */ isExecuting(name: string): boolean; } /** * Status of a tool execution */ export type ToolExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timeout';