/**
 * Message Processor Module
 *
 * Handles message processing, streaming, and tool call extraction.
 * Extracted from CodeBuddyAgent for better modularity and testability.
 */
import { EventEmitter } from "events";
/**
 * Chat entry types for history
 */
export interface ChatEntry {
    type: "user" | "assistant" | "tool_result" | "system";
    content: string;
    timestamp: Date;
    toolCalls?: CodeBuddyToolCall[];
    toolCall?: CodeBuddyToolCall;
    toolResult?: ToolResult;
}
/**
 * Tool call structure from OpenAI/CodeBuddy API
 */
export interface CodeBuddyToolCall {
    id: string;
    type: "function";
    function: {
        name: string;
        arguments: string;
    };
}
/**
 * Result of a tool execution
 */
export interface ToolResult {
    success: boolean;
    output?: string;
    error?: string;
}
/**
 * Message structure for API communication
 */
export interface Message {
    role: "system" | "user" | "assistant" | "tool";
    content: string | null;
    tool_calls?: CodeBuddyToolCall[];
    tool_call_id?: string;
}
/**
 * Streaming event types
 */
export type StreamEvent = {
    type: "content";
    content: string;
} | {
    type: "tool_calls";
    toolCalls: CodeBuddyToolCall[];
} | {
    type: "tool_result";
    toolCall: CodeBuddyToolCall;
    toolResult: ToolResult;
} | {
    type: "token_count";
    tokenCount: number;
} | {
    type: "done";
};
/**
 * Commentary tool call pattern matching result
 */
export interface ExtractedToolCalls {
    toolCalls: Array<{
        name: string;
        arguments: Record<string, unknown>;
    }>;
    remainingContent: string;
}
/**
 * Sanitize LLM output by removing control tokens
 */
export declare function sanitizeLLMOutput(content: string): string;
/**
 * Extract tool calls from commentary-style patterns in content
 *
 * Handles patterns like:
 * - "commentary to=web_search {"query":"..."}"
 * - "web_search({"query":"test"})"
 */
export declare function extractCommentaryToolCalls(content: string): ExtractedToolCalls;
/**
 * MessageProcessor handles message creation and history management.
 */
export declare class MessageProcessor extends EventEmitter {
    private chatHistory;
    private messages;
    constructor(systemPrompt?: string);
    /**
     * Add a user message to history
     */
    addUserMessage(content: string): void;
    /**
     * Add an assistant message to history
     */
    addAssistantMessage(content: string, toolCalls?: CodeBuddyToolCall[]): void;
    /**
     * Add a tool result to history
     */
    addToolResult(toolCall: CodeBuddyToolCall, result: ToolResult): void;
    /**
     * Add a system message
     */
    addSystemMessage(content: string): void;
    /**
     * Get all messages for API call
     */
    getMessages(): Message[];
    /**
     * Get chat history
     */
    getChatHistory(): ChatEntry[];
    /**
     * Set messages (for context management)
     */
    setMessages(messages: Message[]): void;
    /**
     * Get the system message
     */
    getSystemMessage(): Message | undefined;
    /**
     * Update the system message
     */
    updateSystemMessage(content: string): void;
    /**
     * Clear all history except system message
     */
    clear(): void;
    /**
     * Trim history to prevent unbounded growth
     */
    trimHistory(maxSize: number): void;
    /**
     * Get message count
     */
    getMessageCount(): number;
    /**
     * Get the last N messages
     */
    getRecentMessages(count: number): Message[];
    /**
     * Build accumulated message from streaming chunks
     */
    buildAccumulatedMessage(chunks: Array<{
        choices: Array<{
            delta: {
                content?: string;
                tool_calls?: unknown[];
            };
        }>;
    }>): {
        content: string;
        tool_calls?: CodeBuddyToolCall[];
    };
    /**
     * Create an error message entry
     */
    createErrorEntry(error: string): ChatEntry;
    /**
     * Export history to JSON
     */
    exportHistory(): string;
    /**
     * Import history from JSON
     */
    importHistory(json: string): void;
}
