/** * brain-memory — Unified type definitions * * Merges graph-memory (knowledge graph) + memory-lancedb-pro (vector memory) * into a unified 8-category system with optional graph edges and decay. * * Authors: adoresever (graph-memory), win4r (memory-lancedb-pro), brain-memory contributors */ export declare const MEMORY_CATEGORIES: readonly ["profile", "preferences", "entities", "events", "tasks", "skills", "cases", "patterns"]; export type MemoryCategory = (typeof MEMORY_CATEGORIES)[number]; export type GraphNodeType = "TASK" | "SKILL" | "EVENT"; export type EdgeType = "USED_SKILL" | "SOLVED_BY" | "REQUIRES" | "PATCHES" | "CONFLICTS_WITH"; export declare const EDGE_FROM_CONSTRAINT: Record>; export declare const EDGE_TO_CONSTRAINT: Record>; export type NodeStatus = "active" | "deprecated"; export interface BmNode { id: string; type: GraphNodeType; category: MemoryCategory; name: string; description: string; content: string; status: NodeStatus; validatedCount: number; sourceSessions: string[]; communityId: string | null; pagerank: number; /** 衰减模型字段 */ importance: number; accessCount: number; lastAccessedAt: number; /** Temporal: static facts vs dynamic info */ temporalType: "static" | "dynamic"; /** Scope isolation fields */ scopeSession: string | null; scopeAgent: string | null; scopeWorkspace: string | null; createdAt: number; updatedAt: number; } export interface BmEdge { id: string; fromId: string; toId: string; type: EdgeType; instruction: string; condition?: string; sessionId: string; createdAt: number; } export interface WorkingMemoryConfig { enabled: boolean; maxTasks: number; maxDecisions: number; maxConstraints: number; } export interface WorkingMemoryState { /** 当前任务目标(从最近提取的 TASK 节点推断) */ currentTasks: string[]; /** 最近决策和承诺(本轮新增/验证的节点) */ recentDecisions: string[]; /** 需要注意的约束条件(preference 类节点) */ constraints: string[]; /** 当前关注点(最近用户消息摘要) */ attention: string; /** 最后更新时间 */ updatedAt: number; } export interface FusionConfig { enabled: boolean; similarityThreshold: number; minNodes: number; minCommunities: number; } export interface ReasoningConfig { enabled: boolean; maxHops: number; maxConclusions: number; minRecallNodes: number; } export type ReflectionKind = "invariant" | "derived"; export type ReflectionInsightType = "user-model" | "agent-model" | "lesson" | "decision"; export interface ReflectionInsight { /** 洞察文本 */ text: string; /** 洞察类型 */ kind: ReflectionInsightType; /** invariant=稳定规则(半衰45天), derived=临时观察(半衰7天) */ reflectionKind: ReflectionKind; /** 置信度 0-1 */ confidence: number; } export interface ReflectionResult { insights: ReflectionInsight[]; /** 原始 LLM 输出(用于调试) */ rawOutput: string; } export interface ExtractionResult { nodes: Array<{ type: GraphNodeType; category: MemoryCategory; name: string; description: string; content: string; temporalType: "static" | "dynamic"; }>; edges: Array<{ from: string; to: string; type: EdgeType; instruction: string; condition?: string; }>; } export interface FinalizeResult { promotedSkills: Array<{ type: "SKILL"; name: string; description: string; content: string; }>; newEdges: Array<{ from: string; to: string; type: EdgeType; instruction: string; }>; invalidations: string[]; } export interface RecallResult { nodes: BmNode[]; edges: BmEdge[]; tokenEstimate: number; } export interface EmbeddingConfig { apiKey?: string; baseURL?: string; model?: string; dimensions?: number; } export interface DecayConfig { enabled: boolean; recencyHalfLifeDays: number; recencyWeight: number; frequencyWeight: number; intrinsicWeight: number; timeDecayHalfLifeDays: number; betaCore: number; betaWorking: number; betaPeripheral: number; coreDecayFloor: number; workingDecayFloor: number; peripheralDecayFloor: number; } export interface NoiseFilterConfig { enabled: boolean; minContentLength: number; } export type EngineMode = "graph" | "vector" | "hybrid"; export type StorageBackend = "sqlite" | "lancedb"; export interface RerankConfig { enabled: boolean; apiKey?: string; model?: string; endpoint?: string; provider?: string; timeoutMs?: number; } export interface ReflectionConfig { /** 是否启用反思系统 */ enabled: boolean; /** 轮次反思(轻量,afterTurn 时扫描本轮提取结果) */ turnReflection: boolean; /** 会话反思(重量,session_end 时 LLM 全量分析) */ sessionReflection: boolean; /** 安全过滤(防止 prompt injection) */ safetyFilter: boolean; /** 单次反思最大洞察数 */ maxInsights: number; /** 反思节点 importance 提升值 */ importanceBoost: number; /** 最低置信度阈值 */ minConfidence: number; } export interface BmConfig { /** 引擎模式:graph=知识图谱(默认), vector=向量检索, hybrid=双引擎 */ engine: EngineMode; /** 存储后端:sqlite=轻量(默认), lancedb=向量库 */ storage: StorageBackend; dbPath: string; compactTurnCount: number; recallMaxNodes: number; recallMaxDepth: number; recallStrategy: "full" | "summary" | "adaptive" | "off"; embedding?: EmbeddingConfig; llm?: { apiKey?: string; baseURL?: string; model?: string; }; dedupThreshold: number; pagerankDamping: number; pagerankIterations: number; decay: DecayConfig; noiseFilter: NoiseFilterConfig; rerank?: RerankConfig; /** 反思系统配置 */ reflection: ReflectionConfig; /** 工作记忆配置 */ workingMemory: WorkingMemoryConfig; /** 知识融合配置 */ fusion: FusionConfig; /** 推理检索配置 */ reasoning: ReasoningConfig; } export declare const DEFAULT_CONFIG: BmConfig; //# sourceMappingURL=types.d.ts.map