import { Database } from "bun:sqlite"; import type { AggregatedStats, BehaviorModelStats, BehaviorOverallStats, BehaviorTimeSeriesPoint, CostTimeSeriesPoint, FolderStats, MessageStats, ModelPerformancePoint, ModelStats, ModelTimeSeriesPoint, TimeSeriesPoint, UserMessageLink, UserMessageStats } from "./types"; /** * Initialize the database and create tables. */ export declare function initDb(): Promise; /** * Get the stored offset for a session file. */ export declare function getFileOffset(sessionFile: string): { offset: number; lastModified: number; } | null; /** * Update the stored offset for a session file. */ export declare function setFileOffset(sessionFile: string, offset: number, lastModified: number): void; /** * Insert message stats into the database. */ export declare function insertMessageStats(stats: MessageStats[]): number; /** * Get overall aggregated stats. */ export declare function getOverallStats(cutoff?: number): AggregatedStats; /** * Get stats grouped by model. */ export declare function getStatsByModel(cutoff?: number): ModelStats[]; /** * Get stats grouped by folder. */ export declare function getStatsByFolder(cutoff?: number): FolderStats[]; /** * Get time series data. */ export declare function getTimeSeries(hours?: number, cutoff?: number | null, bucketMs?: number): TimeSeriesPoint[]; /** * Get daily performance time series data for the last N days. */ /** * Get daily model usage time series data for the last N days. */ export declare function getModelTimeSeries(days?: number, cutoff?: number | null, bucketMs?: number): ModelTimeSeriesPoint[]; /** * Get daily model performance time series data for the last N days. */ export declare function getModelPerformanceSeries(days?: number, cutoff?: number | null, bucketMs?: number): ModelPerformancePoint[]; /** * Get total message count. */ export declare function getMessageCount(): number; /** * Close the database connection. */ export declare function closeDb(): void; export declare function getRecentRequests(limit?: number): MessageStats[]; export declare function getRecentErrors(limit?: number): MessageStats[]; export declare function getMessageById(id: number): MessageStats | null; /** * Get daily cost time series data for the last N days, broken down by model. */ export declare function getCostTimeSeries(days?: number, cutoff?: number | null): CostTimeSeriesPoint[]; export declare function markPriorityPremiumRequestsBackfillComplete(): void; export declare function markUserMessagesBackfillComplete(): void; export declare function markUserMessageLinksRepairComplete(): void; /** * Insert user-message stats. Idempotent via UNIQUE(session_file, entry_id). */ export declare function insertUserMessageStats(stats: UserMessageStats[]): number; /** * Backfill the responding `model`/`provider` on user-message rows that were * persisted before their assistant reply was parsed (a side effect of * incremental `fromOffset` syncing: the `userByEntryId` map in * `parseSessionFile` only spans a single pass). Each row is updated at most * once because the `model IS NULL` guard short-circuits subsequent passes. * * Returns the number of rows actually updated. */ export declare function updateUserMessageLinks(links: UserMessageLink[]): number; /** * Daily behavioral time series, grouped by responding model+provider. */ export declare function getBehaviorTimeSeries(cutoff?: number | null): BehaviorTimeSeriesPoint[]; /** * Overall behavioral totals across the cutoff window. */ export declare function getBehaviorOverall(cutoff?: number | null): BehaviorOverallStats; /** * Per-model behavioral totals over the cutoff window. "Unknown" represents * user messages that never received an assistant reply. */ export declare function getBehaviorByModel(cutoff?: number | null): BehaviorModelStats[];