Write a store driver
This guide shows how to add a new agent's session store to sepia.
The shape
A driver is a standalone binary named sepia-driver-<id> that speaks ndjson JSON-RPC over stdio — the same framing sepia serve uses. It answers a manifest handshake and the store ops it supports (sessions.list, sessions.get, history, and optionally write ops).
Steps
Model the store. Read the agent's on-disk format and map it onto the session IR (
sepia_core::Session). Mark unrepresentable fieldslossyin metadata rather than dropping them.Implement the ops. New drivers typically start from
crates/sepia-driver-cline— it is the smallest complete example:store.rs(the repository),cline.rs(format mapping),bin/sepia-driver-cline.rs(the serve entry point + manifest).Declare a manifest. Name, version, protocol level, and the capability flags sepia uses to decide what a store supports (history pages, rewind, live attach).
Pass conformance. Point
sepia-testkit's contract suite at your driver — it exercises the invariants every store must satisfy (round-trip listing, unknown-id behaviour, golden fixtures).Install. Drop the binary where discovery finds it:
$SEPIA_DRIVER_DIR,<data-dir>/sepia/drivers, or anywhere onPATH.sepia driverlists what the plane can see.
Conventions
- Blocking I/O (SQLite, file scans) runs on
spawn_blocking. - One driver instance per store root — take the dir as an argument or
<ID>_DIRenv var (SEPIA_CLINE_DIRstyle). - Errors are
RpcErrorwith acode/causepayload — see the protocol reference.