Skip to main content

vtcode_bash_runner/
lib.rs

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