cloud: codex cloud exec (#5060)

By analogy to `codex exec`, this kicks off a task in codex cloud
noninteractively.
This commit is contained in:
Jeremy Rose
2025-10-14 10:49:17 -07:00
committed by GitHub
parent 57584d6f34
commit 8662162f45
3 changed files with 236 additions and 67 deletions

View File

@@ -91,3 +91,18 @@ pub async fn build_chatgpt_headers() -> HeaderMap {
}
headers
}
/// Construct a browser-friendly task URL for the given backend base URL.
pub fn task_url(base_url: &str, task_id: &str) -> String {
let normalized = normalize_base_url(base_url);
if let Some(root) = normalized.strip_suffix("/backend-api") {
return format!("{root}/codex/tasks/{task_id}");
}
if let Some(root) = normalized.strip_suffix("/api/codex") {
return format!("{root}/codex/tasks/{task_id}");
}
if normalized.ends_with("/codex") {
return format!("{normalized}/tasks/{task_id}");
}
format!("{normalized}/codex/tasks/{task_id}")
}