/**
 * Request timing and memory usage tracking
 * Provides comprehensive monitoring for HTTP requests, AI calls, and MCP operations
 */
/**
 * Request tracking metadata
 */
export interface RequestMetadata {
    id: string;
    type: 'http' | 'ai' | 'mcp' | 'database' | 'file' | 'custom';
    method?: string;
    url?: string;
    endpoint?: string;
    provider?: string;
    model?: string;
    toolName?: string;
    serverName?: string;
    correlationId: string;
    startTime: number;
    endTime?: number;
    duration?: number;
    memoryStart?: NodeJS.MemoryUsage;
    memoryEnd?: NodeJS.MemoryUsage;
    memoryDelta?: Record<string, number>;
    status?: 'pending' | 'success' | 'error' | 'timeout' | 'cancelled';
    statusCode?: number;
    errorType?: string;
    errorMessage?: string;
    requestSize?: number;
    responseSize?: number;
    retryCount?: number;
    userId?: string;
    sessionId?: string;
    tags?: string[];
    customData?: Record<string, unknown>;
}
/**
 * Request statistics for monitoring and analysis
 */
export interface RequestStats {
    totalRequests: number;
    requestsByType: Record<string, number>;
    requestsByStatus: Record<string, number>;
    averageDuration: number;
    minDuration: number;
    maxDuration: number;
    totalDuration: number;
    averageMemoryDelta: Record<string, number>;
    errorRate: number;
    timeoutRate: number;
    requestsInLastHour: number;
    requestsInLastDay: number;
    busiestHour: number;
    busiestEndpoint?: string;
    slowestEndpoint?: string;
    mostErrorProneEndpoint?: string;
    timestamp: string;
}
/**
 * Request tracker class for monitoring HTTP requests and operations
 */
export declare class RequestTracker {
    private activeRequests;
    private completedRequests;
    private readonly maxCompletedRequests;
    private readonly correlationId;
    constructor(maxCompletedRequests?: number);
    /**
     * Start tracking a new request
     */
    startRequest(metadata: Omit<RequestMetadata, 'id' | 'startTime' | 'status' | 'correlationId'>): string;
    /**
     * Complete a request successfully
     */
    completeRequest(requestId: string, responseMetadata?: {
        statusCode?: number;
        responseSize?: number;
        customData?: Record<string, unknown>;
    }): RequestMetadata | null;
    /**
     * Mark a request as failed
     */
    failRequest(requestId: string, error: Error | string, errorMetadata?: {
        errorType?: string;
        statusCode?: number;
        customData?: Record<string, unknown>;
    }): RequestMetadata | null;
    /**
     * Mark a request as timed out
     */
    timeoutRequest(requestId: string, timeoutMs: number): RequestMetadata | null;
    /**
     * Cancel a request
     */
    cancelRequest(requestId: string, reason?: string): RequestMetadata | null;
    /**
     * Get request statistics
     */
    getStats(): RequestStats;
    /**
     * Get active requests
     */
    getActiveRequests(): RequestMetadata[];
    /**
     * Get recently completed requests
     */
    getRecentRequests(limit?: number): RequestMetadata[];
    /**
     * Clear all tracking data
     */
    clear(): void;
    private generateRequestId;
    private addToCompleted;
}
/**
 * Global request tracker instance
 */
export declare const globalRequestTracker: RequestTracker;
/**
 * Decorator to automatically track function calls as requests
 */
export declare function trackRequest<T extends (...args: unknown[]) => unknown>(fn: T, options: {
    type: RequestMetadata['type'];
    method?: string;
    endpoint?: string;
    provider?: string;
    model?: string;
    toolName?: string;
    serverName?: string;
    tags?: string[];
    trackMemory?: boolean;
    trackRequestSize?: boolean;
    thresholds?: {
        duration?: number;
        memory?: number;
    };
}): T;
/**
 * HTTP request tracking utilities
 */
export declare const httpTracker: {
    /**
     * Track an HTTP GET request
     */
    get: <T>(url: string, fn: () => Promise<T>, options?: Partial<Parameters<typeof trackRequest>[1]>) => () => Promise<T>;
    /**
     * Track an HTTP POST request
     */
    post: <T>(url: string, fn: () => Promise<T>, options?: Partial<Parameters<typeof trackRequest>[1]>) => () => Promise<T>;
    /**
     * Track an HTTP PUT request
     */
    put: <T>(url: string, fn: () => Promise<T>, options?: Partial<Parameters<typeof trackRequest>[1]>) => () => Promise<T>;
    /**
     * Track an HTTP DELETE request
     */
    delete: <T>(url: string, fn: () => Promise<T>, options?: Partial<Parameters<typeof trackRequest>[1]>) => () => Promise<T>;
};
/**
 * AI request tracking utilities
 */
export declare const aiTracker: {
    /**
     * Track an AI chat request
     */
    chat: <T>(provider: string, model: string, fn: () => Promise<T>, options?: Partial<Parameters<typeof trackRequest>[1]>) => () => Promise<T>;
    /**
     * Track an AI completion request
     */
    completion: <T>(provider: string, model: string, fn: () => Promise<T>, options?: Partial<Parameters<typeof trackRequest>[1]>) => () => Promise<T>;
    /**
     * Track an AI embedding request
     */
    embedding: <T>(provider: string, model: string, fn: () => Promise<T>, options?: Partial<Parameters<typeof trackRequest>[1]>) => () => Promise<T>;
};
/**
 * MCP request tracking utilities
 */
export declare const mcpTracker: {
    /**
     * Track an MCP tool execution
     */
    tool: <T>(_serverName: string, toolName: string, fn: () => Promise<T>, options?: Partial<Parameters<typeof trackRequest>[1]>) => () => Promise<T>;
    /**
     * Track an MCP server connection
     */
    connect: <T>(_serverName: string, fn: () => Promise<T>, options?: Partial<Parameters<typeof trackRequest>[1]>) => () => Promise<T>;
};
//# sourceMappingURL=request-tracker.d.ts.map