export interface RequestContext { /** Fires on `notifications/cancelled` or when the transport closes. */ signal?: AbortSignal; /** Correlation id shared by every log line and forwarded as `X-Request-Id`. */ corrId?: string; /** W3C `traceparent` header received from the client, forwarded verbatim. */ traceparent?: string; } /** Run `fn` with `context` as the current request's context (replaces any enclosing one). */ export declare function runWithRequestContext(context: RequestContext, fn: () => T): T; /** The context of the request being handled, if a handler is on the stack. */ export declare function currentRequestContext(): RequestContext | undefined; /** Run `fn` with `signal` as the current request's cancellation signal; the rest of the context is kept. */ export declare function runWithRequestSignal(signal: AbortSignal | undefined, fn: () => T): T; /** Run `fn` with no cancellation signal, for work whose result other requests share. Correlation is kept. */ export declare function withoutRequestSignal(fn: () => T): T; /** The signal of the request being handled, if a handler is on the stack. */ export declare function currentRequestSignal(): AbortSignal | undefined; /** The correlation id of the request being handled, if any. */ export declare function currentCorrId(): string | undefined; /** Narrowing for the SDK's `extra`, typed `unknown` at every call site. */ export declare function requestSignalFrom(extra: unknown): AbortSignal | undefined; /** Parse a `traceparent` value; `undefined` when absent or malformed. */ export declare function parseTraceparent(value: unknown): { header: string; traceId: string; } | undefined; /** The `traceparent` the client put in the request's `_meta` (SEP-414), if valid. */ export declare function traceparentFrom(extra: unknown): { header: string; traceId: string; } | undefined; /** * Raised when the client cancelled the request. `name` is `AbortError` so it * reads like every other abort in Node; the message names the endpoint the * cancellation interrupted, which is what a log line needs. */ export declare class RequestCancelledError extends Error { readonly method: string; readonly path: string; constructor(method: string, path: string, cause?: unknown); } /** Throw `RequestCancelledError` if `signal` has fired. Cheap — call it before every unit of work. */ export declare function throwIfCancelled(signal: AbortSignal | undefined, method: string, path: string): void; /** A promise that rejects with the signal's reason the moment it fires (never resolves). */ export declare function abortPromise(signal: AbortSignal): Promise; //# sourceMappingURL=request-context.d.ts.map