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:
@@ -81,13 +81,13 @@ pub(crate) struct RouteAwareHttpRequestRunner {
|
||||
impl RouteAwareHttpClient {
|
||||
pub fn new(http_client_factory: HttpClientFactory) -> Self {
|
||||
Self {
|
||||
follow_redirects: RouteAwareClientPool::with_chatgpt_cloudflare_cookies_without_request_logging(
|
||||
follow_redirects: RouteAwareClientPool::new_without_request_logging(
|
||||
http_client_factory.clone(),
|
||||
// Delegated HTTP targets arbitrary endpoints; route class only labels diagnostics.
|
||||
ClientRouteClass::Other,
|
||||
),
|
||||
stop_redirects:
|
||||
RouteAwareClientPool::with_chatgpt_cloudflare_cookies_without_redirects_or_request_logging(
|
||||
RouteAwareClientPool::new_without_redirects_or_request_logging(
|
||||
http_client_factory,
|
||||
// Proxy routing comes from the factory, not this diagnostic-only route class.
|
||||
ClientRouteClass::Other,
|
||||
|
||||
@@ -68,11 +68,9 @@ async fn config_read_timeout_keeps_stdio_connection_usable() {
|
||||
hostname: Some("original".to_string()),
|
||||
config: EnvironmentConfigLayerStack {
|
||||
layers: Vec::new(),
|
||||
cloud_insertion_index: 0,
|
||||
},
|
||||
requirements: EnvironmentConfigLayerStack {
|
||||
layers: Vec::new(),
|
||||
cloud_insertion_index: 0,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -341,7 +341,6 @@ fn parse_root(
|
||||
DiscoveredSource::Plugin(Box::new(ExecutorPlugin {
|
||||
id: plugin.id,
|
||||
display_name,
|
||||
remote_plugin_id: plugin.remote_plugin_id,
|
||||
version: plugin.version,
|
||||
root: location.root,
|
||||
files,
|
||||
|
||||
@@ -7,7 +7,6 @@ use std::collections::BTreeMap;
|
||||
use std::io;
|
||||
|
||||
use crate::LocalFileSystem;
|
||||
use crate::protocol::FsOpenMode;
|
||||
use codex_file_system::ExecutorFileSystem;
|
||||
use codex_file_system::WalkEntryKind;
|
||||
use codex_file_system::WalkOptions;
|
||||
@@ -17,11 +16,8 @@ use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
use codex_core_plugin_common::installed::PLUGINS_CACHE_DIR;
|
||||
use codex_core_plugin_common::installed::REMOTE_PLUGIN_INSTALL_METADATA_FILE;
|
||||
use codex_core_plugin_common::installed::active_plugin_version;
|
||||
use codex_core_plugin_common::installed::parse_remote_plugin_id;
|
||||
use codex_core_plugin_common::plugin_id::PluginId;
|
||||
use tokio::io::AsyncReadExt;
|
||||
|
||||
/// Fixed paths are supplied by the executor, not read from the sandbox helper's sanitized env.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -32,8 +28,6 @@ pub(crate) struct CapabilityLocationRequest {
|
||||
}
|
||||
|
||||
const MAX_LOCATIONS: usize = 512;
|
||||
const MAX_REMOTE_INSTALL_METADATA_BYTES: u64 = 16 * 1024;
|
||||
const MAX_REMOTE_PLUGIN_ID_BYTES: usize = 1024;
|
||||
const AGENTS_SKILLS_SUFFIX: &str = ".agents/skills";
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -47,7 +41,6 @@ pub(crate) struct CapabilityLocation {
|
||||
pub(crate) struct InstalledPlugin {
|
||||
pub id: String,
|
||||
pub version: String,
|
||||
pub remote_plugin_id: Option<String>,
|
||||
}
|
||||
|
||||
/// Selected locations; membership does not authorize capability reads.
|
||||
@@ -156,64 +149,21 @@ async fn discover_cached_plugins(
|
||||
.await
|
||||
.map_err(io::Error::other)?;
|
||||
for (id, package_root, version) in installed {
|
||||
// Avoid reading metadata for plugin locations the final assembly would discard.
|
||||
if locations.locations.len() == MAX_LOCATIONS {
|
||||
locations.warnings.push(format!(
|
||||
"plugin cache reached its {MAX_LOCATIONS}-location limit"
|
||||
));
|
||||
break;
|
||||
}
|
||||
let metadata_path = package_root.join(REMOTE_PLUGIN_INSTALL_METADATA_FILE);
|
||||
let remote_plugin_id = match read_remote_plugin_id(metadata_path.as_path()).await {
|
||||
Ok(remote_plugin_id) => remote_plugin_id,
|
||||
Err(error) => {
|
||||
locations.warnings.push(format!(
|
||||
"could not read remote installation metadata for {id}: {error}"
|
||||
));
|
||||
None
|
||||
}
|
||||
};
|
||||
locations.locations.push(CapabilityLocation {
|
||||
root: PathUri::from_abs_path(&package_root.join(&version)),
|
||||
standalone_root_id: None,
|
||||
plugin: Some(InstalledPlugin {
|
||||
id,
|
||||
version,
|
||||
remote_plugin_id,
|
||||
}),
|
||||
plugin: Some(InstalledPlugin { id, version }),
|
||||
});
|
||||
}
|
||||
Ok(locations)
|
||||
}
|
||||
|
||||
async fn read_remote_plugin_id(path: &std::path::Path) -> io::Result<Option<String>> {
|
||||
// Nonblocking open and handle validation reject FIFOs and other non-regular files.
|
||||
let file = match crate::regular_file::open(path, FsOpenMode::Read).await {
|
||||
Ok(file) => file,
|
||||
Err(error) if error.kind() == io::ErrorKind::NotFound => return Ok(None),
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
let mut contents = Vec::new();
|
||||
file.take(MAX_REMOTE_INSTALL_METADATA_BYTES + 1)
|
||||
.read_to_end(&mut contents)
|
||||
.await?;
|
||||
if contents.len() as u64 > MAX_REMOTE_INSTALL_METADATA_BYTES {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"remote installation metadata exceeds its byte limit",
|
||||
));
|
||||
}
|
||||
let contents = std::str::from_utf8(&contents).map_err(io::Error::other)?;
|
||||
let id = parse_remote_plugin_id(contents).map_err(io::Error::other)?;
|
||||
if id.len() > MAX_REMOTE_PLUGIN_ID_BYTES {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"remote plugin ID exceeds its byte limit",
|
||||
));
|
||||
}
|
||||
Ok(Some(id))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/capability_locations_tests.rs"]
|
||||
pub(crate) mod tests;
|
||||
|
||||
@@ -57,11 +57,6 @@ async fn prewarming_resolves_global_locations_without_cwd_or_config() -> anyhow:
|
||||
MANIFEST,
|
||||
)?;
|
||||
}
|
||||
write(
|
||||
temp.path(),
|
||||
"codex/plugins/cache/team/demo/.codex-remote-plugin-install.json",
|
||||
r#"{"schema_version":1,"remote_plugin_id":"plugins~demo"}"#,
|
||||
)?;
|
||||
let locations = prewarm_locations(&LocalFileSystem::unsandboxed(), &request).await?;
|
||||
let mut actual = locations.locations;
|
||||
actual.sort_unstable_by_key(|location| location.root.to_string());
|
||||
@@ -71,7 +66,6 @@ async fn prewarming_resolves_global_locations_without_cwd_or_config() -> anyhow:
|
||||
plugin: Some(InstalledPlugin {
|
||||
id: "demo@team".to_string(),
|
||||
version: "1.10.0".to_string(),
|
||||
remote_plugin_id: Some("plugins~demo".to_string()),
|
||||
}),
|
||||
}];
|
||||
for (id, root) in [
|
||||
@@ -89,34 +83,6 @@ async fn prewarming_resolves_global_locations_without_cwd_or_config() -> anyhow:
|
||||
assert_eq!(actual, expected);
|
||||
assert!(locations.warnings.is_empty());
|
||||
|
||||
let metadata = "codex/plugins/cache/team/demo/.codex-remote-plugin-install.json";
|
||||
for contents in [
|
||||
"invalid JSON".to_string(),
|
||||
" ".repeat(super::MAX_REMOTE_INSTALL_METADATA_BYTES as usize + 1),
|
||||
] {
|
||||
write(temp.path(), metadata, &contents)?;
|
||||
let locations = prewarm_locations(&LocalFileSystem::unsandboxed(), &request).await?;
|
||||
assert!(locations.warnings.iter().any(|warning| {
|
||||
warning.contains("could not read remote installation metadata for demo@team")
|
||||
}));
|
||||
assert!(locations.locations.iter().any(|location| {
|
||||
location
|
||||
.plugin
|
||||
.as_ref()
|
||||
.is_some_and(|plugin| plugin.id == "demo@team" && plugin.remote_plugin_id.is_none())
|
||||
}));
|
||||
}
|
||||
// Missing remote metadata is valid for locally installed plugins.
|
||||
std::fs::remove_file(temp.path().join(metadata))?;
|
||||
let locations = prewarm_locations(&LocalFileSystem::unsandboxed(), &request).await?;
|
||||
assert!(locations.warnings.is_empty());
|
||||
assert!(locations.locations.iter().any(|location| {
|
||||
location
|
||||
.plugin
|
||||
.as_ref()
|
||||
.is_some_and(|plugin| plugin.id == "demo@team" && plugin.remote_plugin_id.is_none())
|
||||
}));
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
@@ -215,7 +215,6 @@ fn serialize_layer_stack<S>(
|
||||
.collect::<Result<Vec<_>, ReadEnvironmentConfigError>>()?;
|
||||
Ok(EnvironmentConfigLayerStack {
|
||||
layers,
|
||||
cloud_insertion_index: stack.cloud_insertion_index,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,9 @@ fn startup_preference_stays_below_both_managed_layers() -> anyhow::Result<()> {
|
||||
toml: toml::Value::Table(toml::toml! { [features] prefer_mxc = false }),
|
||||
})
|
||||
.collect(),
|
||||
cloud_insertion_index: 0,
|
||||
},
|
||||
requirements: LocalTomlLayerStack {
|
||||
layers: Vec::new(),
|
||||
cloud_insertion_index: 0,
|
||||
},
|
||||
};
|
||||
include_startup_preference(&mut layers, &cwd, Some(true));
|
||||
@@ -46,7 +44,6 @@ fn startup_preference_stays_below_both_managed_layers() -> anyhow::Result<()> {
|
||||
codex_config::merge_toml_values(&mut effective, &layer.toml);
|
||||
}
|
||||
assert_eq!(effective["features"]["prefer_mxc"].as_bool(), Some(false));
|
||||
assert_eq!(projected.config.cloud_insertion_index, 0);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -81,7 +81,6 @@ pub enum RemoteEnvironmentTransport {
|
||||
enum RegistryAuthMode {
|
||||
Legacy,
|
||||
ExecutorCredential,
|
||||
ChatgptToken,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -310,7 +309,7 @@ impl EnvironmentRegistryClient {
|
||||
.map_err(auth::registry_auth_error)?;
|
||||
let scoped = self.auth_mode == RegistryAuthMode::ExecutorCredential;
|
||||
let credential = if self.auth_mode != RegistryAuthMode::Legacy {
|
||||
// Scoped credentials must be the only header. ChatGPT also carries its account ID.
|
||||
// Scoped credentials must be the only header.
|
||||
let token = (!scoped || headers.len() == 1)
|
||||
.then(|| headers.get(AUTHORIZATION))
|
||||
.flatten()
|
||||
@@ -721,12 +720,6 @@ impl RemoteEnvironmentConfig {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/// Omit the bearer from registry diagnostics while retaining the account header.
|
||||
pub fn with_registry_bearer_redaction(mut self) -> Self {
|
||||
self.auth_mode = RegistryAuthMode::ChatgptToken;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_telemetry(mut self, telemetry: ExecServerTelemetry) -> Self {
|
||||
self.telemetry = telemetry;
|
||||
self
|
||||
@@ -1474,11 +1467,6 @@ mod tests {
|
||||
assert_registry_diagnostics_omit_bearer(RegistryAuthMode::ExecutorCredential).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn chatgpt_token_is_never_returned_in_registry_diagnostics() {
|
||||
assert_registry_diagnostics_omit_bearer(RegistryAuthMode::ChatgptToken).await;
|
||||
}
|
||||
|
||||
async fn assert_registry_diagnostics_omit_bearer(mode: RegistryAuthMode) {
|
||||
const TOKEN: &str = "synthetic-scoped-registry-secret";
|
||||
struct ExecutorAuth;
|
||||
|
||||
Reference in New Issue
Block a user