#![deny(unsafe_code)] #![warn(missing_docs)] //! Shared runtime assembly for every interface mode. //! //! One runtime shape serves eval and RPC: resolve an endpoint from the //! catalog, validate credentials without dispatch, and drive the //! provider-independent agent. `mock` provides a scripted provider for //! offline runs and tests. /// Host-owned models.dev catalog fetch and persistent cache. pub mod catalog; /// Typed connection configuration and source precedence. pub mod connection_settings; pub mod durable; pub mod http; /// Read-only session inspection without provider or tool initialization. pub mod inspection; /// Capability-sealed host OAuth lifecycle and metadata-only profiles. pub mod oauth; mod oauth_crypto; /// Interactive read-only observer assembled on a storage worker. pub mod observer; /// User-private runtime notification for validated plugin generations. pub mod plugin_control; pub mod plugins; /// Shared provider protocol bridge. /// /// Connections supply vendor policy. pub mod protocol; mod response_sanitizer; pub mod runtime; /// Bounded session storage requests, executed off the caller thread. pub mod storage; /// Persisted project trust decisions and capability grants. pub mod trust; pub mod wasm; pub use runtime::{RuntimeConfig, RuntimeProvider, build_agent}; pub use smith_ai::auth::{ AuthStore, CredentialKey, credential_env_var, credential_env_vars, credential_key_env_var_present, credential_key_env_vars, }; pub use smith_ai::models::{ModelCapabilities, ProviderKind}; pub use smith_ai::refresh::{CatalogSnapshot, RefreshOutcome}; use smith::id::MessageId; use smith::provider::{ProviderStream, StreamFn}; use smith::stream::StreamEvent; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; /// A scripted mock provider: one canned response per request, then a final /// apologetic refusal. #[must_use] pub fn mock_stream(script: Vec>) -> StreamFn { let script: Arc<[Vec]> = script.into(); let next = AtomicUsize::new(0); Arc::new(move |_request, _cancel| { let index = next.fetch_add(1, Ordering::Relaxed); let response = script.get(index).cloned().unwrap_or_default(); let stream: ProviderStream = Box::pin(futures::stream::iter(response.into_iter().map(Ok))); stream }) } /// Convenience: a mock reply of plain text. #[must_use] pub fn mock_text_reply(text: &str) -> Vec { vec![ StreamEvent::text_delta(MessageId::new(), text), StreamEvent::stop(smith::stream::StopReason::EndTurn, None), ] }