import { t as runSessionStartupMigration } from "./startup-migration-LqDYqbTK.js";
//#region src/gateway/server-startup-session-migration.ts
/** Await SQLite maintenance and projection repair before serving session history. */
async function runStartupSessionMigration(params) {
	const databases = await runSessionStartupMigration(params);
	if (databases.length === 0) return;
	const reconcile = params.deps?.reconcileSessionTranscriptIndexes ?? (await import("./session-transcript-reconcile-u93wQOo5.js")).reconcileSessionTranscriptIndexes;
	let reconciledSessions = 0;
	for (const database of databases) {
		const result = await reconcile(database);
		reconciledSessions += result.reconciledSessions;
	}
	if (reconciledSessions > 0) params.log.info(`session: rebuilt ${reconciledSessions} transcript projection(s) before serving history`);
}
//#endregion
export { runStartupSessionMigration };
