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:
@@ -6,13 +6,11 @@ use std::collections::HashMap;
|
||||
use codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID;
|
||||
use codex_config::McpServerConfig;
|
||||
use codex_config::McpServerDisabledReason;
|
||||
use codex_config::McpServerIdpOAuthConfig;
|
||||
use codex_config::McpServerTransportConfig;
|
||||
use codex_config::RequirementSource;
|
||||
use codex_protocol::mcp_policy::EnvironmentMcpPolicy;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
|
||||
use crate::CODEX_APPS_MCP_SERVER_NAME;
|
||||
use crate::McpProtocolMode;
|
||||
use crate::server::McpCredentialPolicy;
|
||||
|
||||
@@ -81,7 +79,6 @@ pub enum McpServerSource {
|
||||
},
|
||||
Extension {
|
||||
id: String,
|
||||
host_owned_apps: bool,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -95,19 +92,6 @@ impl McpServerSource {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_host_owned_apps(&self, name: &str, config: &McpServerConfig) -> bool {
|
||||
name == CODEX_APPS_MCP_SERVER_NAME
|
||||
&& config.is_local_environment()
|
||||
&& matches!(
|
||||
self,
|
||||
Self::Compatibility { .. }
|
||||
| Self::Extension {
|
||||
host_owned_apps: true,
|
||||
..
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn disabled_registration_is_name_veto(&self) -> bool {
|
||||
// A selected package's policy applies to its registration, not to a higher runtime source
|
||||
// that happens to use the same logical server name.
|
||||
@@ -236,10 +220,7 @@ impl McpServerRegistration {
|
||||
) -> Self {
|
||||
Self::new(
|
||||
name,
|
||||
McpServerSource::Extension {
|
||||
id: id.into(),
|
||||
host_owned_apps: false,
|
||||
},
|
||||
McpServerSource::Extension { id: id.into() },
|
||||
config,
|
||||
RegistrationPrecedence::Extension(contribution_order),
|
||||
McpCredentialPolicy::HostFallbackAllowed,
|
||||
@@ -252,25 +233,6 @@ impl McpServerRegistration {
|
||||
self
|
||||
}
|
||||
|
||||
/// Registers the controller-owned Apps server contributed by a host extension.
|
||||
pub fn from_hosted_apps(
|
||||
id: impl Into<String>,
|
||||
contribution_order: usize,
|
||||
config: McpServerConfig,
|
||||
) -> Self {
|
||||
let host_owned_apps = config.is_local_environment();
|
||||
Self::new(
|
||||
CODEX_APPS_MCP_SERVER_NAME.to_string(),
|
||||
McpServerSource::Extension {
|
||||
id: id.into(),
|
||||
host_owned_apps,
|
||||
},
|
||||
config,
|
||||
RegistrationPrecedence::Extension(contribution_order),
|
||||
McpCredentialPolicy::HostFallbackAllowed,
|
||||
)
|
||||
}
|
||||
|
||||
fn new(
|
||||
name: String,
|
||||
source: McpServerSource,
|
||||
@@ -359,15 +321,9 @@ pub struct McpCatalogBuilder {
|
||||
actions: Vec<CatalogAction>,
|
||||
disabled_server_names: BTreeSet<String>,
|
||||
requirements_disabled_server_names: BTreeMap<String, RequirementSource>,
|
||||
ema_idp: Option<McpServerIdpOAuthConfig>,
|
||||
}
|
||||
|
||||
impl McpCatalogBuilder {
|
||||
/// Enables EMA with the IdP selected from trusted configuration.
|
||||
/// Without this policy, finalization disables EMA registrations.
|
||||
pub fn enable_ema(&mut self, idp: McpServerIdpOAuthConfig) {
|
||||
self.ema_idp = Some(idp);
|
||||
}
|
||||
|
||||
pub fn register(&mut self, registration: McpServerRegistration) {
|
||||
self.actions
|
||||
@@ -395,10 +351,7 @@ impl McpCatalogBuilder {
|
||||
) {
|
||||
self.actions.push(CatalogAction::Remove {
|
||||
name,
|
||||
source: McpServerSource::Extension {
|
||||
id: id.into(),
|
||||
host_owned_apps: false,
|
||||
},
|
||||
source: McpServerSource::Extension { id: id.into() },
|
||||
precedence: RegistrationPrecedence::Extension(contribution_order),
|
||||
});
|
||||
}
|
||||
@@ -412,12 +365,8 @@ impl McpCatalogBuilder {
|
||||
let CatalogAction::Register(registration) = action else {
|
||||
continue;
|
||||
};
|
||||
// Controller-owned Apps and existing managed denials are not attachment-owned.
|
||||
if !registration.config.enabled
|
||||
|| registration
|
||||
.source
|
||||
.is_host_owned_apps(®istration.name, ®istration.config)
|
||||
{
|
||||
// Existing managed denials are not attachment-owned.
|
||||
if !registration.config.enabled {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -475,14 +424,6 @@ impl McpCatalogBuilder {
|
||||
}
|
||||
|
||||
pub fn build(mut self) -> ResolvedMcpCatalog {
|
||||
// Keep source actions unbound so later catalog revisions resolve afresh.
|
||||
for action in &mut self.actions {
|
||||
if let CatalogAction::Register(registration) = action
|
||||
&& let Some(oauth) = &mut registration.config.oauth
|
||||
{
|
||||
oauth.ema_registration = None;
|
||||
}
|
||||
}
|
||||
// Stable sorting makes action order the tie-breaker when precedence is equal.
|
||||
self.actions.sort_by_key(CatalogAction::precedence);
|
||||
|
||||
@@ -516,7 +457,6 @@ impl McpCatalogBuilder {
|
||||
|
||||
let mut disabled_server_names = self.disabled_server_names;
|
||||
let mut requirements_disabled_server_names = self.requirements_disabled_server_names;
|
||||
let ema_idp = self.ema_idp;
|
||||
let servers = winners
|
||||
.into_iter()
|
||||
.filter_map(|(name, action)| match action {
|
||||
@@ -554,25 +494,18 @@ impl McpCatalogBuilder {
|
||||
if disabled_server_names.contains(&name) {
|
||||
registration.config.enabled = false;
|
||||
}
|
||||
// Only trusted Apps may ignore a previous registration's requirements denial.
|
||||
// Retain it so a later custom replacement is still blocked.
|
||||
if !registration
|
||||
.source
|
||||
.is_host_owned_apps(&name, ®istration.config)
|
||||
&& let Some(source) = requirements_disabled_server_names.get(&name)
|
||||
{
|
||||
// Retain a previous registration's requirements denial so a later
|
||||
// replacement is still blocked.
|
||||
if let Some(source) = requirements_disabled_server_names.get(&name) {
|
||||
registration.config.disable_by_requirements(source.clone());
|
||||
}
|
||||
if matches!(
|
||||
registration.config.auth,
|
||||
codex_config::McpServerAuth::EmaAuth
|
||||
) {
|
||||
let allowed = matches!(®istration.source, McpServerSource::Config)
|
||||
&& ema_idp.as_ref().is_some_and(|idp| {
|
||||
registration.config.resolve_ema_registration(idp).is_ok()
|
||||
});
|
||||
// EMA denial must not become a persistent name veto.
|
||||
registration.config.enabled &= allowed;
|
||||
// Enterprise-managed authorization was removed. Never start these
|
||||
// servers, but do not turn the denial into a persistent name veto.
|
||||
registration.config.enabled = false;
|
||||
}
|
||||
Some((
|
||||
name,
|
||||
@@ -592,7 +525,6 @@ impl McpCatalogBuilder {
|
||||
actions: self.actions,
|
||||
disabled_server_names,
|
||||
requirements_disabled_server_names,
|
||||
ema_idp,
|
||||
servers,
|
||||
conflicts,
|
||||
}
|
||||
@@ -632,7 +564,6 @@ pub struct ResolvedMcpCatalog {
|
||||
actions: Vec<CatalogAction>,
|
||||
disabled_server_names: BTreeSet<String>,
|
||||
requirements_disabled_server_names: BTreeMap<String, RequirementSource>,
|
||||
ema_idp: Option<McpServerIdpOAuthConfig>,
|
||||
servers: BTreeMap<String, ResolvedMcpServer>,
|
||||
conflicts: Vec<McpServerConflict>,
|
||||
}
|
||||
@@ -647,7 +578,6 @@ impl ResolvedMcpCatalog {
|
||||
actions: self.actions.clone(),
|
||||
disabled_server_names: self.disabled_server_names.clone(),
|
||||
requirements_disabled_server_names: self.requirements_disabled_server_names.clone(),
|
||||
ema_idp: self.ema_idp.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,12 +592,12 @@ impl ResolvedMcpCatalog {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns whether both catalogs have the same winning servers, sources, and EMA policy.
|
||||
/// Returns whether both catalogs have the same winning servers and sources.
|
||||
pub fn has_same_servers(&self, other: &Self) -> bool {
|
||||
self.servers == other.servers && self.ema_idp == other.ema_idp
|
||||
self.servers == other.servers
|
||||
}
|
||||
|
||||
/// Replaces the resolved server set while preserving known sources and EMA policy.
|
||||
/// Replaces the resolved server set while preserving known sources.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
@@ -676,7 +606,6 @@ impl ResolvedMcpCatalog {
|
||||
let mut builder = McpCatalogBuilder {
|
||||
disabled_server_names: self.disabled_server_names.clone(),
|
||||
requirements_disabled_server_names: self.requirements_disabled_server_names.clone(),
|
||||
ema_idp: self.ema_idp.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
for (name, config) in servers {
|
||||
|
||||
Reference in New Issue
Block a user