Skip to main content

remem/memory/service/
types.rs

1#[derive(Debug, Clone, Default)]
2pub struct SearchRequest {
3    pub query: Option<String>,
4    pub project: Option<String>,
5    pub memory_type: Option<String>,
6    pub limit: i64,
7    pub offset: i64,
8    pub include_stale: bool,
9    pub include_suppressed: bool,
10    pub branch: Option<String>,
11    pub multi_hop: bool,
12    pub explain: bool,
13}
14
15/// Canonical default for `include_stale` across every adapter (MCP, REST, CLI).
16///
17/// Default search returns only current curated memories. Callers that need
18/// stale or archived history must opt in explicitly.
19pub fn default_include_stale() -> bool {
20    false
21}
22
23/// Canonical default for `include_suppressed` across every adapter.
24pub fn default_include_suppressed() -> bool {
25    false
26}
27
28#[derive(Debug, Clone)]
29pub struct MultiHopMeta {
30    pub hops: u8,
31    pub entities_discovered: Vec<String>,
32}
33
34#[derive(Debug, Clone)]
35pub struct SearchResultSet {
36    pub memories: Vec<crate::memory::Memory>,
37    pub multi_hop: Option<MultiHopMeta>,
38    pub has_more: bool,
39    pub explain: Option<crate::retrieval::search::SearchExplain>,
40    /// Raw archive hits attached as fallback when curated memories are sparse.
41    pub raw_hits: Vec<crate::memory::raw_archive::RawMessage>,
42    /// Error from the raw archive fallback path. Curated results remain usable.
43    pub raw_error: Option<String>,
44}
45
46#[derive(Debug, Clone, Default)]
47pub struct SaveMemoryRequest {
48    pub text: String,
49    pub title: Option<String>,
50    pub project: Option<String>,
51    pub session_id: Option<String>,
52    pub host: Option<String>,
53    pub topic_key: Option<String>,
54    pub memory_type: Option<String>,
55    pub files: Option<Vec<String>>,
56    pub scope: Option<String>,
57    pub created_at_epoch: Option<i64>,
58    pub branch: Option<String>,
59    pub local_path: Option<String>,
60    pub local_copy_enabled: Option<bool>,
61    pub claim_enabled: Option<bool>,
62    pub claim_source: Option<String>,
63    pub acknowledge_pattern: Option<String>,
64}
65
66#[derive(Debug, Clone)]
67pub struct LocalCopyResult {
68    pub status: String,
69    pub path: Option<String>,
70    pub reason: Option<String>,
71}
72
73#[derive(Debug, Clone)]
74pub struct SaveMemoryNextStep {
75    pub tool: String,
76    pub ids: Vec<i64>,
77    pub source: String,
78    pub reason: String,
79}
80
81#[derive(Debug, Clone)]
82pub struct SaveMemoryResult {
83    pub id: i64,
84    pub status: String,
85    pub memory_type: String,
86    pub project: String,
87    pub scope: String,
88    pub topic_key: Option<String>,
89    pub branch: Option<String>,
90    pub operation: String,
91    pub created_at_epoch: i64,
92    pub reference_time_epoch: i64,
93    pub updated_at_epoch: i64,
94    /// Compatibility alias: true when the request supplied `topic_key`.
95    /// It does not mean the durable row was updated; use `operation` for that.
96    pub upserted: bool,
97    pub local_copy: LocalCopyResult,
98    pub local_status: String,
99    pub local_path: Option<String>,
100    pub claim_status: String,
101    pub claim_id: Option<i64>,
102    pub claim_error: Option<String>,
103    pub next_step: SaveMemoryNextStep,
104}