import type { Db } from '../storage/database.js'; import type { EventBus } from './events.js'; import type { Message, MessageSendInput, MessageRead, MessageImportance } from '../types.js'; export interface MessageListOptions { channel?: string; from?: string; to?: string; thread?: number; importance?: MessageImportance; since?: string; limit?: number; offset?: number; unreadBy?: string; } export interface SearchResult { message: Message; snippet: string; rank: number; } /** Interface for agent queries needed by MessageService (avoids circular dependency) */ export interface AgentLookup { list(options?: { status?: string; includeOffline?: boolean; }): { id: string; }[]; } export declare class MessageService { private readonly db; private readonly events; private agentLookup; constructor(db: Db, events: EventBus); /** Inject agent lookup to avoid circular dependency */ setAgentLookup(lookup: AgentLookup): void; send(fromAgentId: string, input: MessageSendInput): Message; /** Send a direct message to all online agents (excluding sender) */ broadcast(fromAgentId: string, content: string, importance?: MessageImportance): Message[]; /** Total message count (for dashboard stats) */ count(): number; getById(id: number): Message | null; list(options?: MessageListOptions): Message[]; /** Get the inbox for an agent: direct messages + messages from joined channels */ inbox(agentId: string, options?: { unreadOnly?: boolean; limit?: number; importance?: MessageImportance; }): Message[]; /** Get full thread starting from a root message */ thread(messageId: number): Message[]; markRead(messageId: number, agentId: string): void; /** Mark all unread messages in agent's inbox as read */ markAllRead(agentId: string): number; acknowledge(messageId: number, agentId: string): void; /** Get read/ack status for a message */ readStatus(messageId: number): MessageRead[]; /** Blocking inbox wait — resolves as soon as a new message arrives that * matches the inbox filter, or when timeout_ms elapses. Used to replace * busy-poll loops in coordinating agents. */ pollInbox(agentId: string, timeoutMs: number, options?: { unreadOnly?: boolean; limit?: number; importance?: MessageImportance; }): Promise; /** Full-text search across messages */ search(query: string, options?: { limit?: number; channel?: string; from?: string; }): SearchResult[]; /** Edit a message (only the sender can edit) */ edit(messageId: number, agentId: string, newContent: string): Message; /** Delete a message (only the sender can delete) */ delete(messageId: number, agentId: string): void; } //# sourceMappingURL=messages.d.ts.map