Universal transport library for 5 CLI AI agents (Claude Code, Codex, Gemini, Cursor, OpenCode). Pipe and PTY transports. TransportSession is a thin router over PipeSession.
//! Internal utility functions shared across the crate.
/// Truncate a string to at most `max` bytes on a char boundary.
////// Canonical implementation — replaces all duplicates from original code.
pub(crate)fntruncate_str(s:&str, max:usize)->&str{if s.len()<= max {
s
}else{letmut end = max;while end >0&&!s.is_char_boundary(end){
end -=1;}&s[..end]}}