/** * AIBP IPC Bridge — translates legacy IPC requests into AIBP messages * and routes them through the PluginRegistry. * * This is the Phase 2 integration layer. Existing adapters (Whazaa, Telex) * continue using the old IPC protocol. The bridge translates their calls * to AIBP messages so the PluginRegistry handles routing. * * New plugins (PAILot, MCP) register directly via AIBP handshake. */ import { PluginRegistry, type SendFn } from "./registry.js"; import type { AibpMessage, PluginSpec } from "./types.js"; export declare class AibpBridge { readonly registry: PluginRegistry; private mobileCallbacks; private sessionHandlerAddress; constructor(); /** * Register the PAILot mobile gateway as a plugin. * The callback receives AIBP messages to deliver to connected WebSocket clients. */ registerMobile(id: string, callback: (msg: AibpMessage) => void): void; /** * Register a transport adapter (Whazaa, Telex) as a plugin. * These use legacy IPC — the sendFn wraps an IPC call back to the adapter. */ registerTransport(id: string, sendFn: SendFn, commands?: PluginSpec["commands"]): void; /** * Register a terminal plugin (iTerm2). * Terminal-specific commands (keyboard control) are registered here. */ registerTerminal(id: string, sendFn: SendFn, commands?: PluginSpec["commands"]): void; /** * Register an MCP process as a plugin. * Returns the resolved session address for the MCP to use. */ registerMcp(mcpId: string, sessionEnvId?: string, sendFn?: SendFn): { address: string; resolvedSession?: string; }; /** * Route a message from the hub to a terminal plugin (iTerm2). * Used by the command handler to deliver text to terminal sessions. */ routeToTerminal(sessionId: string, content: string, type?: "TEXT" | "COMMAND"): boolean; /** * Register the hub's session handler as a plugin. * This plugin joins session channels and receives inbound messages * destined for sessions (e.g., from PAILot). The sendFn callback * should dispatch to the hub command handler. * * Hub-owned slash commands are registered here so they're discoverable * through the AIBP command registry. */ registerSessionHandler(sendFn: SendFn): void; /** * Ensure the session handler is joined to a session channel. * Called automatically before routing inbound messages. */ private ensureSessionJoin; /** * Route a message from PAILot to a session. */ routeFromMobile(sessionId: string, content: string, type?: "TEXT" | "VOICE" | "IMAGE", extra?: Record): void; /** * Route a response from a session back to PAILot. * This is called when Claude sends via pailot_send. */ routeToMobile(sessionId: string, content: string, type?: "TEXT" | "VOICE" | "IMAGE" | "TYPING", extra?: Record): void; /** * Route a message from one session to another. * Used for cross-session messaging (session A → session B). */ routeBetweenSessions(fromSessionId: string, toSessionId: string, content: string, type?: "TEXT" | "COMMAND"): void; /** * Send a typing indicator. */ sendTyping(sessionId: string, active: boolean): void; /** * Join the PAILot mobile plugin to a session channel. * This is called when the user switches sessions on PAILot. */ joinSession(sessionId: string): void; /** * Part the PAILot mobile plugin from a session channel. */ partSession(sessionId: string): void; /** * Register a remote hub as a bridge plugin. * Messages addressed to hub:/... are forwarded to this plugin's sendFn, * which should deliver them over the network to the remote hub. */ registerBridge(hubId: string, sendFn: SendFn): void; /** * Send a message to a remote hub via mesh addressing. * The message dst is set to hub:/. * Returns false if no bridge is registered for that hub. */ routeToRemote(hubId: string, remoteDst: string, content: string, localSessionId?: string, type?: "TEXT" | "VOICE" | "COMMAND", extra?: Record): boolean; /** * Handle a message arriving from a remote hub. * The bridge network layer calls this when it receives an AIBP message * from another hub destined for a local session. */ routeFromRemote(fromHubId: string, localDst: string, content: string, remoteSrc: string, type?: "TEXT" | "VOICE" | "IMAGE", extra?: Record): void; /** * List all registered peer hub IDs (bridge plugins). */ listPeers(): string[]; /** Get all registered plugin addresses */ listPlugins(): string[]; /** Get channel membership info */ getChannelInfo(channel: string): import("./types.js").ChannelMembership | undefined; /** List all registered commands with their owning plugins */ listCommands(): { name: string; owner: string; spec?: import("./types.js").CommandSpec; }[]; /** Resolve which plugin owns a command */ getCommandOwner(command: string): string | undefined; } //# sourceMappingURL=bridge.d.ts.map