MemTable is a local-first structured ledger runtime for long-running agents.
It does not replace vector memory, RAG, or long-term text memory. It adds the missing data layer between agents and databases: a way to turn useful facts from conversations, tool results, and agent events into queryable, auditable records.
Memory recalls what happened. Ledger computes what changed.
Agents can usually remember text, but they struggle with questions that are really data questions:
- Did my bench press improve over the last three months?
- What is my body weight trend?
- Which projects have been delayed the longest?
- Where did I spend the most this month?
Those questions need records, timestamps, schemas, aggregation, and source tracing. MemTable gives agents a structured ledger instead of asking the model to behave like a database.
@memtable/core: SQLite-backed ledger runtime@memtable/server: HTTP observer and MCP stdio server@memtable/cli: local CLI for init, packs, proposals, queries, and diagnosticspacks/fitness: first domain pack for workouts and body weightpacks/agent-work: agent task outcome pack for failures, completions, and task categories@memtable/agent-hermes: Hermes enhancer plugin assets@memtable/openclaw-plugin: OpenClaw enhancer plugin
Install dependencies and build:
pnpm install
pnpm buildRun the fitness E2E demo:
pnpm demo:fitnessThe demo creates a temporary SQLite ledger, installs the fitness pack, observes two workout logs, commits generated proposals, and asks:
我最近三个月卧推进步了吗?
Expected answer shape:
基于 2 条卧推记录,卧推最高训练重量从 60kg 到 65kg,提升 5kg。
Initialize a local ledger:
node packages/cli/dist/index.js initInstall the fitness pack:
node packages/cli/dist/index.js pack install packs/fitnessInstall the agent work pack:
node packages/cli/dist/index.js pack install packs/agent-workStart the HTTP observer sidecar:
node packages/cli/dist/index.js serve --httpScan existing agent logs without installing a native enhancer:
node packages/cli/dist/index.js watch ~/.hermes/logs --agent hermes
node packages/cli/dist/index.js watch ~/.openclaw/runs --agent openclawKeep watching appended log lines:
node packages/cli/dist/index.js watch ~/.hermes/logs --agent hermes --followIn another terminal, inspect health and setup:
node packages/cli/dist/index.js doctorMemTable supports three integration surfaces:
- Tool surface: agents call MemTable through MCP or registered tools.
- Observer surface: native plugin hooks send agent events to
memtable serve --http. - Log surface: MemTable scans existing
.jsonlor.logfiles and observes each line.
Enable Hermes:
node packages/cli/dist/index.js agent enable hermes
node packages/cli/dist/index.js agent doctor hermesEnable OpenClaw:
node packages/cli/dist/index.js agent enable openclaw
node packages/cli/dist/index.js agent doctor openclawThe enable commands write local config under .memtable/agents/ and print the native plugin install command for the target agent. The doctor commands also return a lightweight watch.command fallback, so users can start log-based ingestion with memtable watch ... --follow before installing a native enhancer. The Hermes and OpenClaw enhancers are alpha adapters for the current MVP surface: tool registration, event mapping, and sidecar observation.
Start the MCP stdio server:
node packages/cli/dist/index.js serve --mcpCurrent MCP tools expose observing, asking, structured query, proposals, proposal tracing, record tracing, packs, and schemas.
Agent message or tool result
-> MemTable observer
-> Pack matching
-> Structured proposal
-> User or agent commit
-> Ledger record
-> Query / ask
For example, this event:
今天卧推 65kg 5x5,体重 90.4kg
can become two proposals:
fitness.workoutfitness.body_weight
After commit, MemTable can answer trend questions from records instead of chat history.
Review generated proposals:
node packages/cli/dist/index.js proposal list pending --schema fitness.workout
node packages/cli/dist/index.js proposal commit --all --schema fitness.workout
node packages/cli/dist/index.js proposal reject --allThe same review workflow is exposed over HTTP and MCP so agents can list, commit, or reject matching proposals without shelling out to the CLI.
The agent-work pack can also turn task logs such as:
任务 deploy-api 失败,类型 deploy,耗时 12 分钟
into agent_work.task_event proposals and query failure counts by task type.
Use:
node packages/cli/dist/index.js doctor
node packages/cli/dist/index.js agent doctor hermes
node packages/cli/dist/index.js agent doctor openclawThese commands return JSON checks with fix commands for missing config, missing SQLite DB, missing packs, offline sidecar, or incomplete agent enhancer config.
Use CLI tracing when you need to inspect why a value exists in the ledger:
node packages/cli/dist/index.js proposal show <id>
node packages/cli/dist/index.js record show <id>The HTTP sidecar also exposes trace endpoints:
GET /v1/proposals/:id
GET /v1/records/:idMCP exposes the same trace surface through:
memtable.proposal.show
memtable.record.show
Packs can include extractors/*.rules.json files. These rules describe regex-based extraction from observed agent events into structured proposals.
The current rule format supports:
schema: target ledger schemapatternandflags: extraction regexfields: mapping capture groups, constants, or event fields into record fieldsconfidence: proposal confidenceoptional: optional field mapping
This is intentionally conservative for v0.1. More expressive extractors can be added without changing the ledger runtime contract.
memtable watchscans once by default. Add--followto poll for appended.jsonlor.loglines; this is a lightweight alpha tailer, not yet a platform-specific file-system watcher.memtable serve --httpandmemtable serve --mcpare separate modes in the current CLI. Run them in separate processes when both surfaces are needed.- Node may print an experimental warning for
node:sqlite; that is expected for this alpha runtime. - Hermes and OpenClaw enhancers are minimal native adapters. They validate the integration pattern but are not yet version-pinned against every upstream agent release.
This repository is in early v0.1 development. The current target is a local-first MVP that proves the agent ledger loop with the fitness pack, HTTP observer, MCP tools, Hermes enhancer, and OpenClaw enhancer.