use crate::codex_options::CodexOptions;
use crate::errors::Result;
use crate::exec::CodexExec;
use crate::thread::Thread;
use crate::thread_options::ThreadOptions;
#[derive(Debug, Clone)]
pub struct Codex {
exec: CodexExec,
options: CodexOptions,
}
impl Codex {
pub fn new(options: Option<CodexOptions>) -> Result<Self> {
let options = options.unwrap_or_default();
let exec = CodexExec::new(
options.codex_path_override.clone(),
options.env.clone(),
options.config.clone(),
)?;
Ok(Self { exec, options })
}
pub fn start_thread(&self, options: Option<ThreadOptions>) -> Thread {
Thread::new(
self.exec.clone(),
self.options.clone(),
options.unwrap_or_default(),
None,
)
}
pub fn resume_thread(&self, id: impl Into<String>, options: Option<ThreadOptions>) -> Thread {
Thread::new(
self.exec.clone(),
self.options.clone(),
options.unwrap_or_default(),
Some(id.into()),
)
}
}