use schemars::JsonSchema;
use serde::Serialize;
pub fn ts(dt: chrono::DateTime<chrono::Utc>) -> String {
dt.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)
}
pub fn ts_opt(dt: Option<chrono::DateTime<chrono::Utc>>) -> Option<String> {
dt.map(ts)
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct WhoAmI {
pub agent: String,
pub agent_id: String,
pub team: String,
pub team_id: String,
pub unread_direct_messages: i64,
pub open_claimed_tasks: i64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct AgentInfo {
pub name: String,
pub display_name: Option<String>,
pub status: String,
pub repo: Option<String>,
pub branch: Option<String>,
pub activity: Option<String>,
pub last_seen: Option<String>,
pub online: bool,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct AgentList {
pub agents: Vec<AgentInfo>,
pub online_count: usize,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ChannelInfo {
pub name: String,
pub topic: Option<String>,
pub message_count: i64,
pub created_at: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ChannelList {
pub channels: Vec<ChannelInfo>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct MessageInfo {
pub id: i64,
pub from: String,
pub channel: Option<String>,
pub to: Option<String>,
pub body: String,
pub reply_to: Option<i64>,
pub metadata: serde_json::Value,
pub attachments: Vec<AttachmentMeta>,
pub created_at: String,
}
#[derive(Debug, Serialize, serde::Deserialize, JsonSchema)]
pub struct AttachmentMeta {
pub id: i64,
pub filename: String,
pub content_type: String,
pub size_bytes: i64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct AttachmentContent {
pub id: i64,
pub filename: String,
pub content_type: String,
pub size_bytes: i64,
pub uploaded_by: String,
pub created_at: String,
pub data_base64: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct PostMessageResult {
pub message: MessageInfo,
pub delivered_to: Vec<String>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct MessageList {
pub messages: Vec<MessageInfo>,
pub scope: String,
pub cursor: i64,
pub truncated: bool,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct TaskInfo {
pub key: String,
pub title: String,
pub description: Option<String>,
pub status: String,
pub depends_on: Vec<String>,
pub blocked: bool,
pub claimed_by: Option<String>,
pub claimed_at: Option<String>,
pub lease_expires_at: Option<String>,
pub lease_expired: bool,
pub result: Option<String>,
pub metadata: serde_json::Value,
pub attachments: Vec<AttachmentMeta>,
pub created_by: Option<String>,
pub created_at: String,
pub updated_at: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct TaskList {
pub tasks: Vec<TaskInfo>,
pub open: i64,
pub claimed: i64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ClaimResult {
pub claimed: bool,
pub task: Option<TaskInfo>,
pub reason: Option<String>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct TaskEventInfo {
pub event: String,
pub agent: Option<String>,
pub detail: Option<String>,
pub created_at: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct TaskDetail {
pub task: TaskInfo,
pub history: Vec<TaskEventInfo>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct NoteInfo {
pub scope: String,
pub key: String,
pub value: String,
pub tags: Vec<String>,
pub updated_by: Option<String>,
pub updated_at: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct NoteList {
pub notes: Vec<NoteInfo>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct NoteRef {
pub scope: String,
pub key: String,
pub found: bool,
pub note: Option<NoteInfo>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct Ack {
pub ok: bool,
pub detail: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct LockInfo {
pub name: String,
pub holder: String,
pub purpose: Option<String>,
pub acquired_at: String,
pub expires_at: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct LockList {
pub locks: Vec<LockInfo>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct LockResult {
pub acquired: bool,
pub lock: Option<LockInfo>,
pub reason: Option<String>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct WaitEvent {
pub kind: String,
pub summary: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct WaitResult {
pub woke: bool,
pub timed_out: bool,
pub events: Vec<WaitEvent>,
pub unread_direct_messages: i64,
pub suggestion: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct AskResult {
pub answered: bool,
pub to: String,
pub question_message_id: i64,
pub answer: Option<MessageInfo>,
pub suggestion: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct DigestMessage {
pub from: String,
pub body: String,
pub at: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct DigestChannel {
pub name: String,
pub message_count: i64,
pub last_messages: Vec<DigestMessage>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct DigestTask {
pub key: String,
pub title: String,
pub status: String,
pub claimed_by: Option<String>,
pub result: Option<String>,
pub updated_at: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct DigestNote {
pub scope: String,
pub key: String,
pub updated_by: Option<String>,
pub updated_at: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct DigestAgent {
pub name: String,
pub activity: Option<String>,
pub last_seen: Option<String>,
pub online: bool,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct DigestResult {
pub hours: i64,
pub channels: Vec<DigestChannel>,
pub tasks_moved: Vec<DigestTask>,
pub open_tasks: i64,
pub claimed_tasks: i64,
pub notes_updated: Vec<DigestNote>,
pub agents_seen: Vec<DigestAgent>,
pub active_locks: Vec<LockInfo>,
}