Skip to main content

systemprompt_cli/commands/plugins/
types.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
5pub struct CliExtensionInfo {
6    pub name: String,
7    pub binary: String,
8    pub description: String,
9    pub commands: Vec<CliCommandInfo>,
10    pub enabled: bool,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
14pub struct CliCommandInfo {
15    pub name: String,
16    pub description: String,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
20pub struct CliExtListOutput {
21    pub extensions: Vec<CliExtensionInfo>,
22    pub total: usize,
23}
24
25#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
26#[serde(rename_all = "snake_case")]
27pub enum ExtensionSource {
28    Compiled,
29    Manifest,
30}
31
32#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, JsonSchema)]
33pub struct CapabilitySummary {
34    pub jobs: usize,
35    pub templates: usize,
36    pub schemas: usize,
37    pub routes: usize,
38    pub tools: usize,
39    pub roles: usize,
40    pub llm_providers: usize,
41    pub storage_paths: usize,
42}
43
44impl CapabilitySummary {
45    pub fn summary_string(&self) -> String {
46        let mut parts = Vec::new();
47
48        if self.jobs > 0 {
49            parts.push(format!(
50                "{} {}",
51                self.jobs,
52                if self.jobs == 1 { "job" } else { "jobs" }
53            ));
54        }
55        if self.templates > 0 {
56            parts.push(format!(
57                "{} {}",
58                self.templates,
59                if self.templates == 1 {
60                    "template"
61                } else {
62                    "templates"
63                }
64            ));
65        }
66        if self.schemas > 0 {
67            parts.push(format!(
68                "{} {}",
69                self.schemas,
70                if self.schemas == 1 {
71                    "schema"
72                } else {
73                    "schemas"
74                }
75            ));
76        }
77        if self.routes > 0 {
78            parts.push(format!(
79                "{} {}",
80                self.routes,
81                if self.routes == 1 { "route" } else { "routes" }
82            ));
83        }
84        if self.tools > 0 {
85            parts.push(format!(
86                "{} {}",
87                self.tools,
88                if self.tools == 1 { "tool" } else { "tools" }
89            ));
90        }
91        if self.roles > 0 {
92            parts.push(format!(
93                "{} {}",
94                self.roles,
95                if self.roles == 1 { "role" } else { "roles" }
96            ));
97        }
98        if self.llm_providers > 0 {
99            parts.push(format!(
100                "{} {}",
101                self.llm_providers,
102                if self.llm_providers == 1 {
103                    "LLM"
104                } else {
105                    "LLMs"
106                }
107            ));
108        }
109
110        if parts.is_empty() {
111            "none".to_string()
112        } else {
113            parts.join(", ")
114        }
115    }
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
119pub struct ExtensionSummary {
120    pub id: String,
121    pub name: String,
122    pub version: String,
123    pub priority: u32,
124    pub source: ExtensionSource,
125    pub enabled: bool,
126    pub capabilities: CapabilitySummary,
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
130pub struct ExtensionListOutput {
131    pub extensions: Vec<ExtensionSummary>,
132    pub total: usize,
133}
134
135#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
136pub struct JobInfo {
137    pub name: String,
138    pub schedule: String,
139    pub enabled: bool,
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
143pub struct TemplateInfo {
144    pub name: String,
145    pub description: String,
146}
147
148#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
149pub struct SchemaInfo {
150    pub table: String,
151    pub source: String,
152    pub required_columns: Vec<String>,
153}
154
155#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
156pub struct RouteInfo {
157    pub base_path: String,
158    pub requires_auth: bool,
159}
160
161#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
162pub struct ToolInfo {
163    pub name: String,
164}
165
166#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
167pub struct RoleInfo {
168    pub name: String,
169    pub display_name: String,
170    pub description: String,
171    pub permissions: Vec<String>,
172}
173
174#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
175pub struct LlmProviderInfo {
176    pub name: String,
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
180pub struct ExtensionDetailOutput {
181    pub id: String,
182    pub name: String,
183    pub version: String,
184    pub priority: u32,
185    pub source: ExtensionSource,
186    pub dependencies: Vec<String>,
187    pub config_prefix: Option<String>,
188    pub jobs: Vec<JobInfo>,
189    pub templates: Vec<TemplateInfo>,
190    pub schemas: Vec<SchemaInfo>,
191    pub routes: Vec<RouteInfo>,
192    pub tools: Vec<ToolInfo>,
193    pub roles: Vec<RoleInfo>,
194    pub llm_providers: Vec<LlmProviderInfo>,
195    pub storage_paths: Vec<String>,
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
199pub struct ExtensionValidationOutput {
200    pub valid: bool,
201    pub extension_count: usize,
202    pub errors: Vec<ValidationError>,
203    pub warnings: Vec<ValidationWarning>,
204}
205
206#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
207pub struct ValidationError {
208    pub extension_id: Option<String>,
209    pub error_type: String,
210    pub message: String,
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
214pub struct ValidationWarning {
215    pub extension_id: Option<String>,
216    pub warning_type: String,
217    pub message: String,
218}
219
220#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
221pub struct ExtensionConfigOutput {
222    pub extension_id: String,
223    pub config_prefix: Option<String>,
224    pub config_schema: Option<serde_json::Value>,
225    pub has_config: bool,
226}
227
228#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
229pub struct ExtensionConfigSummary {
230    pub extension_id: String,
231    pub config_prefix: Option<String>,
232    pub has_config: bool,
233}
234
235#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
236pub struct ExtensionConfigListOutput {
237    pub extensions: Vec<ExtensionConfigSummary>,
238    pub total: usize,
239}
240
241#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
242pub struct JobWithExtension {
243    pub extension_id: String,
244    pub extension_name: String,
245    pub job_name: String,
246    pub schedule: String,
247    pub enabled: bool,
248}
249
250#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
251pub struct JobsListOutput {
252    pub jobs: Vec<JobWithExtension>,
253    pub total: usize,
254}
255
256#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
257pub struct TemplateWithExtension {
258    pub extension_id: String,
259    pub extension_name: String,
260    pub template_name: String,
261    pub description: String,
262}
263
264#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
265pub struct TemplatesListOutput {
266    pub templates: Vec<TemplateWithExtension>,
267    pub total: usize,
268}
269
270#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
271pub struct SchemaWithExtension {
272    pub extension_id: String,
273    pub extension_name: String,
274    pub table: String,
275    pub source: String,
276    pub migration_weight: u32,
277}
278
279#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
280pub struct SchemasListOutput {
281    pub schemas: Vec<SchemaWithExtension>,
282    pub total: usize,
283}
284
285#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
286pub struct RouteWithExtension {
287    pub extension_id: String,
288    pub extension_name: String,
289    pub base_path: String,
290    pub requires_auth: bool,
291}
292
293#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
294pub struct RoutesListOutput {
295    pub routes: Vec<RouteWithExtension>,
296    pub total: usize,
297}
298
299#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
300pub struct ToolWithExtension {
301    pub extension_id: String,
302    pub extension_name: String,
303    pub tool_name: String,
304}
305
306#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
307pub struct ToolsListOutput {
308    pub tools: Vec<ToolWithExtension>,
309    pub total: usize,
310}
311
312#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
313pub struct RoleWithExtension {
314    pub extension_id: String,
315    pub extension_name: String,
316    pub role_name: String,
317    pub display_name: String,
318    pub description: String,
319    pub permissions: Vec<String>,
320}
321
322#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
323pub struct RolesListOutput {
324    pub roles: Vec<RoleWithExtension>,
325    pub total: usize,
326}
327
328#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
329pub struct LlmProviderWithExtension {
330    pub extension_id: String,
331    pub extension_name: String,
332    pub provider_name: String,
333}
334
335#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
336pub struct LlmProvidersListOutput {
337    pub providers: Vec<LlmProviderWithExtension>,
338    pub total: usize,
339}
340
341#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)]
342pub struct CapabilitiesSummaryOutput {
343    pub jobs: usize,
344    pub templates: usize,
345    pub schemas: usize,
346    pub tools: usize,
347    pub roles: usize,
348    pub llm_providers: usize,
349    pub extension_count: usize,
350}