/** * SQLite memory service — the public memory capability for multi-user RCS. * * Memories — durable team/personal memory entries. Two first-class scopes, * discriminated by `scope_kind`: * - personal: `owner_user_id`, strictly private — visible only to the owner * (not even system admins browse it in listings; admin bypass is limited * to manage operations and pack assembly, mirroring the "private means * private" TDAM semantics). * - team: `team_id`, visible to every active team member. * * Sessions are NOT a first-class scope. `source_session_id` is a provenance * link ("this memory was distilled from that session") and an optional * recall filter — never a registration gate (TDAM task-optional lesson). * * --------------------------------------------------------------------------- * Module map — single-responsibility decomposition (import from here, not * from the individual modules): * * types.ts domain vocabulary shared by every module * store.ts storage CRUD + FTS — trusted primitives, zero permission * logic (storage 写入检索) * permissions.ts visibility / manage checks + permission-filtered listing * (权限) * scopes.ts session→identity resolution, personal→team promotion * (空间管理) * pack.ts bridge injection pack compiler (memdir-mirroring layout) * writeback.ts agent write-back ingest with server-derived identity * * Calling conventions for upper layers: * - User-facing paths (web routes): authenticate → permissions gate → * store/permissions operations. Never call store.ts directly with * caller-supplied identity. * - Worker paths (v1): identity is derived server-side from the session * (scopes.resolveSessionMemoryScope), so pack/writeback are safe to call * with only a session id — caller input is never trusted for identity. * * This store is deliberately separate from the CLI memdir system * (src/memdir/, the file-based per-project memory used in single-user * composite mode via services/memoryBackend.ts). The two share the * frontmatter format and pack layout conventions, not storage or * permissions. */ export { MEMORY_TYPES, MEMORY_LAYERS, MemoryError } from './types' export type { CreateMemoryParams, ListMemoriesFilter, MemoryLayer, MemoryMeta, MemoryPack, MemoryRow, MemoryScopeKind, MemoryType, MemoryWriteBackEntry, SyncMemoriesResult, UpdateMemoryParams, } from './types' export { archiveMemory, createMemory, getMemoryRow, updateMemory, } from './store' export { parseMemoryFrontmatter, serializeMemoryFile } from './fileFormat' export { matchMemoryLines } from './searchMatch' export { canManageMemory, isMemoryVisibleToUser, isTeamMember, listMemoriesForUser, listMemoryRowsForUser, } from './permissions' export { promoteMemoryToTeam, resolveSessionMemoryScope } from './scopes' export { buildMemoryPack } from './pack' export { syncMemories } from './writeback' export { createSqliteMemoryBackend } from './sqliteBackend'