//! Rows and wire types shared by the API and the room. use serde::{Deserialize, Serialize}; /// One chat line. The sequence number orders it in the room log. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Message { pub seq: u64, pub id: String, /// The member id for a human, `None` for the agent and system lines. pub author_id: Option, pub author_name: String, /// `human`, `agent`, or `system`. pub author_kind: String, pub text: String, pub mentions: bool, pub created_at: i64, /// The images riding this line, metadata only: the bytes are served /// from the room's attachment route. Empty for older rows. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub attachments: Vec, } /// An image attached to a chat line. `mime` comes from the stored /// bytes' magic, never from the uploader's header. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Attachment { pub id: String, pub mime: String, pub size: i64, } /// A room as the sidebar needs it. #[derive(Debug, Clone, Serialize)] pub struct RoomSummary { pub id: String, pub name: String, pub role: String, pub member_count: i64, pub last_at: Option, pub last_text: Option, } /// A full room. #[derive(Debug, Clone, Serialize)] pub struct Room { pub id: String, pub name: String, pub owner_id: String, pub provider_config_id: Option, pub sandbox_target_id: Option, pub workspace: String, pub repo_url: Option, pub model: Option, pub max_turn_steps: i64, /// Whether the room's effective model is known to accept images. /// `None` is unknown, not no: facts arrive with a provider listing. pub model_vision: Option, pub created_at: i64, pub archived_at: Option, } /// A member row. #[derive(Debug, Clone, Serialize)] pub struct Member { pub id: String, pub account_id: String, pub display_name: String, pub role: String, pub color: String, pub avatar_updated_at: Option, pub online: bool, } /// The account as the client sees it. #[derive(Debug, Clone, Serialize)] pub struct User { pub id: String, pub handle: String, pub display_name: String, pub kind: String, /// When the account last replaced its picture, or `None`. pub avatar_updated_at: Option, } /// What the room's preview pane shows: a port inside the sandbox, or /// a static file or folder served by the app. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[serde(tag = "kind", rename_all = "lowercase")] pub enum PreviewTarget { /// A listener inside the sandbox. Port { port: u16 }, /// A file, or a folder with an `index.html`, read over ssh and /// served from the signed preview host. Static { /// The workspace-relative path the agent named. path: String, /// The workspace-relative directory the URL paths resolve in. root: String, /// The workspace-relative file a request for `/` serves. entry: String, }, } /// One server-sent event. Durable events are also rows in `events`; /// deltas are live only. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Envelope { pub seq: u64, pub kind: String, pub data: serde_json::Value, } /// A provider configuration without its key. #[derive(Debug, Clone, Serialize)] pub struct ProviderConfig { pub id: String, pub name: String, pub kind: String, pub model: String, pub base_url: Option, } /// A sandbox target without its private key. #[derive(Debug, Clone, Serialize)] pub struct SandboxTarget { pub id: String, pub name: String, pub host: String, pub port: i64, pub user_name: String, pub workspace_root: String, pub public_key: String, pub host_fingerprint: Option, } /// A directory entry in the read-only file pane. #[derive(Debug, Clone, Serialize)] pub struct FileEntry { pub name: String, pub path: String, pub kind: String, pub size: i64, }