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