/** * Read-only view over the active context. * * Used by context providers and codec deserialization to read values * without mutating durable context. */ export interface ContextReader { get(key: ContextKey): T | undefined; require(key: ContextKey): T; has(key: ContextKey): boolean; } /** * Read/write view over the active context. * * Extends {@link ContextReader} with durable write operations. This is * the narrow contract shared by {@link AlsContext} and the channel-facing * `ContextAccessor`. */ export interface ContextAccessor extends ContextReader { set(key: ContextKey, updater: T | ((current: T | undefined) => T)): T; ensure(key: ContextKey, create: () => T): T; } /** * Serialization hooks for one context key. * * `deserialize` receives the already-hydrated durable context so codecs can * depend on earlier durable keys such as the compiled runtime bundle. */ export interface ContextKeyCodec { serialize(value: T): unknown; deserialize(data: unknown, ctx: ContextReader): T | Promise; } export interface ContextKeyOptions { readonly codec?: ContextKeyCodec; } /** * Typed key that identifies a named context slot. */ export declare class ContextKey { readonly name: string; readonly codec?: ContextKeyCodec; constructor(name: string, options?: ContextKeyOptions); } /** * Looks up a registered key by name. Returns `undefined` for unknown names. */ export declare function resolveKey(name: string): ContextKey | undefined;