pub mod agent;
pub mod apply;
pub mod config_cmd;
pub mod dashboard;
pub mod environment;
pub mod init;
pub mod kitchen;
pub mod local;
pub mod login;
pub mod pro_gate;
pub mod prompt;
pub mod provider;
pub mod rag;
pub mod recipe;
pub mod service_account;
pub mod session;
pub mod test_suite;
pub mod tool;
pub mod trace;
pub mod use_cmd;
use clap::{Parser, Subcommand};
const BANNER: &str = r#"
๐บ AgentOven
Bake production-ready AI agents.
"#;
#[derive(Parser)]
#[command(
name = "agentoven",
version,
about = "๐บ AgentOven โ Bake production-ready AI agents",
long_about = BANNER,
propagate_version = true
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
#[arg(long, global = true, env = "AGENTOVEN_URL")]
pub url: Option<String>,
#[arg(long, global = true, env = "AGENTOVEN_API_KEY")]
pub api_key: Option<String>,
#[arg(long, short = 'k', global = true, env = "AGENTOVEN_KITCHEN")]
pub kitchen: Option<String>,
#[arg(long, global = true, default_value = "text")]
pub output: OutputFormat,
}
#[derive(Subcommand)]
pub enum Commands {
Init(init::InitArgs),
Apply(apply::ApplyArgs),
#[command(subcommand)]
Agent(Box<agent::AgentCommands>),
#[command(subcommand)]
Provider(provider::ProviderCommands),
#[command(subcommand)]
Tool(tool::ToolCommands),
#[command(subcommand)]
Prompt(prompt::PromptCommands),
#[command(subcommand)]
Recipe(recipe::RecipeCommands),
#[command(subcommand)]
Session(session::SessionCommands),
#[command(subcommand)]
Kitchen(kitchen::KitchenCommands),
#[command(subcommand)]
Trace(trace::TraceCommands),
#[command(subcommand)]
Rag(rag::RagCommands),
#[command(subcommand)]
Local(local::LocalCommands),
Dashboard(dashboard::DashboardArgs),
Login(login::LoginArgs),
#[command(subcommand)]
Config(config_cmd::ConfigCommands),
Use(use_cmd::UseArgs),
#[command(subcommand)]
Environment(environment::EnvironmentCommands),
#[command(subcommand)]
TestSuite(test_suite::TestSuiteCommands),
#[command(subcommand)]
ServiceAccount(service_account::ServiceAccountCommands),
Status,
}
#[derive(Clone, clap::ValueEnum)]
pub enum OutputFormat {
Text,
Json,
Table,
}
pub async fn execute(cli: Cli) -> anyhow::Result<()> {
match cli.command {
Commands::Init(args) => init::execute(args).await,
Commands::Apply(args) => apply::execute(args).await,
Commands::Agent(cmd) => agent::execute(*cmd).await,
Commands::Provider(cmd) => provider::execute(cmd).await,
Commands::Tool(cmd) => tool::execute(cmd).await,
Commands::Prompt(cmd) => prompt::execute(cmd).await,
Commands::Recipe(cmd) => recipe::execute(cmd).await,
Commands::Session(cmd) => session::execute(cmd).await,
Commands::Kitchen(cmd) => kitchen::execute(cmd).await,
Commands::Trace(cmd) => trace::execute(cmd).await,
Commands::Rag(cmd) => rag::execute(cmd).await,
Commands::Local(cmd) => local::execute(cmd).await,
Commands::Dashboard(args) => dashboard::execute(args).await,
Commands::Login(args) => login::execute(args).await,
Commands::Config(cmd) => config_cmd::execute(cmd).await,
Commands::Use(args) => use_cmd::execute(args).await,
Commands::Environment(cmd) => environment::execute(cmd).await,
Commands::TestSuite(cmd) => test_suite::execute(cmd).await,
Commands::ServiceAccount(cmd) => service_account::execute(cmd).await,
Commands::Status => status().await,
}
}
async fn status() -> anyhow::Result<()> {
println!("{BANNER}");
let client = agentoven_core::AgentOvenClient::from_env()?;
print!(" Control plane: checking...");
match client.server_info().await {
Ok(info) => {
let edition = info["edition"].as_str().unwrap_or("community");
let version = info["version"].as_str().unwrap_or("unknown");
println!("\r Control plane: ๐ข connected ");
println!(" Server: {} v{}", edition, version);
if let Ok(agents) = client.list_agents().await {
println!(" Agents: {} registered", agents.len());
}
}
Err(_) => {
match client.list_agents().await {
Ok(agents) => {
println!("\r Control plane: ๐ข connected ");
println!(" Agents: {} registered", agents.len());
}
Err(_) => {
println!("\r Control plane: ๐ด unreachable ");
println!(" Tip: Run `agentoven local up` or set AGENTOVEN_URL");
}
}
}
}
let config = agentoven_core::AgentOvenConfig::load();
println!(" URL: {}", config.url);
println!(
" Kitchen: {}",
config.kitchen.as_deref().unwrap_or("default")
);
println!(" CLI version: {}", env!("CARGO_PKG_VERSION"));
Ok(())
}