Skip to main content

oxicode_ai/providers/
gemini_cli.rs

1//! Google Gemini CLI transport — explicit typed unsupported-provider path.
2//!
3//! `Api::GoogleGeminiCli` is a first-class dialect in `oxicode_catalog::api::Api`
4//! and appears in the model catalog for the `google-gemini-cli` provider.
5//! However, the Gemini CLI is a remote-AGENT protocol without a dedicated
6//! transport (no `proto/`, no bundled SDK), and the upstream openclaw port
7//! collapses it to `google-generative-ai` (`scripts/catalog/port-openclaw.py:48`).
8//!
9//! Before this module existed, the `build_builtin_transport` factory arm
10//! for `Api::GoogleGeminiCli` fell through to `_ => None`, which silently
11//! surfaced as `ProviderError::UnknownProvider("google-gemini-cli")` downstream.
12//!
13//! This transport keeps the factory dispatch non-`None` (so resolution does
14//! not silently miss) while surfacing a typed `ProviderError::NotImplemented`
15//! error at the moment the caller actually invokes `stream()`. No fake
16//! success, no fabricated HTTP traffic.
17//!
18//! When a real Gemini CLI protocol is integrated (likely a local
19//! subprocess / OAuth helper), replace the body of `Provider::stream` with
20//! the real implementation — the rest of the dispatch path stays unchanged.
21
22use std::future::Future;
23use std::pin::Pin;
24
25use crate::error::ProviderError;
26use crate::{Context, Model, Provider, StreamOptions, StreamResult};
27
28/// Thin transport for the `google-gemini-cli` dialect.
29///
30/// Carries no identity — the canonical catalog id is the registry key (see
31/// `oxicode_ai::providers::register_builtins::create_builtin_provider`).
32#[derive(Clone, Default)]
33pub struct GeminiCliProvider;
34
35impl GeminiCliProvider {
36    /// Construct a new `GeminiCliProvider`.
37    pub fn new() -> Self {
38        Self
39    }
40}
41
42impl Provider for GeminiCliProvider {
43    fn stream<'a>(
44        &'a self,
45        _model: &'a Model,
46        _context: &'a Context,
47        _options: Option<StreamOptions>,
48    ) -> Pin<Box<dyn Future<Output = StreamResult> + Send + 'a>> {
49        Box::pin(async move {
50            Err(ProviderError::NotImplemented(
51                "google-gemini-cli: no dedicated transport in oxicode-ai; \
52                 upstream collapses to google-generative-ai. \
53                 Use the `google` provider instead."
54                    .into(),
55            ))
56        })
57    }
58}