import { type AgentDbMessage, type BuiltEpisodicMemoryCaptureStore, type BuiltEpisodicMemoryStore, type BuiltMemory, type BuiltObservationLogStore, type BuiltObservationLogTaskLockStore, type EpisodicMemoryEntrySource, type MemoryDescriptor, type NewObservationLogEntry, type ObservationCursor, type ObservationLogBatch, type ObservationLogBatchCommitResult, type ObservationLogEntry, type ObservationLogReadOptions, type ObservationLogReflection, type ObservationLogReflectionResult, type ObservationLogScope, type ObservationLogTaskKind, type ObservationLogTaskLockHandle, type Thread } from '@n8n/agents'; import type { AgentMessageAuthor } from '@n8n/api-types'; import type { OperationContext } from '@n8n/db'; import type { AgentMessageOrigin } from '../entities/agent-message.entity'; import { AgentMemoryEntryCandidateRepository } from '../repositories/agent-memory-entry-candidate.repository'; import { AgentMemoryEntryLockRepository } from '../repositories/agent-memory-entry-lock.repository'; import { AgentMemoryEntrySourceRepository } from '../repositories/agent-memory-entry-source.repository'; import { AgentMemoryEntryRepository } from '../repositories/agent-memory-entry.repository'; import { AgentMemoryScopeRepository } from '../repositories/agent-memory-scope.repository'; import { AgentMessageRepository } from '../repositories/agent-message.repository'; import { AgentObservationCursorRepository } from '../repositories/agent-observation-cursor.repository'; import { AgentObservationLockRepository } from '../repositories/agent-observation-lock.repository'; import { AgentObservationRepository } from '../repositories/agent-observation.repository'; import { AgentResourceRepository } from '../repositories/agent-resource.repository'; import { AgentThreadRepository } from '../repositories/agent-thread.repository'; export declare class N8nMemory { private readonly threadRepository; private readonly messageRepository; private readonly resourceRepository; private readonly observationRepository; private readonly observationCursorRepository; private readonly observationLockRepository; private readonly memoryEntryRepository; private readonly memoryEntryCandidateRepository; private readonly memoryEntryLockRepository; private readonly memoryEntrySourceRepository; private readonly memoryScopeRepository; constructor(threadRepository: AgentThreadRepository, messageRepository: AgentMessageRepository, resourceRepository: AgentResourceRepository, observationRepository: AgentObservationRepository, observationCursorRepository: AgentObservationCursorRepository, observationLockRepository: AgentObservationLockRepository, memoryEntryRepository: AgentMemoryEntryRepository, memoryEntryCandidateRepository: AgentMemoryEntryCandidateRepository, memoryEntryLockRepository: AgentMemoryEntryLockRepository, memoryEntrySourceRepository: AgentMemoryEntrySourceRepository, memoryScopeRepository: AgentMemoryScopeRepository); getThreadsMetadata(threadIds: string[]): Promise>>; getImplementation(agentId: string): N8nMemoryImpl; } export type EpisodicMemorySourceWithMessageContext = EpisodicMemoryEntrySource & { author?: AgentMessageAuthor; origin?: AgentMessageOrigin; }; export declare class N8nMemoryImpl implements BuiltMemory, BuiltObservationLogStore, BuiltObservationLogTaskLockStore, BuiltEpisodicMemoryStore, BuiltEpisodicMemoryCaptureStore { private readonly agentId; private readonly threadRepository; private readonly messageRepository; private readonly resourceRepository; private readonly observationRepository; private readonly observationCursorRepository; private readonly observationLockRepository; private readonly memoryEntryRepository; private readonly memoryEntryCandidateRepository; private readonly memoryEntryLockRepository; private readonly memoryEntrySourceRepository; private readonly memoryScopeRepository; constructor(agentId: string, threadRepository: AgentThreadRepository, messageRepository: AgentMessageRepository, resourceRepository: AgentResourceRepository, observationRepository: AgentObservationRepository, observationCursorRepository: AgentObservationCursorRepository, observationLockRepository: AgentObservationLockRepository, memoryEntryRepository: AgentMemoryEntryRepository, memoryEntryCandidateRepository: AgentMemoryEntryCandidateRepository, memoryEntryLockRepository: AgentMemoryEntryLockRepository, memoryEntrySourceRepository: AgentMemoryEntrySourceRepository, memoryScopeRepository: AgentMemoryScopeRepository); readonly episodic: BuiltEpisodicMemoryCaptureStore['episodic']; getThread(threadId: string): Promise; saveThread(thread: Omit): Promise; patchThread(args: { threadId: string; update: (current: Thread) => { title?: string; metadata?: Record; } | null | undefined; }, ctx?: OperationContext): Promise; deleteThread(threadId: string, ctx?: OperationContext): Promise; deleteThreadsByPrefix(threadIdPrefix: string): Promise; deleteThreads(threadIds: string[]): Promise; private deleteThreadsMatching; private deleteEpisodicEntriesWithoutSources; getMessages(threadId: string, opts?: { limit?: number; before?: Date; resourceId?: string; }): Promise; saveMessages(args: Parameters[0]): Promise; deleteMessages(messageIds: string[]): Promise; commitObservationLogBatch(batch: ObservationLogBatch): Promise; appendObservationLogEntries(rows: NewObservationLogEntry[]): Promise; getActiveObservationLog(scope: ObservationLogScope & { limit?: number; order?: 'asc' | 'desc'; }): Promise; getObservationLog(opts: ObservationLogReadOptions): Promise; getMessagesForObservationScope(observationScopeId: string, opts?: { since?: { sinceCreatedAt: Date; sinceMessageId: string; }; }): Promise; dropObservationLogEntries(ids: string[]): Promise; supersedeObservationLogEntries(ids: string[], supersededBy: string): Promise; applyObservationLogReflection(scope: ObservationLogScope, reflection: ObservationLogReflection): Promise; getCursor(observationScopeId: string): Promise; setCursor(cursor: ObservationCursor): Promise; acquireObservationLogTaskLock(observationScopeId: string, taskKind: ObservationLogTaskKind, opts: { ttlMs: number; holderId: string; }): Promise; releaseObservationLogTaskLock(handle: ObservationLogTaskLockHandle): Promise; private releaseScopeLock; private enqueueEpisodicMemoryCaptureCandidate; private getPendingEpisodicMemoryCaptureCandidates; private completeEpisodicMemoryCaptureCandidates; private recordEpisodicMemoryCaptureCandidateFailure; private acquireEpisodicMemoryTaskLock; private releaseEpisodicMemoryTaskLock; private getEpisodicMemoryEntriesByContentHashes; private saveEpisodicMemoryEntryWithSources; private searchEpisodicMemoryEntries; private findSimilarEpisodicMemoryEntries; private loadRankableEpisodicMemoryEntries; private withFullEntries; private addEpisodicMemoryEntrySources; private getEpisodicMemoryEntrySources; getEntrySourcesWithMessageContext(entryIds: string[]): Promise; private applyEpisodicMemoryReflection; describe(): MemoryDescriptor; private toAgentDbMessage; private toObservationLogEntry; private toEpisodicMemoryEntry; private toEpisodicMemoryCaptureCandidate; private toEpisodicMemoryEntrySource; private mergeThreadMetadata; private parseThreadMetadata; private toThread; }