import { type Logger } from "../../util/logger.js";
import { type ExportedLLMObsSpan, type LLMObsNamedSpanOptions, LLMObsTracer } from "../llmobs/index.js";
import { FSM, type FSMConfig, type FSMState, type FSMEventBase } from "./fsm.js";
export type TracedFSMConfig<S extends FSMState, E extends FSMEventBase, C> = FSMConfig<S, E, C> & {
    /**
     * Create a provider function that returns tags to be added to every span.
     * This can be used to attach contextual metadata such as request IDs,
     * user IDs, etc. It is called at the termination of each non-terminal state,
     * and at the end of the FSM lifecycle.
     * @param fsm The TracedFSM instance
     */
    createTagProvider?: TracedFSMTagProviderFactory<S, E, C>;
    /** Optional session ID to associate with all spans created by this FSM instance. */
    sessionId?: string;
};
export type TracedFSMStateSpanOptions = LLMObsNamedSpanOptions | "terminal";
export type TracedFSMTagProviderFactory<S extends FSMState, E extends FSMEventBase, C> = (fsm: TracedFSM<S, E, C>) => TagProvider;
/**
 * FSM wrapper that emits tracing spans for each state transition.
 *
 * ## Span Hierarchy
 *
 * The TracedFSM creates a hierarchical span structure:
 * - **Root Span** (optional): Tracks the entire FSM lifecycle from initialization to terminal state
 * - **State Spans**: Individual spans for each non-terminal state
 *
 * ## Terminal States
 *
 * States marked as "terminal" in the configuration:
 * - Do not create their own spans
 * - Trigger the completion of the root span (if configured)
 * - Represent final states in the FSM lifecycle
 *
 * ## Error Handling
 *
 * Tracing failures are logged but do not interrupt FSM operation. The FSM will continue
 * to function normally even if the tracing infrastructure is unavailable.
 */
export declare abstract class TracedFSM<S extends string, E extends {
    type: string;
}, C> extends FSM<S, E, C> {
    private spans;
    protected sessionId?: string;
    tracer: LLMObsTracer;
    logger: Logger;
    private getTags;
    constructor(config: TracedFSMConfig<S, E, C>, tracer?: LLMObsTracer, logger?: Logger);
    /**
     * Exported representation of the active root span (FSM lifecycle), if any.
     */
    get rootSpan(): ExportedLLMObsSpan | undefined;
    /**
     * Supply the span options for the long-lived root span that wraps
     * the entire FSM lifecycle. Invoked once when the first state transition
     * runs.
     */
    protected abstract getRootSpanOptions(initialEvent: E): LLMObsNamedSpanOptions;
    /**
     * Provide the span options for the state being entered.
     * Return "terminal" to finish the root span instead of
     * creating a new state span.
     */
    protected abstract getStateSpanOptions(state: S): TracedFSMStateSpanOptions;
    /**
     * Sanitize the event object to remove sensitive information
     * before attaching it to the trace.
     * */
    protected abstract sanitizeEvent(event: E): Partial<E>;
    private handleTransitionTracing;
    private startRootSpanIfNeeded;
    private finishRootSpanIfOpen;
    private startStateSpan;
    private finishStateSpanIfOpen;
    private startSpan;
    private finishSpan;
    private isTransitionParams;
    private isErrorTransitionParams;
    private getErrorData;
}
export type Tags = {
    [key: string]: any;
};
export type TagProvider = () => Tags;
//# sourceMappingURL=traced-fsm.d.ts.map