/** * Mesh — BroadcastChannel-based cross-tab agent coordination. * Ported from agi-diy/docs/agent-mesh.js. * * Provides: * - Peer discovery via periodic ping * - Ring context (shared attention across tabs) * - invoke: send prompts to specific tabs * - broadcast: send to all tabs */ interface MeshPeer { id: string; tabId: string; label: string; lastSeen: number; url: string; } interface RingEntry { agentId: string; agentType: string; pageId: string; text: string; timestamp: number; } type MsgType = 'ping' | 'pong' | 'invoke' | 'invoke-response' | 'ring-update' | 'ring-clear' | 'broadcast'; interface MeshMessage { type: MsgType; payload: any; source: MeshPeer; timestamp: number; } declare class MeshImpl { private channel; private peers; private subscribers; private listeners; private tabId; private invokeHandler; private pageLabel; constructor(); setPageLabel(label: string): void; setInvokeHandler(handler: (prompt: string) => Promise): void; init(): void; private me; private post; ping(): void; private handle; private gc; getPeers(): MeshPeer[]; subscribeChange(fn: () => void): () => void; invoke(tabId: string, prompt: string, timeoutMs?: number): Promise; broadcast(message: string): void; getRing(): RingEntry[]; addToRing(agentId: string, agentType: string, text: string): RingEntry; clearRing(): void; getMyTabId(): string; } declare const mesh: MeshImpl; export { MeshImpl, type MeshMessage, type MeshPeer, type RingEntry, mesh };