import { type Database } from "../data/database.js"; import type { RoomMessageAttachment } from "../files/attachments.js"; export interface Message { id: string; seq?: number; sender: string; senderMemberId?: string; content: string; mentions: string[]; mentionMemberIds?: string[]; ts: number; type?: "task_event" | "knowledge_event" | "topic_event"; task_event_meta?: Record; knowledge_event_meta?: Record; topic_event_meta?: Record; artifacts?: string[]; attachments?: RoomMessageAttachment[]; needResponse?: string[]; needResponseMemberIds?: string[]; replyTo?: { seq: number; messageId: string; }; member_chat_meta?: { scopeId: string; fromMemberId: string; toMemberId: string; }; } export type MessageInput = Omit; export interface MessagePageOptions { limit?: number; before?: string; around?: string; fromSeq?: number; } export interface MemberMessageReplyView { seq: number; messageId: string; sender?: string; excerpt?: string; unavailable?: boolean; } export type MemberMessageView = Omit & { replyTo?: MemberMessageReplyView; }; export interface MessageQueryOptions { fromSeq?: number; aroundSeq?: number; beforeTs?: number; afterTs?: number; limit?: number; } export interface MessageSearchOptions { includeAuthors?: boolean; fromLabelOnly?: boolean; query?: string; from?: string; fromMemberId?: string; after?: number; before?: number; offset?: number; limit?: number; } export interface MessageSearchHit { id: string; seq?: number; sender: string; senderMemberId?: string; content: string; ts: number; } export interface MessageSearchAuthor { id: string; name: string; kind: 'user' | 'member' | 'system' | 'legacy'; status: 'current' | 'left' | 'deleted' | 'unknown'; memberId?: string; } export interface MessageSearchResult { total: number; messages: MessageSearchHit[]; authors?: MessageSearchAuthor[]; } export interface ConversationListState { lastMessage: { sender: string; senderMemberId?: string; text: string; ts: number; } | null; unreadCount: number; mentioned: boolean; } export declare function isSystemNoticeHiddenFromMembers(message: Pick): boolean; export declare function validateMessage(message: Message): void; /** SQL-only append for composition with delivery and agent admission. It always * records the committed message snapshot in the generic outbox. */ export declare function appendMessageInTransaction(db: Database, scope: string, input: MessageInput): Message; export type MessageSink = (sourceRef: string, message: Message) => void; /** Connect the transport after startup. Delivery is post-commit and durable; * failures remain pending for the next startup/timer rather than hot-looping. */ export declare function setMessageSink(sink: MessageSink | undefined): void; export declare function scheduleMessageDispatch(): void; export declare function normalizeHistoricalMessage(message: Message): Message; export declare function importMessage(db: Database, scope: string, message: Message): void; export declare function importMessageNextSequence(db: Database, scope: string, nextSeq: number): void; export declare function readMessage(scope: string, id: string, db?: Database): Message | null; export declare function readMessages(scope: string, db?: Database): Message[]; export declare function countUserUnreadAndMention(messages: Message[], cursorId: string | null, cursorSeq: number | null, login: string): Pick; /** Canonical chat-list read model. Cursor windowing and unread eligibility stay in * chat; HTTP consumers only add labels and transport/runtime projections. */ export declare function readConversationListState(scope: string, login: string, db?: Database): ConversationListState; export declare function messagesSince(scope: string, cursor: string | null, db?: Database): Message[]; /** Member-facing ordered query. Sequence anchors are sequence numbers, time * bounds are epoch milliseconds, and the returned window excludes hidden * system notices before limit/ordering are applied. */ export declare function queryMessages(scope: string, options?: MessageQueryOptions, db?: Database): MemberMessageView[]; export declare function pageMessages(scope: string, options?: MessagePageOptions, db?: Database): Message[]; export declare function listMessageSearchAuthors(scope: string, db?: Database): MessageSearchAuthor[]; export declare function searchMessages(scope: string, options?: MessageSearchOptions, db?: Database): MessageSearchResult; //# sourceMappingURL=messages.d.ts.map