refactor(runtime-install): orchestrate through executor primitives

This commit is contained in:
acrognale-oai
2026-05-26 15:47:45 -04:00
parent 9aa19c5e5f
commit 18c9ac5efc
21 changed files with 1347 additions and 1413 deletions

View File

@@ -178,7 +178,6 @@ struct Inner {
http_body_stream_next_id: AtomicU64,
session_id: std::sync::RwLock<Option<String>>,
codex_home: std::sync::RwLock<Option<AbsolutePathBuf>>,
codex_self_exe: std::sync::RwLock<Option<AbsolutePathBuf>>,
reader_task: tokio::task::JoinHandle<()>,
}
@@ -353,14 +352,6 @@ impl ExecServerClient {
.unwrap_or_else(std::sync::PoisonError::into_inner);
*codex_home = Some(response.codex_home.clone());
}
{
let mut codex_self_exe = self
.inner
.codex_self_exe
.write()
.unwrap_or_else(std::sync::PoisonError::into_inner);
*codex_self_exe = Some(response.codex_self_exe.clone());
}
self.notify_initialized().await?;
Ok(response)
})
@@ -491,14 +482,6 @@ impl ExecServerClient {
.clone()
}
pub fn codex_self_exe(&self) -> Option<AbsolutePathBuf> {
self.inner
.codex_self_exe
.read()
.unwrap_or_else(std::sync::PoisonError::into_inner)
.clone()
}
pub(crate) async fn connect(
connection: JsonRpcConnection,
options: ExecServerClientConnectOptions,
@@ -547,7 +530,6 @@ impl ExecServerClient {
http_body_stream_next_id: AtomicU64::new(1),
session_id: std::sync::RwLock::new(None),
codex_home: std::sync::RwLock::new(None),
codex_self_exe: std::sync::RwLock::new(None),
reader_task,
}
});
@@ -1112,10 +1094,6 @@ mod tests {
std::env::current_dir().expect("current dir"),
)
.expect("absolute current dir"),
codex_self_exe: AbsolutePathBuf::try_from(
std::env::current_exe().expect("current exe"),
)
.expect("absolute current exe"),
})
.expect("initialize response should serialize"),
}),
@@ -1151,7 +1129,7 @@ mod tests {
program: "sh".to_string(),
args: vec![
"-c".to_string(),
"read _line; printf '%s\\n' '{\"id\":1,\"result\":{\"sessionId\":\"stdio-test\",\"codexHome\":\"/tmp\",\"codexSelfExe\":\"/tmp/codex\"}}'; read _line; sleep 60".to_string(),
"read _line; printf '%s\\n' '{\"id\":1,\"result\":{\"sessionId\":\"stdio-test\",\"codexHome\":\"/tmp\"}}'; read _line; sleep 60".to_string(),
],
env: HashMap::new(),
cwd: None,
@@ -1175,7 +1153,7 @@ mod tests {
program: "sh".to_string(),
args: vec![
"-c".to_string(),
"read _line; printf '%s\\n' '{\"id\":1,\"result\":{\"sessionId\":\"stdio-test\",\"codexHome\":\"/tmp\",\"codexSelfExe\":\"/tmp/codex\"}}'; read _line; sleep 60".to_string(),
"read _line; printf '%s\\n' '{\"id\":1,\"result\":{\"sessionId\":\"stdio-test\",\"codexHome\":\"/tmp\"}}'; read _line; sleep 60".to_string(),
],
env: HashMap::new(),
cwd: None,
@@ -1198,7 +1176,7 @@ mod tests {
args: vec![
"-NoProfile".to_string(),
"-Command".to_string(),
"$null = [Console]::In.ReadLine(); [Console]::Out.WriteLine('{\"id\":1,\"result\":{\"sessionId\":\"stdio-test\",\"codexHome\":\"C:\\\\Users\\\\codex\\\\.codex\",\"codexSelfExe\":\"C:\\\\codex\\\\codex.exe\"}}'); $null = [Console]::In.ReadLine(); Start-Sleep -Seconds 60".to_string(),
"$null = [Console]::In.ReadLine(); [Console]::Out.WriteLine('{\"id\":1,\"result\":{\"sessionId\":\"stdio-test\",\"codexHome\":\"C:\\\\Users\\\\codex\\\\.codex\"}}'); $null = [Console]::In.ReadLine(); Start-Sleep -Seconds 60".to_string(),
],
env: HashMap::new(),
cwd: None,
@@ -1223,7 +1201,7 @@ mod tests {
"read _line; \
echo \"$$\" > {}; \
sleep 60 >/dev/null 2>&1 & echo \"$!\" > {}; \
printf '%s\\n' '{{\"id\":1,\"result\":{{\"sessionId\":\"stdio-test\",\"codexHome\":\"/tmp\",\"codexSelfExe\":\"/tmp/codex\"}}}}'; \
printf '%s\\n' '{{\"id\":1,\"result\":{{\"sessionId\":\"stdio-test\",\"codexHome\":\"/tmp\"}}}}'; \
read _line; \
wait",
shell_quote(pid_file.as_path()),
@@ -1353,10 +1331,6 @@ mod tests {
std::env::current_dir().expect("current dir"),
)
.expect("absolute current dir"),
codex_self_exe: AbsolutePathBuf::try_from(
std::env::current_exe().expect("current exe"),
)
.expect("absolute current exe"),
})
.expect("initialize response should serialize"),
}),
@@ -1504,10 +1478,6 @@ mod tests {
std::env::current_dir().expect("current dir"),
)
.expect("absolute current dir"),
codex_self_exe: AbsolutePathBuf::try_from(
std::env::current_exe().expect("current exe"),
)
.expect("absolute current exe"),
})
.expect("initialize response should serialize"),
}),
@@ -1649,10 +1619,6 @@ mod tests {
std::env::current_dir().expect("current dir"),
)
.expect("absolute current dir"),
codex_self_exe: AbsolutePathBuf::try_from(
std::env::current_exe().expect("current exe"),
)
.expect("absolute current exe"),
})
.expect("initialize response should serialize"),
}),

View File

@@ -489,21 +489,6 @@ impl Environment {
.codex_home()
.ok_or_else(|| internal_error("remote exec-server did not report a codex home"))
}
pub async fn codex_self_exe(&self) -> Result<AbsolutePathBuf, JSONRPCErrorError> {
if let Some(client) = self.remote_client.as_ref() {
let client = client.get().await.map_err(exec_server_error_to_jsonrpc)?;
return client.codex_self_exe().ok_or_else(|| {
internal_error("remote exec-server did not report its Codex executable")
});
}
self.local_runtime_paths
.as_ref()
.map(|runtime_paths| runtime_paths.codex_self_exe.clone())
.ok_or_else(|| {
internal_error("failed to locate local Codex executable for runtime install")
})
}
}
fn default_local_codex_home() -> Option<AbsolutePathBuf> {

View File

@@ -60,7 +60,6 @@ pub struct InitializeParams {
pub struct InitializeResponse {
pub session_id: String,
pub codex_home: AbsolutePathBuf,
pub codex_self_exe: AbsolutePathBuf,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

View File

@@ -54,7 +54,6 @@ pub(crate) struct ExecServerHandler {
background_task_shutdown: CancellationToken,
background_tasks: TaskTracker,
file_system: FileSystemHandler,
codex_self_exe: codex_utils_absolute_path::AbsolutePathBuf,
initialize_requested: AtomicBool,
initialized: AtomicBool,
}
@@ -72,7 +71,6 @@ impl ExecServerHandler {
active_body_stream_ids: Mutex::new(HashSet::new()),
background_task_shutdown: CancellationToken::new(),
background_tasks: TaskTracker::new(),
codex_self_exe: runtime_paths.codex_self_exe.clone(),
file_system: FileSystemHandler::new(runtime_paths),
initialize_requested: AtomicBool::new(false),
initialized: AtomicBool::new(false),
@@ -127,7 +125,6 @@ impl ExecServerHandler {
Ok(InitializeResponse {
session_id,
codex_home: crate::codex_home::default_codex_home()?,
codex_self_exe: self.codex_self_exe.clone(),
})
}

View File

@@ -1015,7 +1015,6 @@ impl JsonRpcPeer {
InitializeResponse {
session_id: "session-1".to_string(),
codex_home: AbsolutePathBuf::try_from(std::env::current_dir()?)?,
codex_self_exe: AbsolutePathBuf::try_from(std::env::current_exe()?)?,
},
)
.await?;