mod agent;
mod appearance;
mod auth;
mod bash_mode;
mod cancellation;
mod checkpoints;
mod cli;
mod code_mode;
mod commands;
mod compaction;
pub mod config;
pub mod context;
mod diff_review;
mod fast;
mod hash;
mod herdr;
mod hex;
mod hooks;
mod http_body;
mod instructions;
mod local_agent;
mod lsp;
mod mcp;
mod model_catalog;
mod output;
mod path_utils;
mod persistence;
mod primary_agents;
mod process_environment;
#[cfg(test)]
mod profiling;
mod prompt_file;
mod protection;
mod providers;
mod rendering;
mod runtime_context;
mod security;
mod session_titles;
pub mod sessions;
mod shell;
mod skills;
mod subagents;
mod summarizer;
mod thinking;
mod thread_join;
mod tool_output_measurement;
mod tools;
mod tui;
mod typesafe;
mod updates;
pub use providers::{ChatMessage, MessageRole, Usage};
pub use thinking::ThinkingLevel;
use anyhow::Result;
use clap::Parser;
pub fn run_from_env() -> Result<()> {
run_from_env_inner().map_err(crate::cli::AppError::into_error)
}
pub fn run_from_env_with_exit_code() -> std::process::ExitCode {
if let Some(path) = std::env::var_os("MAGI_CLAUDE_INERT_MCP_INVENTORY") {
return match providers::claude_inert::serve_inventory(std::path::Path::new(&path)) {
Ok(()) => std::process::ExitCode::SUCCESS,
Err(_) => std::process::ExitCode::FAILURE,
};
}
match run_from_env_inner() {
Ok(()) => std::process::ExitCode::SUCCESS,
Err(error) => {
if !error.as_error().is::<local_agent::TransportStopped>() {
eprintln!("Error: {:?}", error.as_error());
}
error.exit_code()
}
}
}
fn run_from_env_inner() -> crate::cli::AppResult<()> {
let args = cli::CliArgs::parse();
cli::run(args)
}