Skip to main content

llmrix_rust_sdk/resources/
agents.rs

1use std::sync::Arc;
2use crate::{error::Result, model::*, transport::*};
3
4/// Operations on the Agents API (cloud mode only).
5/// All methods return HTTP 503 when the server runs in native/standalone mode.
6/// Obtain via [`LlmrixClient::agents`].
7pub struct AgentsResource {
8    pub(crate) t: Arc<Transport>,
9}
10
11impl AgentsResource {
12    /// Return all agents.
13    pub async fn list(&self) -> Result<Vec<Agent>> {
14        self.t.get_unwrap(&path_agents(), "agents").await
15    }
16
17    /// Create a new agent.
18    pub async fn create(&self, req: AgentCreateRequest) -> Result<Agent> {
19        self.t.post_unwrap(&path_agents(), &req, "agent").await
20    }
21
22    /// Retrieve a single agent by numeric ID.
23    pub async fn get(&self, agent_id: i64) -> Result<Agent> {
24        self.t.get_unwrap(&path_agent(agent_id), "agent").await
25    }
26
27    /// Update an agent's properties. Only non-`None` fields are sent.
28    pub async fn update(&self, agent_id: i64, req: AgentUpdateRequest) -> Result<Agent> {
29        self.t.patch_unwrap(&path_agent(agent_id), &req, "agent").await
30    }
31
32    /// Permanently delete an agent.
33    pub async fn delete(&self, agent_id: i64) -> Result<()> {
34        self.t.delete(&path_agent(agent_id)).await
35    }
36
37    /// Return all mates assigned to a team agent.
38    pub async fn list_mates(&self, agent_id: i64) -> Result<Vec<Mate>> {
39        self.t.get_unwrap(&path_agent_mates(agent_id), "mates").await
40    }
41
42    /// Atomically replace all mates of a team agent.
43    pub async fn save_mates(&self, agent_id: i64, mates: Vec<Mate>) -> Result<Vec<Mate>> {
44        self.t
45            .post_unwrap(&path_agent_mates(agent_id), &SaveMatesRequest { mates }, "mates")
46            .await
47    }
48}