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 progressive_session_maintenance;
34mod prompt_file;
35mod protection;
36mod providers;
37mod rendering;
38mod runtime_context;
39mod security;
40mod session_titles;
41pub mod sessions;
42mod shell;
43mod skills;
44mod subagents;
45mod summarizer;
46mod thinking;
47mod thread_join;
48mod tool_output_measurement;
49mod tools;
50mod tui;
51mod typesafe;
52mod updates;
53
54pub use providers::{ChatMessage, MessageRole, Usage};
64pub use thinking::ThinkingLevel;
65
66use anyhow::Result;
67use clap::Parser;
68
69pub fn run_from_env() -> Result<()> {
70 run_from_env_inner().map_err(crate::cli::AppError::into_error)
71}
72
73pub fn run_from_env_with_exit_code() -> std::process::ExitCode {
74 match run_from_env_inner() {
75 Ok(()) => std::process::ExitCode::SUCCESS,
76 Err(error) => {
77 if !error.as_error().is::<local_agent::TransportStopped>() {
78 eprintln!("Error: {:?}", error.as_error());
79 }
80 error.exit_code()
81 }
82 }
83}
84
85fn run_from_env_inner() -> crate::cli::AppResult<()> {
86 if let Some(path) = std::env::var_os("MAGI_CLAUDE_INERT_MCP_INVENTORY") {
88 return providers::claude_inert::serve_inventory(std::path::Path::new(&path))
89 .map_err(crate::cli::AppError::runtime);
90 }
91 let args = cli::CliArgs::parse();
92 cli::run(args)
93}