caliban-provider-google 0.3.0

Google Gemini schema family for the caliban agent harness — internal crate for the caliban binary; no API stability, pin exact versions
Documentation
//! Wire-format types for Google Gemini API responses.

use serde::{Deserialize, Serialize};

use super::request::NativeContent;

/// Top-level response from `POST /{version}/models/{model}:generateContent`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NativeResponse {
    /// The list of completion candidates (we use `candidates[0]`).
    #[serde(default)]
    pub candidates: Vec<NativeCandidate>,
    /// Token usage statistics.
    #[serde(default)]
    pub usage_metadata: NativeUsageMetadata,
    /// The model version that generated the response.
    #[serde(default)]
    pub model_version: String,
}

/// A single completion candidate.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NativeCandidate {
    /// The generated content.
    pub content: NativeContent,
    /// Why the model stopped generating.
    #[serde(default)]
    pub finish_reason: Option<NativeFinishReason>,
    /// The candidate index (always 0 for `candidateCount=1`).
    #[serde(default)]
    pub index: u32,
}

/// Why the model stopped generating tokens.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum NativeFinishReason {
    /// Natural end of response.
    Stop,
    /// `maxOutputTokens` limit reached.
    MaxTokens,
    /// Content was filtered by safety systems.
    Safety,
    /// Content was filtered for recitation.
    Recitation,
    /// The model issued a tool call (some Gemini versions).
    ToolUse,
    /// Unspecified / other.
    Other,
    /// Finish reason not set yet (intermediate streaming chunks).
    FinishReasonUnspecified,
}

/// Token usage statistics.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NativeUsageMetadata {
    /// Tokens consumed by the prompt.
    #[serde(default)]
    pub prompt_token_count: u32,
    /// Tokens generated by the candidates.
    #[serde(default)]
    pub candidates_token_count: u32,
    /// Total tokens (prompt + candidates).
    #[serde(default)]
    pub total_token_count: u32,
}