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<readonly [ContextKey<unknown>, unknown]>;
}
/**
 * Default mutable implementation of {@link AlsContext}.
 */
export declare class ContextContainer implements AlsContext {
    private readonly _durableValues;
    private readonly _virtualValues;
    get<T>(key: ContextKey<T>): T | undefined;
    require<T>(key: ContextKey<T>): T;
    has<T>(key: ContextKey<T>): boolean;
    set<T>(key: ContextKey<T>, valueOrUpdater: T | ((current: T | undefined) => T)): T;
    ensure<T>(key: ContextKey<T>, 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<T>(key: ContextKey<T>, value: T): void;
    entries(): Generator<readonly [ContextKey<unknown>, 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<AlsContext>;
/**
 * Returns the active context, throwing when called outside a managed scope.
 */
export declare function loadContext(): AlsContext;
