Skip to main content

Module daemon

Module daemon 

Source
Expand description

The shared-world daemon: hosts one ECS world for every agent and serves the control socket. This module holds the CLI-side pieces that plug into the runtime’s daemon library (leviath_runtime::host, leviath_runtime::control_socket): the tool service that bridges tool calls to the built-in / MCP executors and the interaction hub.

Modules§

client
Client-side helpers for talking to the shared-world daemon: building a spawn request from local inputs and exchanging it over the control socket. Shared by lev run (and reusable by other clients). The socket-path resolution + connect live in the binary; these cores are unit-testable against a fake socket server.
config_reload
Hot-reloading of the daemon’s spawn-time config.
fanout_spawner
The daemon-side FanOutSpawner: resolves a fan-out worker’s blueprint (self-at-worker-stage / a named agent / a capability query) and starts it in the shared world, seeded with its work item.
gate_rules
Scripted taint-gate rules: load ~/.config/leviath/rules/*.rhai and build the ScriptRuleChecker the runtime’s taint gate consults after the static allowlist. The daemon owns the Rhai engine (leviath-runtime has no scripting dependency), so the checker is installed as a world resource.
lifecycle
Deciding what lev daemon start / stop / status should do.
mcp_pool
The shared, lazily-connected MCP pool.
readiness
Waiting for the daemon to appear or go away.
recovery
Restart recovery: reload persisted non-terminal agents into a fresh world when the daemon starts, so runs interrupted by a stop/crash resume where they left off - critically, any agent that was mid-inference re-issues that inference (the reloaded agent is ReadyToInfer), rather than being lost.
sandbox_manager
Per-agent sandbox lifecycle and shell-command routing.
script_host
The daemon’s real ScriptHost for Rhai script tools (permission Layer 3).
seed_command
Execution of seed = { command = "..." } region seeds.
setup
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.
spawn
The daemon spawner: turns a SpawnArgs request into a live agent in the shared world - the CLI-side policy the runtime host calls for a Spawn control op.
subagent
Sub-agent tool handlers: turn spawn_agent / check_agent / wait_for_agent / send_to_agent / kill_agent tool calls into SubAgentOps serviced by the host (which owns the world + spawner). The tool lane runs off the world, so it blocks on the host applying each op via a oneshot - the same shape as an interaction.
tool_service
The real ToolService for the shared world: bridges an agent’s tool calls to the built-in and MCP executors, applying the same policy / approval / interaction flow the imperative worker used - but with interactions routed through the in-memory leviath_runtime::interaction_hub instead of file polling.