import { AsyncLocalStorage } from "node:async_hooks"; import { type ContextAccessor, type ContextKey } from "#context/key.js"; /** * Keyed value container that backs one eve execution scope. * * Durable values are serialized across workflow steps and turns. Virtual * values are rebuilt each step by context providers and are never * serialized. * * Extends {@link ContextAccessor} with the `entries()` iterator used by * the serialization layer. */ export interface AlsContext extends ContextAccessor { /** * Iterates all durable key/value pairs currently stored in the context. * Used by the serialization layer to persist context at step boundaries. */ entries(): Iterable, unknown]>; } /** * Default mutable implementation of {@link AlsContext}. */ export declare class ContextContainer implements AlsContext { private readonly _durableValues; private readonly _virtualValues; get(key: ContextKey): T | undefined; require(key: ContextKey): T; has(key: ContextKey): boolean; set(key: ContextKey, valueOrUpdater: T | ((current: T | undefined) => T)): T; ensure(key: ContextKey, create: () => T): T; /** * Clears all step-local provider values from the context. * * The runtime calls this before rebuilding context providers for a new * step. */ clearVirtualContext(): void; /** * Stores a step-local provider value for one key. * * Virtual values shadow durable values for the lifetime of the current * step and are excluded from serialization. */ setVirtualContext(key: ContextKey, value: T): void; entries(): Generator, unknown]>; } /** * Process-wide AsyncLocalStorage used by every eve module copy in the current * runtime. * * Nitro step bundles can inline parts of eve while authored modules still * import `eve/*` from disk. Backing the storage with a global * symbol keeps those copies on the same ALS instance so authored tools, * model callbacks, and step code observe one unified eve context. */ export declare const contextStorage: AsyncLocalStorage; /** * Returns the active context, throwing when called outside a managed scope. */ export declare function loadContext(): AlsContext;