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//!
4//! Copyright (c) systemprompt.io — Business Source License 1.1.
5//! See <https://systemprompt.io> for licensing details.
6
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9use systemprompt_identifiers::AgentId;
10
11use super::AgentConfig;
12
13#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
14pub struct AgentSummary {
15    pub agent_id: AgentId,
16    pub name: String,
17    pub display_name: String,
18    pub port: u16,
19    pub enabled: bool,
20    pub is_primary: bool,
21    pub is_default: bool,
22    #[serde(default)]
23    pub tags: Vec<String>,
24}
25
26impl AgentSummary {
27    #[must_use]
28    pub fn from_config(name: &str, config: &AgentConfig) -> Self {
29        Self {
30            agent_id: AgentId::new(name),
31            name: name.to_owned(),
32            display_name: config.card.display_name.clone(),
33            port: config.port,
34            enabled: config.enabled,
35            is_primary: config.is_primary,
36            is_default: config.default,
37            tags: config.tags.clone(),
38        }
39    }
40}
41
42impl From<&AgentConfig> for AgentSummary {
43    fn from(config: &AgentConfig) -> Self {
44        Self {
45            agent_id: AgentId::new(config.name.clone()),
46            name: config.name.clone(),
47            display_name: config.card.display_name.clone(),
48            port: config.port,
49            enabled: config.enabled,
50            is_primary: config.is_primary,
51            is_default: config.default,
52            tags: config.tags.clone(),
53        }
54    }
55}