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