Expand description
§spn-client
Client library for communicating with the spn daemon.
This crate provides a simple interface for applications (like Nika) to securely retrieve secrets from the spn daemon without directly accessing the OS keychain.
§Usage
use spn_client::{SpnClient, ExposeSecret};
// Connect to the daemon
let mut client = SpnClient::connect().await?;
// Get a secret
let api_key = client.get_secret("anthropic").await?;
println!("Got key: {}", api_key.expose_secret());
// Check if a secret exists
if client.has_secret("openai").await? {
println!("OpenAI key available");
}
// List all providers
let providers = client.list_providers().await?;
println!("Available providers: {:?}", providers);§Fallback Mode
If the daemon is not running, the client can fall back to reading from environment variables:
use spn_client::SpnClient;
let mut client = SpnClient::connect_with_fallback().await?;
// Works even if daemon is not runningStructs§
- Chat
Message - A message in a chat conversation.
- Chat
Options - Options for chat completion.
- Chat
Response - Response from a chat completion.
- GpuInfo
- GPU device information.
- IpcJob
Status - Job status for IPC responses.
- IpcScheduler
Stats - Scheduler statistics for IPC responses.
- 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.
- Model
Progress - Progress update for model operations (pull, load, delete).
- 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.
- SpnClient
- Client for communicating with the spn daemon.
- SpnPaths
- Centralized path management for the ~/.spn directory structure.
Enums§
- Backend
Error - Error types for backend operations.
- Chat
Role - Role in a chat conversation.
- Error
- Errors that can occur when communicating with the spn daemon.
- IpcJob
State - Job state in the scheduler (IPC version).
- McpServer
Type - Type of MCP server transport.
- McpSource
- Source of an MCP configuration.
- Package
Type - Type of package in the registry.
- Path
Error - Error type for path operations.
- Provider
Category - Category of provider service.
- Request
- Request sent to the daemon.
- Response
- Response from the daemon.
- Source
- Source of a package - where to fetch the actual content.
- Validation
Result - Result of key format validation.
Constants§
- DEFAULT_
IPC_ TIMEOUT - Default timeout for IPC operations (30 seconds).
- PROTOCOL_
VERSION - Current protocol version.
Statics§
- KNOWN_
PROVIDERS - All known providers in the SuperNovae ecosystem.
Traits§
- Expose
Secret - Expose a reference to an inner secret
Functions§
- daemon_
socket_ exists - Check if the daemon socket exists.
- 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.
- socket_
path - Get socket path for the spn daemon, returning an error if HOME is unavailable.
- validate_
key_ format - Validate an API key format for a specific provider.
Type Aliases§
- Secret
String - Secret string type.