/**
 * Telemetry module — opt-in command telemetry for CLEO self-improvement.
 *
 * Entry point for all telemetry operations:
 *   - Recording events (fire-and-forget)
 *   - Querying patterns for `cleo diagnostics analyze`
 *   - Managing the anonymous ID and opt-in state
 *   - Emitting BRAIN observations from high-signal patterns
 *
 * Telemetry is DISABLED by default. Enable with `cleo diagnostics enable`.
 *
 * @task T624
 */
/** A single telemetry event to record. */
export interface TelemetryEvent {
    /** Canonical domain (e.g. "tasks", "session"). */
    domain: string;
    /** CQRS gateway. */
    gateway: 'query' | 'mutate';
    /** Operation name (e.g. "show", "add"). */
    operation: string;
    /** Wall-clock duration in milliseconds. */
    durationMs: number;
    /** LAFS exit code (0 = success). */
    exitCode: number;
    /** Machine-readable error code (null on success). */
    errorCode?: string | null;
}
/** Aggregated stats for a single command. */
export interface CommandStats {
    /** Composed "{domain}.{operation}" command name. */
    command: string;
    /** Total invocation count. */
    count: number;
    /** Count of invocations that returned exitCode != 0. */
    failureCount: number;
    /** Failure rate as a fraction (0..1). */
    failureRate: number;
    /** Mean duration in milliseconds. */
    avgDurationMs: number;
    /** Max duration in milliseconds. */
    maxDurationMs: number;
    /** Most frequent error code, or null if no failures. */
    topErrorCode: string | null;
}
/** Aggregated diagnostics summary. */
export interface DiagnosticsReport {
    /** Period analyzed (ISO-8601 start and end). */
    period: {
        from: string;
        to: string;
    };
    /** Total events in period. */
    totalEvents: number;
    /** Top 10 commands by failure rate (min 5 invocations). */
    topFailing: CommandStats[];
    /** Top 10 slowest commands by average duration. */
    topSlow: CommandStats[];
    /** Commands invoked exactly once (potential dead ends). */
    rareCommands: string[];
    /** High-signal observations suitable for BRAIN storage. */
    observations: string[];
}
/** Global telemetry config stored in ~/.local/share/cleo/telemetry-config.json */
export interface TelemetryConfig {
    /** Whether telemetry collection is enabled. */
    enabled: boolean;
    /** Anonymous UUID stable across invocations. Generated on first enable. */
    anonymousId: string;
}
/** Return the path to the telemetry config JSON file. */
export declare function getTelemetryConfigPath(): string;
/** Load telemetry config from disk. Returns default (disabled) config if absent. */
export declare function loadTelemetryConfig(): TelemetryConfig;
/** Persist telemetry config to disk. */
export declare function saveTelemetryConfig(config: TelemetryConfig): void;
/** Return true if telemetry collection is currently enabled. */
export declare function isTelemetryEnabled(): boolean;
/**
 * Enable telemetry and generate a stable anonymous ID.
 * Idempotent — calling again preserves the existing anonymousId.
 */
export declare function enableTelemetry(): TelemetryConfig;
/**
 * Disable telemetry collection.
 * Existing data in telemetry.db is not deleted.
 */
export declare function disableTelemetry(): TelemetryConfig;
/**
 * Record one telemetry event.
 * Fire-and-forget — errors are swallowed; never blocks the calling command.
 * No-op when telemetry is disabled.
 */
export declare function recordTelemetryEvent(event: TelemetryEvent): Promise<void>;
/**
 * Build a diagnostics report over the last `days` days (default 30).
 * Requires telemetry to be enabled; returns null if disabled or no data.
 */
export declare function buildDiagnosticsReport(days?: number): Promise<DiagnosticsReport | null>;
/**
 * Export all telemetry events as a JSON array.
 * Returns empty array when telemetry is disabled or DB is empty.
 */
export declare function exportTelemetryEvents(days?: number): Promise<TelemetryEvent[]>;
export * from './schema.js';
export { getTelemetryDb, getTelemetryDbPath } from './sqlite.js';
//# sourceMappingURL=index.d.ts.map