import { XPEvent } from '../events'; import { FlagValue } from '../scenario/types'; import { ConditionTrace } from '../scenario/trace'; /** Why a matched trigger did not fire (undefined when it fired). */ export type SkipReason = 'once' | 'max' | 'when'; /** One trigger's outcome for a single event. */ export interface TriggerReport { /** Trigger id, or its index as a string. */ id: string; index: number; on: string | string[]; /** Did the event type match the trigger's `on`? */ matchedOn: boolean; /** Present when `matchedOn` and the once/max budget allowed evaluation. */ when?: ConditionTrace; fired: boolean; skip?: SkipReason; /** Times this trigger has fired so far. */ fireCount: number; } /** A flag mutation attributed to the trigger that caused it. */ export interface FlagChange { flag: string; value: FlagValue; /** The firing trigger's id/index. */ by: string; } /** The ScenarioRunner's full report for one processed event. */ export interface EvalReport { /** Monotonic sequence number within this instance. */ seq: number; event: XPEvent; triggers: TriggerReport[]; /** Flags snapshot after the event was processed. */ flags: Record; /** Flags changed while processing this event, with attribution. */ changes: FlagChange[]; } type Listener = (report: EvalReport) => void; /** Publish a report to everyone listening on `prefix`. Never throws. */ export declare const publishTrace: (prefix: string, report: EvalReport) => void; /** * Whether anyone is listening on `prefix`. The ScenarioRunner guards its extra * trace-building on this so a production build with no panel pays nothing. */ export declare const hasTraceListeners: (prefix: string) => boolean; /** Subscribe to reports on `prefix`; returns an unsubscribe function. */ export declare const subscribeTrace: (prefix: string, fn: Listener) => (() => void); export {};