gitdataai/libs/transport/event/message.rs
ZhenYi 14f6e1e500 feat(core): initialize project with access control and AI integration
- Add gitignore and prettier configuration files for project scaffolding
- Implement room access control service with project member verification
- Create user access key management with CRUD operations and activity logging
- Add accordion UI component for frontend expandable sections
- Implement room AI configuration with list, upsert, and delete operations
- Add AI event types for agent join/leave/status change tracking
- Create streaming AI processing services for mode and react patterns
- Build room AI service with model detection and idempotency handling
- Integrate chat service orchestration for AI message processing
- Add typing indicators and stream cancellation for AI interactions
- Implement mention parsing and context extraction for AI agents
2026-05-03 06:04:31 +08:00

113 lines
2.9 KiB
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use models::{MessageId, RoomId, RoomThreadId, Seq, UserId, Uuid};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum MessageEventType {
New,
Edited,
Revoked,
StreamChunk,
StreamDone,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum MessageEvent {
New(MessageNewService),
Edited(MessageEditedService),
Revoked(MessageRevokedService),
StreamChunk(MessageStreamChunkService),
StreamDone(MessageStreamDoneService),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageNewService {
pub id: MessageId,
pub seq: Seq,
pub room: RoomId,
pub sender_type: String,
pub sender_id: Option<UserId>,
pub display_name: Option<String>,
pub thread: Option<RoomThreadId>,
pub in_reply_to: Option<MessageId>,
pub content: String,
pub content_type: String,
pub thinking_content: Option<String>,
pub thinking_is_chunked: bool,
pub send_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageEditedService {
pub id: MessageId,
pub seq: Seq,
pub room: RoomId,
pub sender_id: Option<UserId>,
pub content: String,
pub edited_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageRevokedService {
pub id: MessageId,
pub seq: Seq,
pub room: RoomId,
pub revoked_at: DateTime<Utc>,
pub revoked_by: Option<UserId>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageStreamStartService {
pub message_id: MessageId,
pub room: RoomId,
/// SSE endpoint the client should open to receive full chunk content.
pub sse_url: String,
pub display_name: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageStreamChunkService {
pub message_id: MessageId,
pub room: RoomId,
pub seq: u64,
pub content: String,
pub chunk_type: Option<String>,
pub display_name: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MessageStreamDoneService {
pub message_id: MessageId,
pub room: RoomId,
pub content: String,
pub thinking_content: Option<String>,
pub display_name: Option<String>,
pub error: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MessageSendClient {
pub room: RoomId,
pub content: String,
pub content_type: Option<String>,
pub thread: Option<RoomThreadId>,
pub in_reply_to: Option<MessageId>,
#[serde(default)]
pub attachment_ids: Vec<Uuid>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MessageEditClient {
pub room: RoomId,
pub message_id: MessageId,
pub content: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MessageRevokeClient {
pub room: RoomId,
pub message_id: MessageId,
}