/**
* Per-channel conversation persistence to local JSONL.
*
* Each channel's history is streamed to `
/.jsonl`, one
* message per line. JSONL append is fsync'd to survive process kill. On
* boot, `loadAll()` scans the dir and rehydrates the brain's history Map.
*
* NOT anchored to 0G Storage — these are chat transcripts, not memory facts.
* Memory-worthy items still flow through `memory.save` and the typed
* frontmatter file system.
*/
import { existsSync, mkdirSync, readFileSync, readdirSync, unlinkSync } from 'node:fs'
import { open } from 'node:fs/promises'
import { join } from 'node:path'
import type { BrainMessage } from './types'
export interface HistoryPersist {
/** Read every persisted channel into a Map. Best-effort: bad lines are dropped, missing dir returns empty. */
loadAll(): Promise