Skip to main content

Crate spn_client

Crate spn_client 

Source
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 running

Structs§

ChatMessage
A message in a chat conversation.
ChatOptions
Options for chat completion.
ChatResponse
Response from a chat completion.
ForeignMcpInfo
Foreign MCP info for watcher status.
GpuInfo
GPU device information.
IpcJobStatus
Job status for IPC responses.
IpcSchedulerStats
Scheduler statistics for IPC responses.
LoadConfig
Configuration for loading a model.
McpConfig
Complete MCP configuration containing multiple servers.
McpServer
MCP server configuration.
ModelInfo
Information about an installed model.
ModelProgress
Progress update for model operations (pull, load, delete).
PackageManifest
Package manifest (spn.yaml content).
PackageRef
Reference to a package in the registry.
Provider
Provider metadata.
PullProgress
Progress information during model pull/download.
RecentProjectInfo
Recent project info for watcher status.
RunningModel
Information about a currently running/loaded model.
SpnClient
Client for communicating with the spn daemon.
SpnPaths
Centralized path management for the ~/.spn directory structure.
WatcherStatusInfo
Watcher status for IPC responses.

Enums§

BackendError
Error types for backend operations.
ChatRole
Role in a chat conversation.
Error
Errors that can occur when communicating with the spn daemon.
IpcJobState
Job state in the scheduler (IPC version).
McpServerType
Type of MCP server transport.
McpSource
Source of an MCP configuration.
PackageType
Type of package in the registry.
PathError
Error type for path operations.
ProviderCategory
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.
ValidationResult
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§

ExposeSecret
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§

SecretString
Secret string type.