supercode-runtime 0.4.12

Optional native model and tool runtime for Supercode
Documentation
//! Conservative context-window metadata used by the native runtime.

/// Known context-window sizes in tokens, keyed by full model slug.
const KNOWN_MODEL_CONTEXT_LIMITS: &[(&str, u64)] = &[
    ("z-ai/glm-5.2", 1_048_576),
    ("deepseek/deepseek-v4-flash", 1_048_576),
    ("deepseek/deepseek-v4-pro", 1_048_576),
    ("google/gemini-2.5-pro", 1_048_576),
    ("meta-llama/llama-4-maverick", 1_048_576),
    ("openai/gpt-5.5", 400_000),
    ("openai/gpt-5", 400_000),
    ("anthropic/claude-opus-4-8", 500_000),
    ("anthropic/claude-sonnet-4-6", 500_000),
    ("anthropic/claude-haiku-4-5", 200_000),
];

/// Conservative fallback context limit for an unrecognized model.
pub const UNKNOWN_MODEL_CONTEXT_FLOOR: u64 = 200_000;

/// Look up a model's context-window size by its full provider slug.
pub fn model_context_limit(model: &str) -> Option<u64> {
    KNOWN_MODEL_CONTEXT_LIMITS
        .iter()
        .find(|(slug, _)| *slug == model)
        .map(|(_, limit)| *limit)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn exact_slug_resolves_and_alias_does_not() {
        assert_eq!(model_context_limit("openai/gpt-5"), Some(400_000));
        assert_eq!(model_context_limit("gpt-5"), None);
    }

    #[test]
    fn fallback_is_no_larger_than_any_known_limit() {
        assert!(KNOWN_MODEL_CONTEXT_LIMITS
            .iter()
            .all(|(_, limit)| UNKNOWN_MODEL_CONTEXT_FLOOR <= *limit));
    }
}