pub struct CliRunnerBase { /* private fields */ }Expand description
Shared base struct for all CLI runners.
Holds the common fields (config, model info) that every CLI runner needs. Individual runners wrap this and add only their command-building and response-parsing logic.
A runner holds no conversation state between calls. Every request carries
its whole history, and one runner instance serves every caller in the
process — so a CLI session id kept here and passed back as --resume
would splice one caller’s conversation into the next caller’s turn.
Implementations§
Source§impl CliRunnerBase
impl CliRunnerBase
Sourcepub fn new(
config: RunnerConfig,
default_model: &str,
fallback_models: &[&str],
) -> Self
pub fn new( config: RunnerConfig, default_model: &str, fallback_models: &[&str], ) -> Self
Create a new base with the given config, default model, and fallback model list.
Sourcepub fn default_model(&self) -> &str
pub fn default_model(&self) -> &str
Get the default model identifier
Sourcepub fn available_models(&self) -> &[String]
pub fn available_models(&self) -> &[String]
Get the list of available models
Sourcepub async fn health_check(&self, runner_name: &str) -> Result<bool, RunnerError>
pub async fn health_check(&self, runner_name: &str) -> Result<bool, RunnerError>
Run a --version health check against the runner binary.
Returns true if the binary exits 0, false otherwise.
§Errors
Returns RunnerError if the subprocess cannot be spawned.
Sourcepub fn check_exit_code(
&self,
output: &CliOutput,
runner_name: &str,
) -> Result<(), RunnerError>
pub fn check_exit_code( &self, output: &CliOutput, runner_name: &str, ) -> Result<(), RunnerError>
Check CLI exit code and return an error if non-zero.
Logs output byte lengths (not content) and constructs an error
message that surfaces the most diagnostic stream available.
Stderr is preferred (where well-behaved Unix programs report
errors), but some CLIs — notably claude-code exit-1 paths —
write the error to stdout instead, so a non-empty stdout is used
as a fallback rather than rendering the misleading (no output)
the earlier implementation produced. Up to 500 chars are
surfaced so multi-line diagnostics aren’t truncated to one line.
§Errors
Returns RunnerError::external_service when output.exit_code != 0.