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