Skip to main content

vtcode_bash_runner/
lib.rs

1#![allow(missing_docs)]
2//! Cross-platform command runner modeled after VT Code's original bash
3//! wrapper. The crate exposes a trait-based executor so downstream
4//! applications can swap the underlying process strategy (system shell,
5//! pure-Rust emulation, or dry-run logging) while reusing the higher-level
6//! helpers for workspace-safe filesystem manipulation.
7//!
8//! ## Modules
9//!
10//! - [`executor`] - Command execution strategies (process, dry-run, pure-rust)
11//! - [`runner`] - High-level `BashRunner` for workspace-safe operations
12//! - [`background`] - Background task management
13//! - [`pipe`] - Async pipe-based process spawning with unified handles
14//! - [`process`] - Process handle types for PTY and pipe backends
15//! - [`process_group`] - Process group management for reliable cleanup
16//! - [`stream`] - Stream utilities for reading output
17
18pub mod background;
19pub mod executor;
20pub mod pipe;
21pub mod policy;
22pub mod process;
23pub mod process_group;
24pub mod runner;
25pub mod stream;
26
27// Background task management
28pub use background::{BackgroundCommandManager, BackgroundTaskHandle, BackgroundTaskStatus};
29
30// Executor variants
31#[cfg(feature = "dry-run")]
32pub use executor::DryRunCommandExecutor;
33#[cfg(feature = "exec-events")]
34pub use executor::EventfulExecutor;
35#[cfg(feature = "pure-rust")]
36pub use executor::PureRustCommandExecutor;
37pub use executor::{
38    CommandCategory, CommandExecutor, CommandInvocation, CommandOutput, CommandStatus,
39    ProcessCommandExecutor, ShellKind,
40};
41
42// Policy types
43pub use policy::{AllowAllPolicy, CommandPolicy, WorkspaceGuardPolicy};
44
45// Runner
46pub use runner::BashRunner;
47
48// Stream utilities
49pub use stream::{ReadLineResult, read_line_with_limit};
50
51// Pipe-based process spawning (codex-rs compatible)
52pub use pipe::{
53    PipeSpawnOptions, PipeStdinMode, spawn_process as spawn_pipe_process,
54    spawn_process_no_stdin as spawn_pipe_process_no_stdin,
55    spawn_process_with_options as spawn_pipe_process_with_options,
56};
57
58// Process handle types (unified interface for PTY and pipe)
59pub use process::{
60    ChildTerminator, ExecCommandSession, ProcessHandle, PtyHandles, SpawnedProcess, SpawnedPty,
61    collect_output_until_exit,
62};
63
64// Process group utilities
65pub use process_group::{
66    DEFAULT_GRACEFUL_TIMEOUT_MS, GracefulTerminationResult, KillSignal, detach_from_tty,
67    graceful_kill_process_group, graceful_kill_process_group_default,
68    graceful_kill_process_group_default_async, kill_child_process_group,
69    kill_child_process_group_with_signal, kill_process_group, kill_process_group_by_pid,
70    kill_process_group_by_pid_with_signal, kill_process_group_with_signal, set_parent_death_signal,
71    set_process_group,
72};
73
74#[cfg(windows)]
75pub use process_group::kill_process;