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