Skip to main content

vtcode_bash_runner/
lib.rs

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