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