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