mod commands;
mod config;
mod docker;
mod state;
use anyhow::Result;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(
name = "room-sandbox",
about = "Dockerized multi-agent sandbox for room"
)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
Init(commands::init::InitArgs),
Apply,
#[command(subcommand)]
Agent(AgentCommand),
Tui {
#[arg(long = "as")]
username: Option<String>,
},
Shell {
name: Option<String>,
#[arg(long)]
root: bool,
},
Up,
Down,
Logs,
Claude {
name: String,
#[arg(last = true)]
claude_args: Vec<String>,
},
Clean,
}
#[derive(Subcommand)]
enum AgentCommand {
Add {
name: String,
},
Remove {
name: String,
},
List,
Start {
names: Vec<String>,
#[arg(short, long)]
all: bool,
#[arg(short, long)]
tail: bool,
#[arg(last = true)]
ralph_args: Vec<String>,
},
Stop {
names: Vec<String>,
#[arg(short, long)]
all: bool,
},
Restart {
names: Vec<String>,
#[arg(short, long)]
all: bool,
#[arg(short, long)]
tail: bool,
#[arg(last = true)]
ralph_args: Vec<String>,
},
}
fn main() -> Result<()> {
let cli = Cli::parse();
match cli.command {
Command::Init(args) => commands::init::run(args),
Command::Apply => commands::apply::run(),
Command::Agent(cmd) => match cmd {
AgentCommand::Add { name } => commands::agent::add(&name),
AgentCommand::Remove { name } => commands::agent::remove(&name),
AgentCommand::List => commands::agent::list(),
AgentCommand::Start {
names,
all,
tail,
ralph_args,
} => commands::agent::start(&names, all, tail, &ralph_args),
AgentCommand::Stop { names, all } => commands::agent::stop(&names, all),
AgentCommand::Restart {
names,
all,
tail,
ralph_args,
} => commands::agent::restart(&names, all, tail, &ralph_args),
},
Command::Tui { username } => commands::tui::run(username.as_deref()),
Command::Claude { name, claude_args } => commands::claude::run(&name, &claude_args),
Command::Shell { name, root } => commands::shell::run(name.as_deref(), root),
Command::Up => commands::up::run(),
Command::Down => commands::down::run(),
Command::Logs => commands::logs::run(),
Command::Clean => commands::clean::run(),
}
}