Skip to main content

Module setup

Module setup 

Source
Expand description

Daemon assembly: build a fully-wired WorldHost (world + tool service + interaction hub + the blueprint spawner) ready to be driven by WorldHost::serve. The async setup (provider registry, MCP connections) happens in the binary and is passed in; this wiring is synchronous and testable - spawning an agent through the installed spawner exercises the whole path.

Constants§

CURRENT_BUILD
This CLI binary’s build id (short git hash, -dirty when the tree had uncommitted changes), embedded at compile time by build.rs. A long-lived daemon records the build it started from; a mismatch means the installed binary is newer and the daemon is running stale code.

Functions§

build_host
Build the daemon’s WorldHost: one world hosting every agent, its tool service + interaction hub, and a Spawn-op spawner that loads blueprints and registers per-agent tool state. shared_mcp / mcp_tool_defs are the MCP connections built once at startup and reused by every agent.
build_marker_path
Path to the file where a running daemon records its build id (<leviath-home>/.leviath/daemon.build).
control_address
The daemon’s control-channel id, derived from <leviath-home>/.leviath (honoring LEVIATH_HOME): a Unix-socket path on Unix, a named-pipe name on Windows. None if no home directory can be resolved.
control_dir
The directory holding the control channel and its token.
daemon_build_is_stale
Whether a running daemon should be restarted because it is on a different build than this CLI (or recorded no build at all - e.g. it predates this check).
read_build_marker
The build id a running daemon recorded, if the marker exists and is readable.
setup_daemon_host
Build the daemon’s WorldHost, doing the async startup work: build the provider registry from config and connect the shared MCP servers (both reused by every agent), then wire the host + spawner via build_host.
write_build_marker
Record CURRENT_BUILD so the CLI can detect a stale daemon later. Best-effort - a missing marker just triggers a restart on the next command.