1use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
9#[serde(rename_all = "snake_case")]
10pub enum EventKind {
11 Prompt,
12 System,
13 Command,
14 Warn,
15 Alert,
16 ModeChange,
17}
18
19impl EventKind {
20 #[must_use]
21 pub const fn as_str(self) -> &'static str {
22 match self {
23 Self::Prompt => "prompt",
24 Self::System => "system",
25 Self::Command => "command",
26 Self::Warn => "warn",
27 Self::Alert => "alert",
28 Self::ModeChange => "mode_change",
29 }
30 }
31
32 #[must_use]
40 pub fn parse_str(s: &str) -> Option<Self> {
41 Some(match s {
42 "prompt" => Self::Prompt,
43 "system" => Self::System,
44 "command" => Self::Command,
45 "warn" => Self::Warn,
46 "alert" => Self::Alert,
47 "mode_change" => Self::ModeChange,
48 _ => return None,
49 })
50 }
51}
52
53#[derive(Debug, Clone, PartialEq, Eq)]
57pub struct StoredEvent {
58 pub id: i64,
59 pub session_id: i64,
60 pub seq: i64,
61 pub at: DateTime<Utc>,
62 pub kind: EventKind,
63 pub text: String,
64}
65
66#[derive(Debug, Clone, PartialEq, Eq)]
68pub struct SessionRow {
69 pub id: i64,
70 pub ulid: String,
71 pub started_at: DateTime<Utc>,
72 pub ended_at: Option<DateTime<Utc>>,
73 pub engine_base_url: Option<String>,
74 pub cli_version: String,
75 pub parent_ulid: Option<String>,
76}