// Node-only append-only JSONL ledger.
import fs from 'node:fs';
export class FileStore {
constructor(path) { this.path = path; if (!fs.existsSync(path)) fs.writeFileSync(path, ''); }
_all() { return fs.readFileSync(this.path, 'utf8').split('\n').filter(Boolean).map((l) => JSON.parse(l)); }
async head() { const a = this._all(); const r = a.at(-1); return r ? { seq: r.chain.seq, hash: r.integrity.hash } : null; }
async append(r) { fs.appendFileSync(this.path, JSON.stringify(r) + '\n'); }
async list() { return this._all(); }
}
agentgate-source: code mirror on Cloudflare Pages. All repos