import { UserMessageParams, type AgentToolBlockUpdateParams, type AddNotificationMessageParams } from "../utils/messageOperations.js";
import type { Message, Usage } from "../types/index.js";
import { SessionData } from "../services/session.js";
import { ChatCompletionMessageFunctionToolCall } from "openai/resources.js";
import { Container } from "../utils/container.js";
export interface MessageManagerCallbacks {
    onMessagesChange?: (messages: Message[]) => void;
    onSessionIdChange?: (sessionId: string) => void;
    onLatestTotalTokensChange?: (latestTotalTokens: number) => void;
    onUsagesChange?: (usages: Usage[]) => void;
    onUserMessageAdded?: (params: UserMessageParams) => void;
    onAssistantMessageAdded?: () => void;
    onAssistantContentUpdated?: (chunk: string, accumulated: string) => void;
    onAssistantReasoningUpdated?: (chunk: string, accumulated: string) => void;
    onToolBlockUpdated?: (params: AgentToolBlockUpdateParams) => void;
    onErrorBlockAdded?: (error: string) => void;
    onCompressBlockAdded?: (content: string) => void;
    onCompressionStateChange?: (isCompressing: boolean) => void;
    onAddBangMessage?: (command: string) => void;
    onUpdateBangMessage?: (command: string, output: string) => void;
    onCompleteBangMessage?: (command: string, exitCode: number) => void;
    onInfoBlockAdded?: (content: string) => void;
    onShowRewind?: () => void;
    onFileHistoryBlockAdded?: (snapshots: import("../types/reversion.js").FileSnapshot[]) => void;
    onNotificationMessageAdded?: (params: {
        taskId: string;
        taskType: "shell" | "agent";
        status: "completed" | "failed" | "killed";
        summary: string;
    }) => void;
}
export interface MessageManagerOptions {
    callbacks: MessageManagerCallbacks;
    workdir: string;
    sessionType?: "main" | "subagent";
    subagentType?: string;
}
export declare class MessageManager {
    private container;
    private sessionId;
    private rootSessionId;
    private parentSessionId?;
    private messages;
    private latestTotalTokens;
    private workdir;
    private encodedWorkdir;
    private callbacks;
    private transcriptPath;
    private savedMessageCount;
    private filesInContext;
    private sessionType;
    private subagentType?;
    private _usages;
    constructor(container: Container, options: MessageManagerOptions);
    private get memoryRuleManager();
    private get memoryService();
    getSessionId(): string;
    getRootSessionId(): string;
    getParentSessionId(): string | undefined;
    getMessages(): Message[];
    getUsages(): Usage[];
    getLatestTotalTokens(): number;
    getWorkdir(): string;
    /**
     * Returns all files mentioned in the current conversation context.
     */
    getFilesInContext(): string[];
    getSessionDir(): string;
    getTranscriptPath(): string;
    /**
     * Get combined memory content (project memory + user memory + modular rules)
     */
    getCombinedMemory(): Promise<string>;
    /**
     * Compute the transcript path using cached encoded workdir
     * Called during construction and when sessionId changes
     */
    private computeTranscriptPath;
    setSessionId(sessionId: string): void;
    /**
     * Create session if needed (async helper)
     */
    private createSessionIfNeeded;
    /**
     * Adds a file path to the set of files in context, normalizing it if necessary.
     */
    touchFile(filePath: string): void;
    /**
     * Extracts and adds file paths from a message's tool blocks.
     */
    private addPathsFromMessage;
    setMessages(messages: Message[]): void;
    /**
     * Save current session
     */
    saveSession(): Promise<void>;
    setlatestTotalTokens(latestTotalTokens: number): void;
    /**
     * Clear messages
     */
    clearMessages(): void;
    /**
     * Trigger the rewind UI callback
     */
    triggerShowRewind(): void;
    initializeFromSession(sessionData: SessionData): void;
    addUserMessage(params: UserMessageParams): string;
    /**
     * Update an existing user message by its ID.
     */
    updateUserMessage(id: string, params: Partial<UserMessageParams>): void;
    addAssistantMessage(content?: string, toolCalls?: ChatCompletionMessageFunctionToolCall[], usage?: Usage, additionalFields?: Record<string, unknown>): void;
    mergeAssistantAdditionalFields(additionalFields: Record<string, unknown>): void;
    updateToolBlock(params: AgentToolBlockUpdateParams): void;
    /**
     * Add a tool block to a specific message by ID.
     */
    addToolBlockToMessage(messageId: string, params: Omit<AgentToolBlockUpdateParams, "id">): string;
    addErrorBlock(error: string): void;
    addInfoBlock(content: string): void;
    /**
     * Compress messages and update session, delete compressed messages, only keep compressed messages and last 3 messages
     */
    compressMessagesAndUpdateSession(compressedContent: string, usage?: Usage): void;
    addFileHistoryBlock(snapshots: import("../types/reversion.js").FileSnapshot[]): void;
    addBangMessage(command: string): void;
    updateBangMessage(command: string, output: string): void;
    completeBangMessage(command: string, exitCode: number, output?: string): void;
    addNotificationMessage(params: Omit<AddNotificationMessageParams, "messages">): void;
    /**
     * Rebuild usage array from messages containing usage metadata
     * Called during session restoration to reconstruct usage tracking
     */
    rebuildUsageFromMessages(messages: Message[]): void;
    /**
     * Add usage data to the tracking array and trigger callbacks
     * @param usage Usage data from AI operations
     */
    addUsage(usage: Usage): void;
    /**
     * Trigger usage change callback with all usage data from assistant messages
     */
    triggerUsageChange(): void;
    /**
     * Update the current assistant message content during streaming
     * This method updates the last assistant message's content without creating a new message
     * FR-001: Tracks and provides both chunk (new content) and accumulated (total content)
     */
    updateCurrentMessageContent(newAccumulatedContent: string): void;
    /**
     * Update the current assistant message reasoning during streaming
     * This method updates the last assistant message's reasoning content without creating a new message
     */
    updateCurrentMessageReasoning(newAccumulatedReasoning: string): void;
    /**
     * Public wrapper for finalizeCurrentStreamingBlocks.
     * Finalizes text/reasoning blocks after streaming completes (e.g. final response with no tools).
     */
    finalizeStreamingBlocks(): void;
    /**
     * Finalize streaming text/reasoning blocks by setting their stage to "end".
     * Called when a new block (e.g. tool) is appended during streaming.
     */
    private finalizeCurrentStreamingBlocks;
    /**
     * Remove the last user message from the conversation
     * Used for hook error handling when the user prompt needs to be erased
     */
    removeLastUserMessage(): void;
    getFullMessageThread(): Promise<{
        messages: Message[];
        sessionIds: string[];
    }>;
    /**
     * Truncate history to a specific index and revert file changes.
     * @param index - The index of the user message to truncate to.
     * @param reversionManager - Optional ReversionManager to handle file rollbacks.
     */
    truncateHistory(index: number, reversionManager?: import("./reversionManager.js").ReversionManager): Promise<void>;
    /**
     * Rewrite the session file with the current messages.
     */
    private rewriteSessionFile;
    private extractPathsFromParams;
}
//# sourceMappingURL=messageManager.d.ts.map