UNPKG

@essentialai/cogent-bridge

Version:

Cogent Bridge — cross-agent comms for Claude Code, OpenAI Codex and Slack. Codex users: install with `curl -fsSL https://cogent.tools/install.sh | sh`, then start with `cogent-codex` for real-time peer wake.

49 lines • 1.64 kB
import type { MessageRecord } from "../types.js"; /** * In-memory message inbox with deduplication and timestamp ordering. * * Aggregates messages from both WebSocket push and poll fallback channels. * Deduplicates by message ID (bounded to last 1000 IDs) and maintains * messages ordered by server timestamp for consistent display. */ export declare class MessageInbox { private messages; private seenIds; private seenOrder; private listeners; private lastMessageId; /** * Add a single message to the inbox. * Returns true if the message was new (not a duplicate). */ addMessage(msg: MessageRecord): boolean; /** * Add multiple messages at once. * Returns the count of new (non-duplicate) messages added. */ addMessages(msgs: MessageRecord[]): number; /** * Get all unread messages (copy of the internal array). */ getUnread(): MessageRecord[]; /** * Mark messages as read by removing them from the unread list. * Does NOT remove from seenIds -- they remain for deduplication. */ markRead(messageIds: string[]): void; /** * Get the ID of the last message received (by timestamp order). * Used for poll sync -- pass as lastMessageId query parameter. */ getLastMessageId(): string | null; /** * Subscribe to new message notifications. * Returns an unsubscribe function. */ onNewMessage(listener: () => void): () => void; /** * Clear all state: messages, seen IDs, last message ID, and listeners. */ clear(): void; } //# sourceMappingURL=message-inbox.d.ts.map