use std::path::Path;
use std::process::Command;
use super::app_server::build_gemini_acp_command;
use super::backend::{AgentBackend, AgentBackendError, BuildCommandRequest};
pub(super) struct GeminiBackend;
impl AgentBackend for GeminiBackend {
fn setup(&self, _folder: &Path) -> Result<(), AgentBackendError> {
Ok(())
}
fn build_command<'request>(
&'request self,
request: BuildCommandRequest<'request>,
) -> Result<Command, AgentBackendError> {
super::execution_policy::validate(ag_session::AgentKind::Gemini, request.execution_policy)?;
let mut command = build_gemini_acp_command(request.folder, request.model);
if request.permission_mode.is_read_only()
&& !matches!(
request.request_kind,
ag_contracts::AgentRequestKind::FocusedReview
| ag_contracts::AgentRequestKind::ReviewMetadata
| ag_contracts::AgentRequestKind::UtilityPrompt
)
{
command.arg("--approval-mode").arg("plan").arg("--sandbox");
}
Ok(command)
}
}
#[cfg(test)]
#[path = "gemini_test.rs"]
mod tests;