whycodes_storage/
models.rs1use serde::{Deserialize, Serialize};
2use whycodes_core::types::Usage;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct SessionRow {
7 pub id: String,
8 pub title: String,
9 pub created_at: String,
10 pub updated_at: String,
11 pub project_path: String,
12 #[serde(default)]
14 pub usage: Usage,
15}
16
17#[derive(Debug, Clone)]
19pub struct SessionTextHit {
20 pub session: SessionRow,
21 pub hits: usize,
23 pub sample: String,
25}
26
27#[derive(Debug, Clone, Default, Serialize, Deserialize)]
29pub struct UsageTotals {
30 pub session_count: usize,
31 pub message_count: usize,
32 pub usage: Usage,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct MessageRow {
38 pub id: String,
39 pub session_id: String,
40 pub role: String,
41 pub content: String,
42 pub tool_call_id: Option<String>,
43 pub name: Option<String>,
44 pub created_at: String,
45}
46
47#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
50pub struct BranchRow {
51 pub name: Option<String>,
52 pub messages: Vec<String>,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct StateRow {
58 pub key: String,
59 pub value: String,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct MemoryRow {
65 pub id: String,
66 pub project_key: String,
68 pub text: String,
69 pub embedding: Vec<u8>,
71 pub source_session: Option<String>,
72 pub created_at: String,
73 pub last_recalled_at: Option<String>,
74 pub recall_count: i64,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79pub struct CodeChunkRow {
80 pub id: String,
81 pub project_key: String,
82 pub path: String,
83 pub start_line: i64,
84 pub end_line: i64,
85 pub text: String,
86 pub embedding: Vec<u8>,
87 pub updated_at: String,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92pub struct SessionChunkRow {
93 pub id: String,
94 pub project_key: String,
95 pub session_id: String,
96 pub turn_index: i64,
97 pub text: String,
98 pub embedding: Vec<u8>,
99 pub created_at: String,
100}