//! Message types shared between producer and worker. use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use uuid::Uuid; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct RoomMessageEnvelope { pub id: Uuid, pub dedup_key: Option, pub room_id: Uuid, pub sender_type: String, pub sender_id: Option, pub thread_id: Option, pub in_reply_to: Option, pub content: String, pub content_type: String, pub send_at: DateTime, pub seq: i64, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct RoomMessageEvent { pub id: Uuid, pub room_id: Uuid, pub sender_type: String, pub sender_id: Option, pub thread_id: Option, pub in_reply_to: Option, pub content: String, pub content_type: String, pub send_at: DateTime, pub seq: i64, pub display_name: Option, /// Present when this event carries reaction updates for the message. #[serde(skip_serializing_if = "Option::is_none")] pub reactions: Option>, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ReactionGroup { pub emoji: String, pub count: i64, pub reacted_by_me: bool, pub users: Vec, } impl From for RoomMessageEvent { fn from(e: RoomMessageEnvelope) -> Self { Self { id: e.id, room_id: e.room_id, sender_type: e.sender_type, sender_id: e.sender_id, thread_id: e.thread_id, in_reply_to: e.in_reply_to, content: e.content, content_type: e.content_type, send_at: e.send_at, seq: e.seq, display_name: None, reactions: None, } } } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ProjectRoomEvent { pub event_type: String, pub project_id: Uuid, pub room_id: Option, pub category_id: Option, pub message_id: Option, pub seq: Option, pub timestamp: DateTime, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct RoomMessageStreamChunkEvent { pub message_id: Uuid, pub room_id: Uuid, pub content: String, pub done: bool, pub error: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct EmailEnvelope { pub id: Uuid, pub to: String, pub subject: String, pub body: String, pub created_at: DateTime, } /// Agent task event pushed via Redis Pub/Sub to notify WebSocket clients. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct AgentTaskEvent { /// Task ID pub task_id: i64, /// Project this task belongs to. pub project_id: Uuid, /// Parent task ID (null for root tasks). pub parent_id: Option, /// Event type: started | progress | done | failed | child_done pub event: String, /// Human-readable progress/status text. pub message: Option, /// Task output (only on done event). pub output: Option, /// Error message (only on failed event). pub error: Option, /// Current status. pub status: String, /// Timestamp. pub timestamp: DateTime, }