import { Context } from 'koishi'; import type { MemoryEntryRecord, MemoryMutationInput, MemoryScope, MemorySourceMessage, MemoryUpdatePatch } from '../../contracts/memory'; import type { LegacyMemoryEmbeddingRecord, MemoryIndexSourceRecord } from '../../contracts/vector_index'; import type { AttributedMemoryItem, DreamMemoryEntryRecord, RecallRepository, UserProfileMemoryRepository } from '../../contracts/workflows'; import type { LivingMemoryTransact } from './types'; export declare class LivingMemoryEntryRepository implements RecallRepository, UserProfileMemoryRepository { private readonly ctx; private readonly transact; constructor(ctx: Context, transact: LivingMemoryTransact); /** * 回填活跃记忆的用户关联行。读取按 id 游标分页,峰值内存只与单页记忆条数 * 相关;分页与写入同处一个事务,保持要么整体生效要么不生效的语义与迁移 * 标记的幂等性。 */ migrateActiveMemorySpeakers(): Promise; private selectActiveMemorySpeakerPage; migrateMemorySourceOriginsArray(): Promise; migrateWebuiSourceConversationKeys(): Promise; hasMigratedLegacyEmbeddings(): Promise; completeLegacyEmbeddingMigration(): Promise; listEntriesByPreset(presetId: string): Promise; listArchivedEntriesBefore(presetId: string, updatedBefore: Date): Promise[]>; listDreamEntriesByPreset(presetId: string): Promise; listActiveMemorySpeakerKeys(presetId: string): Promise; listActiveMemorySpeakerLinks(presetId: string, speakerKeys: string[]): Promise[]>; listEntryIndexSourcePage(afterId: string | null, limit: number): Promise; listEntryIndexSourcePageByPreset(presetId: string, afterId: string | null, limit: number): Promise; private selectEntryIndexSourcePage; listLegacyEmbeddingPage(afterId: string | null, limit: number): Promise; countEntriesByPreset(presetId: string): Promise; countEntries(): Promise; listEntryPresetIds(): Promise; countActiveEntries(presetId: string): Promise; getEntryById(id: string): Promise; getEntriesByPresetAndIds(presetId: string, ids: string[]): Promise; getSearchEntriesByPresetAndIds(presetId: string, ids: string[]): Promise[]>; appendMemories(scope: MemoryScope, sourceOriginMessages: MemorySourceMessage[], extracted: AttributedMemoryItem[], sourceLabel?: string | null): Promise; createMemory(scope: MemoryScope, input: MemoryMutationInput, speakerKeys?: string[]): Promise; private buildMemoryEntry; updateMemory(id: string, patch: MemoryUpdatePatch): Promise<{ record: { id: string; presetId: string; sourceConversationId: string | null; sourceLabel: string | null; sourceOrigins: import("../..").MemorySourceOrigin[]; createdAt: Date; updatedAt: Date; speakerKeys: string[]; type: "context" | "fact" | "identity" | "other" | "plan" | "preference"; status: "active" | "archived"; content: string; keywords: string[]; summary: string | null; sentiment: string | null; importance: number | null; }; contentChanged: boolean; } | null>; archiveActiveEntries(presetId: string, ids: string[]): Promise<{ id: string; presetId: string; speakerKeys: string[]; type: import("../..").MemoryEntryType; content: string; keywords: string[]; summary: string | null; sentiment: string | null; importance: number | null; sourceConversationId: string | null; sourceLabel: string | null; sourceOrigins: import("../..").MemorySourceOrigin[]; createdAt: Date; status: 'archived'; updatedAt: Date; }[]>; splitMemory(presetId: string, sourceMemoryId: string, memories: AttributedMemoryItem[]): Promise<{ memories: MemoryEntryRecord[]; archivedSource: { id: string; presetId: string; speakerKeys: string[]; type: import("../..").MemoryEntryType; content: string; keywords: string[]; summary: string | null; sentiment: string | null; importance: number | null; sourceConversationId: string | null; sourceLabel: string | null; sourceOrigins: import("../..").MemorySourceOrigin[]; createdAt: Date; status: 'archived'; updatedAt: Date; }; }>; mergeMemories(presetId: string, sourceMemoryIds: string[], memory: AttributedMemoryItem): Promise<{ memory: MemoryEntryRecord; archivedSources: { id: string; presetId: string; speakerKeys: string[]; type: import("../..").MemoryEntryType; content: string; keywords: string[]; summary: string | null; sentiment: string | null; importance: number | null; sourceConversationId: string | null; sourceLabel: string | null; sourceOrigins: import("../..").MemorySourceOrigin[]; createdAt: Date; status: 'archived'; updatedAt: Date; }[]; }>; deleteMemory(id: string): Promise; deleteEntries(presetId: string, ids: string[]): Promise; private replaceActiveMemorySpeakers; private buildMemoryUpdatePatch; }