Expand description
On-disk run state for background agent executions.
Each run lives under ~/.leviath/runs/<run-id>/ with:
meta.json- run metadata, updated atomically (tmp + rename)output.log- append-only combined worker stdout (legacy/fallback)stages.json- index of per-stage recordsstages/<idx>/output.log- readable agent output for that stagestages/<idx>/logs.log- operational events + tool activitystages/<idx>/context.json- context snapshot for that stage
The dashboard’s activity log is persisted separately at:
~/.leviath/dashboard.log- never cleared, appended across sessions
Structs§
- Context
Snapshot - Snapshot of the full context window, written to
context.jsonalongsidemeta.json. - Region
Entry Snapshot - One content entry within a region, captured at snapshot time.
- Region
Snapshot - Per-region token snapshot written by the background worker after each inference.
- RunMeta
- Metadata for a single background agent run.
- Stage
Record - Metadata record for a single stage within a run.
Enums§
- Force
Cancel Outcome - The outcome of forcing a run to a terminal state on disk.
- RunStatus
- Current status of a background run.
- Stage
RunStatus - Status of an individual stage within a run.
Constants§
- STALE_
AFTER_ SECS - How long a run may claim to be live on disk, while the daemon is not holding it, before anything treats it as abandoned.
Functions§
- append_
dashboard_ log - Append a timestamped line to the persistent dashboard activity log at the
default
dashboard_log_path. Silently ignores I/O errors - best-effort. - append_
dashboard_ log_ to - Append a timestamped line to the dashboard activity log at an explicit
path. Silently ignores I/O errors - the dashboard log is best-effort. - append_
stage_ log - Append a line of operational/tool-activity log to the per-stage logs file.
- append_
stage_ output - Append a line of readable agent output to the per-stage output log.
- context_
history - A run’s context-window history: the full window (+ metadata) at each recorded point over time, oldest first. Empty when there’s no readable archive.
- create_
run - Create the run directory and write initial metadata.
- dashboard_
log_ path - Path to the persistent dashboard activity log (~/.leviath/dashboard.log).
- force_
cancel - Force a run’s on-disk metadata to
Cancelled, in the runs dir resolved from the environment. Seeforce_cancel_in. - force_
cancel_ in - Force the run in
run_dirtoCancelled, stampingupdated_atwithnow. - force_
error_ in - Force the run in
run_dirtoErrorwithmessage, stampingupdated_at. - is_
terminal_ status - Whether an on-disk run status means the run has finished and should be left
alone.
Starting/Running/WaitingInputare all “still going” as far as anything reading the runs dir is concerned. - list_
runs - List all runs, sorted by started_at descending (most recent first). Silently skips any runs whose metadata cannot be read.
- looks_
abandoned - Whether a run that claims to be live on disk has nothing driving it: the
daemon is not holding it and it has not moved in
STALE_AFTER_SECS. - new_
run_ id - Generate a unique run ID:
<agent_name>-<timestamp>-<random>. - read_
context_ snapshot - Read the context snapshot for a run, if present.
- read_
meta - Read run metadata for a given run ID.
- read_
run_ archive - Read + parse a run’s portable archive (
<run_dir>/run.lvr), returning its records, orNoneif the archive is missing or unreadable. - read_
stage_ context - Read the context snapshot for a specific stage, if present.
- read_
stages_ index - Read the stages index for a run, or return an empty vec on any error.
- run_dir
- Directory for a specific run.
- runs_
dir - Directory where all run state is stored.
- stage_
dir - Directory for per-stage files within a run.
- tail_
file - Read the last
max_bytesof any file on disk, returning UTF-8 text. If the file is smaller thanmax_bytesthe whole file is returned. Partial UTF-8 at the truncation boundary is handled by skipping to the first newline. Returns an empty string on any I/O error. - tail_
stage_ log - Read the last
max_bytesof the operational log for a specific stage. - tail_
stage_ output - Read the last
max_bytesof the readable output log for a specific stage. - write_
context_ snapshot - Atomically write a context snapshot for the run.
- write_
meta - Atomically write run metadata (write to tmp, then rename).
- write_
stage_ context - Atomically write a context snapshot for a specific stage.
- write_
stages_ index - Atomically write the stages index for a run.