Skip to main content

leviath_core/
lib.rs

1//! # Leviath Core
2//!
3//! Core types and traits for the Leviath agent framework.
4//!
5//! This crate provides the foundational types for building agents with structured,
6//! hardware-inspired context window management. It includes:
7//!
8//! - **Regions**: Typed memory regions with different lifecycle policies
9//! - **Layouts**: Complete memory maps defining how context is structured
10//! - **Blueprints**: Agent definitions including stages, models, and tools
11//! - **Lifecycle**: Policies for eviction, compaction, and context management
12
13pub mod blueprint;
14pub mod cache;
15pub mod config;
16pub mod context_cause;
17pub mod credentials;
18pub mod duration;
19pub mod error;
20pub mod execution;
21pub mod files;
22pub mod interaction;
23pub mod layout;
24pub mod lifecycle;
25pub mod manifest;
26pub mod mcp_names;
27pub mod mime;
28pub mod output;
29pub mod panic_payload;
30pub mod paths;
31pub mod policy;
32pub mod read_paths;
33pub mod region;
34pub mod run_archive;
35pub mod run_meta;
36pub mod sandbox;
37pub mod secrets;
38pub mod sync;
39pub mod taint;
40pub mod telemetry;
41pub mod text;
42pub mod write_limits;
43
44pub use blueprint::{
45    Blueprint, ContextTransform, EdgeTransform, FileTrackingConfig, NudgeConfig, ReadPathsConfig,
46    RepetitionDetectionConfig, ResolvedNudge, Stage, StuckConfig, ToolResultRouting,
47    TransitionCondition, TransitionEdge, resolve_nudge,
48};
49pub use cache::CacheHint;
50pub use context_cause::ContextCause;
51pub use credentials::{
52    CredentialStore, CredentialStoreKind, MemoryStore, mcp_account, provider_account,
53};
54pub use error::{Error, Result, ValidationError};
55pub use layout::{BudgetSpec, ContextLayout, RegionDefinition};
56pub use lifecycle::CompactionConfig;
57pub use output::{
58    FINAL_OUTPUT_FILE, FinalOutput, FinalOutputDescriptor, MAX_FINAL_OUTPUT_BYTES, OutputSpec,
59    describe_spec, resolve_output_spec,
60};
61pub use panic_payload::panic_message;
62pub use paths::{
63    agents_dir, canonicalize_for_match, data_dir, home_dir, is_safe_path_component, providers_dir,
64    resolves_within, tools_dir,
65};
66pub use policy::{AllowlistRule, McpToolOverride, PolicyConfig};
67pub use read_paths::{
68    ReadPathDecision, ReadPathEntry, ReadPathPolicy, ReadPathSet, validate_entry_syntax,
69};
70pub use region::{
71    ContentFormat, EntryKind, EvictionStrategy, Region, RegionEntry, RegionKind, RegionSchema,
72    SerializedToolCall, Volatility,
73};
74pub use sandbox::{OnUnavailable, SandboxKind, ToolSandboxConfig, resolve_sandbox};
75pub use secrets::{
76    ShellEnvMode, child_env_allowed, constant_time_eq, dotenv_var_allowed, is_secret_header,
77    is_sensitive_env_name, redact, script_env_allowed, withheld_child_vars,
78};
79pub use taint::{
80    GateDecision, GateDecisionSource, GateEvent, RegionTaint, SecurityConfig, TaintLevel,
81    ToolClassification, ToolDirection,
82};
83pub use text::{estimate_tokens, floor_char_boundary, truncate_at_boundary, truncate_chars};
84
85/// Serde default for a flag that is on unless a file turns it off.
86///
87/// `#[serde(default)]` on a `bool` is `false`, so every "on by default" field
88/// needs a named function, and eight modules across two crates had written
89/// this one. Name it as `default = "crate::default_true"` inside this crate and
90/// `"leviath_core::default_true"` outside it; serde pastes the path as written.
91pub fn default_true() -> bool {
92    true
93}