Expand description
spn-core: Core types and validation for the SuperNovae ecosystem.
This crate provides:
- Provider definitions (13+ LLM and MCP service providers)
- 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 definitions in one place
- Shared types: Used by spn-cli, spn-client, spn-keyring, 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-••••••••");Structs§
- Chat
Message - A message in a chat conversation.
- Chat
Options - Options for chat completion.
- Chat
Response - Response from a chat completion.
- Embedding
Response - Response from an embedding request.
- GpuInfo
- GPU device information.
- 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.
- 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.
- Running
Model - Information about a currently running/loaded model.
Enums§
- Backend
Error - Error types for backend operations.
- Chat
Role - Role in a chat conversation.
- McpServer
Type - Type of MCP server transport.
- McpSource
- Source of an MCP configuration.
- Package
Type - Type of package in the registry.
- Provider
Category - Category of provider service.
- Source
- Source of a package - where to fetch the actual content.
- Validation
Result - Result of key format validation.
Statics§
- KNOWN_
PROVIDERS - All known providers in the SuperNovae ecosystem.
Functions§
- find_
provider - Find a provider by ID (case-insensitive).
- mask_
key - Mask an API key for safe display.
- provider_
to_ env_ var - Get the environment variable name for a provider.
- providers_
by_ category - Get all providers in a specific category.
- validate_
key_ format - Validate an API key format for a specific provider.