mesh-llm-config
mesh-llm-config owns the shared config.toml schema, path resolution, file
I/O, preservation-friendly edits, and validation rules used by MeshLLM.
Use this crate when an application or SDK surface needs to read or write the
same ~/.mesh-llm/config.toml file as the CLI without depending on the full
host runtime.
This crate includes:
- typed config data structures such as
MeshConfig,ModelConfigEntry,GpuConfig,PluginConfigEntry, and telemetry settings - high-level authoring APIs for configuring nodes, models, and plugins without hand-writing TOML
- default config path resolution, including
MESH_LLM_CONFIG - validated typed loading through
load_configandConfigStore::load - atomic typed saves through
ConfigStore::save - typed load/edit/save through
ConfigStore::update - TOML parse/serialize helpers used by MeshLLM control-plane payloads
Examples
Load the real MeshLLM config
Use ConfigStore::default_path() when you want the same config file the CLI
uses. It honors MESH_LLM_CONFIG before falling back to
~/.mesh-llm/config.toml.
use ConfigStore;
let store = default_path?;
let config = store.load?;
println!;
Use ConfigStore::open(path) for tests, importers, or explicit config paths.
use ConfigStore;
let store = open;
let config = store.load?;
Configure a local serving node
Configure a local serving node from an SDK or desktop app:
use ;
use ModelRuntimeKind;
let store = default_path?;
store.update?;
This writes the canonical nested config shape and validates it before replacing the file.
Set shared defaults
Use defaults when an app wants all configured models to inherit the same runtime, device, context, or throughput policy.
use ;
use ModelRuntimeKind;
let store = default_path?;
store.update?;
Add or update a model
Model refs are stored as the same strings the CLI understands, so callers can write catalog names, Hugging Face GGUF refs, or direct local model refs without knowing the TOML layout.
use ConfigStore;
use ModelRuntimeKind;
let store = default_path?;
store.update?;
Remove a model through the same typed editor:
use ConfigStore;
let store = default_path?;
store.update?;
Configure plugins
Use plugin helpers for common cases instead of writing [[plugin]] tables.
use ConfigStore;
let store = default_path?;
store.update?;
web_ui_enabled controls only a plugin-declared console projection. It is
independent from .enabled(true), which controls whether the plugin process is
started.
Validate imported TOML
Apps that import or receive TOML can still use the shared parser and validation rules before deciding whether to save.
use ;
let imported = parse_config_toml?;
let canonical_toml = config_to_toml?;
let store = default_path?;
store.save?;
Preserve comments for narrow edits
ConfigStore::update is the preferred high-level API for SDKs and apps. For a
small edit to an existing user-authored file where comments and ordering matter,
use the dedicated preserving helpers.
use ConfigStore;
let store = default_path?;
let models = store.add_model_ref?;
println!;
let models = store.remove_model_ref?;
println!;
Runtime interpretation should stay outside this crate. In particular, plugin resolution, plugin process lifecycle, model serving, live config apply revisions, and mesh control-plane behavior belong in the host runtime or SDK layers that consume this crate.