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