aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT

- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser,
  device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity,
  runtime agent instance, backend-client e openapi-models, workspace routing.
- Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin
  remoti (catalogo, sync, share), cyber access program, daybreak, cloud config
  e requirements (config_server ora fail-closed), attestation, frozen cloud
  skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/
  routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime.
- Messaggi d'errore senza link a chatgpt.com.
- Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed.
- Test: cancellati solo quelli del codice rimosso; test di sicurezza
  (sandbox estensioni, permessi, redazione, auth storage, requirements)
  adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents).
- Istruzioni di sistema invariate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:20:15 +01:00
parent 82347a58ed
commit 6089fbde91
1573 changed files with 10289 additions and 177679 deletions

View File

@@ -1,4 +1,5 @@
use super::*;
use crate::auth::KnownPlan;
use crate::exec_output::StreamOutput;
use crate::protocol::RateLimitWindow;
use chrono::DateTime;
@@ -166,7 +167,7 @@ fn usage_limit_reached_error_formats_plus_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit https://chatgpt.com/settings/usage to purchase more credits or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -175,7 +176,7 @@ fn usage_limit_reached_error_formats_rate_limit_reached_types() {
let cases = [
(
RateLimitReachedType::RateLimitReached,
"You’ve hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit https://chatgpt.com/settings/usage to purchase more credits or try again later.",
"You’ve hit your usage limit with the model provider. Try again later.",
),
(
RateLimitReachedType::WorkspaceOwnerCreditsDepleted,
@@ -330,7 +331,7 @@ fn usage_limit_reached_error_formats_free_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Upgrade to Plus to continue using Codex (https://chatgpt.com/explore/plus), or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -346,7 +347,7 @@ fn usage_limit_reached_error_formats_go_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Upgrade to Plus to continue using Codex (https://chatgpt.com/explore/plus), or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -362,7 +363,7 @@ fn usage_limit_reached_error_formats_default_when_none() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -381,7 +382,7 @@ fn usage_limit_reached_error_formats_team_plan() {
rate_limit_reached_type: None,
};
let expected = format!(
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again at {expected_time}."
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
@@ -404,7 +405,7 @@ fn usage_limit_reached_error_formats_business_plan_without_reset() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
}
@@ -421,7 +422,7 @@ fn usage_limit_reached_error_formats_self_serve_business_prolite_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -437,7 +438,7 @@ fn usage_limit_reached_error_formats_self_serve_business_usage_based_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -453,7 +454,7 @@ fn usage_limit_reached_error_formats_enterprise_cbp_usage_based_plan() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. To get more access now, send a request to your admin or try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
@@ -475,7 +476,7 @@ fn usage_limit_reached_error_formats_default_for_other_plans() {
};
assert_eq!(
err.to_string(),
"You’ve hit your usage limit. Try again later."
"You’ve hit your usage limit with the model provider. Try again later."
);
}
}
@@ -495,7 +496,7 @@ fn usage_limit_reached_error_formats_pro_plan_with_reset() {
rate_limit_reached_type: None,
};
let expected = format!(
"You’ve hit your usage limit. Visit https://chatgpt.com/settings/usage to purchase more credits or try again at {expected_time}."
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
@@ -516,9 +517,7 @@ fn usage_limit_reached_error_hides_upsell_for_non_codex_limit_name() {
limit_name: Some("codex_other".to_string()),
..rate_limit_snapshot()
})),
promo_message: Some(
"Visit https://chatgpt.com/settings/usage to purchase more credits".to_string(),
),
promo_message: Some("Server promo copy".to_string()),
rate_limit_reached_type: None,
};
let expected = format!(
@@ -542,7 +541,9 @@ fn usage_limit_reached_includes_minutes_when_available() {
promo_message: None,
rate_limit_reached_type: None,
};
let expected = format!("You’ve hit your usage limit. Try again at {expected_time}.");
let expected = format!(
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
}
@@ -593,7 +594,7 @@ fn unexpected_status_prefers_error_message_when_present() {
body: r#"{"error":{"message":"Workspace is not authorized in this region."},"status":401}"#
.to_string(),
user_message: None,
url: Some("https://chatgpt.com/backend-api/codex/responses".to_string()),
url: Some("https://api.example.com/v1/responses".to_string()),
cf_ray: None,
request_id: Some("req-123".to_string()),
identity_authorization_error: None,
@@ -603,7 +604,7 @@ fn unexpected_status_prefers_error_message_when_present() {
assert_eq!(
err.to_string(),
format!(
"unexpected status {status}: Workspace is not authorized in this region., url: https://chatgpt.com/backend-api/codex/responses, request id: req-123"
"unexpected status {status}: Workspace is not authorized in this region., url: https://api.example.com/v1/responses, request id: req-123"
)
);
}
@@ -637,7 +638,7 @@ fn unexpected_status_includes_cf_ray_and_request_id() {
status: StatusCode::UNAUTHORIZED,
body: "plain text error".to_string(),
user_message: None,
url: Some("https://chatgpt.com/backend-api/codex/responses".to_string()),
url: Some("https://api.example.com/v1/responses".to_string()),
cf_ray: Some("9c81f9f18f2fa49d-LHR".to_string()),
request_id: Some("req-xyz".to_string()),
identity_authorization_error: None,
@@ -647,7 +648,7 @@ fn unexpected_status_includes_cf_ray_and_request_id() {
assert_eq!(
err.to_string(),
format!(
"unexpected status {status}: plain text error, url: https://chatgpt.com/backend-api/codex/responses, cf-ray: 9c81f9f18f2fa49d-LHR, request id: req-xyz"
"unexpected status {status}: plain text error, url: https://api.example.com/v1/responses, cf-ray: 9c81f9f18f2fa49d-LHR, request id: req-xyz"
)
);
}
@@ -658,7 +659,7 @@ fn unexpected_status_includes_identity_auth_details() {
status: StatusCode::UNAUTHORIZED,
body: "plain text error".to_string(),
user_message: None,
url: Some("https://chatgpt.com/backend-api/codex/models".to_string()),
url: Some("https://api.example.com/v1/models".to_string()),
cf_ray: Some("cf-ray-auth-401-test".to_string()),
request_id: Some("req-auth".to_string()),
identity_authorization_error: Some("missing_authorization_header".to_string()),
@@ -668,7 +669,7 @@ fn unexpected_status_includes_identity_auth_details() {
assert_eq!(
err.to_string(),
format!(
"unexpected status {status}: plain text error, url: https://chatgpt.com/backend-api/codex/models, cf-ray: cf-ray-auth-401-test, request id: req-auth, auth error: missing_authorization_header, auth error code: token_expired"
"unexpected status {status}: plain text error, url: https://api.example.com/v1/models, cf-ray: cf-ray-auth-401-test, request id: req-auth, auth error: missing_authorization_header, auth error code: token_expired"
)
);
}
@@ -688,7 +689,7 @@ fn usage_limit_reached_includes_hours_and_minutes() {
rate_limit_reached_type: None,
};
let expected = format!(
"You’ve hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit https://chatgpt.com/settings/usage to purchase more credits or try again at {expected_time}."
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
@@ -709,7 +710,9 @@ fn usage_limit_reached_includes_days_hours_minutes() {
promo_message: None,
rate_limit_reached_type: None,
};
let expected = format!("You’ve hit your usage limit. Try again at {expected_time}.");
let expected = format!(
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
}
@@ -728,13 +731,15 @@ fn usage_limit_reached_less_than_minute() {
promo_message: None,
rate_limit_reached_type: None,
};
let expected = format!("You’ve hit your usage limit. Try again at {expected_time}.");
let expected = format!(
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});
}
#[test]
fn usage_limit_reached_with_promo_message() {
fn usage_limit_reached_ignores_server_promo_message() {
let base = Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 0).unwrap();
let resets_at = base + ChronoDuration::seconds(30);
with_now_override(base, move || {
@@ -750,7 +755,7 @@ fn usage_limit_reached_with_promo_message() {
rate_limit_reached_type: None,
};
let expected = format!(
"You’ve hit your usage limit. To continue using Codex, start a free trial of <PLAN> today, or try again at {expected_time}."
"You’ve hit your usage limit with the model provider. Try again at {expected_time}."
);
assert_eq!(err.to_string(), expected);
});