/**
 * Middleware Pipeline
 *
 * Orchestrates middleware execution in priority order.
 * Inspired by Mistral Vibe's elegant middleware architecture.
 */
import { ConversationMiddleware, ConversationContext, MiddlewareResult, MiddlewareAction } from './types.js';
export type PipelineEventType = 'middleware:before' | 'middleware:after' | 'middleware:action' | 'middleware:error' | 'pipeline:reset';
export interface PipelineEvent {
    type: PipelineEventType;
    middlewareName?: string;
    action?: MiddlewareAction;
    message?: string;
    error?: Error;
    timestamp: Date;
}
export type PipelineEventHandler = (event: PipelineEvent) => void;
/**
 * Orchestrates middleware execution in priority order
 */
export declare class MiddlewarePipeline {
    private middlewares;
    private eventHandlers;
    private enabled;
    constructor(middlewares?: ConversationMiddleware[]);
    /**
     * Add middleware to the pipeline (maintains priority order)
     */
    add(middleware: ConversationMiddleware): this;
    /**
     * Remove middleware by name
     */
    remove(name: string): boolean;
    /**
     * Get middleware by name
     */
    get(name: string): ConversationMiddleware | undefined;
    /**
     * Check if middleware exists
     */
    has(name: string): boolean;
    /**
     * Get all middleware names in priority order
     */
    getNames(): string[];
    /**
     * Enable/disable the entire pipeline
     */
    setEnabled(enabled: boolean): void;
    /**
     * Check if pipeline is enabled
     */
    isEnabled(): boolean;
    /**
     * Subscribe to pipeline events
     */
    on(handler: PipelineEventHandler): () => void;
    /**
     * Emit an event to all handlers
     */
    private emit;
    /**
     * Run beforeTurn on all middlewares
     * Stops at first non-continue result
     */
    runBefore(context: ConversationContext): Promise<MiddlewareResult>;
    /**
     * Run afterTurn on all middlewares
     * Stops at first non-continue result
     */
    runAfter(context: ConversationContext): Promise<MiddlewareResult>;
    /**
     * Reset all middlewares
     */
    reset(): void;
    /**
     * Clear all middlewares
     */
    clear(): void;
    /**
     * Get middleware count
     */
    get count(): number;
}
/**
 * Fluent builder for creating middleware pipelines
 */
export declare class PipelineBuilder {
    private middlewares;
    /**
     * Add middleware to the pipeline
     */
    use(middleware: ConversationMiddleware): this;
    /**
     * Add multiple middlewares
     */
    useAll(middlewares: ConversationMiddleware[]): this;
    /**
     * Conditionally add middleware
     */
    useIf(condition: boolean, middleware: ConversationMiddleware): this;
    /**
     * Build the pipeline
     */
    build(): MiddlewarePipeline;
}
/**
 * Create a new pipeline builder
 */
export declare function createPipeline(): PipelineBuilder;
