/** * Society Protocol — Rooms Module v1.0 * * Manages rooms (federations), chat messaging, presence, and CoC events. * Ties together P2P, SWP, and Storage layers. * Supports GossipSub and direct protocol streaming. */ import { type Identity } from './identity.js'; import { P2PNode } from './p2p.js'; import { type SwpEnvelope, type MessageType, type AdapterCapabilities, type AdapterHeartbeatBody, type AdapterOfferBody, type AdapterProfile } from './swp.js'; import { Storage } from './storage.js'; import { type KnowledgePool } from './knowledge.js'; import { EventEmitter } from 'events'; export interface RoomEvents { 'chat:message': (roomId: string, envelope: SwpEnvelope) => void; 'chat:reaction': (roomId: string, envelope: SwpEnvelope) => void; 'chat:edit': (roomId: string, envelope: SwpEnvelope) => void; 'presence:update': (roomId: string, envelope: SwpEnvelope) => void; 'coc:event': (roomId: string, envelope: SwpEnvelope) => void; 'coc:open': (roomId: string, envelope: SwpEnvelope) => void; 'coc:plan': (roomId: string, envelope: SwpEnvelope) => void; 'coc:assign': (roomId: string, envelope: SwpEnvelope) => void; 'coc:submit': (roomId: string, envelope: SwpEnvelope) => void; 'coc:review': (roomId: string, envelope: SwpEnvelope) => void; 'coc:merge': (roomId: string, envelope: SwpEnvelope) => void; 'coc:close': (roomId: string, envelope: SwpEnvelope) => void; 'coc:handoff': (roomId: string, envelope: SwpEnvelope) => void; 'coc:cancel': (roomId: string, envelope: SwpEnvelope) => void; 'adapter:event': (roomId: string, envelope: SwpEnvelope) => void; 'capsule:event': (roomId: string, envelope: SwpEnvelope) => void; 'federation:event': (roomId: string, envelope: SwpEnvelope) => void; 'persona:event': (roomId: string, envelope: SwpEnvelope) => void; 'mission:event': (roomId: string, envelope: SwpEnvelope) => void; } export declare class RoomManager extends EventEmitter { private identity; private p2p; private storage; private heartbeatIntervals; private joinedRooms; private encryptedRooms; private verifiedPeers; private knowledgePool?; private presenceBroadcastInterval?; private replayCachePruneInterval?; constructor(identity: Identity, p2p: P2PNode, storage: Storage); /** * Attach a KnowledgePool for conversational knowledge exchange. * When set, all chat messages are automatically ingested into the * collaborative context for auto-compaction and knowledge extraction. */ setKnowledgePool(pool: KnowledgePool): void; private setupP2PHandlers; createRoom(name: string): string; joinRoom(roomId: string, roomName?: string): Promise; leaveRoom(roomId: string): Promise; sendMessage(roomId: string, textOrBody: string | Record | any, type?: MessageType): Promise; sendChatMessage(roomId: string, text: string, options?: { replyTo?: string; mentions?: string[]; attachments?: string[]; formatting?: 'markdown' | 'plain' | 'html'; }): Promise; sendReaction(roomId: string, messageId: string, emoji: string, action?: 'add' | 'remove'): Promise; editMessage(roomId: string, messageId: string, newText: string): Promise; sendPresence(roomId: string, status: 'online' | 'busy' | 'running' | 'offline' | 'away', options?: { load?: number; specialties?: string[]; capabilities?: string[]; }): Promise; broadcastCapabilitiesUpdate(roomId: string, added: string[], removed: string[]): Promise; publishCocEvent(roomId: string, envelope: SwpEnvelope): Promise; publishAdapterRegistration(roomId: string, profile: AdapterProfile): Promise; publishAdapterOffer(roomId: string, offer: AdapterOfferBody): Promise; publishAdapterHeartbeat(roomId: string, heartbeat: AdapterHeartbeatBody): Promise; publishAdapterCapabilities(roomId: string, capabilities: AdapterCapabilities & { worker_did?: string; }): Promise; publishMissionEvent(roomId: string, type: 'mission.start' | 'mission.pause' | 'mission.resume' | 'mission.stop' | 'mission.checkpoint' | 'mission.alert', body: Record): Promise; private handleTopicMessage; private handleIncomingMessage; private applyEnvelope; private routeMessage; private handleChatMessage; private handleKnowledgeContextSync; private handleKnowledgeSync; private handlePresenceMessage; getMessages(roomId: string, limit?: number): { id: string; room_id: string; from_did: string; from_name: string | null; text: string; ts: number; }[]; getOnlinePeers(staleSeconds?: number): { peer_did: string; peer_name: string | null; status: string; capabilities: string | null; last_seen: number; }[]; getJoinedRooms(): string[]; getVisibleWorkers(roomId: string): import("./storage.js").SwarmWorkerRecord[]; isJoined(roomId: string): boolean; /** * Enable E2E encryption for all messages in a room. * All chat, CoC, and data topics for this room will be encrypted. */ enableEncryption(roomId: string): void; /** * Disable E2E encryption for a room. */ disableEncryption(roomId: string): void; /** * Check if a room has encryption enabled. */ isEncrypted(roomId: string): boolean; private startHeartbeat; destroy(): void; /** * Broadcast a ZKP identity proof to a room. * Called automatically on room join. */ broadcastIdentityProof(roomId: string): Promise; private handleIdentityProof; /** * Check if a peer has a verified identity in a room. */ isVerifiedPeer(roomId: string, did: string): boolean; } //# sourceMappingURL=rooms.d.ts.map