1mod agent;
2mod appearance;
3mod auth;
4mod bash_mode;
5mod cancellation;
6mod checkpoints;
7mod cli;
8mod code_mode;
9mod commands;
10mod compaction;
11pub mod config;
12pub mod context;
13mod diff_review;
14mod fast;
15mod hash;
16mod herdr;
17mod hex;
18mod hooks;
19mod http_body;
20mod instructions;
21mod local_agent;
22mod lsp;
23mod mcp;
24mod model_catalog;
25mod output;
26mod path_utils;
27mod persistence;
28mod primary_agents;
29mod process_environment;
30#[cfg(test)]
31mod profiling;
32mod prompt_file;
33mod protection;
34mod providers;
35mod rendering;
36mod runtime_context;
37mod security;
38mod session_titles;
39pub mod sessions;
40mod shell;
41mod skills;
42mod subagents;
43mod summarizer;
44mod thinking;
45mod thread_join;
46mod tool_output_measurement;
47mod tools;
48mod tui;
49mod typesafe;
50mod updates;
51
52pub use providers::{ChatMessage, MessageRole, Usage};
62pub use thinking::ThinkingLevel;
63
64use anyhow::Result;
65use clap::Parser;
66
67pub fn run_from_env() -> Result<()> {
68 run_from_env_inner().map_err(crate::cli::AppError::into_error)
69}
70
71pub fn run_from_env_with_exit_code() -> std::process::ExitCode {
72 if let Some(path) = std::env::var_os("MAGI_CLAUDE_INERT_MCP_INVENTORY") {
73 return match providers::claude_inert::serve_inventory(std::path::Path::new(&path)) {
74 Ok(()) => std::process::ExitCode::SUCCESS,
75 Err(_) => std::process::ExitCode::FAILURE,
76 };
77 }
78 match run_from_env_inner() {
79 Ok(()) => std::process::ExitCode::SUCCESS,
80 Err(error) => {
81 if !error.as_error().is::<local_agent::TransportStopped>() {
82 eprintln!("Error: {:?}", error.as_error());
83 }
84 error.exit_code()
85 }
86 }
87}
88
89fn run_from_env_inner() -> crate::cli::AppResult<()> {
90 let args = cli::CliArgs::parse();
91 cli::run(args)
92}