1use schemars::JsonSchema;
8use serde::Serialize;
9
10pub fn ts(dt: chrono::DateTime<chrono::Utc>) -> String {
11 dt.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)
12}
13
14pub fn ts_opt(dt: Option<chrono::DateTime<chrono::Utc>>) -> Option<String> {
15 dt.map(ts)
16}
17
18#[derive(Debug, Serialize, JsonSchema)]
19pub struct WhoAmI {
20 pub agent: String,
22 pub agent_id: String,
23 pub team: String,
24 pub team_id: String,
25 pub unread_direct_messages: i64,
27 pub open_claimed_tasks: i64,
29}
30
31#[derive(Debug, Serialize, JsonSchema)]
34pub struct AgentInfo {
35 pub name: String,
36 pub display_name: Option<String>,
37 pub status: String,
40 pub repo: Option<String>,
41 pub branch: Option<String>,
42 pub activity: Option<String>,
44 pub last_seen: Option<String>,
45 pub online: bool,
46}
47
48#[derive(Debug, Serialize, JsonSchema)]
49pub struct AgentList {
50 pub agents: Vec<AgentInfo>,
51 pub online_count: usize,
52}
53
54#[derive(Debug, Serialize, JsonSchema)]
57pub struct ChannelInfo {
58 pub name: String,
59 pub topic: Option<String>,
60 pub message_count: i64,
61 pub created_at: String,
62}
63
64#[derive(Debug, Serialize, JsonSchema)]
65pub struct ChannelList {
66 pub channels: Vec<ChannelInfo>,
67}
68
69#[derive(Debug, Serialize, JsonSchema)]
70pub struct MessageInfo {
71 pub id: i64,
72 pub from: String,
73 pub channel: Option<String>,
75 pub to: Option<String>,
77 pub body: String,
78 pub reply_to: Option<i64>,
79 pub metadata: serde_json::Value,
80 pub attachments: Vec<AttachmentMeta>,
82 pub created_at: String,
83}
84
85#[derive(Debug, Serialize, serde::Deserialize, JsonSchema)]
86pub struct AttachmentMeta {
87 pub id: i64,
89 pub filename: String,
90 pub content_type: String,
91 pub size_bytes: i64,
92}
93
94#[derive(Debug, Serialize, JsonSchema)]
95pub struct AttachmentContent {
96 pub id: i64,
97 pub filename: String,
98 pub content_type: String,
99 pub size_bytes: i64,
100 pub uploaded_by: String,
101 pub created_at: String,
102 pub data_base64: String,
104}
105
106#[derive(Debug, Serialize, JsonSchema)]
107pub struct PostMessageResult {
108 pub message: MessageInfo,
109 pub delivered_to: Vec<String>,
111}
112
113#[derive(Debug, Serialize, JsonSchema)]
114pub struct MessageList {
115 pub messages: Vec<MessageInfo>,
116 pub scope: String,
118 pub cursor: i64,
121 pub truncated: bool,
123}
124
125#[derive(Debug, Serialize, JsonSchema)]
128pub struct TaskInfo {
129 pub key: String,
130 pub title: String,
131 pub description: Option<String>,
132 pub status: String,
134 pub depends_on: Vec<String>,
136 pub blocked: bool,
139 pub claimed_by: Option<String>,
140 pub claimed_at: Option<String>,
141 pub lease_expires_at: Option<String>,
144 pub lease_expired: bool,
146 pub result: Option<String>,
147 pub metadata: serde_json::Value,
148 pub attachments: Vec<AttachmentMeta>,
150 pub created_by: Option<String>,
151 pub created_at: String,
152 pub updated_at: String,
153}
154
155#[derive(Debug, Serialize, JsonSchema)]
156pub struct TaskList {
157 pub tasks: Vec<TaskInfo>,
158 pub open: i64,
159 pub claimed: i64,
160}
161
162#[derive(Debug, Serialize, JsonSchema)]
163pub struct ClaimResult {
164 pub claimed: bool,
165 pub task: Option<TaskInfo>,
166 pub reason: Option<String>,
168}
169
170#[derive(Debug, Serialize, JsonSchema)]
171pub struct TaskEventInfo {
172 pub event: String,
173 pub agent: Option<String>,
174 pub detail: Option<String>,
175 pub created_at: String,
176}
177
178#[derive(Debug, Serialize, JsonSchema)]
179pub struct TaskDetail {
180 pub task: TaskInfo,
181 pub history: Vec<TaskEventInfo>,
182}
183
184#[derive(Debug, Serialize, JsonSchema)]
187pub struct NoteInfo {
188 pub scope: String,
189 pub key: String,
190 pub value: String,
191 pub tags: Vec<String>,
192 pub updated_by: Option<String>,
193 pub updated_at: String,
194}
195
196#[derive(Debug, Serialize, JsonSchema)]
197pub struct NoteList {
198 pub notes: Vec<NoteInfo>,
199}
200
201#[derive(Debug, Serialize, JsonSchema)]
202pub struct NoteRef {
203 pub scope: String,
204 pub key: String,
205 pub found: bool,
206 pub note: Option<NoteInfo>,
207}
208
209#[derive(Debug, Serialize, JsonSchema)]
210pub struct Ack {
211 pub ok: bool,
212 pub detail: String,
213}
214
215#[derive(Debug, Serialize, JsonSchema)]
218pub struct LockInfo {
219 pub name: String,
220 pub holder: String,
221 pub purpose: Option<String>,
222 pub acquired_at: String,
223 pub expires_at: String,
225}
226
227#[derive(Debug, Serialize, JsonSchema)]
228pub struct LockList {
229 pub locks: Vec<LockInfo>,
230}
231
232#[derive(Debug, Serialize, JsonSchema)]
233pub struct LockResult {
234 pub acquired: bool,
235 pub lock: Option<LockInfo>,
236 pub reason: Option<String>,
238}
239
240#[derive(Debug, Serialize, JsonSchema)]
243pub struct WaitEvent {
244 pub kind: String,
246 pub summary: String,
248}
249
250#[derive(Debug, Serialize, JsonSchema)]
251pub struct WaitResult {
252 pub woke: bool,
254 pub timed_out: bool,
255 pub events: Vec<WaitEvent>,
256 pub unread_direct_messages: i64,
258 pub suggestion: String,
260}
261
262#[derive(Debug, Serialize, JsonSchema)]
263pub struct AskResult {
264 pub answered: bool,
266 pub to: String,
268 pub question_message_id: i64,
271 pub answer: Option<MessageInfo>,
274 pub suggestion: String,
276}
277
278#[derive(Debug, Serialize, JsonSchema)]
281pub struct DigestMessage {
282 pub from: String,
283 pub body: String,
284 pub at: String,
285}
286
287#[derive(Debug, Serialize, JsonSchema)]
288pub struct DigestChannel {
289 pub name: String,
290 pub message_count: i64,
291 pub last_messages: Vec<DigestMessage>,
292}
293
294#[derive(Debug, Serialize, JsonSchema)]
295pub struct DigestTask {
296 pub key: String,
297 pub title: String,
298 pub status: String,
299 pub claimed_by: Option<String>,
300 pub result: Option<String>,
301 pub updated_at: String,
302}
303
304#[derive(Debug, Serialize, JsonSchema)]
305pub struct DigestNote {
306 pub scope: String,
307 pub key: String,
308 pub updated_by: Option<String>,
309 pub updated_at: String,
310}
311
312#[derive(Debug, Serialize, JsonSchema)]
313pub struct DigestAgent {
314 pub name: String,
315 pub activity: Option<String>,
316 pub last_seen: Option<String>,
317 pub online: bool,
318}
319
320#[derive(Debug, Serialize, JsonSchema)]
321pub struct DigestResult {
322 pub hours: i64,
324 pub channels: Vec<DigestChannel>,
325 pub tasks_moved: Vec<DigestTask>,
327 pub open_tasks: i64,
328 pub claimed_tasks: i64,
329 pub notes_updated: Vec<DigestNote>,
330 pub agents_seen: Vec<DigestAgent>,
331 pub active_locks: Vec<LockInfo>,
332}