| 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 | | #[serde(default)] |
| 44 | | pub state: String, |
| 45 | | |
| 46 | | #[serde(default)] |
| 47 | | pub delegation_expires: Option<u64>, |
| 48 | | |
| 49 | | |
| 50 | | #[serde(default)] |
| 51 | | pub channels: Vec<String>, |
| 52 | | } |
| 53 | |
|
| 54 | |
|
| 55 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 56 | | pub struct Project { |
| 57 | | pub name: String, |
| 58 | | |
| 59 | | pub path: Option<String>, |
| 60 | | #[serde(default)] |
| 61 | | pub description: String, |
| 62 | | |
| 63 | | pub url: Option<String>, |
| 64 | | pub depends_on: Vec<String>, |
| 65 | | pub depended_on_by: Vec<String>, |
| 66 | | |
| 67 | | #[serde(default)] |
| 68 | | pub agents: Vec<String>, |
| 69 | | } |
| 70 | |
|
| 71 | |
|
| 72 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 73 | | pub struct Channel { |
| 74 | | pub id: String, |
| 75 | | pub name: String, |
| 76 | | |
| 77 | | pub display: String, |
| 78 | | pub kind: String, |
| 79 | | pub purpose: Option<String>, |
| 80 | | pub messages: i64, |
| 81 | | } |
| 82 | |
|
| 83 | |
|
| 84 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 85 | | pub struct Message { |
| 86 | | pub id: String, |
| 87 | | pub channel: String, |
| 88 | | pub reply_to: Option<String>, |
| 89 | | pub author: String, |
| 90 | | pub author_display: String, |
| 91 | | pub kind: String, |
| 92 | | pub body: String, |
| 93 | | pub mentions: Vec<String>, |
| 94 | | pub refs: Vec<String>, |
| 95 | | pub at_ms: i64, |
| 96 | | pub replies: i64, |
| 97 | | pub redacted: bool, |
| 98 | | } |
| 99 | |
|
| 100 | |
|
| 101 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 102 | | pub struct Messages { |
| 103 | | pub channel: String, |
| 104 | | pub items: Vec<Message>, |
| 105 | | pub next: Option<String>, |
| 106 | | } |
| 107 | |
|
| 108 | |
|
| 109 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 110 | | pub struct NewMessage { |
| 111 | | pub body: String, |
| 112 | | #[serde(default)] |
| 113 | | pub reply_to: Option<String>, |
| 114 | | #[serde(default)] |
| 115 | | pub kind: Option<String>, |
| 116 | | } |
| 117 | |
|
| 118 | |
|
| 119 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 120 | | pub struct Posted { |
| 121 | | pub id: String, |
| 122 | | pub channel: String, |
| 123 | | |
| 124 | | pub duplicate: bool, |
| 125 | | } |
| 126 | |
|
| 127 | |
|
| 128 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 129 | | pub struct InboxItem { |
| 130 | | pub id: String, |
| 131 | | pub kind: String, |
| 132 | | pub at_ms: i64, |
| 133 | | pub from: String, |
| 134 | | |
| 135 | | #[serde(default)] |
| 136 | | pub from_display: String, |
| 137 | | pub channel: String, |
| 138 | | pub summary: String, |
| 139 | | } |
| 140 | |
|
| 141 | |
|
| 142 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 143 | | pub struct Ack { |
| 144 | | pub ids: Vec<String>, |
| 145 | | #[serde(default)] |
| 146 | | pub reaction: Option<String>, |
| 147 | | } |
| 148 | |
|
| 149 | |
|
| 150 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 151 | | pub struct Hit { |
| 152 | | pub id: String, |
| 153 | | pub channel: String, |
| 154 | | pub author: String, |
| 155 | | pub at_ms: i64, |
| 156 | | pub snippet: String, |
| 157 | | pub thread: Option<String>, |
| 158 | | #[serde(default)] |
| 159 | | pub author_display: String, |
| 160 | | } |
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 165 | | pub struct EventSummary { |
| 166 | | pub seq: u64, |
| 167 | | pub id: String, |
| 168 | | pub at_ms: u64, |
| 169 | | pub kind: String, |
| 170 | | pub actor: String, |
| 171 | | pub subject: Option<String>, |
| 172 | | |
| 173 | | pub method: String, |
| 174 | | pub assurance: u8, |
| 175 | | pub hash: String, |
| 176 | | } |
| 177 | |
|
| 178 | |
|
| 179 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 180 | | pub struct Events { |
| 181 | | pub items: Vec<EventSummary>, |
| 182 | | pub next: Option<u64>, |
| 183 | | } |
| 184 | |
|
| 185 | |
|
| 186 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 187 | | pub struct Brief { |
| 188 | | pub you: String, |
| 189 | | pub actor: String, |
| 190 | | pub project: Option<String>, |
| 191 | | pub rules_version: String, |
| 192 | | pub unread: i64, |
| 193 | | pub inbox: Vec<InboxItem>, |
| 194 | | pub agents: Vec<Agent>, |
| 195 | | pub head: u64, |
| 196 | | } |
| 197 | |
|
| 198 | |
|
| 199 | 0× | pub fn schemas() -> Vec<(&'static str, schemars::Schema)> { |
| 200 | 0× | vec![ |
| 201 | 0× | ("Problem", schemars::schema_for!(Problem)), |
| 202 | 0× | ("Version", schemars::schema_for!(Version)), |
| 203 | 0× | ("Agent", schemars::schema_for!(Agent)), |
| 204 | 0× | ("Project", schemars::schema_for!(Project)), |
| 205 | 0× | ("Channel", schemars::schema_for!(Channel)), |
| 206 | 0× | ("Message", schemars::schema_for!(Message)), |
| 207 | 0× | ("Messages", schemars::schema_for!(Messages)), |
| 208 | 0× | ("NewMessage", schemars::schema_for!(NewMessage)), |
| 209 | 0× | ("Posted", schemars::schema_for!(Posted)), |
| 210 | 0× | ("InboxItem", schemars::schema_for!(InboxItem)), |
| 211 | 0× | ("Ack", schemars::schema_for!(Ack)), |
| 212 | 0× | ("Hit", schemars::schema_for!(Hit)), |
| 213 | 0× | ("Briefs", schemars::schema_for!(Briefs)), |
| 214 | 0× | ("ProjectBrief", schemars::schema_for!(ProjectBrief)), |
| 215 | 0× | ("SetBrief", schemars::schema_for!(SetBrief)), |
| 216 | 0× | ("EventSummary", schemars::schema_for!(EventSummary)), |
| 217 | 0× | ("Events", schemars::schema_for!(Events)), |
| 218 | 0× | ("Brief", schemars::schema_for!(Brief)), |
| 219 | | ] |
| 220 | 0× | } |
| 221 | |
|
| 222 | |
|
| 223 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 224 | | pub struct Briefs { |
| 225 | | pub overall: Option<String>, |
| 226 | | pub projects: Vec<ProjectBrief>, |
| 227 | | } |
| 228 | |
|
| 229 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 230 | | pub struct ProjectBrief { |
| 231 | | pub project: String, |
| 232 | | pub text: String, |
| 233 | | } |
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | | #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] |
| 238 | | pub struct SetBrief { |
| 239 | | #[serde(default)] |
| 240 | | pub project: Option<String>, |
| 241 | | pub text: String, |
| 242 | | } |