pub struct CommonAgentState {
pub system_prompt: String,
pub model: String,
pub root: Option<String>,
pub skip_permissions: bool,
pub output_format: Option<String>,
pub add_dirs: Vec<String>,
pub capture_output: bool,
pub sandbox: Option<SandboxConfig>,
pub max_turns: Option<u32>,
pub env_vars: Vec<(String, String)>,
}Expand description
Shared configuration state for CLI-based agent providers.
Embed this struct in each provider to avoid duplicating field declarations and trivial setter implementations.
Fields§
§system_prompt: String§model: String§root: Option<String>§skip_permissions: bool§output_format: Option<String>§add_dirs: Vec<String>§capture_output: bool§sandbox: Option<SandboxConfig>§max_turns: Option<u32>§env_vars: Vec<(String, String)>Implementations§
Source§impl CommonAgentState
impl CommonAgentState
pub fn new(default_model: &str) -> Self
Sourcepub fn get_base_path(&self) -> &Path
pub fn get_base_path(&self) -> &Path
Get the effective base path (root directory or “.”).
Sourcepub fn make_command(
&self,
binary_name: &str,
agent_args: Vec<String>,
) -> Command
pub fn make_command( &self, binary_name: &str, agent_args: Vec<String>, ) -> Command
Create a Command either directly or wrapped in sandbox.
Standard pattern used by Claude, Copilot, and Gemini. Sets
current_dir, args, and env vars. Providers with custom sandbox
behavior (Codex, Ollama) keep their own make_command().
Sourcepub async fn run_interactive_command(
cmd: &mut Command,
agent_display_name: &str,
) -> Result<()>
pub async fn run_interactive_command( cmd: &mut Command, agent_display_name: &str, ) -> Result<()>
Execute a command interactively (inheriting stdin/stdout/stderr).
Returns ProcessError on non-zero exit.
Sourcepub async fn run_non_interactive_simple(
&self,
cmd: &mut Command,
agent_display_name: &str,
) -> Result<Option<AgentOutput>>
pub async fn run_non_interactive_simple( &self, cmd: &mut Command, agent_display_name: &str, ) -> Result<Option<AgentOutput>>
Execute a non-interactive command with simple capture-or-passthrough.
If capture_output is set, captures stdout and returns Some(AgentOutput).
Otherwise streams stdout to the terminal and returns None.
Used by Copilot, Gemini, Ollama. Providers with custom output parsing (Claude, Codex) keep their own non-interactive logic.