harn-vm 0.10.153

Async bytecode virtual machine for the Harn programming language
Documentation
//! Built-in LLM provider implementations.
//!
//! Each provider implements the `LlmProvider` + `LlmProviderOps` traits from
//! `super::provider`. The three main families are:
//!
//! - **Anthropic** — Claude models via the Anthropic Messages API
//! - **OpenAI-compatible** — OpenAI, OpenRouter, Together, Groq, DeepSeek,
//!   Fireworks, HuggingFace, local vLLM/SGLang servers, etc.
//! - **Ollama** — local Ollama server with NDJSON streaming
//! - **Bedrock / Azure OpenAI / Vertex AI** — enterprise cloud shims
//! - **Mock** — deterministic test responses without any network I/O

mod acp;
pub(crate) mod anthropic;
#[cfg(test)]
mod anthropic_test_support;
#[cfg(test)]
mod anthropic_thinking_tests;
#[cfg(test)]
mod anthropic_wire_tests;
pub(crate) mod azure_openai;
pub(crate) mod bedrock;
mod common;
mod gemini;
mod mock;
mod ollama;
pub(crate) mod openai_compat;
#[cfg(test)]
mod openai_compat_tests;
pub(crate) mod openai_responses;
pub(crate) mod schema_compat;
#[cfg(test)]
mod storage_metadata_egress_tests;
pub(crate) mod vertex;

pub(crate) use acp::AcpProvider;
pub(crate) use anthropic::AnthropicProvider;
pub(crate) use azure_openai::AzureOpenAiProvider;
pub(crate) use bedrock::BedrockProvider;
pub(crate) use gemini::interactions::GeminiInteractions;
#[cfg(test)]
pub(crate) use gemini::parse_response as parse_gemini_response;
pub(crate) use gemini::{gemini_tool_call_thought_signature, GeminiProvider};
pub(crate) use mock::MockProvider;
pub(crate) use ollama::OllamaProvider;
pub(crate) use openai_compat::OpenAiCompatibleProvider;
pub(crate) use openai_responses::OpenAiResponsesProvider;
pub(crate) use vertex::VertexProvider;

/// A prerequisite a platform-managed provider's own client needs and could not
/// find without the network.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum PlatformPrerequisiteGap {
    /// No region resolves from the environment or the platform's config files.
    Region,
    /// No credential source is discoverable from the environment, the
    /// platform's config files, or a prepared identity.
    Credentials,
}

/// Check the offline prerequisites of a platform-managed provider.
///
/// `credential_resolution = "platform_managed"` hands credential discovery to
/// the provider's own client, so the generic `auth_env` lookup cannot answer
/// whether the route can run. Each such client owns the answer here, keyed the
/// same way `transport` dispatches to it. A provider whose client declares no
/// offline check is reported as deferred, as before.
pub(crate) fn platform_offline_prerequisites(
    provider: &str,
) -> Result<(), PlatformPrerequisiteGap> {
    match provider {
        "bedrock" => bedrock::offline_prerequisites(),
        _ => Ok(()),
    }
}

/// Deterministic in-process providers used by tests and replay. They are not
/// network routes and must not participate in provider-health recovery.
pub(crate) fn is_internal_simulator(provider: &str) -> bool {
    MockProvider::should_intercept(provider)
        || super::fake::FakeLlmProvider::should_intercept(provider)
}