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