- 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
38 lines
864 B
Rust
38 lines
864 B
Rust
use serde::{Deserialize, Serialize};
|
|
use uuid::Uuid;
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TransportEnvelope<T> {
|
|
#[serde(default = "uuid::Uuid::now_v7")]
|
|
pub message_id: Uuid,
|
|
pub user_id: Uuid,
|
|
pub payload: T,
|
|
#[serde(default = "default_timestamp")]
|
|
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
#[serde(default)]
|
|
pub attempt: u8,
|
|
}
|
|
|
|
fn default_timestamp() -> chrono::DateTime<chrono::Utc> {
|
|
chrono::Utc::now()
|
|
}
|
|
|
|
impl<T> TransportEnvelope<T> {
|
|
pub fn new(user_id: Uuid, payload: T) -> Self {
|
|
Self {
|
|
message_id: Uuid::now_v7(),
|
|
user_id,
|
|
payload,
|
|
created_at: chrono::Utc::now(),
|
|
attempt: 1,
|
|
}
|
|
}
|
|
|
|
pub fn retry(self) -> Self {
|
|
Self {
|
|
attempt: self.attempt + 1,
|
|
..self
|
|
}
|
|
}
|
|
}
|