Expand description
spn-core: Core types and validation for the SuperNovae ecosystem.
This crate provides:
- Provider definitions (20+ LLM and MCP service providers)
- Model definitions (curated models for native inference)
- Model storage trait (download-only, no inference)
- Key format validation with detailed error messages
- MCP server configuration types
- Package registry types
§Design Principles
- Zero dependencies: Pure Rust, fast compilation, WASM-compatible
- Single source of truth: All provider and model definitions in one place
- Shared types: Used by spn-cli, spn-client, spn-keyring, spn-native, and nika
§Example
use spn_core::{
Provider, ProviderCategory, KNOWN_PROVIDERS,
find_provider, provider_to_env_var,
validate_key_format, mask_key, ValidationResult,
};
// Find a provider
let provider = find_provider("anthropic").unwrap();
assert_eq!(provider.env_var, "ANTHROPIC_API_KEY");
// Validate a key format
match validate_key_format("anthropic", "sk-ant-api03-xxx") {
ValidationResult::Valid => println!("Key is valid!"),
ValidationResult::InvalidPrefix { expected, .. } => {
println!("Key should start with: {}", expected);
}
_ => {}
}
// Mask a key for display
let masked = mask_key("sk-ant-secret-key-12345");
assert_eq!(masked, "sk-ant-••••••••");§Model Resolution
use spn_core::{find_model, resolve_model, ResolvedModel, Quantization};
// Find a curated model
let model = find_model("qwen3:8b").unwrap();
assert_eq!(model.model_type.name(), "Text");
// Resolve model (curated or HuggingFace passthrough)
match resolve_model("hf:bartowski/Qwen3-8B-GGUF") {
Some(ResolvedModel::HuggingFace { repo }) => {
println!("HF repo: {}", repo);
}
Some(ResolvedModel::Curated(model)) => {
println!("Curated: {}", model.name);
}
None => {}
}
// Auto-select quantization based on RAM
use spn_core::auto_select_quantization;
let model = find_model("qwen3:8b").unwrap();
let quant = auto_select_quantization(model, 16); // 16GB RAM
assert_eq!(quant, Quantization::Q8_0);Structs§
- Backup
Contents - Summary of what each subsystem contributed to the backup.
- Backup
Info - Information about a completed backup.
- Backup
Manifest - Backup manifest containing metadata about the backup.
- Chat
Message - A message in a chat conversation.
- Chat
Options - Options for chat completion.
- Chat
Response - Response from a chat completion.
- Component
Versions - Component version information.
- Download
Request - Request to download a model.
- Download
Result - Result of a model download.
- Embedding
Response - Response from an embedding request.
- GpuInfo
- GPU device information.
- Known
Model - A curated model in the registry.
- Load
Config - Configuration for loading a model.
- McpConfig
- Complete MCP configuration containing multiple servers.
- McpServer
- MCP server configuration.
- Model
Info - Information about an installed model.
- Nika
Contents - Nika-specific backup contents.
- Nova
NetContents - NovaNet-specific backup contents.
- Package
Manifest - Package manifest (spn.yaml content).
- Package
Ref - Reference to a package in the registry.
- Provider
- Provider metadata.
- Pull
Progress - Progress information during model pull/download.
- Restore
Info - Information about a completed restore.
- Running
Model - Information about a currently running/loaded model.
- SpnContents
- spn-specific backup contents.
Enums§
- Backend
Error - Error types for backend operations.
- Backup
Error - Backup operation errors.
- Chat
Role - Role in a chat conversation.
- McpServer
Type - Type of MCP server transport.
- McpSource
- Source of an MCP configuration.
- Model
Architecture - Architecture supported by mistral.rs v0.7.0.
- Model
Type - Model capability type.
- Package
Type - Type of package in the registry.
- Provider
Category - Category of provider service.
- Quantization
- Quantization levels for GGUF models.
- Resolved
Model - Result of model resolution.
- Source
- Source of a package - where to fetch the actual content.
- Validation
Result - Result of key format validation.
Statics§
- KNOWN_
MODELS - Curated model registry.
- KNOWN_
PROVIDERS - All known providers in the SuperNovae ecosystem.
Traits§
- Model
Storage - Model storage backend (sync version).
Functions§
- auto_
select_ quantization - Auto-select quantization based on available RAM.
- default_
model_ dir - Default model storage directory (fallback when
dirsfeature is disabled). - detect_
available_ ram_ gb - Detect available system RAM in gigabytes.
- find_
model - Find a curated model by ID.
- find_
provider - Find a provider by ID (case-insensitive).
- mask_
key - Mask an API key for safe display.
- models_
by_ type - List all models of a specific type.
- provider_
to_ env_ var - Get the environment variable name for a provider.
- providers_
by_ category - Get all providers in a specific category.
- resolve_
model - Resolve a model ID to a
KnownModelor HuggingFace passthrough. - validate_
key_ format - Validate an API key format for a specific provider.
Type Aliases§
- Progress
Callback - Type alias for download progress callbacks.