/** * [WHO]: Provides TurnContext, setTurnContext(), getTurnContext(), resetTurnContext(), TURN_CONTEXT_GLOBAL_KEY * [FROM]: Depends on nothing; uses globalThis as cross-package singleton storage * [TO]: Consumed by extensions that publish per-turn hints (e.g. SAL) and by packages that read them (e.g. mem-core via its own mirror) * [HERE]: core/runtime/turn-context.ts - generic per-turn hint bus; decouples producers from consumers via a documented globalThis key * * Design note: * This is the canonical home of the bus. Packages that cannot reverse-import * from the main app (e.g. catui-mem) define a structurally * identical mirror that targets the same globalThis key. The contract is the * key string + TurnContext schema, not the implementation file. */ /** Per-memory scoring breakdown published by mem-core for eval collection. */ export interface MemoryRecallRecord { memoryId: string; memoryKind: string; anchorModule?: string; anchorFile?: string; scoreBreakdownStatus: "available" | "unavailable"; scoreRecency?: number; scoreImportance?: number; scoreRelevance?: number; scoreStructural?: number; scoreFinal: number; wasInjected: boolean; injectRank?: number; } /** Channel for per-turn hints that one extension may publish and others may consume. */ export interface TurnContext { /** * Structural anchor for the active turn (set by SAL or any future locator). * `candidatePaths` are scored alternatives, used for soft overlap matching. */ structuralAnchor?: { modulePath?: string; filePath?: string; candidatePaths?: string[]; }; /** * Memory recall snapshot for the active turn (set by mem-core after scoring). * Contains per-entry score breakdowns for eval collection. */ memoryRecallSnapshot?: MemoryRecallRecord[]; } /** Reserved globalThis key. Mirrors must use exactly this string. */ export declare const TURN_CONTEXT_GLOBAL_KEY = "__catuiTurnContext"; /** Publish (or clear, when value is undefined) a turn-context channel. */ export declare function setTurnContext(key: K, value: TurnContext[K]): void; /** Read the current value of a turn-context channel. Returns undefined when no producer has published. */ export declare function getTurnContext(key: K): TurnContext[K]; /** Clear all channels. Should be called at the start of each turn by the producer that owns the turn boundary. */ export declare function resetTurnContext(): void;