/** * AIBP Plugin Registry — manages plugin connections, channels, and routing. * * This is the hub's brain. It knows: * - Which plugins are registered and their capabilities * - Which channels exist and who has joined them * - Where to route each message based on dst address * - What to buffer when a recipient is offline */ import type { AibpMessage, ChannelMembership, CommandSpec, PluginSpec, RegisteredPlugin } from "./types.js"; export type SendFn = (msg: AibpMessage) => void; export declare class PluginRegistry { /** address → connection */ private plugins; /** channel name → membership */ private channels; /** command name → plugin address */ private commands; /** * Register a plugin. Returns the REGISTER_ACK message to send back, * or an ERROR message if registration fails. */ register(spec: PluginSpec, send: SendFn): AibpMessage; /** * Unregister a plugin (graceful disconnect or crash cleanup). */ unregister(address: string, reason?: string): void; /** * Join a channel. Creates the channel if it doesn't exist. */ join(address: string, channel: string): AibpMessage; /** * Part a channel. */ part(address: string, channel: string, reason?: string): AibpMessage; /** * Route a message to its destination. * * Routing rules: * 1. If dst is a direct address (plugin/session/mobile), deliver to that plugin * 2. If dst is a channel, fan out to all members * 3. If dst is "hub:local", handle as a hub command * 4. If dst contains "/" (mesh), forward to bridge plugin * 5. If recipient is offline, buffer in outbox */ route(msg: AibpMessage): void; private fanOut; private routeToMesh; private handleHubMessage; private handleBuiltinCommand; private bufferMessage; private drainOutbox; /** * Call periodically (e.g., every 30s) to check plugin health. */ heartbeatCheck(): void; getPlugin(address: string): RegisteredPlugin | undefined; getChannel(channel: string): ChannelMembership | undefined; getPluginByType(type: string): RegisteredPlugin[]; getCommandOwner(command: string): string | undefined; listPlugins(): RegisteredPlugin[]; listChannels(): ChannelMembership[]; listCommands(): Array<{ name: string; owner: string; spec?: CommandSpec; }>; private sendTo; private resolveAddress; } //# sourceMappingURL=registry.d.ts.map