Skip to main content

Crate nika_daemon

Crate nika_daemon 

Source
Expand description

Nika native daemon — background services for secrets, jobs, watch, and cache.

The daemon is Nika’s optional background brain. nika run works without it, but the daemon adds persistent features: keychain secrets, job scheduling, file watching, and LLM response caching.

§Architecture

  • Single binary: nika daemon start uses the same binary
  • Unix socket IPC: ~/.nika/daemon/nika.sock
  • Wire format: 4-byte big-endian length + JSON payload
  • tokio-native async runtime

§Crate Independence

This crate depends on nika-core only (for path constants and provider info). It does NOT depend on nika-engine — the daemon is lightweight.

Re-exports§

pub use client::read_auth_token;
pub use client::ConnectedClient;
pub use client::DaemonClient;
pub use error::DaemonError;
pub use error::DaemonResult;
pub use protocol::DaemonRequest;
pub use protocol::DaemonResponse;
pub use server::DaemonConfig;
pub use server::DaemonServer;

Modules§

client
Daemon client — connects to the daemon over Unix socket.
error
Daemon error types.
events
Event bus — broadcast channel for daemon events.
install
Daemon auto-start installation — launchd (macOS) + systemd (Linux).
lifecycle
Daemon lifecycle — PID file, daemonize, signal handling.
protocol
IPC protocol — message types and wire format.
server
Daemon server — accepts connections on Unix socket and routes requests.
services
Daemon services — secrets, jobs, watch, cache.
storage
SQLite storage layer for jobs and cache.

Constants§

NIKA_HOME_ENV
Environment variable to override the Nika home directory.

Functions§

daemon_dir
Returns the daemon directory (~/.nika/daemon/).
daemon_log_path
Returns the daemon log file path (~/.nika/daemon/nika.log).
daemon_pid_path
Returns the daemon PID file path (~/.nika/daemon/nika.pid).
daemon_socket_path
Returns the daemon socket path (~/.nika/daemon/nika.sock).
daemon_token_path
Returns the daemon auth token file path (~/.nika/daemon/.token).