Skip to main content

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/// Error types and result alias for llm-kernel.
35pub mod error;
36
37#[cfg(feature = "provider")]
38pub mod provider;
39
40#[cfg(feature = "discovery")]
41pub mod discovery;
42
43#[cfg(feature = "secrets")]
44pub mod secrets;
45
46#[cfg(feature = "client-async")]
47pub mod llm;
48
49#[cfg(feature = "store")]
50pub mod store;
51
52#[cfg(feature = "config")]
53pub mod config;
54
55#[cfg(feature = "graph")]
56pub mod graph;
57
58#[cfg(feature = "mcp")]
59pub mod mcp;
60
61#[cfg(feature = "tokens")]
62pub mod tokens;
63
64#[cfg(feature = "install")]
65pub mod install;
66
67#[cfg(feature = "search")]
68pub mod search;
69
70#[cfg(any(feature = "embedding", feature = "embedding-openai"))]
71pub mod embedding;
72
73#[cfg(feature = "telemetry")]
74pub mod telemetry;
75
76#[cfg(feature = "safety")]
77pub mod safety;
78
79pub mod prelude;
80
81/// Returns the crate name (`"llm-kernel"`).
82pub fn name() -> &'static str {
83    "llm-kernel"
84}
85
86/// Returns the crate version (from `Cargo.toml`).
87pub fn version() -> &'static str {
88    env!("CARGO_PKG_VERSION")
89}