/** * Request-scoped context for structured logging fields (requestId, sessionId, userId, …). * * Wire `onRequest` / `onResponse` around a handling scope; use `getContext` with * `logger.withContext` when you need request fields on log lines. * * import { ContextMiddleware } from './middleware/index.js'; */ import type { LogContext } from '../../utils/logger.js'; export interface RequestContext { sessionKey: string; userId?: string; channel?: string; chatId?: string; metadata?: Record; } export declare class ContextMiddleware { private currentContext; private contextDepth; private generateRequestId; private extractSessionId; onRequest(context: RequestContext): string; onResponse(): void; getContext(): LogContext; getRequestId(): string | undefined; extendContext(fields: Record): void; }