import { DataSource } from '@n8n/typeorm'; import { InstanceAiMessage } from '../entities/instance-ai-message.entity'; import { InstanceAiThread } from '../entities/instance-ai-thread.entity'; export interface ConversationThreadSearchRow { id: string; title: string; updatedAt: Date; } export interface ConversationThreadScope { userId: string; projectId: string; excludeThreadId: string; } export interface ConversationWindowAnchor { createdAt: Date; id: string; } export interface ConversationWindowParams { threadId: string; anchor?: ConversationWindowAnchor; before: number; after: number; project: (row: InstanceAiMessage) => T | undefined; } export interface ConversationWindow { rows: T[]; hasMoreBefore: boolean; hasMoreAfter: boolean; } export declare class InstanceAiConversationHistoryRepository { private readonly dataSource; constructor(dataSource: DataSource); searchProjectThreadsForUser(params: ConversationThreadScope & { query: string; limit: number; }): Promise; listRecentProjectThreadsForUser(params: ConversationThreadScope & { limit: number; }): Promise; countProjectThreadsForUser(scope: ConversationThreadScope): Promise; findOwnedThread(threadId: string, userId: string, projectId: string): Promise; findSearchMatchRows(threadIds: string[], query: string, maxRowsPerThread: number): Promise>; findFirstUserMessages(threadIds: string[]): Promise>; findMessageInThread(threadId: string, messageId: string): Promise; getConversationWindow(params: ConversationWindowParams): Promise>; private pageByRecency; private scopedThreads; private buildSearchQuery; private fetchWindowSide; private conversationRows; private orderMessages; private threads; private messages; }