import { RunningServer } from './server.js';
import 'hono/types';
import 'hono';

interface SeedReport {
    insertedAgents: number;
    chairBackfilledRooms: number;
}
declare function runSeed(): SeedReport;

/**
 * SQLite connection + migration runner.
 *
 *   getDb()         singleton (opened once per process)
 *   runMigrations() applies any registered migrations not yet recorded
 *
 * Migrations are imported as text (tsup `.sql` loader), so they ship inside
 * dist/cli.js — no separate file copy step.
 */

declare function closeDb(): void;

interface BoardroomDirs {
    base: string;
    knowledge: string;
    briefs: string;
    exports: string;
    logs: string;
}

/**
 * Shared boot / shutdown for every PrivateBoard entrypoint.
 *
 * Two entrypoints call into here:
 *   - src/cli.ts          → `npx privateboard`
 *   - electron/main.ts    → packaged desktop app
 *
 * Both must run the same migrations + recoveries + reconcile + dream sweep so
 * `~/.boardroom/state.db` stays consistent regardless of who opens it. The
 * banner / signal-handler bookkeeping stays in the caller — `bootApp` returns
 * structured results so each surface can render its own progress.
 */

interface BootOptions {
    port?: number;
    host?: string;
}
interface BootResult {
    server: RunningServer;
    dirs: BoardroomDirs;
    port: number;
    host: string;
    applied: string[];
    seed: ReturnType<typeof runSeed>;
    reconcile: {
        switched: number;
        cleared: number;
    } | null;
}
declare function bootApp(opts?: BootOptions): Promise<BootResult>;
declare function shutdownApp(server: RunningServer | null): Promise<void>;

export { type BootOptions, type BootResult, bootApp, closeDb, shutdownApp };
