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