Skip to main content

systemprompt_cli/commands/admin/agents/
shared.rs

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