Skip to main content

Crate leviathan

Crate leviathan 

Source
Expand description

Leviathan: deep memory for agents over large datasets.

Index JSONL, JSON, CSV or SQLite records into a single SQLite/FTS5 file, then answer questions with a few ranked, cited cards instead of the raw data. A small field mapping (leviathan.toml, CLI flags, or inference) says which fields are the id, title, searchable text, group, date and filters. Use it from the CLI, as an MCP server, or as a library:

use leviathan::{card::CardOptions, query::{SearchRequest, Store}};

let store = Store::open("leviathan.db".as_ref(), CardOptions::default())?;
let hits = store.search(&SearchRequest {
    group: Some("acme".into()),
    query: "login loops after password reset".into(),
    filters: vec![("status".into(), "closed".into())],
    limit: 5,
    fallback: true,
    ..Default::default()
})?;
println!("{}", leviathan::render::search(&hits));

Modules§

card
Result cards: the compact, citable view of one record.
config
The field mapping: which parts of a record are its id, title, searchable text, group, date, filters and display fields.
fields
Field paths into JSON records, and the compiled Mapping that turns a record into what the index stores.
index
Build and update the on-disk index.
infer
leviathan init: profile a sample of the data and propose a mapping.
mcp
Minimal Model Context Protocol server over stdio (JSON-RPC 2.0, one message per line). Read-only: every tool is a fixed query shape over the index; there is no SQL passthrough, no file access and no write path. stdout carries protocol messages only; diagnostics go to stderr.
query
Read-only query layer over the index.
render
Compact text rendering. This is what agents read by default, so every line is spent deliberately: scope and counts in the header, one short block per record, and an explicit statement when nothing was found.
source
Record sources: JSONL / NDJSON, JSON arrays, CSV / TSV (each optionally gzip), SQLite tables or queries, and stdin. Every source yields JSON objects; line-oriented formats stream, so inputs far larger than memory are fine.
text
Text helpers shared by the indexer and the query layer.
wrap
leviathan wrap <agent>: print the configuration snippet that registers Leviathan with an agent. It prints; it never edits anyone’s config.

Functions§

now_rfc3339
Current UTC time as RFC 3339, without a date-time dependency.