magi-code 0.96.2

Repository-aware CLI coding agent for terminal work
Documentation
mod bodies;
mod catalog;
mod codex;
mod compatible;
mod headers;

#[cfg(test)]
mod profiling;

pub use codex::OpenAiCodexProvider;
pub(crate) use codex::{codex_account_id_for, normalize_codex_model};
pub use compatible::OpenAiCompatibleProvider;

pub(crate) use bodies::response_instructions;
pub(crate) use catalog::fetch_model_catalog_response_text_cancellable;
pub(crate) use headers::{codex_sse_headers_with_routing_hint, package_user_agent};

use crate::{
    cancellation::AgentCancellation,
    providers::{ProviderEvent, ProviderRequest},
};

/// ChatGPT/Codex backend compatibility version for model catalog discovery.
///
/// The Codex `/models` endpoint gates the returned account-available catalog by
/// client version. The crate package version is not a Codex client version and
/// can cause the backend to return an artificially narrow catalog.
pub(crate) const CODEX_MODEL_CATALOG_CLIENT_VERSION: &str = "0.159.0";

pub trait Provider: Send + Sync {
    fn requested_service_tier(&self) -> Option<&str> {
        None
    }

    fn stream_cancellable(
        &self,
        request: ProviderRequest,
        cancellation: &AgentCancellation,
        on_event: &mut dyn FnMut(ProviderEvent) -> anyhow::Result<()>,
    ) -> anyhow::Result<()>;
}
#[cfg(test)]
pub(crate) use bodies::{
    build_chat_completion_tools_json, chat_completion_tools_json,
    openai_compatible_chat_completions_body,
};