Skip to main content

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` and `vllm serve` are launched and probed, and
8//!   [`Wrap`] for a stock OpenAI-compatible server on loopback.
9//! - [`supervisor`]: the local supervisor: load (random loopback port, per-process API key in
10//!   the environment, readiness probe), drain and unload, swap groups, idle unload, crash
11//!   restarts with backoff and crash loops, [`SupervisorEvent`]s and per-model logs; chat,
12//!   completion and embedding forwarding.
13//! - [`sse`]: OpenAI server-sent events decoded into [`Chunk`]s, and [`ToolCalls`] to join
14//!   streamed tool calls.
15//! - [`openai`]: engine request bodies from `weirdnet-agent` infer/2 requests.
16//! - [`host`]: [`ModelHost`], a `weirdnet-agent` `InferHost` serving raw infer/2 from the
17//!   supervisor's models.
18//! - `node` (feature): `/weirdnet-backends/node/1` over `weirdnet-net`: signed capability
19//!   records, `Load`, `Unload`, `Drain`, `GroupUp`/`GroupDown` and health.
20//!
21//! Platforms: the supervisor runs on Unix and Windows. On Unix an engine gets its own process
22//! group, stops with SIGTERM then SIGKILL after a grace period, and on Linux dies with its
23//! parent; on Windows the engine process is killed outright and processes it started are not.
24//! vLLM runs on Linux only.
25
26pub mod engine;
27pub mod error;
28pub mod host;
29#[cfg(feature = "node")]
30pub mod link;
31#[cfg(feature = "node")]
32pub mod node;
33pub mod openai;
34pub mod sse;
35pub mod supervisor;
36
37pub use engine::{EngineConfig, EngineKind, ModelLaunch, Wrap, find_in_path};
38pub use host::{EngineModel, ModelHost, RAW_INFER_PROTOCOL, RawInferDialer, Speed};
39pub use sse::{Chunk, ChunkDecoder, SseParser, ToolCalls};
40pub use supervisor::{ChunkStream, ModelState, ModelStatus, Supervisor, SupervisorEvent, SupervisorOptions};