@vitaminm/lcm-core
v0.0.3
Published
Local Conversational Memory core: SQLite-backed message + summary store with FTS5 search and multi-tier compaction.
Readme
@vitaminm/lcm-core
Local Conversational Memory — core library. SQLite-backed message + summary store with FTS5 full-text search and multi-tier compaction (Haiku / Sonnet / Opus).
Standalone port of NanoClaw v1's src/lcm/. No nanoclaw coupling: no process.env reads in the library, logger and summarizer config injected by the caller. Used as the engine behind @vitaminm/lcm-mcp (MCP server) and @vitaminm/lcm-cli (CLI).
Install
npm install @vitaminm/lcm-coreNative dep: better-sqlite3@^11.5.0. Prebuilt binaries available for linux-x64, linux-arm64, darwin-x64, darwin-arm64.
Quick use
import { openLcmDb, insertMessage, lcm_grep } from '@vitaminm/lcm-core';
const db = openLcmDb({
agentName: 'Sage',
basePath: '/path/to/Sage',
});
insertMessage(db, {
role: 'user',
content: 'How much iron is in a serving of beef liver?',
source: 'user',
});
const result = lcm_grep(
{ db, modelTier: 'sonnet', forRole: 'owner' },
{ pattern: 'iron', paginate: { limit: 10 } },
);
console.log(result.matches);What's exposed
- Storage:
openLcmDb,insertMessage,insertSummary,ftsGrep - Tools (also exposed by
@vitaminm/lcm-mcp):lcm_grep,lcm_describe,lcm_expand - Context assembly:
assembleActiveContext,activeContextToPromptString - Compaction:
maybeCompact,threeLevelEscalate,chooseGeneratedBy - Summarizers:
AnthropicCloudSummarizer,createFallbackSummarizer - Logger injection:
setLogger,getLogger,NOOP_LOGGER
Schema
The library manages SQLite schema migrations on openLcmDb. Current version is v2 with FTS5 virtual table over messages.content. Schema lives in src/schema.ts.
Testing
npm test --workspace @vitaminm/lcm-core58 tests covering types, tokens, schema, store, tools, assemble, compact, summarizers.
License
MIT
