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 credentials;
17pub mod duration;
18pub mod error;
19pub mod files;
20pub mod interaction;
21pub mod layout;
22pub mod lifecycle;
23pub mod manifest;
24pub mod output;
25pub mod panic_payload;
26pub mod paths;
27pub mod policy;
28pub mod read_paths;
29pub mod region;
30pub mod run_archive;
31pub mod run_meta;
32pub mod sandbox;
33pub mod secrets;
34pub mod sync;
35pub mod taint;
36pub mod telemetry;
37pub mod text;
38pub mod write_limits;
39
40pub use blueprint::{
41    Blueprint, ContextTransform, EdgeTransform, FileTrackingConfig, NudgeConfig, ReadPathsConfig,
42    RepetitionDetectionConfig, ResolvedNudge, Stage, StuckConfig, ToolResultRouting,
43    TransitionCondition, TransitionEdge, resolve_nudge,
44};
45pub use cache::CacheHint;
46pub use credentials::{
47    CredentialStore, CredentialStoreKind, MemoryStore, mcp_account, provider_account,
48};
49pub use error::{Error, Result, ValidationError};
50pub use layout::{BudgetSpec, ContextLayout, RegionDefinition};
51pub use lifecycle::CompactionConfig;
52pub use output::{
53    FINAL_OUTPUT_FILE, FinalOutput, FinalOutputDescriptor, MAX_FINAL_OUTPUT_BYTES, OutputSpec,
54    describe_spec, resolve_output_spec,
55};
56pub use panic_payload::panic_message;
57pub use paths::{
58    agents_dir, canonicalize_for_match, data_dir, home_dir, is_safe_path_component, providers_dir,
59    resolves_within, tools_dir,
60};
61pub use policy::{AllowlistRule, McpToolOverride, PolicyConfig};
62pub use read_paths::{
63    ReadPathDecision, ReadPathEntry, ReadPathPolicy, ReadPathSet, validate_entry_syntax,
64};
65pub use region::{
66    ContentFormat, EntryKind, EvictionStrategy, Region, RegionEntry, RegionKind, RegionSchema,
67    SerializedToolCall, Volatility,
68};
69pub use sandbox::{OnUnavailable, SandboxKind, ToolSandboxConfig, resolve_sandbox};
70pub use secrets::{
71    ShellEnvMode, child_env_allowed, constant_time_eq, dotenv_var_allowed, is_secret_header,
72    is_sensitive_env_name, redact, script_env_allowed, withheld_child_vars,
73};
74pub use taint::{
75    GateDecision, GateDecisionSource, GateEvent, RegionTaint, SecurityConfig, TaintLevel,
76    ToolClassification, ToolDirection,
77};
78pub use text::{estimate_tokens, floor_char_boundary, truncate_at_boundary, truncate_chars};
79
80/// Serde default for a flag that is on unless a file turns it off.
81///
82/// `#[serde(default)]` on a `bool` is `false`, so every "on by default" field
83/// needs a named function, and eight modules across two crates had written
84/// this one. Name it as `default = "crate::default_true"` inside this crate and
85/// `"leviath_core::default_true"` outside it; serde pastes the path as written.
86pub fn default_true() -> bool {
87    true
88}