Skip to main content

agent_core/
lib.rs

1//! `agent-core` — foundational types, config, session, auth, logging,
2//! protocol, memory, and pricing. Leaf crate: no in-repo upward deps.
3
4pub mod core;
5pub mod memory;
6pub mod pricing;
7
8// Re-export stream event types at crate root so engine/tui can import them
9// cleanly as `agent_core::{StreamEvent, LlmEvent, ...}` without digging
10// into the internal module path.
11pub use core::stream_types::{
12    next_turn_correlation_id, AgentEvent, BudgetDimension, LlmEvent, SessionEvent, SharedMessage,
13    StreamEvent, TurnError, TurnOutcome,
14};
15
16// Replicate the root lib.rs aliases so internal `crate::config`,
17// `crate::models`, `crate::session`, etc. resolve INSIDE agent-core.
18pub use core::auth;
19pub use core::chain;
20pub use core::compaction;
21pub use core::config;
22pub use core::disclosure;
23pub use core::error;
24pub use core::logging;
25pub use core::models;
26pub use core::private_fs;
27pub use core::protocol;
28pub use core::reasoning;
29pub use core::retention;
30pub use core::session;
31pub use core::session_journal;
32pub use core::watcher_types;
33
34/// Current time as Unix epoch milliseconds. Panics only if system clock is before 1970.
35#[inline]
36pub fn epoch_millis() -> u64 {
37    std::time::SystemTime::now()
38        .duration_since(std::time::UNIX_EPOCH)
39        .expect("system clock before Unix epoch")
40        .as_millis() as u64
41}
42
43// Expose Result + RuntimeError at crate root so `crate::Result<T>` resolves
44// inside agent-core modules (mirrors root lib.rs lines 28-29).
45pub use error::{Result, RuntimeError};
46
47/// Truncate a string to at most `max` bytes at a valid UTF-8 boundary.
48#[inline]
49pub fn truncate_str(s: &str, max: usize) -> &str {
50    if s.len() <= max {
51        return s;
52    }
53    let mut end = max;
54    while end > 0 && !s.is_char_boundary(end) {
55        end -= 1;
56    }
57    &s[..end]
58}
59
60pub mod orchestration;
61pub mod prompt;
62pub mod text;
63
64pub use text::BoundedText;