llm_kernel/lib.rs
1#![deny(missing_docs)]
2//! # llm-kernel
3//!
4//! Foundation library for Rust AI-native applications.
5//!
6//! Provides a composable, feature-gated set of modules for building
7//! LLM-powered tools, agents, and servers:
8//!
9//! | Feature | Module | Description |
10//! |---------------|-------------|-----------------------------------------------------|
11//! | `provider` | [`provider`] | Provider catalog, model descriptors, pricing — **default** |
12//! | `client-async`| [`llm`] | Async LLM client (OpenAI, Anthropic) with SSE streaming |
13//! | `discovery` | [`discovery`] | Dynamic model discovery (models.dev, Ollama, OpenAI-compat) |
14//! | `secrets` | [`secrets`] | SecretVault — dotenv-style credential management |
15//! | `store` | [`store`] | SQLite init helpers (WAL, PRAGMA, schema versioning) |
16//! | `config` | [`config`] | TOML config loader with auto-create from template |
17//! | `graph` | [`graph`] | Knowledge graph — SQLite, FTS5, smart recall, BFS traversal |
18//! | `mcp` | [`mcp`] | MCP server framework — JSON-RPC 2.0, stdio transport |
19//! | `tokens` | [`tokens`] | Token estimation with Unicode-script heuristics |
20//! | `install` | [`install`] | AI tool installation wizard (Claude, Cursor, Copilot, etc.) |
21//! | `search` | [`search`] | Hybrid search with Reciprocal Rank Fusion |
22//! | `embedding` | [`embedding`] | Embedding provider trait + cosine similarity |
23//! | `telemetry` | [`telemetry`] | Telemetry framework — enum-gated events, no PII |
24//! | `safety` | [`safety`] | Secret masking, error classification, output sanitization |
25//!
26//! ## Quick start
27//!
28//! The [`prelude`] module re-exports the most commonly used types:
29//!
30//! ```no_run
31//! use llm_kernel::prelude::*;
32//! ```
33
34// `embedding-fastembed` (static ONNX Runtime archive) and
35// `embedding-fastembed-dynamic-linking` (runtime `libonnxruntime.{so,dll,dylib}`
36// load) are mutually exclusive. Enabling both unifies `ort-download-binaries-*`
37// and `ort-load-dynamic` on the shared `fastembed`/`ort-sys` crate, which makes
38// ort-sys skip the static-archive download and silently expect a runtime dylib
39// llm-kernel never ships — the original #50/#55 failure mode. Force a hard
40// build error so the conflict can never be silent. See `Cargo.toml` feature
41// docs and #55.
42#[cfg(all(
43 feature = "embedding-fastembed",
44 feature = "embedding-fastembed-dynamic-linking"
45))]
46compile_error!(
47 "embedding-fastembed and embedding-fastembed-dynamic-linking are mutually exclusive \
48 (static vs dynamic ONNX Runtime linking). Enabling both triggers Cargo feature \
49 unification that silently disables the static link path (#50/#55). Enable exactly one."
50);
51
52/// Error types and result alias for llm-kernel.
53pub mod error;
54
55#[cfg(feature = "provider")]
56pub mod provider;
57
58#[cfg(feature = "discovery")]
59pub mod discovery;
60
61#[cfg(feature = "secrets")]
62pub mod secrets;
63
64#[cfg(feature = "client-async")]
65pub mod llm;
66
67#[cfg(feature = "store")]
68pub mod store;
69
70#[cfg(feature = "config")]
71pub mod config;
72
73#[cfg(feature = "graph")]
74pub mod graph;
75
76#[cfg(feature = "mcp")]
77pub mod mcp;
78
79#[cfg(feature = "tokens")]
80pub mod tokens;
81
82#[cfg(feature = "install")]
83pub mod install;
84
85#[cfg(feature = "search")]
86pub mod search;
87
88#[cfg(any(feature = "embedding", feature = "embedding-openai"))]
89pub mod embedding;
90
91#[cfg(feature = "telemetry")]
92pub mod telemetry;
93
94#[cfg(feature = "safety")]
95pub mod safety;
96
97pub mod prelude;
98
99/// Returns the crate name (`"llm-kernel"`).
100pub fn name() -> &'static str {
101 "llm-kernel"
102}
103
104/// Returns the crate version (from `Cargo.toml`).
105pub fn version() -> &'static str {
106 env!("CARGO_PKG_VERSION")
107}