import { BufferTurn, ConversationThread } from './types.js';

/**
 * Conversation Threading (Phase 3B)
 *
 * Groups related memories into conversation threads with auto-generated titles.
 * Thread boundary detection: new session key OR time gap > threshold.
 */

declare class ThreadingManager {
    private readonly threadsDir;
    private readonly gapMinutes;
    private currentThreadId;
    private lastTurnTimestamp;
    private lastSessionKey;
    constructor(threadsDir: string, gapMinutes?: number);
    ensureDirectory(): Promise<void>;
    /**
     * Check if we should start a new thread based on session key and time gap.
     */
    shouldStartNewThread(turn: BufferTurn): boolean;
    /**
     * Process a turn and return the thread ID it belongs to.
     * Creates a new thread if needed.
     */
    processTurn(turn: BufferTurn, episodeIds: string[]): Promise<string>;
    /**
     * Append persisted memory IDs to an existing thread.
     * Keeps IDs unique and updates the thread timestamp.
     */
    appendEpisodeIds(threadId: string, episodeIds: string[]): Promise<void>;
    /**
     * Update thread title based on accumulated content.
     */
    updateThreadTitle(threadId: string, content: string): Promise<void>;
    /**
     * Get all threads, sorted by updatedAt desc.
     */
    getAllThreads(): Promise<ConversationThread[]>;
    /**
     * Get a thread by ID.
     */
    loadThread(threadId: string): Promise<ConversationThread | null>;
    /**
     * Save a thread.
     */
    saveThread(thread: ConversationThread): Promise<void>;
    /**
     * Link two threads together.
     */
    linkThreads(threadId1: string, threadId2: string): Promise<boolean>;
    /**
     * Get the current thread ID (if any).
     */
    getCurrentThreadId(): string | null;
    /**
     * Reset threading state (e.g., on plugin restart).
     */
    reset(): void;
}

export { ThreadingManager };
