Skip to main content

caliban_provider/
capabilities.rs

1//! Capability discovery types.
2
3use serde::{Deserialize, Serialize};
4
5/// The full set of capabilities offered by a model/provider combination.
6// The many boolean fields are intentional; each represents a distinct yes/no capability.
7#[allow(clippy::struct_excessive_bools)]
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
9pub struct Capabilities {
10    /// Maximum number of input tokens supported.
11    pub max_input_tokens: u32,
12    /// Maximum number of output tokens supported.
13    pub max_output_tokens: u32,
14    /// Whether the model accepts image inputs.
15    pub vision: bool,
16    /// The level of tool-use support.
17    pub tool_use: ToolUseCapability,
18    /// Whether extended thinking is supported.
19    pub thinking: bool,
20    /// The level of prompt-caching support.
21    pub prompt_caching: PromptCachingCapability,
22    /// Whether structured JSON output mode is supported.
23    pub json_mode: bool,
24    /// Whether token streaming is supported.
25    pub streaming: bool,
26    /// Whether stop sequences are supported.
27    pub stop_sequences: bool,
28    /// Whether top-k sampling is supported.
29    pub top_k: bool,
30    /// How system prompts are passed to this model.
31    pub system_prompt: SystemPromptCapability,
32    /// Whether the provider returns a structured refusal field.
33    pub refusal_field: bool,
34}
35
36/// Level of tool-use support.
37#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
38#[serde(rename_all = "snake_case")]
39pub enum ToolUseCapability {
40    /// Tool use is not supported.
41    None,
42    /// A single tool call per turn.
43    Basic,
44    /// Multiple parallel tool calls per turn.
45    ParallelCalls,
46}
47
48/// Level of prompt-caching support.
49#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
50#[serde(tag = "kind", rename_all = "snake_case")]
51pub enum PromptCachingCapability {
52    /// No prompt caching.
53    None,
54    /// The provider caches automatically without explicit markers.
55    Automatic,
56    /// The caller must mark breakpoints; carries the maximum number.
57    Explicit {
58        /// Maximum number of cache breakpoints allowed.
59        max_breakpoints: u32,
60    },
61}
62
63/// How the model/provider expects system prompts to be passed.
64#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
65#[serde(rename_all = "snake_case")]
66pub enum SystemPromptCapability {
67    /// Provider has a dedicated top-level `system` field.
68    SeparateField,
69    /// System prompts are passed as a message with `role: "system"`.
70    SystemRole,
71    /// System prompts are passed as a message with `role: "developer"`.
72    DeveloperRole,
73}
74
75/// Metadata for a single model variant.
76#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
77pub struct ModelInfo {
78    /// Caliban-internal model identifier.
79    pub id: String,
80    /// The model identifier used in API requests.
81    pub native_id: String,
82    /// Human-readable display name.
83    pub display_name: String,
84    /// The capabilities of this model.
85    pub capabilities: Capabilities,
86}