1use chrono::{DateTime, Utc};
2use serde::Serialize;
3use std::path::PathBuf;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
6#[serde(rename_all = "lowercase")]
7pub enum Role {
8 User,
9 Assistant,
10 Tool,
11}
12
13impl Role {
14 pub fn label(&self) -> &'static str {
15 match self {
16 Role::User => "user",
17 Role::Assistant => "assistant",
18 Role::Tool => "tool",
19 }
20 }
21}
22
23#[derive(Debug, Serialize)]
24pub struct Message {
25 pub role: Role,
26 pub text: String,
27 pub ts: Option<DateTime<Utc>>,
28}
29
30#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
33#[serde(rename_all = "lowercase")]
34pub enum EditKind {
35 Edit,
36 Write,
37 MultiEdit,
38 NotebookEdit,
39}
40
41impl EditKind {
42 pub fn as_str(&self) -> &'static str {
44 match self {
45 EditKind::Edit => "edit",
46 EditKind::Write => "write",
47 EditKind::MultiEdit => "multiedit",
48 EditKind::NotebookEdit => "notebookedit",
49 }
50 }
51}
52
53#[derive(Debug, Serialize)]
58pub struct EditEvent {
59 pub path: String,
60 pub kind: EditKind,
61 pub snippet: String,
62 pub ts: Option<DateTime<Utc>>,
63}
64
65#[derive(Debug, Serialize)]
66pub struct Session {
67 pub id: String,
69 pub tool: &'static str,
70 pub path: PathBuf,
71 pub project: String,
72 pub started: Option<DateTime<Utc>>,
73 pub ended: Option<DateTime<Utc>>,
74 pub title: String,
75 pub subagent: bool,
77 pub messages: Vec<Message>,
78 pub touched: Vec<String>,
82 pub edits: Vec<EditEvent>,
86}
87
88pub struct StoreReport {
90 pub tool: &'static str,
91 pub root: PathBuf,
92 pub files: usize,
93 pub bytes: u64,
94 pub oldest: Option<DateTime<Utc>>,
95 pub newest: Option<DateTime<Utc>>,
96}