/**
 * Codex Event Mapper
 *
 * Maps Codex app-server JSON-RPC notifications to the provider-agnostic
 * AgentMessage interface. Handles deduplication of tool_use/tool_result
 * events and text delta buffering.
 *
 * @module
 */
import type { AgentMessage } from '../types.js';
/** Item types within Codex notifications */
interface CodexCommandExecution {
    type: 'commandExecution';
    id: string;
    command?: string;
    cwd?: string;
    stdout?: string;
    exitCode?: number;
    status?: string;
}
interface CodexFileChange {
    type: 'fileChange';
    id: string;
    changes?: unknown;
    content?: string;
}
interface CodexMcpToolCall {
    type: 'mcpToolCall';
    id: string;
    tool?: string;
    arguments?: unknown;
    result?: string;
}
interface CodexAgentMessage {
    type: 'agentMessage';
    id: string;
    text?: string;
}
type CodexItem = CodexCommandExecution | CodexFileChange | CodexMcpToolCall | CodexAgentMessage;
/** Codex notification params shape */
export interface CodexNotificationParams {
    threadId?: string;
    item?: CodexItem;
    delta?: string;
    itemId?: string;
    status?: string;
    error?: {
        message?: string;
    } | string;
    [key: string]: unknown;
}
/** Codex notification (JSON-RPC notification from the app-server) */
export interface CodexNotification {
    method: string;
    params?: CodexNotificationParams;
}
/**
 * Maps Codex JSON-RPC notifications to AgentMessage arrays.
 *
 * Tracks emitted tool IDs to avoid duplicate tool_use/tool_result messages.
 * Buffers streaming text deltas and emits a single accumulated `assistant`
 * message when the next non-text event arrives.
 */
export declare class CodexEventMapper {
    private emittedToolUses;
    private emittedToolResults;
    private pendingText;
    private outputBuffers;
    /**
     * Maps a Codex notification to zero or more AgentMessages.
     *
     * @param notification - The raw Codex JSON-RPC notification
     * @param threadId - Our thread ID for filtering
     * @returns Array of AgentMessages (may be empty)
     */
    mapNotification(notification: CodexNotification, threadId: string): AgentMessage[];
    /** Flush any buffered text as a final assistant message. Call after stream ends. */
    flush(): AgentMessage[];
    /** Reset state for a new conversation turn */
    reset(): void;
    private handleServerError;
    private handleOutputDelta;
    private handleTextDelta;
    private handleItemStarted;
    private handleItemCompleted;
    private handleTurnCompleted;
    private flushPendingText;
    private extractErrorMessage;
}
export {};
//# sourceMappingURL=event-mapper.d.ts.map