systemprompt_sync/models/
local_sync.rs1use chrono::{DateTime, Utc};
2use serde::Serialize;
3use std::fmt;
4use systemprompt_identifiers::{AgentId, SkillId, SourceId};
5
6#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)]
7pub enum LocalSyncDirection {
8 #[default]
9 ToDisk,
10 ToDatabase,
11}
12
13impl fmt::Display for LocalSyncDirection {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 match self {
16 Self::ToDisk => write!(f, "to_disk"),
17 Self::ToDatabase => write!(f, "to_database"),
18 }
19 }
20}
21
22#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
23pub enum DiffStatus {
24 Added,
25 Removed,
26 Modified,
27}
28
29#[derive(Clone, Debug, Serialize)]
30pub struct ContentDiffItem {
31 pub slug: String,
32 pub source_id: SourceId,
33 pub status: DiffStatus,
34 pub disk_hash: Option<String>,
35 pub db_hash: Option<String>,
36 pub disk_updated_at: Option<DateTime<Utc>>,
37 pub db_updated_at: Option<DateTime<Utc>>,
38 pub title: Option<String>,
39}
40
41#[derive(Clone, Debug, Serialize)]
42pub struct SkillDiffItem {
43 pub skill_id: SkillId,
44 pub file_path: String,
45 pub status: DiffStatus,
46 pub disk_hash: Option<String>,
47 pub db_hash: Option<String>,
48 pub name: Option<String>,
49}
50
51#[derive(Clone, Debug, Serialize)]
52pub struct ContentDiffResult {
53 pub source_id: SourceId,
54 pub added: Vec<ContentDiffItem>,
55 pub removed: Vec<ContentDiffItem>,
56 pub modified: Vec<ContentDiffItem>,
57 pub unchanged: usize,
58}
59
60impl Default for ContentDiffResult {
61 fn default() -> Self {
62 Self {
63 source_id: SourceId::new(""),
64 added: Vec::new(),
65 removed: Vec::new(),
66 modified: Vec::new(),
67 unchanged: 0,
68 }
69 }
70}
71
72impl ContentDiffResult {
73 pub fn has_changes(&self) -> bool {
74 !self.added.is_empty() || !self.removed.is_empty() || !self.modified.is_empty()
75 }
76}
77
78#[derive(Clone, Debug, Default, Serialize)]
79pub struct SkillsDiffResult {
80 pub added: Vec<SkillDiffItem>,
81 pub removed: Vec<SkillDiffItem>,
82 pub modified: Vec<SkillDiffItem>,
83 pub unchanged: usize,
84}
85
86impl SkillsDiffResult {
87 pub fn has_changes(&self) -> bool {
88 !self.added.is_empty() || !self.removed.is_empty() || !self.modified.is_empty()
89 }
90}
91
92#[derive(Clone, Debug, Default, Serialize)]
93pub struct LocalSyncResult {
94 pub items_synced: usize,
95 pub items_skipped: usize,
96 pub items_skipped_modified: usize,
97 pub items_deleted: usize,
98 pub errors: Vec<String>,
99 pub direction: LocalSyncDirection,
100}
101
102#[derive(Debug)]
103pub struct DiskContent {
104 pub slug: String,
105 pub title: String,
106 pub body: String,
107}
108
109#[derive(Debug)]
110pub struct DiskSkill {
111 pub skill_id: SkillId,
112 pub name: String,
113 pub description: String,
114 pub instructions: String,
115 pub file_path: String,
116}
117
118#[derive(Clone, Debug, Serialize)]
119pub struct AgentDiffItem {
120 pub agent_id: AgentId,
121 pub name: String,
122 pub status: DiffStatus,
123 pub disk_hash: Option<String>,
124 pub db_hash: Option<String>,
125}
126
127#[derive(Clone, Debug, Default, Serialize)]
128pub struct AgentsDiffResult {
129 pub added: Vec<AgentDiffItem>,
130 pub removed: Vec<AgentDiffItem>,
131 pub modified: Vec<AgentDiffItem>,
132 pub unchanged: usize,
133}
134
135impl AgentsDiffResult {
136 pub fn has_changes(&self) -> bool {
137 !self.added.is_empty() || !self.removed.is_empty() || !self.modified.is_empty()
138 }
139}
140
141#[derive(Debug)]
142pub struct DiskAgent {
143 pub agent_id: AgentId,
144 pub name: String,
145 pub display_name: String,
146 pub description: String,
147 pub system_prompt: Option<String>,
148 pub port: u16,
149}