use super::permission::PermissionDecision;
use crate::cli_runtime::{agent_event::AgentEvent, status_sink::RuntimeLabel, CliExecutable};
use agent_client_protocol::schema::v1::{
AuthMethod, AuthMethodId, Meta, RequestPermissionRequest, SessionConfigId,
SessionConfigValueId, SessionModeId, SessionUpdate,
};
use serde_json::Value;
use std::{
ffi::OsString,
path::{Path, PathBuf},
};
pub(crate) trait AcpAgentPolicy: Send + 'static {
fn label(&self) -> RuntimeLabel;
fn resolve_executable(&self) -> Result<CliExecutable, String>;
fn spawn_plan(&self, frozen: Option<Vec<String>>) -> Result<AcpSpawnPlan, String>;
fn prepare(&mut self, run_dir: &Path) -> Result<Vec<String>, String>;
fn log_path(&self, output_file: &Path) -> PathBuf;
fn auth_method(&self, advertised: &[AuthMethod]) -> Option<AuthMethodId>;
fn session_mode(&self) -> Option<SessionModeId>;
fn session_meta(&self) -> Option<Meta> {
None
}
fn session_config(&self) -> Vec<SessionConfigChoice> {
Vec::new()
}
fn decide_permission(&self, request: &RequestPermissionRequest) -> PermissionDecision;
fn answer_extension(&self, method: &str, params: &Value) -> Option<ExtensionAnswer>;
fn normalize_update(&self, update: SessionUpdate) -> SessionUpdate {
update
}
}
pub(crate) struct AcpSpawnPlan {
pub(crate) argv: Vec<OsString>,
pub(crate) cwd: PathBuf,
pub(crate) env: Vec<(OsString, OsString)>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct SessionConfigChoice {
pub(crate) id: SessionConfigId,
pub(crate) value: SessionConfigValueId,
}
pub(crate) struct ExtensionAnswer {
pub(crate) reply: Value,
pub(crate) events: Vec<AgentEvent>,
}