weirdnet_backends/lib.rs
1//! The Weirdnet model-node wrapper.
2//!
3//! A model node runs models and takes requests, like a llama.cpp or vLLM server (it can be one:
4//! a stock server it only wraps). This crate starts and stops the engines and serves them; it
5//! decides nothing beyond the node: what to load is the caller's decision.
6//!
7//! - [`engine`]: how llama.cpp `llama-server`, `vllm serve` and MLX-LM's `mlx_lm.server` are
8//! launched and probed, each model's [`Capabilities`] (chat, embeddings, images, audio), and
9//! [`Wrap`] for a stock OpenAI-compatible server on loopback.
10//! - [`mlx`]: installing a pinned `mlx-lm` into a venv, and the proxy the supervisor puts in front
11//! of `mlx_lm.server` (API key check, readiness after a one-token completion, `default_model`
12//! rewrite, text only).
13//! - [`supervisor`]: the local supervisor: load (random loopback port, per-process API key in
14//! the environment, readiness probe), drain and unload, swap groups, idle unload, crash
15//! restarts with backoff and crash loops, [`SupervisorEvent`]s and per-model logs; chat,
16//! completion and embedding forwarding.
17//! - [`sse`]: OpenAI server-sent events decoded into [`Chunk`]s, and [`ToolCalls`] to join
18//! streamed tool calls.
19//! - [`openai`]: engine request bodies from `weirdnet-agent` infer/2 requests.
20//! - [`host`]: [`ModelHost`], a `weirdnet-agent` `InferHost` serving raw infer/2 from the
21//! supervisor's models.
22//! - `node` (feature): `/weirdnet-backends/node/1` over `weirdnet-net`: signed capability
23//! records, `Load`, `Unload`, `Drain`, `GroupUp`/`GroupDown` and health.
24//!
25//! Platforms: the supervisor runs on Unix and Windows. On Unix an engine gets its own process
26//! group, stops with SIGTERM then SIGKILL after a grace period, and on Linux dies with its
27//! parent; on Windows the engine process is killed outright and processes it started are not.
28//! vLLM runs on Linux only; MLX-LM on macOS on Apple silicon only.
29
30pub mod engine;
31pub mod error;
32pub mod host;
33#[cfg(feature = "node")]
34pub mod link;
35pub mod mlx;
36#[cfg(feature = "node")]
37pub mod node;
38pub mod openai;
39pub mod sse;
40pub mod supervisor;
41
42pub use engine::{Capabilities, EngineConfig, EngineKind, ModelLaunch, Wrap, find_in_path};
43pub use host::{EngineModel, ModelHost, RAW_INFER_PROTOCOL, RawInferDialer, Speed};
44pub use sse::{Chunk, ChunkDecoder, SseParser, ToolCalls};
45pub use supervisor::{ChunkStream, ModelState, ModelStatus, Supervisor, SupervisorEvent, SupervisorOptions};