Skip to main content

systemprompt_cli/commands/admin/agents/
mod.rs

1//! `admin agents` command group: manage A2A agent configurations and runtime.
2//!
3//! Exposes [`AgentsCommands`] covering the agent lifecycle — list, show,
4//! validate, create, edit, delete, status, logs — plus A2A interaction
5//! (registry discovery, message, task, tools) and direct `run`. Each variant
6//! dispatches to a sibling module that returns a
7//! [`crate::shared::CommandOutput`].
8
9pub 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::context::CommandContext;
37use crate::shared::render_result;
38
39#[derive(Debug, Subcommand)]
40pub enum AgentsCommands {
41    #[command(about = "List configured agents")]
42    List(list::ListArgs),
43
44    #[command(about = "Display agent configuration")]
45    Show(show::ShowArgs),
46
47    #[command(about = "Check agent configs for errors")]
48    Validate(validate::ValidateArgs),
49
50    #[command(about = "Create new agent")]
51    Create(create::CreateArgs),
52
53    #[command(about = "Edit agent configuration")]
54    Edit(edit::EditArgs),
55
56    #[command(about = "Delete an agent")]
57    Delete(delete::DeleteArgs),
58
59    #[command(about = "Show agent process status")]
60    Status(status::StatusArgs),
61
62    #[command(about = "View agent logs")]
63    Logs(logs::LogsArgs),
64
65    #[command(about = "Get running agents from gateway registry (A2A discovery)")]
66    Registry(registry::RegistryArgs),
67
68    #[command(about = "Send a message to an agent via A2A protocol")]
69    Message(message::MessageArgs),
70
71    #[command(about = "Get task details and response from an agent")]
72    Task(task::TaskArgs),
73
74    #[command(about = "List MCP tools available to an agent")]
75    Tools(tools::ToolsArgs),
76
77    #[command(about = "Run an agent server directly (bypasses orchestration)")]
78    Run(run::RunArgs),
79}
80
81pub async fn execute(command: AgentsCommands, ctx: &CommandContext) -> Result<()> {
82    let result = match command {
83        AgentsCommands::List(args) => {
84            list::execute(args, &ctx.cli).context("Failed to list agents")?
85        },
86        AgentsCommands::Show(args) => {
87            show::execute(args, &ctx.cli).context("Failed to show agent")?
88        },
89        AgentsCommands::Validate(args) => {
90            validate::execute(&args, &ctx.cli).context("Failed to validate agents")?
91        },
92        AgentsCommands::Create(args) => {
93            create::execute(args, &ctx.cli).context("Failed to create agent")?
94        },
95        AgentsCommands::Edit(args) => {
96            edit::execute(&args, &ctx.cli).context("Failed to edit agent")?
97        },
98        AgentsCommands::Delete(args) => delete::execute(args, &ctx.cli)
99            .await
100            .context("Failed to delete agent")?,
101        AgentsCommands::Status(args) => status::execute(args, &ctx.cli)
102            .await
103            .context("Failed to get agent status")?,
104        AgentsCommands::Logs(args) => logs::execute(args, &ctx.cli)
105            .await
106            .context("Failed to get agent logs")?,
107        AgentsCommands::Registry(args) => registry::execute(args, &ctx.cli)
108            .await
109            .context("Failed to get agent registry")?,
110        AgentsCommands::Message(args) => message::execute(args, ctx)
111            .await
112            .context("Failed to send message to agent")?,
113        AgentsCommands::Task(args) => task::execute(args, ctx)
114            .await
115            .context("Failed to get task details")?,
116        AgentsCommands::Tools(args) => tools::execute(args, ctx)
117            .await
118            .context("Failed to list agent tools")?,
119        AgentsCommands::Run(args) => {
120            return run::execute(args).await.context("Failed to run agent");
121        },
122    };
123    render_result(&result, &ctx.cli);
124    Ok(())
125}