import type { NodeRegistry } from "../node-registry.js";
import type { RemoteNodeInfo } from "./mesh-node-registry.js";
import { MeshDiscovery, type DiscoveryOptions } from "./discovery.js";
import { MeshNodeRegistry } from "./mesh-node-registry.js";
import { PeerManager } from "./peer-manager.js";
import { PeerRegistry } from "./peer-registry.js";
import { SessionSync } from "./session-sync.js";
export type MeshManagerOptions = {
    token: string;
    displayName: string;
    nodeRegistry: NodeRegistry;
    meshConfig?: {
        enabled?: boolean;
        peers?: string[];
        platformUrl?: string;
        pollIntervalMs?: number;
        mdnsDiscovery?: boolean;
    };
    log: {
        info: (msg: string) => void;
        warn: (msg: string) => void;
        error: (msg: string) => void;
    };
};
/**
 * Top-level mesh manager that coordinates peer discovery, connections,
 * and the unified node registry.
 */
export declare class MeshManager {
    readonly gatewayId: string;
    readonly peerRegistry: PeerRegistry;
    readonly peerManager: PeerManager;
    readonly meshNodeRegistry: MeshNodeRegistry;
    readonly sessionSync: SessionSync;
    discovery?: MeshDiscovery;
    private nodeRegistry;
    private log;
    constructor(opts: MeshManagerOptions);
    /** Called when a peer gateway announces itself (mesh.announce handler). */
    handlePeerAnnounce(gatewayId: string, displayName: string, nodes: RemoteNodeInfo[]): void;
    /** Called when a peer notifies us of node changes (mesh.nodes.changed handler). */
    handlePeerNodesChanged(gatewayId: string, nodes: RemoteNodeInfo[]): void;
    /** Get a snapshot of local nodes for announcing to peers. */
    getLocalNodeList(): RemoteNodeInfo[];
    /** Notify all peers that our local node set changed. */
    broadcastLocalNodesChanged(): void;
    /** Add a peer by URL (e.g. the remote gateway URL from config). */
    addConfigPeer(url: string): void;
    /** Start automatic peer discovery (platform polling + mDNS). */
    startDiscovery(opts: Omit<DiscoveryOptions, "peerRegistry" | "log">): Promise<void>;
    /** List peers for the mesh.peer.list handler. */
    listPeers(): Array<{
        gatewayId: string;
        displayName: string;
        url: string;
        status: string;
        nodeCount: number;
    }>;
    /** Stop all mesh connections and cleanup. */
    stop(): void;
}
/**
 * Start the gateway mesh if configured.
 * Returns null if mesh is disabled.
 */
export declare function startGatewayMesh(opts: MeshManagerOptions): MeshManager | null;
