apoc 0.9.1

Agentic process control for LLMs
Documentation
//! apoc executable entry point.

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    apoc::error_telemetry::install_panic_hook();
    let argv = std::env::args().skip(1).collect::<Vec<_>>();
    if let Some(message) = apoc::cli::exact_argv_cli_error(&argv) {
        apoc::error_telemetry::record_cli_error("VALIDATION_ERROR", message);
        println!(
            "code: VALIDATION_ERROR\nmessage: {}",
            serde_json::to_string(message)?
        );
        std::process::exit(2);
    }
    // `--mcp` is dispatched by incurs into its default tool-router surface. apoc
    // serves Code Mode instead, and an MCP stdio session owns stdout for its
    // whole life, so it cannot run inside the command graph's output envelope.
    //
    // Only a flag before the first `--` selects the surface. Matching anywhere in
    // argv hijacked `apoc execution command ... -- --mcp`, where `--mcp` is an
    // argument being forwarded to a child and means nothing to apoc.
    if argv
        .iter()
        .take_while(|arg| *arg != "--")
        .any(|arg| arg == "--mcp")
    {
        return apoc::mcp_surface::serve_stdio().await.inspect_err(|error| {
            apoc::error_telemetry::record_cli_error("MCP_RUNTIME_ERROR", &error.to_string());
        });
    }

    apoc::error_telemetry::serve_cli(argv)
        .await
        .inspect_err(|error| {
            apoc::error_telemetry::record_cli_error("CLI_RUNTIME_ERROR", &error.to_string());
        })
}