//#region src/utils/async-context.d.ts /** * Thin typed wrapper around Node's `AsyncLocalStorage`. Used to thread a * tool-execution / request-scoped context through the async stack * without explicit parameter passing. * * The wrapper exists because: * - The Node API requires a fresh `AsyncLocalStorage` per scope; this * helper centralizes the construction with consistent typing. * - Downstream packages (security, tools) want a single canonical * constructor so that their `getStore()` code paths share the same * identity (matters for HMR / multi-realm setups). * * @stable */ interface AsyncContext { /** Run `fn` inside a fresh scope carrying `value`. */ run(value: T, fn: () => R): R; /** Run `fn` inside a fresh scope carrying `value` (async-friendly). */ runAsync(value: T, fn: () => Promise): Promise; /** Get the value of the current scope, or `undefined` outside one. */ get(): T | undefined; /** Replace the value of the current scope (advanced; rarely needed). */ enterWith(value: T): void; /** Exit any in-flight scope (advanced; rarely needed). */ disable(): void; } /** * Construct a typed `AsyncContext`. The optional `name` is surfaced in * the diagnostics channel of `AsyncLocalStorage` (debugging only). * * @stable */ declare function createAsyncContext(_name?: string): AsyncContext; //#endregion export { AsyncContext, createAsyncContext }; //# sourceMappingURL=async-context.d.ts.map