lean-ctx 3.9.18

Context Runtime for AI Agents with CCP. 71 MCP tools, 10 read modes, 95+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing, LITM-aware positioning, AAAK compact format, adaptive compression with Thompson Sampling bandits. Supports 24+ AI tools. Reduces LLM token consumption by up to 99%.
Documentation
#[allow(dead_code)]
pub(crate) mod conversation_tracker;
#[allow(dead_code)]
pub(crate) mod normalize;
#[cfg(test)]
mod proof_tests;

/// Recognized web-app AI providers (domain-detected, not path-detected).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WebAppProvider {
    ClaudeWeb,
    ChatGptWeb,
    GeminiWeb,
}

/// A web-app request normalized to the canonical messages format that
/// the existing compression pipeline understands.
#[derive(Debug, Clone)]
pub struct NormalizedRequest {
    pub provider: WebAppProvider,
    pub messages: Vec<serde_json::Value>,
    pub system_prompt: Option<String>,
    pub model: Option<String>,
    pub conversation_id: Option<String>,
    pub parent_message_id: Option<String>,
}

pub(crate) fn detect_web_provider(host: &str, path: &str) -> Option<WebAppProvider> {
    let _ = path;
    let host = host
        .trim()
        .trim_end_matches('.')
        .split(':')
        .next()
        .unwrap_or_default();

    if host.eq_ignore_ascii_case("claude.ai") {
        Some(WebAppProvider::ClaudeWeb)
    } else if host.eq_ignore_ascii_case("chat.openai.com")
        || host.eq_ignore_ascii_case("chatgpt.com")
    {
        Some(WebAppProvider::ChatGptWeb)
    } else if host.eq_ignore_ascii_case("gemini.google.com") {
        Some(WebAppProvider::GeminiWeb)
    } else {
        None
    }
}