/** * Ambient per-request context carried across async boundaries via * AsyncLocalStorage. Loggers read from it so every log line can be * correlated to a request without threading IDs through parameters. */ interface RequestContext { /** Correlation ID: one per HTTP request (or per scheduled run). */ requestId: string; userId?: string; threadId?: string; } /** * Runs `fn` with `context` as the ambient request context. Everything in * the async call tree of `fn` (awaits, promises, timers) sees the context. */ declare const runWithRequestContext: (context: RequestContext, fn: () => T) => T; /** Returns the ambient context, or undefined outside of one. */ declare const getRequestContext: () => RequestContext | undefined; /** * Merges fields into the current context (e.g. userId after auth, * threadId once resolved). No-op when called outside of a context. */ declare const updateRequestContext: (patch: Partial>) => void; export { type RequestContext, getRequestContext, runWithRequestContext, updateRequestContext };