import { type EpisodicMemoryReflectionApply, type EpisodicMemoryStatus, type NewEpisodicMemoryEntry, type NewEpisodicMemoryEntrySourceForEntry } from '@n8n/agents'; import { BaseRepository, TransactionRunner, type OperationContext } from '@n8n/db'; import { DataSource } from '@n8n/typeorm'; import { AgentMemoryEntryEntity } from '../entities/agent-memory-entry.entity'; import { AgentMemoryScopeRepository } from './agent-memory-scope.repository'; export type MemorySourceMessageField = 'channelId' | 'teamId' | 'authorId'; export interface MemoryEntrySourceFilter { resourceIds?: string[]; resourceIdPrefixes?: string[]; integration?: { type: string; resourceIdPrefixes: string[]; }; sourceMessage?: { integrationType: string; field: MemorySourceMessageField; value: string; }; } export interface MemorySourceFacetRow { resourceId: string; integrationType: string | null; conversationKind: string | null; channelId: string | null; channelName: string | null; teamId: string | null; teamName: string | null; authorId: string | null; authorName: string | null; } export interface AppliedMemoryReflection { droppedIds: string[]; supersededIds: string[]; inserted: AgentMemoryEntryEntity[]; } export declare class AgentMemoryEntryRepository extends BaseRepository { private readonly memoryScopeRepository; constructor(dataSource: DataSource, transactionRunner: TransactionRunner, memoryScopeRepository: AgentMemoryScopeRepository); findByContentHashes(agentId: string, resourceId: string, contentHashes: string[]): Promise; findRankableEntries(agentId: string, resourceIds: string[], statuses: EpisodicMemoryStatus[]): Promise; findInAnyStatus(agentId: string, ids: string[]): Promise; listActiveByAgent(agentId: string, limit: number, after?: { createdAt: Date; id: string; }, filter?: MemoryEntrySourceFilter): Promise; countActiveByAgent(agentId: string, filter?: MemoryEntrySourceFilter): Promise; findSourceFacetRows(agentId: string): Promise; markDeleted(agentId: string, entryId: string): Promise; retireUserScopes(resourceIds: string[], ctx: OperationContext): Promise; saveEntryWithSources(agentId: string, entry: NewEpisodicMemoryEntry, sources: NewEpisodicMemoryEntrySourceForEntry[], ctx: OperationContext): Promise; addSources(agentId: string, entryId: string, sources: NewEpisodicMemoryEntrySourceForEntry[], lastSeenAt: Date, ctx: OperationContext): Promise; applyReflection(agentId: string, resourceId: string, reflection: EpisodicMemoryReflectionApply, ctx: OperationContext): Promise; deleteCandidate(agentId: string, candidateId: string, ctx: OperationContext): Promise; private removeCandidateSources; private claimCandidates; private applyMerge; private findSourcesToCopy; private updateActive; private upsertEntry; private saveSources; private activeEntriesQuery; private whereFromIntegration; private sourceMessageEntryIds; private messageFieldEquals; private messageJsonText; }