Skip to main content

zag_agent/
lib.rs

1pub mod agent;
2pub mod attachment;
3pub mod auto_selector;
4pub mod builder;
5pub mod capability;
6pub mod config;
7pub mod factory;
8pub mod file_util;
9pub mod json_validation;
10pub mod listen;
11pub mod manpages;
12pub mod mcp;
13pub mod output;
14pub mod plan;
15pub mod preflight;
16pub mod process;
17pub mod process_registration;
18pub mod process_store;
19pub mod progress;
20pub mod providers;
21pub mod review;
22pub mod sandbox;
23pub mod search;
24pub mod session;
25pub mod session_log;
26pub mod skills;
27pub mod streaming;
28pub mod worktree;
29
30/// Truncate a string to at most `max_bytes` bytes, rounding down to a valid
31/// UTF-8 char boundary. Equivalent to `str::floor_char_boundary` (Rust 1.91+).
32pub(crate) fn truncate_str(s: &str, max_bytes: usize) -> &str {
33    if max_bytes >= s.len() {
34        return s;
35    }
36    let mut end = max_bytes;
37    while end > 0 && !s.is_char_boundary(end) {
38        end -= 1;
39    }
40    &s[..end]
41}
42
43#[cfg(test)]
44#[path = "mock_integration_tests.rs"]
45mod mock_integration_tests;