Skip to main content

uarp_sdk/generated/api/
memory.rs

1// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
2//!
3//! Agent memory management
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::util::encode_path;
15
16/// Query and header parameters for `listMemories`.
17#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
18pub struct ListMemoriesParams {
19    #[serde(default, skip_serializing_if = "Option::is_none")]
20    pub limit: Option<i64>,
21}
22
23/// Agent memory management
24#[derive(Debug, Clone)]
25pub struct MemoryApi {
26    pub(crate) client: Client,
27}
28
29impl Client {
30    /// Agent memory management
31    pub fn memory(&self) -> MemoryApi {
32        MemoryApi { client: self.clone() }
33    }
34}
35
36impl MemoryApi {
37    /// Delete memory entry
38    ///
39    /// `DELETE /api/v1/agents/{agentId}/memory/{entryId}`
40    ///
41    /// Required scopes: `memory:write`.
42    pub async fn delete_memory_entry(&self, agent_id: &str, entry_id: &str) -> Result<models::DeleteMemoryEntryResponse> {
43        self.client
44            .request_json(Request {
45                method: Method::DELETE,
46                path: format!("/api/v1/agents/{}/memory/{}", encode_path(agent_id), encode_path(entry_id)),
47                query: NO_QUERY,
48                body: NO_BODY,
49                headers: Vec::new(),
50                idempotent: true,
51            })
52            .await
53    }
54
55    /// Get a core memory block
56    ///
57    /// `GET /api/v1/agents/{agentId}/memory/core/{label}`
58    ///
59    /// Required scopes: `memory:read`.
60    pub async fn get_core_memory_block(&self, agent_id: &str, label: &str) -> Result<models::CoreMemoryBlock> {
61        self.client
62            .request_json(Request {
63                method: Method::GET,
64                path: format!("/api/v1/agents/{}/memory/core/{}", encode_path(agent_id), encode_path(label)),
65                query: NO_QUERY,
66                body: NO_BODY,
67                headers: Vec::new(),
68                idempotent: false,
69            })
70            .await
71    }
72
73    /// Get memory entries associated with an entity
74    ///
75    /// `GET /api/v1/agents/{agentId}/memory/entities/{entityId}`
76    ///
77    /// Required scopes: `memory:read`.
78    pub async fn get_memories_by_entity(&self, agent_id: &str, entity_id: &str) -> Result<models::GetMemoriesByEntityResponse> {
79        self.client
80            .request_json(Request {
81                method: Method::GET,
82                path: format!("/api/v1/agents/{}/memory/entities/{}", encode_path(agent_id), encode_path(entity_id)),
83                query: NO_QUERY,
84                body: NO_BODY,
85                headers: Vec::new(),
86                idempotent: false,
87            })
88            .await
89    }
90
91    /// Get memory entry
92    ///
93    /// `GET /api/v1/agents/{agentId}/memory/{entryId}`
94    ///
95    /// Required scopes: `memory:read`.
96    pub async fn get_memory_entry(&self, agent_id: &str, entry_id: &str) -> Result<serde_json::Value> {
97        self.client
98            .request_json(Request {
99                method: Method::GET,
100                path: format!("/api/v1/agents/{}/memory/{}", encode_path(agent_id), encode_path(entry_id)),
101                query: NO_QUERY,
102                body: NO_BODY,
103                headers: Vec::new(),
104                idempotent: false,
105            })
106            .await
107    }
108
109    /// Put back what an export took out
110    ///
111    /// Accepts the `memory.json` an account export writes: a flat `entries` array, or
112    /// `agents\[\].entries` (every agent's entries are imported into THIS agent). Each entry is
113    /// tagged `imported`. Dedup is the store's: re-importing the same file returns the existing
114    /// entries as `duplicates` instead of doubling them. A file with no entries is 400.
115    ///
116    /// `POST /api/v1/agents/{agentId}/memory/import`
117    ///
118    /// Required scopes: `memory:write`.
119    pub async fn import_agent_memory(&self, agent_id: &str, body: &models::ImportAgentMemoryRequest) -> Result<models::ImportAgentMemoryResponse> {
120        self.client
121            .request_json(Request {
122                method: Method::POST,
123                path: format!("/api/v1/agents/{}/memory/import", encode_path(agent_id)),
124                query: NO_QUERY,
125                body: Some(body),
126                headers: Vec::new(),
127                idempotent: true,
128            })
129            .await
130    }
131
132    /// Ingest a file into agent memory
133    ///
134    /// Chunks the file content (default 600 chars), embeds each chunk, and stores embeddings as
135    /// memory entries. Source: pre-uploaded `file_id` (preferred) or inline `content`. Max 2 MB of
136    /// text per ingest call; rate-limited and quota-counted.
137    ///
138    /// `POST /api/v1/agents/{agentId}/memory/ingest`
139    ///
140    /// Required scopes: `memory:write`.
141    pub async fn ingest_memory(&self, agent_id: &str, body: &models::IngestMemoryRequest) -> Result<models::IngestMemoryResponse> {
142        self.client
143            .request_json(Request {
144                method: Method::POST,
145                path: format!("/api/v1/agents/{}/memory/ingest", encode_path(agent_id)),
146                query: NO_QUERY,
147                body: Some(body),
148                headers: Vec::new(),
149                idempotent: true,
150            })
151            .await
152    }
153
154    /// List recent memories for an agent
155    ///
156    /// `GET /api/v1/agents/{agentId}/memory`
157    ///
158    /// Required scopes: `memory:read`.
159    pub async fn list_memories(&self, agent_id: &str, params: &ListMemoriesParams) -> Result<models::ListMemoriesResponse> {
160        self.client
161            .request_json(Request {
162                method: Method::GET,
163                path: format!("/api/v1/agents/{}/memory", encode_path(agent_id)),
164                query: Some(params),
165                body: NO_BODY,
166                headers: Vec::new(),
167                idempotent: false,
168            })
169            .await
170    }
171
172    /// Search agent memories
173    ///
174    /// `POST /api/v1/agents/{agentId}/memory/search`
175    ///
176    /// Required scopes: `memory:write`.
177    pub async fn search(&self, agent_id: &str, body: &serde_json::Value) -> Result<models::SearchMemoryResponse> {
178        self.client
179            .request_json(Request {
180                method: Method::POST,
181                path: format!("/api/v1/agents/{}/memory/search", encode_path(agent_id)),
182                query: NO_QUERY,
183                body: Some(body),
184                headers: Vec::new(),
185                idempotent: true,
186            })
187            .await
188    }
189
190    /// Update memory entry
191    ///
192    /// `PUT /api/v1/agents/{agentId}/memory/{entryId}`
193    ///
194    /// Required scopes: `memory:write`.
195    pub async fn update_agent_memory_entry(&self, agent_id: &str, entry_id: &str, body: &serde_json::Map<String, serde_json::Value>) -> Result<models::MemoryEntry> {
196        self.client
197            .request_json(Request {
198                method: Method::PUT,
199                path: format!("/api/v1/agents/{}/memory/{}", encode_path(agent_id), encode_path(entry_id)),
200                query: NO_QUERY,
201                body: Some(body),
202                headers: Vec::new(),
203                idempotent: true,
204            })
205            .await
206    }
207
208    /// Update a core memory block
209    ///
210    /// `PUT /api/v1/agents/{agentId}/memory/core/{label}`
211    ///
212    /// Required scopes: `memory:write`.
213    pub async fn update_core_memory_block(&self, agent_id: &str, label: &str, body: &models::UpdateCoreMemoryBlockRequest) -> Result<models::CoreMemoryBlock> {
214        self.client
215            .request_json(Request {
216                method: Method::PUT,
217                path: format!("/api/v1/agents/{}/memory/core/{}", encode_path(agent_id), encode_path(label)),
218                query: NO_QUERY,
219                body: Some(body),
220                headers: Vec::new(),
221                idempotent: true,
222            })
223            .await
224    }
225}