/**
 * Source manager with LISTEN/NOTIFY hot reload.
 *
 * Subscribes to PostgreSQL LISTEN/NOTIFY on the `sources_change` channel
 * to detect source configuration changes. When a change is detected,
 * reloads sources from the database, rebuilds the ProviderRegistry,
 * and notifies the caller of added/removed sources via a callback.
 *
 * Debounces rapid changes to avoid excessive reloads.
 */
import type pg from 'pg';
import { ProviderRegistry } from '../provider-registry.js';
import type { ProviderSource } from '../entry-helpers.js';
import type { SourceStore } from './source-store.js';
/**
 * Options for creating a SourceManager.
 */
export interface SourceManagerOptions {
    /** Raw pg pool for LISTEN/NOTIFY subscriber. */
    pool: pg.Pool;
    /** SourceStore for reading sources and secrets. */
    sourceStore: SourceStore;
    /** Callback invoked when source diff is detected (for Platform registration). */
    onSourcesChanged: (diff: {
        added: ProviderSource[];
        removed: ProviderSource[];
    }) => void;
    /** Debounce interval in ms for coalescing rapid changes. Default: 200. */
    debounceMs?: number;
}
/**
 * Manages webhook sources from the database with hot reload support.
 *
 * On start, loads all sources, builds a ProviderRegistry, and subscribes
 * to LISTEN sources_change. On each NOTIFY, debounces and reloads,
 * rebuilding the registry and computing the diff for Platform registration.
 */
export declare class SourceManager {
    private readonly opts;
    private client;
    private registry;
    private currentSources;
    private debounceTimer;
    private readonly debounceMs;
    /**
     * Change callback. Stored in a mutable field (not read off `opts`) so a
     * mode-specific hook can rewire it after construction — the platform-mode
     * boot wires it to push the full source list to the Platform via
     * `platformClient.updateSources()`. Defaults to the (possibly no-op) value
     * passed at construction.
     */
    private onSourcesChanged;
    constructor(opts: SourceManagerOptions);
    /**
     * Replace the change callback after construction. The SourceManager is built
     * early (before the Platform client exists); the platform-mode boot calls
     * this once the client is ready so live source changes propagate upstream.
     */
    setOnSourcesChanged(cb: SourceManagerOptions['onSourcesChanged']): void;
    /** Get current ProviderRegistry (rebuilt on each reload). */
    getRegistry(): ProviderRegistry;
    /** Get current sources for Platform registration. */
    getSources(): ProviderSource[];
    /** Initial load + subscribe to changes. */
    start(): Promise<ProviderRegistry>;
    /** Stop listening and release the dedicated pg client. */
    stop(): Promise<void>;
    private scheduleReload;
    /** Reload sources from DB and rebuild the ProviderRegistry. */
    reload(): Promise<void>;
    /**
     * Build a ProviderBundle for a source with decrypted secrets.
     * Currently only supports GitHub; throws for unknown providers.
     */
    private buildBundle;
}
//# sourceMappingURL=source-manager.d.ts.map