feat(FN-4177): add heartbeat messaging support for chat rooms

The merge delivers room heartbeat messaging for agents, allowing heartbeat-triggered agents to send messages into chat rooms and subscribe to room activity. Core changes include new chat-store room APIs, engine heartbeat room message tools, and corresponding tests, with a small dashboard ChatView up

Fusion-Task-Id: FN-4177
This commit is contained in:
Fusion
2026-05-12 18:16:49 -07:00
committed by gsxdsm
parent df52cc2e84
commit e7fc3a9d17
13 changed files with 632 additions and 16 deletions

View File

@@ -936,6 +936,29 @@ export class ChatStore extends EventEmitter<ChatStoreEvents> {
return rows.map((row) => this.rowToRoomMessage(row));
}
listRoomMessagesSince(
roomId: string,
sinceIso: string,
options?: { excludeSenderAgentId?: string; limit?: number },
): ChatRoomMessage[] {
const whereClauses: string[] = ["roomId = ?", "createdAt > ?"];
const params: Array<string | number | null> = [roomId, sinceIso];
if (options?.excludeSenderAgentId) {
whereClauses.push("(senderAgentId IS NULL OR senderAgentId != ?)");
params.push(options.excludeSenderAgentId);
}
const rows = this.db.prepare(`
SELECT * FROM chat_room_messages
WHERE ${whereClauses.join(" AND ")}
ORDER BY createdAt ASC
LIMIT ?
`).all(...params, options?.limit ?? 50) as ChatRoomMessageRow[];
return rows.map((row) => this.rowToRoomMessage(row));
}
getRoomMessage(id: string): ChatRoomMessage | undefined {
const row = this.db.prepare("SELECT * FROM chat_room_messages WHERE id = ?").get(id) as ChatRoomMessageRow | undefined;
return row ? this.rowToRoomMessage(row) : undefined;