aKode fase 2a: rimossi cloud tasks, chatgpt apply, responses-api-proxy, codex app, remote control, guardian decisions; realtime senza fallback OpenAI; doctor senza sonde OpenAI

This commit is contained in:
Andrea
2026-11-09 13:15:08 +01:00
parent 39a103d16f
commit 137106bf17
172 changed files with 485 additions and 42398 deletions

View File

@@ -44,8 +44,10 @@ use codex_features::FEATURES;
use codex_features::Feature;
use codex_http_client::ClientRouteClass;
use codex_http_client::HttpClientFactory;
use codex_http_client::OpenAiDestination;
use codex_http_client::OutboundProxyPolicy;
use codex_http_client::RouteAwareClientPool;
use codex_http_client::classify_openai_api_url;
use codex_install_context::CodexPackageLayout;
use codex_install_context::InstallContext;
use codex_install_context::InstallMethod;
@@ -569,11 +571,6 @@ async fn build_report(
progress.begin("desktop");
if let Some(desktop) = desktop::collect().await {
#[cfg(any(target_os = "macos", target_os = "windows"))]
if let Some(application) = desktop.application.as_ref() {
updates::append_desktop_update(&mut checks, config_result.as_ref().ok(), application)
.await;
}
progress.finish("desktop", overall_status(&desktop.checks));
checks.extend(desktop.checks);
}
@@ -2339,6 +2336,21 @@ async fn websocket_reachability_check(
.details(details);
}
// aKode: never open a probe connection to OpenAI/ChatGPT, including the implicit default.
if provider
.base_url
.as_deref()
.is_none_or(|url| classify_openai_api_url(url) != OpenAiDestination::Other)
{
return DoctorCheck::new(
"network.websocket_reachability",
"websocket",
CheckStatus::Ok,
"Responses WebSocket probe skipped: no explicit non-OpenAI provider base URL",
)
.details(details);
}
details.push(format!(
"connect timeout: {} ms",
provider.websocket_connect_timeout().as_millis()
@@ -2670,21 +2682,20 @@ fn provider_reachability_plan(config: &Config) -> ReachabilityPlan {
config.model_provider.base_url.as_deref(),
query_params.as_ref(),
config.model_provider.is_amazon_bedrock(),
&config.chatgpt_base_url,
);
plan.http_client_factory = config.http_client_factory();
plan
}
/// aKode: without a loaded config there is no explicit provider endpoint, so nothing is probed.
fn default_reachability_plan() -> ReachabilityPlan {
provider_reachability_plan_from_parts(
ProviderAuthReachabilityMode::Chatgpt,
"openai",
"OpenAI",
ProviderAuthReachabilityMode::NotRequired,
"unknown",
"unknown",
/*provider_base_url*/ None,
/*provider_query_params*/ None,
/*is_amazon_bedrock*/ false,
"https://chatgpt.com/backend-api/",
)
}
@@ -2730,35 +2741,20 @@ fn provider_reachability_plan_from_parts(
provider_base_url: Option<&str>,
provider_query_params: Option<&HashMap<String, String>>,
is_amazon_bedrock: bool,
chatgpt_base_url: &str,
) -> ReachabilityPlan {
let provider_route_probe_url = provider_base_url
.or_else(|| {
(mode == ProviderAuthReachabilityMode::ApiKey).then_some("https://api.openai.com/v1")
})
.and_then(|url| {
should_probe_models_route(provider_name, url, is_amazon_bedrock)
.then(|| provider_url_for_path(url, "models", provider_query_params))
});
let endpoints = match (mode, provider_base_url) {
(ProviderAuthReachabilityMode::ApiKey, _) | (_, Some(_)) => vec![ReachabilityEndpoint {
// aKode: only an explicitly configured base URL outside OpenAI/ChatGPT is probed. The
// implicit chatgpt.com and api.openai.com endpoints are never contacted.
let endpoints = provider_base_url
.filter(|url| classify_openai_api_url(url) == OpenAiDestination::Other)
.map(|base_url| ReachabilityEndpoint {
label: format!("{provider_id} API"),
url: provider_url_for_path(
provider_base_url.unwrap_or("https://api.openai.com/v1"),
"responses",
provider_query_params,
),
url: provider_url_for_path(base_url, "responses", provider_query_params),
required: true,
route_probe_url: provider_route_probe_url,
}],
(ProviderAuthReachabilityMode::Chatgpt, None) => vec![ReachabilityEndpoint {
label: "ChatGPT".to_string(),
url: provider_url_for_path(chatgpt_base_url, "codex/responses", provider_query_params),
required: true,
route_probe_url: None,
}],
(ProviderAuthReachabilityMode::NotRequired, None) => Vec::new(),
};
route_probe_url: should_probe_models_route(provider_name, base_url, is_amazon_bedrock)
.then(|| provider_url_for_path(base_url, "models", provider_query_params)),
})
.into_iter()
.collect();
ReachabilityPlan {
description: mode.description().to_string(),
endpoints,
@@ -2878,7 +2874,7 @@ async fn provider_reachability_check(plan: ReachabilityPlan) -> DoctorCheck {
)
.measured(format!("{route_probe_url} returned {status}"))
.expected("GET /models returns 2xx, 401, or 403")
.remedy("Set base_url to the provider API root, for example https://api.openai.com/v1")
.remedy("Set base_url to the provider API root, for example http://localhost:8080/v1")
.field("route probe"),
);
}
@@ -3922,7 +3918,6 @@ mod tests {
Some("https://example.openai.azure.com/openai/v1"),
/*provider_query_params*/ None,
/*is_amazon_bedrock*/ false,
"https://chatgpt.com/backend-api/",
),
ReachabilityPlan {
description: "provider auth".to_string(),
@@ -3953,7 +3948,6 @@ mod tests {
Some("https://example.com/openai/v1/"),
Some(&query_params),
/*is_amazon_bedrock*/ false,
"https://chatgpt.com/backend-api/",
),
ReachabilityPlan {
description: description.to_string(),
@@ -3984,14 +3978,13 @@ mod tests {
Some("https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1"),
/*provider_query_params*/ None,
/*is_amazon_bedrock*/ true,
"https://chatgpt.com/backend-api/",
);
assert_eq!(plan.endpoints[0].route_probe_url, None);
}
#[test]
fn provider_reachability_api_key_does_not_require_chatgpt() {
fn provider_reachability_never_infers_openai_endpoints() {
let plan = provider_reachability_plan_from_parts(
ProviderAuthReachabilityMode::ApiKey,
"openai",
@@ -3999,31 +3992,28 @@ mod tests {
/*provider_base_url*/ None,
/*provider_query_params*/ None,
/*is_amazon_bedrock*/ false,
"https://chatgpt.com/backend-api/",
);
assert_eq!(plan.endpoints, Vec::new());
assert_eq!(
plan.endpoints,
vec![ReachabilityEndpoint {
label: "openai API".to_string(),
url: "https://api.openai.com/v1/responses".to_string(),
required: true,
route_probe_url: Some("https://api.openai.com/v1/models".to_string()),
}]
);
for base_url in [
"https://api.openai.com/v1",
"https://chatgpt.com/backend-api/",
] {
let plan = provider_reachability_plan_from_parts(
ProviderAuthReachabilityMode::Chatgpt,
"openai",
"OpenAI",
Some(base_url),
/*provider_query_params*/ None,
/*is_amazon_bedrock*/ false,
);
assert_eq!(plan.endpoints, Vec::new(), "{base_url}");
}
}
#[test]
fn provider_reachability_chatgpt_uses_inference_endpoint() {
assert_eq!(
default_reachability_plan().endpoints,
vec![ReachabilityEndpoint {
label: "ChatGPT".to_string(),
url: "https://chatgpt.com/backend-api/codex/responses".to_string(),
required: true,
route_probe_url: None,
}]
);
fn provider_reachability_default_plan_probes_nothing() {
assert_eq!(default_reachability_plan().endpoints, Vec::new());
}
#[test]
@@ -4065,7 +4055,6 @@ mod tests {
Some(&format!("http://{addr}/xxxx")),
/*provider_query_params*/ None,
/*is_amazon_bedrock*/ false,
"https://chatgpt.com/backend-api/",
);
let check = provider_reachability_check(plan).await;
@@ -4081,7 +4070,7 @@ mod tests {
assert_eq!(check.issues.len(), 1);
assert_eq!(
check.issues[0].remedy.as_deref(),
Some("Set base_url to the provider API root, for example https://api.openai.com/v1")
Some("Set base_url to the provider API root, for example http://localhost:8080/v1")
);
}
@@ -4106,7 +4095,6 @@ mod tests {
Some(&format!("http://{addr}/v1")),
/*provider_query_params*/ None,
/*is_amazon_bedrock*/ false,
"https://chatgpt.com/backend-api/",
);
let check = provider_reachability_check(plan).await;