devflow_core/agents/
codex.rs1use super::AgentAdapter;
6use std::path::PathBuf;
7
8pub struct CodexAgent;
9
10impl AgentAdapter for CodexAgent {
11 fn name(&self) -> &'static str {
12 "OpenAI Codex"
13 }
14
15 fn exec_command(
16 &self,
17 _phase: u32,
18 prompt: &str,
19 extra_writable_roots: &[PathBuf],
20 ) -> (&'static str, Vec<String>) {
21 let mut args: Vec<String> = vec![
22 "exec".into(),
23 "--sandbox".into(),
24 "workspace-write".into(),
25 "--json".into(),
26 ];
27 if !extra_writable_roots.is_empty() {
33 let list = extra_writable_roots
34 .iter()
35 .map(|root| {
36 let escaped = root
37 .display()
38 .to_string()
39 .replace('\\', "\\\\")
40 .replace('"', "\\\"");
41 format!("\"{escaped}\"")
42 })
43 .collect::<Vec<_>>()
44 .join(",");
45 args.push("-c".into());
46 args.push(format!("sandbox_workspace_write.writable_roots=[{list}]"));
47 }
48 args.push(prompt.to_string());
49 ("codex", args)
50 }
51
52 fn extra_env(&self) -> Vec<(String, String)> {
56 vec![
57 ("GIT_CONFIG_COUNT".into(), "2".into()),
58 ("GIT_CONFIG_KEY_0".into(), "commit.gpgsign".into()),
59 ("GIT_CONFIG_VALUE_0".into(), "false".into()),
60 ("GIT_CONFIG_KEY_1".into(), "tag.gpgsign".into()),
61 ("GIT_CONFIG_VALUE_1".into(), "false".into()),
62 ]
63 }
64
65 fn completion_signal_detected(&self, _output: &str) -> bool {
66 false
67 }
68}