interface ProfileSpan {
    name: string;
    startOffsetMs: number;
    durationMs: number;
}
interface ProfileParallelGroupMember {
    name: string;
    durationMs: number;
    resolvedIndex: number;
}
interface ProfileParallelGroup {
    name: string;
    startOffsetMs: number;
    wallMs: number;
    members: ProfileParallelGroupMember[];
}
interface ProfileTrace {
    ts: string;
    kind: "recall" | "extraction";
    traceId: string;
    sessionKey?: string;
    totalMs: number;
    spans: ProfileSpan[];
    parallelGroups?: ProfileParallelGroup[];
    configSnapshot?: Record<string, unknown>;
}
interface ProfilingConfig {
    enabled: boolean;
    storageDir: string;
    maxTraces: number;
}
interface ParallelGroupHandle {
    name: string;
    startOffsetMs: number;
    traceId?: string;
}
interface ProfilingStats {
    byKind: Record<string, {
        count: number;
        avgMs: number;
        p50Ms: number;
        p95Ms: number;
        maxMs: number;
    }>;
    bySpan: Record<string, {
        count: number;
        avgMs: number;
        p50Ms: number;
        p95Ms: number;
        maxMs: number;
    }>;
}
declare class ProfilingCollector {
    private enabled;
    private storageDir;
    private maxTraces;
    private traces;
    private prunePromise;
    private activeTraces;
    private latestTraceId;
    constructor(config: ProfilingConfig);
    get isEnabled(): boolean;
    startTrace(kind: "recall" | "extraction", sessionKey?: string, configSnapshot?: Record<string, unknown>): string;
    startSpan(name: string, traceId?: string): void;
    endSpan(name: string, traceId?: string): void;
    endTrace(traceId?: string): ProfileTrace | null;
    startParallelGroup(name: string, traceId?: string): ParallelGroupHandle;
    endParallelGroup(handle: ParallelGroupHandle, members: Array<{
        name: string;
        promise: Promise<unknown>;
    }>): Promise<void>;
    getRecentTraces(limit?: number): ProfileTrace[];
    getStats(): ProfilingStats;
    identifyBottleneck(): string | null;
    private persistTrace;
    pruneFiles(): Promise<void>;
}
declare function formatProfileTraceAscii(trace: ProfileTrace): string;

export { type ParallelGroupHandle, type ProfileParallelGroup, type ProfileParallelGroupMember, type ProfileSpan, type ProfileTrace, ProfilingCollector, type ProfilingConfig, type ProfilingStats, formatProfileTraceAscii };
