pub struct Runner {
pub mode: RunnerMode,
pub wsl_options: WslOptions,
pub buffer_config: BufferConfig,
}Expand description
Runner for cross-platform Claude CLI execution with automatic detection
Fields§
§mode: RunnerModeThe execution mode to use
wsl_options: WslOptionsWSL-specific configuration options
buffer_config: BufferConfigOutput buffering configuration
Implementations§
Source§impl Runner
impl Runner
Sourcepub fn detect_auto() -> Result<RunnerMode, RunnerError>
pub fn detect_auto() -> Result<RunnerMode, RunnerError>
Detect the best runner mode automatically
On Windows:
- Try
claude --versionon PATH -> Native if succeeds - Else try
wsl -e claude --version-> WSL if returns 0 - Else: friendly preflight error suggesting
wsl --installif needed
On Linux/macOS: always Native
Sourcepub fn test_native_claude() -> Result<(), RunnerError>
pub fn test_native_claude() -> Result<(), RunnerError>
Test if native Claude CLI is available
Sourcepub fn test_wsl_claude() -> Result<(), RunnerError>
pub fn test_wsl_claude() -> Result<(), RunnerError>
Test if WSL Claude CLI is available
Sourcepub fn validate(&self) -> Result<(), RunnerError>
pub fn validate(&self) -> Result<(), RunnerError>
Validate the runner configuration
Sourcepub fn description(&self) -> String
pub fn description(&self) -> String
Get a user-friendly description of the runner configuration
Source§impl Runner
impl Runner
Sourcepub fn new(mode: RunnerMode, wsl_options: WslOptions) -> Self
pub fn new(mode: RunnerMode, wsl_options: WslOptions) -> Self
Create a new Runner with the specified mode and options
Sourcepub const fn with_buffer_config(
mode: RunnerMode,
wsl_options: WslOptions,
buffer_config: BufferConfig,
) -> Self
pub const fn with_buffer_config( mode: RunnerMode, wsl_options: WslOptions, buffer_config: BufferConfig, ) -> Self
Create a new Runner with custom buffer configuration
Sourcepub fn parse_ndjson(stdout: &str) -> NdjsonResult
pub fn parse_ndjson(stdout: &str) -> NdjsonResult
Parse NDJSON output from Claude CLI
Treats stdout as NDJSON where each line is a JSON object.
Returns the last valid JSON object found, or NoValidJson with a tail excerpt.
§Arguments
stdout- The stdout content to parse
§Returns
NdjsonResult::ValidJson- If at least one valid JSON object was found (returns the last one)NdjsonResult::NoValidJson- If no valid JSON was found (includes tail excerpt for error reporting)
Sourcepub fn auto() -> Result<Self, RunnerError>
pub fn auto() -> Result<Self, RunnerError>
Create a Runner with automatic detection
The runner will be in Auto mode and will detect the appropriate concrete mode (Native or WSL) during execution.
§Internal API
This is an internal helper for future use. The CLI only supports native and wsl
modes via --runner-mode. Auto mode detection is handled internally when the config
specifies runner_mode = "auto", but goes through Runner::with_buffer_config().
Sourcepub async fn execute_claude(
&self,
args: &[String],
stdin_content: &str,
timeout_duration: Option<Duration>,
) -> Result<ClaudeResponse, RunnerError>
pub async fn execute_claude( &self, args: &[String], stdin_content: &str, timeout_duration: Option<Duration>, ) -> Result<ClaudeResponse, RunnerError>
Execute Claude CLI with the configured runner mode
Uses wsl.exe --exec with argv (no shell) for WSL execution and pipes packet via STDIN.
Records runner_distro from wsl -l -q or $WSL_DISTRO_NAME for WSL mode.
Source§impl Runner
impl Runner
Sourcepub fn get_claude_version_sync(&self) -> Result<String, RunnerError>
pub fn get_claude_version_sync(&self) -> Result<String, RunnerError>
Get the Claude CLI version synchronously, respecting runner mode
This method is used during initialization to capture the Claude CLI version without requiring an async runtime. It correctly routes through WSL when the runner is configured for WSL mode.
§Returns
Ok(String)- The version string (e.g., “0.8.1”)Err(RunnerError)- Failed to execute or parse version