import { readJson, writeJson, globalDataDir } from './base-store.js';
/** Max journal entries kept on disk — matches engine constant. */
const MAX_ENTRIES = 90;
function journalPath() {
    return `${globalDataDir()}/session-journal.json`;
}
/** Load the journal from disk. Returns empty store if file not found. */
export async function loadJournal() {
    return readJson(journalPath(), { entries: [] });
}
/** Save the journal to disk, pruning to MAX_ENTRIES. */
export async function saveJournal(journal) {
    const entries = journal.entries.length > MAX_ENTRIES ? journal.entries.slice(-MAX_ENTRIES) : journal.entries;
    await writeJson(journalPath(), { entries });
}
/** List the last N session entries (most recent first). */
export async function listSessions(limit = 10) {
    const journal = await loadJournal();
    return journal.entries.slice(-limit).reverse();
}
//# sourceMappingURL=session-journal-store.js.map