Async-context-friendly request/SSR context primitives for aihu.
_enterContextfunction _enterContext( parent: Record<symbol, unknown> | null, onOwn: (own: Record<symbol, unknown>) => void, ): [Record<symbol, unknown> | null, boolean, ((own: Record<symbol, unknown>) => void) | null]_exitContextfunction _exitContext( prev: [Record<symbol, unknown> | null, boolean, ((own: Record<symbol, unknown>) => void) | null], ): voidclearSsrContextMapfunction clearSsrContextMap(): voidClear the active context map (SSR teardown).
contextKeyfunction contextKey(key: string): ContextToken<unknown>Intern a stable context token for a string key, so the compiler-lowered `$context` provide/consume (which are string-keyed) resolve to one shared token app-wide.
createContextfunction createContext<T>(defaultValue?: T): ContextToken<T>Create a new context token.
injectfunction inject<T>(token: ContextToken<T>): T | undefinedRead a value for the given token.
providefunction provide<T>(token: ContextToken<T>, value: T): voidWrite a value for the given token into the active context map.
runWithContextfunction runWithContext<R>(map: Map<symbol, unknown>, fn: () => R): RRun fn() with the given map as the active context map, then restore the previous state (null) in a finally block.
setSsrContextMapfunction setSsrContextMap(map: Map<symbol, unknown>): voidSet the active context map (SSR entry point).
ContextTokeninterface ContextToken<T> {
readonly _id: symbol
readonly _default: T | undefined
}Opaque token that identifies a context slot and carries its default value.