| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
use schemars::JsonSchema; |
| 7 |
use serde::{Deserialize, Serialize}; |
| 8 |
|
| 9 |
|
| 10 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 11 |
pub struct Problem { |
| 12 |
#[serde(rename = "type")] |
| 13 |
pub kind: String, |
| 14 |
pub title: String, |
| 15 |
pub status: u16, |
| 16 |
#[serde(skip_serializing_if = "Option::is_none")] |
| 17 |
pub detail: Option<String>, |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 22 |
pub struct Version { |
| 23 |
pub version: String, |
| 24 |
pub ledger_format: u32, |
| 25 |
pub mcp_protocol_versions: Vec<String>, |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 30 |
pub struct Agent { |
| 31 |
pub name: String, |
| 32 |
|
| 33 |
pub display: String, |
| 34 |
pub owner: String, |
| 35 |
pub key: String, |
| 36 |
pub kind: String, |
| 37 |
pub project: String, |
| 38 |
|
| 39 |
pub presence: String, |
| 40 |
pub status: Option<String>, |
| 41 |
pub disabled: bool, |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 46 |
pub struct Project { |
| 47 |
pub name: String, |
| 48 |
pub path: String, |
| 49 |
pub remote: Option<String>, |
| 50 |
pub depends_on: Vec<String>, |
| 51 |
pub depended_on_by: Vec<String>, |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 56 |
pub struct Channel { |
| 57 |
pub id: String, |
| 58 |
pub name: String, |
| 59 |
|
| 60 |
pub display: String, |
| 61 |
pub kind: String, |
| 62 |
pub purpose: Option<String>, |
| 63 |
pub messages: i64, |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 68 |
pub struct Message { |
| 69 |
pub id: String, |
| 70 |
pub channel: String, |
| 71 |
pub reply_to: Option<String>, |
| 72 |
pub author: String, |
| 73 |
pub author_display: String, |
| 74 |
pub kind: String, |
| 75 |
pub body: String, |
| 76 |
pub mentions: Vec<String>, |
| 77 |
pub refs: Vec<String>, |
| 78 |
pub at_ms: i64, |
| 79 |
pub replies: i64, |
| 80 |
pub redacted: bool, |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 85 |
pub struct Messages { |
| 86 |
pub channel: String, |
| 87 |
pub items: Vec<Message>, |
| 88 |
pub next: Option<String>, |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 93 |
pub struct NewMessage { |
| 94 |
pub body: String, |
| 95 |
#[serde(default)] |
| 96 |
pub reply_to: Option<String>, |
| 97 |
#[serde(default)] |
| 98 |
pub kind: Option<String>, |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 103 |
pub struct Posted { |
| 104 |
pub id: String, |
| 105 |
pub channel: String, |
| 106 |
|
| 107 |
pub duplicate: bool, |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 112 |
pub struct InboxItem { |
| 113 |
pub id: String, |
| 114 |
pub kind: String, |
| 115 |
pub at_ms: i64, |
| 116 |
pub from: String, |
| 117 |
pub channel: String, |
| 118 |
pub summary: String, |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 123 |
pub struct Ack { |
| 124 |
pub ids: Vec<String>, |
| 125 |
#[serde(default)] |
| 126 |
pub reaction: Option<String>, |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 131 |
pub struct Hit { |
| 132 |
pub id: String, |
| 133 |
pub channel: String, |
| 134 |
pub author: String, |
| 135 |
pub at_ms: i64, |
| 136 |
pub snippet: String, |
| 137 |
pub thread: Option<String>, |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 143 |
pub struct EventSummary { |
| 144 |
pub seq: u64, |
| 145 |
pub id: String, |
| 146 |
pub at_ms: u64, |
| 147 |
pub kind: String, |
| 148 |
pub actor: String, |
| 149 |
pub subject: Option<String>, |
| 150 |
|
| 151 |
pub method: String, |
| 152 |
pub assurance: u8, |
| 153 |
pub hash: String, |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 158 |
pub struct Events { |
| 159 |
pub items: Vec<EventSummary>, |
| 160 |
pub next: Option<u64>, |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 165 |
pub struct Brief { |
| 166 |
pub you: String, |
| 167 |
pub actor: String, |
| 168 |
pub project: Option<String>, |
| 169 |
pub rules_version: String, |
| 170 |
pub unread: i64, |
| 171 |
pub inbox: Vec<InboxItem>, |
| 172 |
pub agents: Vec<Agent>, |
| 173 |
pub head: u64, |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
pub fn schemas() -> Vec<(&'static str, schemars::Schema)> { |
| 178 |
vec![ |
| 179 |
("Problem", schemars::schema_for!(Problem)), |
| 180 |
("Version", schemars::schema_for!(Version)), |
| 181 |
("Agent", schemars::schema_for!(Agent)), |
| 182 |
("Project", schemars::schema_for!(Project)), |
| 183 |
("Channel", schemars::schema_for!(Channel)), |
| 184 |
("Message", schemars::schema_for!(Message)), |
| 185 |
("Messages", schemars::schema_for!(Messages)), |
| 186 |
("NewMessage", schemars::schema_for!(NewMessage)), |
| 187 |
("Posted", schemars::schema_for!(Posted)), |
| 188 |
("InboxItem", schemars::schema_for!(InboxItem)), |
| 189 |
("Ack", schemars::schema_for!(Ack)), |
| 190 |
("Hit", schemars::schema_for!(Hit)), |
| 191 |
("EventSummary", schemars::schema_for!(EventSummary)), |
| 192 |
("Events", schemars::schema_for!(Events)), |
| 193 |
("Brief", schemars::schema_for!(Brief)), |
| 194 |
] |
| 195 |
} |