mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
d45cd26248
## Summary - Adapts the moved `codex-cloud-config` crate from the legacy cloud requirements endpoint to the new config bundle endpoint. - Switches runtime consumers from `CloudRequirementsLoader` to `CloudConfigBundleLoader` so one shared bundle supplies cloud-delivered config and requirements. - Removes the legacy cloud requirements domain loader path. ## Details This intentionally keeps `codex-cloud-config` monolithic for review lineage: the previous PR establishes the crate move, and this PR shows the behavior change against that moved implementation. A follow-up PR splits the module back into focused files. The new bundle path preserves the important cloud requirements loader semantics where intended: account-scoped signed cache, 30 minute TTL, 5 minute refresh cadence, retry/backoff, auth recovery, and fail-closed startup loading. The cached payload changes from a single requirements TOML string to the backend-delivered bundle, and validation rejects malformed config or requirements fragments before cache write/use.
36 lines
1.2 KiB
Rust
36 lines
1.2 KiB
Rust
use super::*;
|
|
|
|
fn cloud_config_bundle_load_error(err: &std::io::Error) -> Option<&CloudConfigBundleLoadError> {
|
|
let mut current: Option<&(dyn std::error::Error + 'static)> = err
|
|
.get_ref()
|
|
.map(|source| source as &(dyn std::error::Error + 'static));
|
|
while let Some(source) = current {
|
|
if let Some(cloud_error) = source.downcast_ref::<CloudConfigBundleLoadError>() {
|
|
return Some(cloud_error);
|
|
}
|
|
current = source.source();
|
|
}
|
|
None
|
|
}
|
|
|
|
pub(super) fn config_load_error(err: &std::io::Error) -> JSONRPCErrorError {
|
|
let data = cloud_config_bundle_load_error(err).map(|cloud_error| {
|
|
let mut data = serde_json::json!({
|
|
"reason": "cloudConfigBundle",
|
|
"errorCode": format!("{:?}", cloud_error.code()),
|
|
"detail": cloud_error.to_string(),
|
|
});
|
|
if let Some(status_code) = cloud_error.status_code() {
|
|
data["statusCode"] = serde_json::json!(status_code);
|
|
}
|
|
if cloud_error.code() == CloudConfigBundleLoadErrorCode::Auth {
|
|
data["action"] = serde_json::json!("relogin");
|
|
}
|
|
data
|
|
});
|
|
|
|
let mut error = invalid_request(format!("failed to load configuration: {err}"));
|
|
error.data = data;
|
|
error
|
|
}
|