crabmate 0.5.0

Rust AI agent: OpenAI-compatible chat/completions, function calling, HTTP serve, ops CLI
Documentation
//! CLI 退出码与 `CliExitError` 类型(与 `classify_model_error_message` 分离,
//! 后者因依赖根包 `agent_errors` / `plan_artifact` 保留在根包)。

/// 一般失败(配置、I/O、未分类错误)
pub const EXIT_GENERAL: i32 = 1;
/// 参数/用法错误
pub const EXIT_USAGE: i32 = 2;
/// 模型接口或解析失败
pub const EXIT_MODEL_ERROR: i32 = 3;
/// Historical:同进程 `chat` 下本回合内所有 `run_command` 均被用户拒绝(码 4)。
/// D2.2 后生产路径不再发出该码(无同进程 CLI 工具审批);契约测试仍断言常量值 == 4 作占位。
pub const EXIT_TOOLS_ALL_RUN_COMMAND_DENIED: i32 = 4;
/// 配额 / 限流
pub const EXIT_QUOTA_OR_RATE_LIMIT: i32 = 5;
/// `tool-replay` 下存在不一致的工具输出
pub const EXIT_TOOL_REPLAY_MISMATCH: i32 = 6;

#[derive(Debug, Clone)]
pub struct CliExitError {
    pub code: i32,
    pub message: String,
}

impl std::fmt::Display for CliExitError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.message)
    }
}

impl std::error::Error for CliExitError {}

impl CliExitError {
    pub fn new(code: i32, message: impl Into<String>) -> Self {
        Self {
            code,
            message: message.into(),
        }
    }
}