Skip to main content

systemprompt_cli/commands/admin/agents/
shared.rs

1use anyhow::{Result, anyhow};
2use clap::Args;
3
4use crate::interactive::Prompter;
5
6pub fn prompt_agent_selection(
7    prompter: &dyn Prompter,
8    prompt: &str,
9    config: &systemprompt_models::ServicesConfig,
10) -> Result<String> {
11    let agents: Vec<String> = config.agents.keys().cloned().collect();
12    select_agent_from_names(prompter, prompt, agents)
13}
14
15pub fn select_agent_from_names(
16    prompter: &dyn Prompter,
17    prompt: &str,
18    mut agents: Vec<String>,
19) -> Result<String> {
20    agents.sort();
21
22    if agents.is_empty() {
23        return Err(anyhow!("No agents configured"));
24    }
25
26    let selection = prompter.select(prompt, &agents)?;
27    Ok(agents[selection].clone())
28}
29
30#[derive(Debug, Args, Default, Clone)]
31pub struct AgentArgs {
32    #[arg(long, help = "Port for the agent")]
33    pub port: Option<u16>,
34
35    #[arg(long, help = "Custom endpoint path (default: /api/v1/agents/{name})")]
36    pub endpoint: Option<String>,
37
38    #[arg(long, help = "Mark agent as dev-only (won't run in production)")]
39    pub dev_only: bool,
40
41    #[arg(long, help = "Mark agent as primary")]
42    pub is_primary: bool,
43
44    #[arg(long, help = "Mark agent as the default agent")]
45    pub default: bool,
46
47    #[arg(long, help = "Display name for the agent")]
48    pub display_name: Option<String>,
49
50    #[arg(long, help = "Description of the agent")]
51    pub description: Option<String>,
52
53    #[arg(long, help = "Version string for the agent (default: 1.0.0)")]
54    pub version: Option<String>,
55
56    #[arg(long, help = "URL to the agent's icon")]
57    pub icon_url: Option<String>,
58
59    #[arg(long, help = "URL to the agent's documentation")]
60    pub documentation_url: Option<String>,
61
62    #[arg(long, help = "Enable streaming capability (default: true)")]
63    pub streaming: Option<bool>,
64
65    #[arg(long, help = "Enable push notifications capability")]
66    pub push_notifications: Option<bool>,
67
68    #[arg(long, help = "Enable state transition history (default: true)")]
69    pub state_transition_history: Option<bool>,
70
71    #[arg(long, help = "AI provider (e.g., anthropic, openai, gemini)")]
72    pub provider: Option<String>,
73
74    #[arg(long, help = "AI model (e.g., claude-sonnet-4-6)")]
75    pub model: Option<String>,
76
77    #[arg(long = "system-prompt", help = "Set the system prompt inline")]
78    pub system_prompt: Option<String>,
79
80    #[arg(long = "system-prompt-file", help = "Load system prompt from a file")]
81    pub system_prompt_file: Option<String>,
82
83    #[arg(
84        long = "mcp-server",
85        help = "Add an MCP server reference (can be specified multiple times)"
86    )]
87    pub mcp_servers: Vec<String>,
88
89    #[arg(
90        long = "skill",
91        help = "Add a skill reference (can be specified multiple times)"
92    )]
93    pub skills: Vec<String>,
94}
95
96impl AgentArgs {
97    pub const fn has_any_value(&self) -> bool {
98        self.port.is_some()
99            || self.endpoint.is_some()
100            || self.dev_only
101            || self.is_primary
102            || self.default
103            || self.display_name.is_some()
104            || self.description.is_some()
105            || self.version.is_some()
106            || self.icon_url.is_some()
107            || self.documentation_url.is_some()
108            || self.streaming.is_some()
109            || self.push_notifications.is_some()
110            || self.state_transition_history.is_some()
111            || self.provider.is_some()
112            || self.model.is_some()
113            || self.system_prompt.is_some()
114            || self.system_prompt_file.is_some()
115            || !self.mcp_servers.is_empty()
116            || !self.skills.is_empty()
117    }
118}