import type { Helia } from "helia"; import type { PubSub } from "@libp2p/interface"; export declare const NODE_CAPS_TOPIC = "pokapali._node-caps._p2p._pubsub"; export interface NodeNeighbor { peerId: string; role?: string; } export interface NodeCapabilities { version: 2; peerId: string; roles: string[]; neighbors?: NodeNeighbor[]; browserCount?: number; /** Public WSS addresses for direct dialing. */ addrs?: string[]; /** HTTPS block endpoint URL. */ httpUrl?: string; } export declare function encodeNodeCaps(caps: NodeCapabilities): Uint8Array; export declare function decodeNodeCaps(data: Uint8Array): NodeCapabilities | null; /** * Listen for incoming caps messages on pubsub and * track peer roles. Returns a cleanup function. */ export declare function setupCapsListener(pubsub: PubSub, selfPeerId: string, knownPeerRoles: Map): () => void; /** * Dynamic app-topic subscription: when peers * subscribe to announcement topics, the relay * auto-subscribes so it joins the mesh and can * forward messages. This makes the relay fully * app-agnostic — no pinAppIds config needed. * * Originator refcounting prevents relay-to-relay * keep-alive deadlock: only non-relay peers * (browsers) count as originators. When the last * originator leaves, the relay unsubscribes — * other relays see the change and cascade. */ export declare function setupDynamicSubscription(pubsub: PubSub, knownPeerRoles: Map): { autoSubOriginators: Map>; remove: () => void; }; /** * Publish our capabilities to the caps topic. * Also cleans up auto-subscribed topics with no * remaining non-relay originators. */ export declare function publishCaps(helia: Helia, pubsub: PubSub, selfPeerId: string, roles: string[], knownPeerRoles: Map, autoSubOriginators: Map>, httpUrl: string | undefined): void; //# sourceMappingURL=relay-caps.d.ts.map