UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

26 lines • 1.05 kB
export function materializeSessionEntries(entries, options) { const { residentStore, loadHistoryEntries, onMaterialized } = options; const missingEntryIds = new Set(); const materialized = entries.map((entry) => residentStore.materialize(entry, () => { missingEntryIds.add(entry.id); return undefined; })); if (missingEntryIds.size === 0) { for (const entry of materialized) onMaterialized(entry); return materialized; } const persistedById = new Map(loadHistoryEntries() .filter((entry) => entry.type !== "session") .map((entry) => [entry.id, entry])); const repaired = materialized.map((entry) => { if (!missingEntryIds.has(entry.id)) return entry; const persisted = persistedById.get(entry.id); return persisted === undefined ? entry : residentStore.materialize(persisted); }); for (const entry of repaired) onMaterialized(entry); return repaired; } //# sourceMappingURL=session-entry-materializer.js.map