import { ChatEntry } from "./llm-agent.js"; /** * State information for message rephrasing operations */ export interface RephraseState { /** Index of the original assistant message being rephrased */ originalAssistantMessageIndex: number; /** Index of the rephrase request message */ rephraseRequestIndex: number; /** Index where the new response will be inserted */ newResponseIndex: number; /** Type of message being sent for the rephrase */ messageType: "user" | "system"; /** Optional prefill text to start the rephrased response */ prefillText?: string; } /** * Dependencies required by MessageProcessor */ export interface MessageProcessorDependencies { /** Chat history array */ chatHistory: ChatEntry[]; /** Function to get current token count */ getCurrentTokenCount(): number; /** Function to get maximum context size */ getMaxContextSize(): number; /** Function to set rephrase state */ setRephraseState(originalAssistantMessageIndex: number, rephraseRequestIndex: number, newResponseIndex: number, messageType: "user" | "system", prefillText?: string): void; } /** * Handles message processing, parsing, and transformation for the LLM agent */ export declare class MessageProcessor { private deps; /** Stores prefill text from hooks */ private hookPrefillText; /** * Creates a new MessageProcessor instance * @param deps - Dependencies required for message processing */ constructor(deps: MessageProcessorDependencies); /** * Processes rephrase commands and sets up rephrase state * @param message - The input message to check for rephrase commands * @returns Object containing rephrase information and processed message */ setupRephraseCommand(message: string): Promise<{ isRephraseCommand: boolean; messageType: "user" | "system"; messageToSend: string; prefillText?: string; }>; /** * Parses message content and assembles it with variables * @param messageToSend - The message to parse and assemble * @returns Object containing parsed content and assembled message */ parseAndAssembleMessage(messageToSend: string): Promise<{ parsed: any; assembledMessage: string; }>; /** * Prepares message content for LLM consumption, handling images and content types * @param messageType - Type of message ("user" or "system") * @param assembledMessage - The assembled message text * @param parsed - Parsed message content including images * @param messageToSend - Original message to send * @param supportsVision - Whether the LLM supports vision/images * @returns Object containing user entry and formatted message content */ prepareMessageContent(messageType: "user" | "system", assembledMessage: string, parsed: any, messageToSend: string, supportsVision: boolean): { userEntry: ChatEntry; messageContent: any; }; /** * Parse XML-formatted tool calls from message content (x.ai format) * Converts elements to standard LLMToolCall format * @param message - Message object that may contain XML tool calls * @returns Modified message with parsed tool calls */ parseXMLToolCalls(message: any): any; /** * Reduces streaming message chunks into a complete message object * @param previous - Previously accumulated message data * @param item - Current streaming chunk to process * @returns Updated accumulated message object */ messageReducer(previous: any, item: any): any; /** * Gets the current hook prefill text * @returns The prefill text or null if none is set */ getHookPrefillText(): string | null; /** * Clears the hook prefill text */ clearHookPrefillText(): void; /** * Sets the hook prefill text * @param text - The prefill text to set */ setHookPrefillText(text: string): void; }