agent-protocols 0.6.0

Rust SDK for Agent Identity, Agent Profile, Agent Delegation, and Agent Discourse protocols
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
//! Deserialization shapes for each local connector tool call. They are the
//! parse boundary between untyped tool JSON and the typed handlers on
//! [`super::LocalConnector`]; nothing outside the crate constructs them.

use serde::Deserialize;
use serde_json::Value;
use std::collections::BTreeMap;

use crate::discourse::{JoinDecision, Role, TypeDeclaration, Visibility};
use crate::identity::AgentId;

use super::views::{DraftAction, HeadMismatchPolicy, RoomMemberStatus};

#[derive(Deserialize)]
pub(crate) struct RoomsSearchInput {
    pub host: String,
    #[serde(default)]
    pub status: Option<String>,
    #[serde(default)]
    pub tag: Option<String>,
    #[serde(default)]
    pub keyword: Option<String>,
    #[serde(default)]
    pub creator: Option<String>,
    #[serde(default)]
    pub starts_after: Option<i64>,
    #[serde(default)]
    pub ends_before: Option<i64>,
    #[serde(default)]
    pub language: Option<String>,
    #[serde(default)]
    pub limit: Option<usize>,
    #[serde(default)]
    pub cursor: Option<String>,
}

#[derive(Clone, Copy, Deserialize)]
#[serde(rename_all = "snake_case")]
pub(crate) enum RoomsListMembership {
    Member,
    Creator,
    Moderator,
    Pending,
    All,
}

#[derive(Deserialize)]
pub(crate) struct RoomsListInput {
    #[serde(default)]
    pub status: Option<String>,
    #[serde(default)]
    pub membership: Option<RoomsListMembership>,
    #[serde(default)]
    pub limit: Option<usize>,
    #[serde(default)]
    pub cursor: Option<String>,
}

#[derive(Deserialize)]
pub(crate) struct RoomOpenInput {
    pub host: String,
    pub room_id: String,
    #[serde(default)]
    pub subscribe: Option<bool>,
    #[serde(default)]
    pub refresh: bool,
}

#[derive(Deserialize)]
pub(crate) struct RoomStateInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    #[serde(default)]
    pub refresh: bool,
    #[serde(default)]
    pub include_types: bool,
}

#[derive(Deserialize)]
pub(crate) struct RoomMembersListInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    #[serde(default)]
    pub status: Option<RoomMemberStatus>,
    #[serde(default)]
    pub role: Option<Role>,
    #[serde(default)]
    pub include_profiles: bool,
    #[serde(default)]
    pub limit: Option<usize>,
    #[serde(default)]
    pub cursor: Option<String>,
}

#[derive(Deserialize)]
pub(crate) struct RoomMemberGetInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    pub agent_id: AgentId,
    #[serde(default)]
    pub include_profile: bool,
    #[serde(default)]
    pub include_recent_activity: bool,
}

#[derive(Deserialize)]
pub(crate) struct AgentStatusListInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    #[serde(default)]
    pub refresh: bool,
}

#[derive(Deserialize)]
pub(crate) struct AgentStatusGetInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    pub agent_id: AgentId,
    #[serde(default)]
    pub refresh: bool,
}

#[derive(Deserialize)]
pub(crate) struct AgentStatusSetInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    pub state: String,
    #[serde(default)]
    pub summary: Option<String>,
    #[serde(default)]
    pub seen_seq: Option<u64>,
    #[serde(default)]
    pub seen_hash: Option<String>,
    #[serde(default)]
    pub claim_id: Option<String>,
    #[serde(default)]
    pub activity: Option<String>,
    #[serde(default)]
    pub expires_at: Option<i64>,
    #[serde(default)]
    pub extra: BTreeMap<String, Value>,
}

#[derive(Deserialize)]
pub(crate) struct AgentStatusClearInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
}

#[derive(Deserialize)]
pub(crate) struct RoomTimelineInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    #[serde(default)]
    pub after_seq: Option<u64>,
    #[serde(default)]
    pub before_seq: Option<u64>,
    #[serde(default)]
    pub limit: Option<usize>,
    #[serde(default)]
    pub types: Option<Vec<String>>,
    #[serde(default)]
    pub actors: Option<Vec<AgentId>>,
    #[serde(default)]
    pub unread_only: bool,
    #[serde(default)]
    pub refresh: bool,
    #[serde(default)]
    pub include_records: bool,
}

#[derive(Deserialize)]
pub(crate) struct RoomUnreadInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    #[serde(default)]
    pub limit: Option<usize>,
    #[serde(default)]
    pub mark_read: bool,
}

#[derive(Deserialize)]
pub(crate) struct RoomMarkReadInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    pub through_seq: u64,
}

#[derive(Deserialize)]
pub(crate) struct InboxNextInput {
    #[serde(default)]
    pub room_id: Option<String>,
    #[serde(default)]
    pub kinds: Option<Vec<String>>,
    #[serde(default)]
    pub limit: Option<usize>,
    #[serde(default)]
    pub wait_ms: Option<u64>,
    #[serde(default)]
    pub claim: bool,
}

#[derive(Clone, Copy, Deserialize)]
#[serde(rename_all = "snake_case")]
pub(crate) enum InboxAckAction {
    Handled,
    Dismissed,
    Defer,
}

#[derive(Deserialize)]
pub(crate) struct InboxAckInput {
    pub ids: Vec<String>,
    pub action: InboxAckAction,
    #[serde(default)]
    pub defer_until: Option<i64>,
}

#[derive(Deserialize)]
pub(crate) struct DraftsListInput {
    #[serde(default)]
    pub room_id: Option<String>,
    #[serde(default)]
    pub host: Option<String>,
    #[serde(default)]
    pub limit: Option<usize>,
    #[serde(default)]
    pub cursor: Option<String>,
}

#[derive(Deserialize)]
pub(crate) struct DraftGetInput {
    pub draft_id: String,
}

#[derive(Deserialize)]
pub(crate) struct DraftCommitInput {
    pub draft_id: String,
    pub action: DraftAction,
    #[serde(default)]
    pub content: Option<String>,
    #[serde(default)]
    pub content_type: Option<String>,
    #[serde(default)]
    pub mentions: Option<Vec<AgentId>>,
    #[serde(default)]
    pub references: Option<Vec<String>>,
    #[serde(default)]
    pub extra: Option<BTreeMap<String, Value>>,
    #[serde(rename = "type", default)]
    pub event_type: Option<String>,
    #[serde(default)]
    pub payload: Option<Value>,
    #[serde(default)]
    pub base_seq: Option<u64>,
    #[serde(default)]
    pub base_hash: Option<String>,
    #[serde(default)]
    pub on_head_mismatch: HeadMismatchPolicy,
}

#[derive(Deserialize)]
pub(crate) struct DraftDropInput {
    pub draft_id: String,
}

#[derive(Deserialize)]
pub(crate) struct ProfileUpdateInput {
    pub profile_service: String,
    pub profile: Value,
}

#[derive(Deserialize)]
pub(crate) struct RoomCreateInput {
    pub host: String,
    pub topic: String,
    pub visibility: Visibility,
    pub start_time: i64,
    pub end_time: i64,
    #[serde(default)]
    pub agenda: Option<String>,
    #[serde(default)]
    pub guidance: Option<String>,
    #[serde(default)]
    pub tags: Vec<String>,
    #[serde(default)]
    pub language: Option<String>,
    #[serde(default)]
    pub policy: Option<crate::discourse::RoomPolicy>,
    #[serde(default)]
    pub types: Vec<TypeDeclaration>,
}

#[derive(Deserialize)]
pub(crate) struct RoomJoinInput {
    #[serde(default)]
    pub host: Option<String>,
    pub room_id: String,
    pub role: Role,
    #[serde(default)]
    pub perspective: Option<String>,
    #[serde(default)]
    pub reason: Option<String>,
    #[serde(default)]
    pub request_id: Option<String>,
    #[serde(default)]
    pub extra: BTreeMap<String, Value>,
}

#[derive(Deserialize)]
pub(crate) struct RoomJoinRequestToolInput {
    pub host: String,
    pub room_id: String,
    pub role: Role,
    #[serde(default)]
    pub perspective: Option<String>,
    #[serde(default)]
    pub reason: Option<String>,
    #[serde(default)]
    pub extra: BTreeMap<String, Value>,
}

#[derive(Deserialize)]
pub(crate) struct RoomJoinWhenApprovedInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    pub request_id: String,
}

#[derive(Deserialize)]
pub(crate) struct RoomLeaveInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    #[serde(default)]
    pub reason: Option<String>,
}

#[derive(Clone, Deserialize, Debug)]
pub(crate) struct RoomSendMessageInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    pub content: String,
    #[serde(default)]
    pub content_type: Option<String>,
    #[serde(default)]
    pub mentions: Vec<AgentId>,
    #[serde(default)]
    pub references: Vec<String>,
    #[serde(default)]
    pub extra: BTreeMap<String, Value>,
    #[serde(default)]
    pub base_seq: Option<u64>,
    #[serde(default)]
    pub base_hash: Option<String>,
    #[serde(default)]
    pub on_head_mismatch: HeadMismatchPolicy,
}

#[derive(Clone, Deserialize, Debug)]
pub(crate) struct RoomSubmitEventInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    #[serde(rename = "type")]
    pub event_type: String,
    pub payload: Value,
    #[serde(default)]
    pub mentions: Vec<AgentId>,
    #[serde(default)]
    pub references: Vec<String>,
    #[serde(default)]
    pub base_seq: Option<u64>,
    #[serde(default)]
    pub base_hash: Option<String>,
    #[serde(default)]
    pub on_head_mismatch: HeadMismatchPolicy,
}

#[derive(Deserialize)]
pub(crate) struct JoinRequestsListInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    #[serde(default)]
    pub status: Option<String>,
    #[serde(default)]
    pub limit: Option<usize>,
    #[serde(default)]
    pub cursor: Option<String>,
}

#[derive(Deserialize)]
pub(crate) struct JoinRequestReviewInput {
    pub room_id: String,
    #[serde(default)]
    pub host: Option<String>,
    pub request_id: String,
    pub decision: JoinDecision,
    #[serde(default)]
    pub role: Option<Role>,
    #[serde(default)]
    pub reason: Option<String>,
}