/** * Correlation ID and Context Management for PromptSpeak MCP Server * * Provides thread-safe (async-safe) correlation ID management using AsyncLocalStorage. * This enables tracking related log entries across async operations. */ /** * Context stored in AsyncLocalStorage for each async execution context */ interface ExecutionContext { correlationId: string; traceId?: string; additionalContext?: Record; } /** * Manages logging context including correlation IDs and trace IDs. * Uses AsyncLocalStorage for proper async context propagation. */ export declare class LogContextManager { private static storage; /** * Sets the correlation ID for the current execution context. * Note: This only works within a runWithContext call. */ static setCorrelationId(id: string): void; /** * Gets the correlation ID for the current execution context. * Returns undefined if not in a managed context. */ static getCorrelationId(): string | undefined; /** * Sets the trace ID for the current execution context. */ static setTraceId(id: string): void; /** * Gets the trace ID for the current execution context. */ static getTraceId(): string | undefined; /** * Generates a new correlation ID using UUID v4. */ static generateCorrelationId(): string; /** * Generates a shorter correlation ID for more compact logs. * Format: 8 character hex string */ static generateShortCorrelationId(): string; /** * Runs a function within a new correlation context. * All async operations within the function will have access to the correlation ID. * * @param fn - Function to run within the context * @param correlationId - Optional correlation ID (auto-generated if not provided) * @returns The result of the function */ static runWithCorrelation(fn: () => T, correlationId?: string): T; /** * Runs an async function within a new correlation context. * * @param fn - Async function to run within the context * @param correlationId - Optional correlation ID (auto-generated if not provided) * @returns Promise resolving to the result of the function */ static runWithCorrelationAsync(fn: () => Promise, correlationId?: string): Promise; /** * Gets all context data for the current execution. */ static getContext(): ExecutionContext | undefined; /** * Sets additional context data for the current execution. */ static setAdditionalContext(data: Record): void; /** * Gets additional context data for the current execution. */ static getAdditionalContext(): Record | undefined; } /** * Decorator for wrapping methods with correlation context. * Usage: @withCorrelation() */ export declare function withCorrelation(): (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; export {}; //# sourceMappingURL=context.d.ts.map