Skip to main content

systemprompt_cli/commands/admin/agents/
mod.rs

1pub mod types;
2
3mod create;
4mod delete;
5mod edit;
6mod list;
7mod logs;
8mod message;
9mod registry;
10mod run;
11mod shared;
12mod show;
13mod status;
14mod task;
15mod tools;
16mod validate;
17
18use anyhow::{Context, Result};
19use clap::Subcommand;
20
21use crate::cli_settings::get_global_config;
22use crate::shared::render_result;
23use crate::CliConfig;
24
25#[derive(Debug, Subcommand)]
26pub enum AgentsCommands {
27    #[command(about = "List configured agents")]
28    List(list::ListArgs),
29
30    #[command(about = "Display agent configuration")]
31    Show(show::ShowArgs),
32
33    #[command(about = "Check agent configs for errors")]
34    Validate(validate::ValidateArgs),
35
36    #[command(about = "Create new agent")]
37    Create(create::CreateArgs),
38
39    #[command(about = "Edit agent configuration")]
40    Edit(edit::EditArgs),
41
42    #[command(about = "Delete an agent")]
43    Delete(delete::DeleteArgs),
44
45    #[command(about = "Show agent process status")]
46    Status(status::StatusArgs),
47
48    #[command(about = "View agent logs")]
49    Logs(logs::LogsArgs),
50
51    #[command(about = "Get running agents from gateway registry (A2A discovery)")]
52    Registry(registry::RegistryArgs),
53
54    #[command(about = "Send a message to an agent via A2A protocol")]
55    Message(message::MessageArgs),
56
57    #[command(about = "Get task details and response from an agent")]
58    Task(task::TaskArgs),
59
60    #[command(about = "List MCP tools available to an agent")]
61    Tools(tools::ToolsArgs),
62
63    #[command(about = "Run an agent server directly (bypasses orchestration)")]
64    Run(run::RunArgs),
65}
66
67pub async fn execute(command: AgentsCommands) -> Result<()> {
68    let config = get_global_config();
69    execute_with_config(command, &config).await
70}
71
72pub async fn execute_with_config(command: AgentsCommands, config: &CliConfig) -> Result<()> {
73    match command {
74        AgentsCommands::List(args) => {
75            let result = list::execute(args, config).context("Failed to list agents")?;
76            render_result(&result);
77            Ok(())
78        },
79        AgentsCommands::Show(args) => {
80            let result = show::execute(args, config).context("Failed to show agent")?;
81            render_result(&result);
82            Ok(())
83        },
84        AgentsCommands::Validate(args) => {
85            let result = validate::execute(&args, config).context("Failed to validate agents")?;
86            render_result(&result);
87            Ok(())
88        },
89        AgentsCommands::Create(args) => {
90            let result = create::execute(args, config).context("Failed to create agent")?;
91            render_result(&result);
92            Ok(())
93        },
94        AgentsCommands::Edit(args) => {
95            let result = edit::execute(args, config).context("Failed to edit agent")?;
96            render_result(&result);
97            Ok(())
98        },
99        AgentsCommands::Delete(args) => {
100            let result = delete::execute(args, config)
101                .await
102                .context("Failed to delete agent")?;
103            render_result(&result);
104            Ok(())
105        },
106        AgentsCommands::Status(args) => {
107            let result = status::execute(args, config)
108                .await
109                .context("Failed to get agent status")?;
110            render_result(&result);
111            Ok(())
112        },
113        AgentsCommands::Logs(args) => {
114            let result = logs::execute(args, config)
115                .await
116                .context("Failed to get agent logs")?;
117            render_result(&result);
118            Ok(())
119        },
120        AgentsCommands::Registry(args) => {
121            let result = registry::execute(args, config)
122                .await
123                .context("Failed to get agent registry")?;
124            render_result(&result);
125            Ok(())
126        },
127        AgentsCommands::Message(args) => {
128            let result = message::execute(args, config)
129                .await
130                .context("Failed to send message to agent")?;
131            render_result(&result);
132            Ok(())
133        },
134        AgentsCommands::Task(args) => {
135            let result = task::execute(args, config)
136                .await
137                .context("Failed to get task details")?;
138            render_result(&result);
139            Ok(())
140        },
141        AgentsCommands::Tools(args) => {
142            let result = tools::execute(args, config)
143                .await
144                .context("Failed to list agent tools")?;
145            render_result(&result);
146            Ok(())
147        },
148        AgentsCommands::Run(args) => {
149            run::execute(args).await.context("Failed to run agent")?;
150            Ok(())
151        },
152    }
153}