/**
 * Process Stream Service
 *
 * Processes the async iterator from agent.stream() and updates UI state.
 * This replaces the event bus subscriptions for streaming events,
 * providing direct, synchronous control over the streaming lifecycle.
 *
 * Architecture:
 * - Messages being streamed are tracked in `pendingMessages` (rendered dynamically)
 * - Only finalized messages are added to `messages` (rendered in <Static>)
 * - Progressive finalization: large streaming content is split at safe markdown
 *   boundaries, moving completed paragraphs to Static to reduce flickering
 * - This prevents duplicate output in static terminal mode
 *
 * IMPORTANT: React batching fix (see commit history for race condition details)
 * - We use a local `localPending` array that mirrors React state synchronously
 * - This allows us to flatten nested setState calls (which caused ordering bugs)
 * - Nested setState: inner setMessages inside setPendingMessages callback gets
 *   queued and runs AFTER other setMessages calls in the same batch
 * - Flattened: setMessages and setPendingMessages are sibling calls, processed in order
 */
import type React from 'react';
import type { StreamingEvent } from '@dexto/core';
import type { Message, UIState } from '../state/types.js';
import type { ApprovalRequest } from '../components/ApprovalPrompt.js';
/**
 * State setters needed by processStream
 */
export interface ProcessStreamSetters {
    /** Setter for finalized messages (rendered in <Static>) */
    setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
    /** Setter for pending/streaming messages (rendered dynamically outside <Static>) */
    setPendingMessages: React.Dispatch<React.SetStateAction<Message[]>>;
    /** Setter for dequeued buffer (user messages waiting to render after pending) */
    setDequeuedBuffer: React.Dispatch<React.SetStateAction<Message[]>>;
    setUi: React.Dispatch<React.SetStateAction<UIState>>;
    /** Setter for session state (for session switch on compaction) */
    setSession: React.Dispatch<React.SetStateAction<import('../state/types.js').SessionState>>;
    /** Setter for active-turn steer messages */
    setSteerMessages: React.Dispatch<React.SetStateAction<import('@dexto/core').QueuedMessage[]>>;
    /** Setter for queued follow-up messages */
    setQueuedMessages: React.Dispatch<React.SetStateAction<import('@dexto/core').QueuedMessage[]>>;
    /** Setter for current approval request (for approval UI) */
    setApproval: React.Dispatch<React.SetStateAction<ApprovalRequest | null>>;
    /** Setter for approval queue (for queued approvals) */
    setApprovalQueue: React.Dispatch<React.SetStateAction<ApprovalRequest[]>>;
}
/**
 * Options for processStream
 */
export interface ProcessStreamOptions {
    /** Whether to stream chunks (true) or wait for complete response (false). Default: true */
    useStreaming?: boolean;
    /** Ref to check if "accept all edits" mode is enabled (reads .current for latest value) */
    autoApproveEditsRef: {
        current: boolean;
    };
    /** Ref to check if "bypass permissions" mode is enabled (auto-approve all approvals) */
    bypassPermissionsRef: {
        current: boolean;
    };
    /** Event emitter for emitting auto-approval responses */
    eventBus: Pick<import('@dexto/core').AgentEventBus, 'emit'>;
    /** Sound notification service for playing sounds on events */
    soundService?: import('../utils/soundNotification.js').SoundNotificationService;
    /** Optional setter for todos (from service:event todo updates) */
    setTodos?: React.Dispatch<React.SetStateAction<import('../state/types.js').TodoItem[]>>;
}
/**
 * Processes the async iterator from agent.stream() and updates UI state.
 *
 * For static mode compatibility:
 * - Streaming content goes to `pendingMessages` (rendered dynamically)
 * - Finalized content is moved to `messages` (rendered in <Static>)
 *
 * @param iterator - The async iterator from agent.stream()
 * @param setters - State setters for updating UI
 * @param options - Configuration options
 */
export declare function processStream(iterator: AsyncIterableIterator<StreamingEvent>, setters: ProcessStreamSetters, options: ProcessStreamOptions): Promise<void>;
//# sourceMappingURL=processStream.d.ts.map