pub struct CliBackend {
pub command: String,
pub args: Vec<String>,
pub prompt_mode: PromptMode,
pub prompt_flag: Option<String>,
pub output_format: OutputFormat,
}Expand description
A CLI backend configuration for executing prompts.
Fields§
§command: StringThe command to execute.
args: Vec<String>Additional arguments before the prompt.
prompt_mode: PromptModeHow to pass the prompt.
prompt_flag: Option<String>Argument flag for prompt (if prompt_mode is Arg).
output_format: OutputFormatOutput format emitted by this backend.
Implementations§
Source§impl CliBackend
impl CliBackend
Sourcepub fn from_config(config: &CliConfig) -> Result<Self, CustomBackendError>
pub fn from_config(config: &CliConfig) -> Result<Self, CustomBackendError>
Creates a backend from configuration.
§Errors
Returns CustomBackendError if backend is “custom” but no command is specified.
Sourcepub fn claude() -> Self
pub fn claude() -> Self
Creates the Claude backend.
Uses -p flag for headless/print mode execution. This runs Claude
in non-interactive mode where it executes the prompt and exits.
For interactive mode, stdin is used instead (handled in build_command).
Emits --output-format stream-json for NDJSON streaming output.
Note: --verbose is required when using --output-format stream-json with -p.
Sourcepub fn claude_interactive() -> Self
pub fn claude_interactive() -> Self
Creates the Claude backend for interactive prompt injection.
Runs Claude without -p flag, passing prompt as a positional argument.
Used by SOP runner for interactive command injection.
Note: This is NOT for TUI mode - Ralph’s TUI uses the standard claude()
backend. This is for cases where Claude’s interactive mode is needed.
Uses = syntax for --disallowedTools to prevent variadic consumption
of the positional prompt argument.
Sourcepub fn kiro() -> Self
pub fn kiro() -> Self
Creates the Kiro backend.
Uses kiro-cli in headless mode with all tools trusted.
Sourcepub fn kiro_with_agent(agent: String, extra_args: &[String]) -> Self
pub fn kiro_with_agent(agent: String, extra_args: &[String]) -> Self
Creates the Kiro backend with a specific agent and optional extra args.
Uses kiro-cli with –agent flag to select a specific agent.
Sourcepub fn from_name_with_args(
name: &str,
extra_args: &[String],
) -> Result<Self, CustomBackendError>
pub fn from_name_with_args( name: &str, extra_args: &[String], ) -> Result<Self, CustomBackendError>
Creates a backend from a named backend with additional args.
§Errors
Returns error if the backend name is invalid.
Sourcepub fn from_name(name: &str) -> Result<Self, CustomBackendError>
pub fn from_name(name: &str) -> Result<Self, CustomBackendError>
Creates a backend from a named backend string.
§Errors
Returns error if the backend name is invalid.
Sourcepub fn from_hat_backend(
hat_backend: &HatBackend,
) -> Result<Self, CustomBackendError>
pub fn from_hat_backend( hat_backend: &HatBackend, ) -> Result<Self, CustomBackendError>
Creates a backend from a HatBackend configuration.
§Errors
Returns error if the backend configuration is invalid.
Sourcepub fn copilot() -> Self
pub fn copilot() -> Self
Creates the Copilot backend for autonomous mode.
Uses GitHub Copilot CLI with --allow-all-tools for automated tool approval.
Output is plain text (no JSON streaming available).
Sourcepub fn copilot_tui() -> Self
pub fn copilot_tui() -> Self
Creates the Copilot TUI backend for interactive mode.
Runs Copilot in full interactive mode (no -p flag), allowing Copilot’s native TUI to render. The prompt is passed as a positional argument.
Sourcepub fn for_interactive_prompt(
backend_name: &str,
) -> Result<Self, CustomBackendError>
pub fn for_interactive_prompt( backend_name: &str, ) -> Result<Self, CustomBackendError>
Creates a backend configured for interactive mode with initial prompt.
This factory method returns the correct backend configuration for running an interactive session with an initial prompt. The key differences from headless mode are:
| Backend | Interactive + Prompt |
|---|---|
| Claude | positional arg (no -p flag) |
| Kiro | removes --no-interactive |
| Gemini | uses -i instead of -p |
| Codex | no exec subcommand |
| Amp | removes --dangerously-allow-all |
| Copilot | removes --allow-all-tools |
| OpenCode | run subcommand with positional prompt |
§Errors
Returns CustomBackendError if the backend name is not recognized.
Sourcepub fn kiro_interactive() -> Self
pub fn kiro_interactive() -> Self
Kiro in interactive mode (removes –no-interactive).
Unlike headless kiro(), this allows the user to interact with
Kiro’s TUI while still passing an initial prompt.
Sourcepub fn gemini_interactive() -> Self
pub fn gemini_interactive() -> Self
Gemini in interactive mode with initial prompt (uses -i, not -p).
Critical quirk: Gemini requires -i flag for interactive+prompt mode.
Using -p would make it run headless and exit after one response.
Sourcepub fn codex_interactive() -> Self
pub fn codex_interactive() -> Self
Codex in interactive TUI mode (no exec subcommand).
Unlike headless codex(), this runs without exec and --full-auto
flags, allowing interactive TUI mode.
Sourcepub fn amp_interactive() -> Self
pub fn amp_interactive() -> Self
Amp in interactive mode (removes –dangerously-allow-all).
Unlike headless amp(), this runs without the auto-approve flag,
requiring user confirmation for tool usage.
Sourcepub fn copilot_interactive() -> Self
pub fn copilot_interactive() -> Self
Copilot in interactive mode (removes –allow-all-tools).
Unlike headless copilot(), this runs without the auto-approve flag,
requiring user confirmation for tool usage.
Sourcepub fn opencode() -> Self
pub fn opencode() -> Self
Creates the OpenCode backend for autonomous mode.
Uses OpenCode CLI with run subcommand. The prompt is passed as a
positional argument after the subcommand:
opencode run "prompt text here"Output is plain text (no JSON streaming available).
Sourcepub fn opencode_tui() -> Self
pub fn opencode_tui() -> Self
Creates the OpenCode TUI backend for interactive mode.
Runs OpenCode with run subcommand. The prompt is passed as a
positional argument:
opencode run "prompt text here"Sourcepub fn opencode_interactive() -> Self
pub fn opencode_interactive() -> Self
OpenCode in interactive TUI mode.
Runs OpenCode TUI with an initial prompt via --prompt flag:
opencode --prompt "prompt text here"Unlike opencode() which uses opencode run (headless mode),
this launches the interactive TUI and injects the prompt.
Sourcepub fn custom(config: &CliConfig) -> Result<Self, CustomBackendError>
pub fn custom(config: &CliConfig) -> Result<Self, CustomBackendError>
Creates a custom backend from configuration.
§Errors
Returns CustomBackendError if no command is specified.
Sourcepub fn build_command(
&self,
prompt: &str,
interactive: bool,
) -> (String, Vec<String>, Option<String>, Option<NamedTempFile>)
pub fn build_command( &self, prompt: &str, interactive: bool, ) -> (String, Vec<String>, Option<String>, Option<NamedTempFile>)
Builds the full command with arguments for execution.
§Arguments
prompt- The prompt text to pass to the agentinteractive- Whether to run in interactive mode (affects agent flags)
Trait Implementations§
Source§impl Clone for CliBackend
impl Clone for CliBackend
Source§fn clone(&self) -> CliBackend
fn clone(&self) -> CliBackend
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CliBackend
impl RefUnwindSafe for CliBackend
impl Send for CliBackend
impl Sync for CliBackend
impl Unpin for CliBackend
impl UnwindSafe for CliBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more