Skip to main content

uarp_sdk/generated/api/
squads.rs

1// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
2//!
3//! Squads — multi-agent groups that run a shared brief
4
5#![allow(unused_imports, clippy::too_many_arguments)]
6
7use reqwest::Method;
8use serde::{Deserialize, Serialize};
9
10use crate::client::{Client, Request, NO_BODY, NO_QUERY};
11use crate::error::Result;
12use crate::generated::models;
13use crate::multipart::{field_text, FilePart};
14use crate::sse::EventStream;
15use crate::util::encode_path;
16
17/// Query and header parameters for `getSquadChatHistory`.
18#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
19pub struct GetSquadChatHistoryParams {
20    #[serde(default, skip_serializing_if = "Option::is_none")]
21    pub thread_id: Option<String>,
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub include_internal: Option<bool>,
24}
25
26/// Query and header parameters for `streamSquadChatEvents`.
27#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
28pub struct StreamSquadChatEventsParams {
29    #[serde(default, skip_serializing_if = "Option::is_none")]
30    pub thread_id: Option<String>,
31}
32
33/// Squads — multi-agent groups that run a shared brief
34#[derive(Debug, Clone)]
35pub struct SquadsApi {
36    pub(crate) client: Client,
37}
38
39impl Client {
40    /// Squads — multi-agent groups that run a shared brief
41    pub fn squads(&self) -> SquadsApi {
42        SquadsApi { client: self.clone() }
43    }
44}
45
46impl SquadsApi {
47    /// Add graph edge
48    ///
49    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
50    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
51    /// endpoint and cannot drift apart.
52    ///
53    /// `POST /api/v1/squads/{squadId}/graph/edges`
54    pub async fn add_squad_graph_edge(&self, squad_id: &str, body: &models::AddSquadGraphEdgeRequest) -> Result<serde_json::Map<String, serde_json::Value>> {
55        self.client
56            .request_json(Request {
57                method: Method::POST,
58                path: format!("/api/v1/squads/{}/graph/edges", encode_path(squad_id)),
59                query: NO_QUERY,
60                body: Some(body),
61                headers: Vec::new(),
62                idempotent: true,
63            })
64            .await
65    }
66
67    /// Add graph node
68    ///
69    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
70    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
71    /// endpoint and cannot drift apart.
72    ///
73    /// `POST /api/v1/squads/{squadId}/graph/nodes`
74    pub async fn add_squad_graph_node(&self, squad_id: &str, body: &models::AddSquadGraphNodeRequest) -> Result<serde_json::Map<String, serde_json::Value>> {
75        self.client
76            .request_json(Request {
77                method: Method::POST,
78                path: format!("/api/v1/squads/{}/graph/nodes", encode_path(squad_id)),
79                query: NO_QUERY,
80                body: Some(body),
81                headers: Vec::new(),
82                idempotent: true,
83            })
84            .await
85    }
86
87    /// Cancel a squad run
88    ///
89    /// Stops the orchestration loop first, then every non-terminal child run, and releases the chat
90    /// state so the canvas does not stay locked on a run that was just killed.
91    ///
92    /// Order matters and is not an implementation detail: killing children while the loop is still
93    /// running makes it spawn more — two fresh child runs were measured within two minutes of a
94    /// “successful” cancel.
95    ///
96    /// `cancelledCount` is camelCase on the wire, unlike every neighbouring field. That is what the
97    /// server sends.
98    ///
99    /// `/api/v1/squads/*` is the canonical surface; `/api/v1/teams/*` is the same handler under the
100    /// older noun.
101    ///
102    /// `POST /api/v1/squads/{squadId}/runs/{teamRunId}/cancel`
103    pub async fn cancel_squad_run(&self, squad_id: &str, team_run_id: &str) -> Result<models::CancelSquadRunResponse> {
104        self.client
105            .request_json(Request {
106                method: Method::POST,
107                path: format!("/api/v1/squads/{}/runs/{}/cancel", encode_path(squad_id), encode_path(team_run_id)),
108                query: NO_QUERY,
109                body: NO_BODY,
110                headers: Vec::new(),
111                idempotent: true,
112            })
113            .await
114    }
115
116    /// Create a squad
117    ///
118    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
119    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
120    /// endpoint and cannot drift apart.
121    ///
122    /// `POST /api/v1/squads`
123    pub async fn create(&self, body: &models::TeamCreate) -> Result<models::Team> {
124        self.client
125            .request_json(Request {
126                method: Method::POST,
127                path: "/api/v1/squads".to_string(),
128                query: NO_QUERY,
129                body: Some(body),
130                headers: Vec::new(),
131                idempotent: true,
132            })
133            .await
134    }
135
136    /// Delete squad
137    ///
138    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
139    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
140    /// endpoint and cannot drift apart.
141    ///
142    /// `DELETE /api/v1/squads/{squadId}`
143    pub async fn delete(&self, squad_id: &str) -> Result<models::DeleteSquadResponse> {
144        self.client
145            .request_json(Request {
146                method: Method::DELETE,
147                path: format!("/api/v1/squads/{}", encode_path(squad_id)),
148                query: NO_QUERY,
149                body: NO_BODY,
150                headers: Vec::new(),
151                idempotent: true,
152            })
153            .await
154    }
155
156    /// Remove edge
157    ///
158    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
159    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
160    /// endpoint and cannot drift apart.
161    ///
162    /// `DELETE /api/v1/squads/{squadId}/graph/edges/{edgeId}`
163    pub async fn delete_squad_graph_edge(&self, squad_id: &str, edge_id: &str) -> Result<models::DeleteSquadGraphEdgeResponse> {
164        self.client
165            .request_json(Request {
166                method: Method::DELETE,
167                path: format!("/api/v1/squads/{}/graph/edges/{}", encode_path(squad_id), encode_path(edge_id)),
168                query: NO_QUERY,
169                body: NO_BODY,
170                headers: Vec::new(),
171                idempotent: true,
172            })
173            .await
174    }
175
176    /// Remove node
177    ///
178    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
179    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
180    /// endpoint and cannot drift apart.
181    ///
182    /// `DELETE /api/v1/squads/{squadId}/graph/nodes/{agentId}`
183    pub async fn delete_squad_graph_node(&self, squad_id: &str, agent_id: &str) -> Result<models::DeleteSquadGraphNodeResponse> {
184        self.client
185            .request_json(Request {
186                method: Method::DELETE,
187                path: format!("/api/v1/squads/{}/graph/nodes/{}", encode_path(squad_id), encode_path(agent_id)),
188                query: NO_QUERY,
189                body: NO_BODY,
190                headers: Vec::new(),
191                idempotent: true,
192            })
193            .await
194    }
195
196    /// Get squad
197    ///
198    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
199    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
200    /// endpoint and cannot drift apart.
201    ///
202    /// `GET /api/v1/squads/{squadId}`
203    pub async fn get(&self, squad_id: &str) -> Result<models::Team> {
204        self.client
205            .request_json(Request {
206                method: Method::GET,
207                path: format!("/api/v1/squads/{}", encode_path(squad_id)),
208                query: NO_QUERY,
209                body: NO_BODY,
210                headers: Vec::new(),
211                idempotent: false,
212            })
213            .await
214    }
215
216    /// Get squad chat history
217    ///
218    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
219    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
220    /// endpoint and cannot drift apart.
221    ///
222    /// `GET /api/v1/squads/{squadId}/chat`
223    pub async fn get_squad_chat_history(&self, squad_id: &str, params: &GetSquadChatHistoryParams) -> Result<models::GetSquadChatHistoryResponse> {
224        self.client
225            .request_json(Request {
226                method: Method::GET,
227                path: format!("/api/v1/squads/{}/chat", encode_path(squad_id)),
228                query: Some(params),
229                body: NO_BODY,
230                headers: Vec::new(),
231                idempotent: false,
232            })
233            .await
234    }
235
236    /// Get full squad graph
237    ///
238    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
239    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
240    /// endpoint and cannot drift apart.
241    ///
242    /// `GET /api/v1/squads/{squadId}/graph`
243    pub async fn get_squad_graph(&self, squad_id: &str) -> Result<models::GetSquadGraphResponse> {
244        self.client
245            .request_json(Request {
246                method: Method::GET,
247                path: format!("/api/v1/squads/{}/graph", encode_path(squad_id)),
248                query: NO_QUERY,
249                body: NO_BODY,
250                headers: Vec::new(),
251                idempotent: false,
252            })
253            .await
254    }
255
256    /// Get graph node
257    ///
258    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
259    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
260    /// endpoint and cannot drift apart.
261    ///
262    /// `GET /api/v1/squads/{squadId}/graph/nodes/{agentId}`
263    pub async fn get_squad_graph_node(&self, squad_id: &str, agent_id: &str) -> Result<models::TeamGraphNode> {
264        self.client
265            .request_json(Request {
266                method: Method::GET,
267                path: format!("/api/v1/squads/{}/graph/nodes/{}", encode_path(squad_id), encode_path(agent_id)),
268                query: NO_QUERY,
269                body: NO_BODY,
270                headers: Vec::new(),
271                idempotent: false,
272            })
273            .await
274    }
275
276    /// Get specific squad run
277    ///
278    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
279    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
280    /// endpoint and cannot drift apart.
281    ///
282    /// `GET /api/v1/squads/{squadId}/runs/{teamRunId}`
283    pub async fn get_squad_run(&self, squad_id: &str, team_run_id: &str) -> Result<models::TeamRunDetail> {
284        self.client
285            .request_json(Request {
286                method: Method::GET,
287                path: format!("/api/v1/squads/{}/runs/{}", encode_path(squad_id), encode_path(team_run_id)),
288                query: NO_QUERY,
289                body: NO_BODY,
290                headers: Vec::new(),
291                idempotent: false,
292            })
293            .await
294    }
295
296    /// Get squad run messages
297    ///
298    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
299    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
300    /// endpoint and cannot drift apart.
301    ///
302    /// `GET /api/v1/squads/{squadId}/runs/{teamRunId}/messages`
303    pub async fn get_squad_run_messages(&self, squad_id: &str, team_run_id: &str) -> Result<models::GetSquadRunMessagesResponse> {
304        self.client
305            .request_json(Request {
306                method: Method::GET,
307                path: format!("/api/v1/squads/{}/runs/{}/messages", encode_path(squad_id), encode_path(team_run_id)),
308                query: NO_QUERY,
309                body: NO_BODY,
310                headers: Vec::new(),
311                idempotent: false,
312            })
313            .await
314    }
315
316    /// List squads
317    ///
318    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
319    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
320    /// endpoint and cannot drift apart.
321    ///
322    /// `GET /api/v1/squads`
323    pub async fn list(&self) -> Result<models::ListSquadsResponse> {
324        self.client
325            .request_json(Request {
326                method: Method::GET,
327                path: "/api/v1/squads".to_string(),
328                query: NO_QUERY,
329                body: NO_BODY,
330                headers: Vec::new(),
331                idempotent: false,
332            })
333            .await
334    }
335
336    /// List graph edges
337    ///
338    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
339    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
340    /// endpoint and cannot drift apart.
341    ///
342    /// `GET /api/v1/squads/{squadId}/graph/edges`
343    pub async fn list_squad_graph_edges(&self, squad_id: &str) -> Result<models::ListSquadGraphEdgesResponse> {
344        self.client
345            .request_json(Request {
346                method: Method::GET,
347                path: format!("/api/v1/squads/{}/graph/edges", encode_path(squad_id)),
348                query: NO_QUERY,
349                body: NO_BODY,
350                headers: Vec::new(),
351                idempotent: false,
352            })
353            .await
354    }
355
356    /// List graph nodes
357    ///
358    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
359    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
360    /// endpoint and cannot drift apart.
361    ///
362    /// `GET /api/v1/squads/{squadId}/graph/nodes`
363    pub async fn list_squad_graph_nodes(&self, squad_id: &str) -> Result<models::ListSquadGraphNodesResponse> {
364        self.client
365            .request_json(Request {
366                method: Method::GET,
367                path: format!("/api/v1/squads/{}/graph/nodes", encode_path(squad_id)),
368                query: NO_QUERY,
369                body: NO_BODY,
370                headers: Vec::new(),
371                idempotent: false,
372            })
373            .await
374    }
375
376    /// List runs for a squad
377    ///
378    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
379    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
380    /// endpoint and cannot drift apart.
381    ///
382    /// `GET /api/v1/squads/{squadId}/runs`
383    pub async fn list_squad_runs(&self, squad_id: &str) -> Result<models::ListSquadRunsResponse> {
384        self.client
385            .request_json(Request {
386                method: Method::GET,
387                path: format!("/api/v1/squads/{}/runs", encode_path(squad_id)),
388                query: NO_QUERY,
389                body: NO_BODY,
390                headers: Vec::new(),
391                idempotent: false,
392            })
393            .await
394    }
395
396    /// Start a squad run
397    ///
398    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
399    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
400    /// endpoint and cannot drift apart.
401    ///
402    /// `POST /api/v1/squads/{squadId}/runs`
403    pub async fn start_squad_run(&self, squad_id: &str, body: &models::StartSquadRunRequest) -> Result<models::StartSquadRunResponse> {
404        self.client
405            .request_json(Request {
406                method: Method::POST,
407                path: format!("/api/v1/squads/{}/runs", encode_path(squad_id)),
408                query: NO_QUERY,
409                body: Some(body),
410                headers: Vec::new(),
411                idempotent: true,
412            })
413            .await
414    }
415
416    /// SSE stream for squad chat
417    ///
418    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
419    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
420    /// endpoint and cannot drift apart.
421    ///
422    /// `GET /api/v1/squads/{squadId}/chat/events`
423    ///
424    /// Required scopes: `events:read`.
425    ///
426    /// Returns a server-sent event stream.
427    pub fn stream_squad_chat_events(&self, squad_id: &str, params: &StreamSquadChatEventsParams) -> EventStream {
428        self.client.request_stream(
429            &format!("/api/v1/squads/{}/chat/events", encode_path(squad_id)),
430            Some(params),
431            Vec::new(),
432        )
433    }
434
435    /// Stream squad run events (SSE)
436    ///
437    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
438    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
439    /// endpoint and cannot drift apart.
440    ///
441    /// `GET /api/v1/squads/{squadId}/runs/{runId}/events`
442    ///
443    /// Required scopes: `events:read`.
444    ///
445    /// Returns a server-sent event stream.
446    pub fn stream_squad_run_events(&self, squad_id: &str, run_id: &str) -> EventStream {
447        self.client.request_stream(
448            &format!("/api/v1/squads/{}/runs/{}/events", encode_path(squad_id), encode_path(run_id)),
449            NO_QUERY,
450            Vec::new(),
451        )
452    }
453
454    /// Update squad
455    ///
456    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
457    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
458    /// endpoint and cannot drift apart.
459    ///
460    /// `PUT /api/v1/squads/{squadId}`
461    pub async fn update(&self, squad_id: &str, body: &models::TeamUpdate) -> Result<models::Team> {
462        self.client
463            .request_json(Request {
464                method: Method::PUT,
465                path: format!("/api/v1/squads/{}", encode_path(squad_id)),
466                query: NO_QUERY,
467                body: Some(body),
468                headers: Vec::new(),
469                idempotent: true,
470            })
471            .await
472    }
473
474    /// Update graph node
475    ///
476    /// `/api/v1/squads/*` is the canonical surface. `/api/v1/teams/*` is the same handler under the
477    /// older noun: the server rewrites the leading path segment before dispatch, so the two are one
478    /// endpoint and cannot drift apart.
479    ///
480    /// `PATCH /api/v1/squads/{squadId}/graph/nodes/{agentId}`
481    pub async fn update_squad_graph_node(&self, squad_id: &str, agent_id: &str, body: &models::UpdateSquadGraphNodeRequest) -> Result<serde_json::Map<String, serde_json::Value>> {
482        self.client
483            .request_json(Request {
484                method: Method::PATCH,
485                path: format!("/api/v1/squads/{}/graph/nodes/{}", encode_path(squad_id), encode_path(agent_id)),
486                query: NO_QUERY,
487                body: Some(body),
488                headers: Vec::new(),
489                idempotent: true,
490            })
491            .await
492    }
493}