import type { HumanMessage } from '@langchain/core/messages'; import { Context, Service } from 'koishi'; import type { LivingMemoryPresetExport, LivingMemoryPresetImportResult, LivingMemorySearchDetailedResult, LivingMemorySearchInput, LivingMemoryTranscriptMessage, MemoryMutationInput, MemoryScope, MemoryUpdatePatch, PresetPersonaCardInfo } from '../../contracts/memory'; import type { JobListQuery, MemoryListFilter, MemoryListQuery, SnapshotListQuery, UserProfileListQuery } from '../../contracts/rpc'; import type { AttributedMemoryItem, DreamTriggerResult, LivingMemoryConfig, MemoryConfigWarning, MemoryServiceStatus } from '../../contracts/workflows'; import type { QueueExtractionOptions } from '../memory/helpers'; import { type CreateLivingMemoryScopeOptions } from './scope'; import { type LivingMemoryPromptSectionsOptions } from './prompt_hydration'; import { LivingMemoryLogger } from '../logging/logger'; import { MessageLogRegistry } from '../transcript/message_log/message_log_registry'; export declare class ChatLunaLivingMemoryService extends Service { readonly ctx: Context; config: LivingMemoryConfig; readonly memoryLogger: LivingMemoryLogger; /** 会话消息日志:召回与提取共用的唯一消息历史视界。 */ readonly messageLog: MessageLogRegistry; private readonly repository; private readonly recallCoordinator; private readonly extractionCoordinator; private readonly dreamCoordinator; private readonly presetCatalog; private readonly userProfiles; private readonly presetPersona; private readonly searchEngine; private readonly vectorIndex; private readonly dreamWorker; private readonly mutations; private archivedMemoryCleanup; constructor(ctx: Context, config: LivingMemoryConfig); private createRecallCoordinator; private createDreamCoordinator; private createExtractionCoordinator; /** 每日维护:清理过期任务,并调度过期归档记忆的衰减清理。 */ private scheduleDailyMaintenance; protected start(): Promise; protected stop(): Promise; validateConfig(): MemoryConfigWarning[]; getStatus(): MemoryServiceStatus; resolvePresetId(message: HumanMessage, fallbackPresetId?: string): string | null; createScope(conversationId: string, presetId: string, userId?: string, channelId?: string, options?: CreateLivingMemoryScopeOptions): MemoryScope; recordPresetSpeaker(scope: Pick, speakerLabel: string): Promise; hydratePromptSections(scope: Pick, options?: LivingMemoryPromptSectionsOptions): Promise<{ snapshot: string; userProfiles: string; }>; queueRecall(scope: MemoryScope, currentMessage: LivingMemoryTranscriptMessage, loadHistoryMessages: () => Promise): Promise; queueExtraction(scope: MemoryScope, options: QueueExtractionOptions, initialCursor?: () => number): Promise; clearExtractionState(): void; clearRecallState(): void; cleanupConversation(conversationId: string): Promise; listPresetIds(): Promise; /** * 读取预设人设卡片正文,供外部插件使用:已落库时返回卡片,否则返回预设 * system 部分原文。只读,不调模型、不落库。 */ resolvePresetPersona(presetId: string): Promise; /** * 读取单个预设人设卡片(只读视图,不含模型调用)。外部插件需要卡片正文时 * 用 `resolvePresetPersona`,需要异常提示或落库时间时用这里。 */ getPresetPersonaCard(presetId: string): Promise; /** 列出全部预设人设卡片及其异常提示,供 Console 展示与外部插件读取。 */ listPresetPersonas(): Promise; /** 保存手工编辑的预设人设卡片;此后不再被自动覆盖。 */ savePresetPersonaCard(presetId: string, card: string): Promise; /** 丢弃手工卡片并按当前预设原文重新生成。 */ resetPresetPersonaCard(presetId: string): Promise; listMemories(query: MemoryListQuery): Promise; listMemoryIds(filter: MemoryListFilter): Promise; findActiveMemoryIdsByText(presetId: string, text: string): Promise; findActiveMemoryIdsByUser(presetId: string, platform: string, userId: string): Promise; findUserProfileIdByUser(presetId: string, platform: string, userId: string): Promise; archiveActiveMemories(presetId: string, ids: string[]): Promise<{ archived: number; }>; getMemory(memoryId: string): Promise; searchMemoriesDetailed(presetId: string, input: LivingMemorySearchInput): Promise; searchMemories(presetId: string, input: LivingMemorySearchInput, conversationId?: string): Promise; getMemorySourceMessages(presetId: string, memoryId: string): Promise; createMemory(scope: MemoryScope, input: MemoryMutationInput, speakerKeys?: string[]): Promise; updateMemory(memoryId: string, patch: MemoryUpdatePatch): Promise; updateActiveMemory(presetId: string, memoryId: string, patch: Omit): Promise; splitActiveMemory(presetId: string, sourceMemoryId: string, memories: AttributedMemoryItem[]): Promise<{ memories: import("../..").MemoryEntryRecord[]; warnings: string[]; }>; mergeActiveMemories(presetId: string, sourceMemoryIds: string[], memory: AttributedMemoryItem): Promise<{ memory: import("../..").MemoryEntryRecord; warnings: string[]; }>; deleteMemory(memoryId: string): Promise; deleteMemories(presetId: string, ids: string[]): Promise<{ deleted: number; }>; deleteSnapshot(snapshotId: string): Promise; listSnapshots(query: SnapshotListQuery): Promise>; listJobs(query: JobListQuery): Promise>; listUserProfiles(query: UserProfileListQuery): Promise>; listPresetSpeakers(presetId: string): Promise; deleteUserProfile(profileId: string): Promise; updateUserProfile(profileId: string, content: string): Promise; regenerateUserProfile(presetId: string, speakerKey: string): Promise; runDream(presetId: string): Promise; reconcileVectorIndex(presetId: string): Promise; rebuildVectorIndex(): void; restartVectorIndex(): Promise; clearPresetData(presetId: string): Promise; exportPreset(presetId: string): Promise; importPreset(targetPresetId: string, data: LivingMemoryPresetExport): Promise; cleanupStaleJobs(maxAge?: number): Promise; private queueExpiredArchivedMemoryCleanup; private cleanupExpiredArchivedMemories; }