Skip to main content

systemprompt_models/services/agent_config/
summary.rs

1//! Lightweight projection of [`AgentConfig`] used by listing endpoints
2//! and CLI tables.
3
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use systemprompt_identifiers::AgentId;
7
8use super::AgentConfig;
9
10#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
11pub struct AgentSummary {
12    pub agent_id: AgentId,
13    pub name: String,
14    pub display_name: String,
15    pub port: u16,
16    pub enabled: bool,
17    pub is_primary: bool,
18    pub is_default: bool,
19    #[serde(default)]
20    pub tags: Vec<String>,
21}
22
23impl AgentSummary {
24    #[must_use]
25    pub fn from_config(name: &str, config: &AgentConfig) -> Self {
26        Self {
27            agent_id: AgentId::new(name),
28            name: name.to_string(),
29            display_name: config.card.display_name.clone(),
30            port: config.port,
31            enabled: config.enabled,
32            is_primary: config.is_primary,
33            is_default: config.default,
34            tags: config.tags.clone(),
35        }
36    }
37}
38
39impl From<&AgentConfig> for AgentSummary {
40    fn from(config: &AgentConfig) -> Self {
41        Self {
42            agent_id: AgentId::new(config.name.clone()),
43            name: config.name.clone(),
44            display_name: config.card.display_name.clone(),
45            port: config.port,
46            enabled: config.enabled,
47            is_primary: config.is_primary,
48            is_default: config.default,
49            tags: config.tags.clone(),
50        }
51    }
52}