zc2 0.0.27

P2P compute broker with credit-based billing, WAL, and broker mesh support
//! `zc agent`: the loopback control service that supervises this Mac's
//! sharing and serves the menu-bar app and widget
//! (spec docs/superpowers/specs/2026-09-13-macos-widget-design.md §6).

pub mod cli;
pub mod client;
pub mod config;
pub mod core;
pub mod files;
pub mod handoff;
pub mod hub;
pub mod hubwire;
pub mod launchd;
pub mod merge;
pub mod plan;
pub mod run;
pub mod server;
pub mod summary;
pub mod supervisor;
#[cfg(test)]
pub mod testbin;

/// `zc agent run | install | uninstall | status [--json]` → exit code.
pub fn run_cli(args: &[String], json: bool) -> i32 {
    match args.first().map(String::as_str).unwrap_or("status") {
        "run" => match config::AgentConfig::from_env() {
            Ok(cfg) => run::run(cfg),
            Err(e) => {
                eprintln!("zc agent: {e}");
                1
            }
        },
        "install" => cli::install(),
        "uninstall" => cli::uninstall(),
        "status" => cli::status(json),
        other => {
            eprintln!("usage: zc agent [run|install|uninstall|status [--json]] (got '{other}')");
            2
        }
    }
}