codex: use config for plugin service preview (#28582)

This commit is contained in:
Steven Lee
2026-06-23 07:28:54 +00:00
parent e750db2ccb
commit 39df203474
30 changed files with 182 additions and 114 deletions
+1
View File
@@ -2294,6 +2294,7 @@ dependencies = [
"codex-app-server-protocol",
"codex-connectors",
"codex-core",
"codex-features",
"codex-git-utils",
"codex-login",
"codex-model-provider",
@@ -115,6 +115,13 @@ fn load_shared_plugin_ids_by_local_path(
})
}
fn remote_plugin_service_config(config: &Config) -> RemotePluginServiceConfig {
RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
plugin_service_preview: config.features.enabled(Feature::PluginServicePreview),
}
}
fn share_context_for_source(
source: &MarketplacePluginSource,
shared_plugin_ids_by_local_path: &std::collections::BTreeMap<AbsolutePathBuf, String>,
@@ -567,9 +574,7 @@ impl PluginRequestProcessor {
!explicit_marketplace_kinds && config.features.enabled(Feature::RemotePlugin);
let use_remote_global_catalog =
include_global_remote && auth_mode.is_some_and(AuthMode::uses_codex_backend);
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
let refresh_global_remote_catalog_cache = use_remote_global_catalog
&& codex_core_plugins::remote::has_cached_global_remote_plugin_catalog(
config.codex_home.as_path(),
@@ -1016,9 +1021,7 @@ impl PluginRequestProcessor {
);
let share_context = match share_context {
Some(context) => {
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
match codex_core_plugins::remote::fetch_remote_plugin_share_context(
&remote_plugin_service_config,
auth.as_ref(),
@@ -1122,9 +1125,7 @@ impl PluginRequestProcessor {
"remote plugin read is not enabled for marketplace {remote_marketplace_name}"
)));
}
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
validate_remote_plugin_id(&plugin_name)?;
let remote_detail = codex_core_plugins::remote::fetch_remote_plugin_detail(
&remote_plugin_service_config,
@@ -1180,9 +1181,7 @@ impl PluginRequestProcessor {
}
let auth = self.auth_manager.auth().await;
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
let remote_skill_detail = codex_core_plugins::remote::fetch_remote_plugin_skill_detail(
&remote_plugin_service_config,
auth.as_ref(),
@@ -1233,9 +1232,7 @@ impl PluginRequestProcessor {
validate_client_plugin_share_targets(share_targets)?;
}
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
let access_policy = codex_core_plugins::remote::RemotePluginShareAccessPolicy {
discoverability: discoverability.map(remote_plugin_share_discoverability),
share_targets: share_targets.map(remote_plugin_share_targets),
@@ -1276,9 +1273,7 @@ impl PluginRequestProcessor {
}
validate_client_plugin_share_targets(&share_targets)?;
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
let result = codex_core_plugins::remote::update_remote_plugin_share_targets(
&remote_plugin_service_config,
auth.as_ref(),
@@ -1306,9 +1301,7 @@ impl PluginRequestProcessor {
_params: PluginShareListParams,
) -> Result<PluginShareListResponse, JSONRPCErrorError> {
let (config, auth) = self.load_plugin_share_config_and_auth().await?;
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
let data = codex_core_plugins::remote::list_remote_plugin_shares(
&remote_plugin_service_config,
auth.as_ref(),
@@ -1345,9 +1338,7 @@ impl PluginRequestProcessor {
return Err(invalid_request("invalid remote plugin id"));
}
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
let result = codex_core_plugins::remote::checkout_remote_plugin_share(
&remote_plugin_service_config,
auth.as_ref(),
@@ -1378,9 +1369,7 @@ impl PluginRequestProcessor {
return Err(invalid_request("invalid remote plugin id"));
}
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
codex_core_plugins::remote::delete_remote_plugin_share(
&remote_plugin_service_config,
auth.as_ref(),
@@ -1512,9 +1501,7 @@ impl PluginRequestProcessor {
validate_remote_plugin_id(&remote_plugin_id)?;
let auth = self.auth_manager.auth().await;
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
let remote_detail =
codex_core_plugins::remote::fetch_remote_plugin_detail_with_download_urls(
&remote_plugin_service_config,
@@ -1977,9 +1964,7 @@ impl PluginRequestProcessor {
validate_remote_plugin_id(&plugin_id)?;
let auth = self.auth_manager.auth().await;
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let remote_plugin_service_config = remote_plugin_service_config(&config);
let uninstall_result = codex_core_plugins::remote::uninstall_remote_plugin(
&remote_plugin_service_config,
auth.as_ref(),
+1
View File
@@ -13,6 +13,7 @@ clap = { workspace = true, features = ["derive"] }
codex-app-server-protocol = { workspace = true }
codex-connectors = { workspace = true }
codex-core = { workspace = true }
codex-features = { workspace = true }
codex-git-utils = { workspace = true }
codex-login = { workspace = true }
codex-model-provider = { workspace = true }
+4 -2
View File
@@ -1,8 +1,8 @@
use codex_core::config::Config;
use codex_features::Feature;
use codex_login::AuthManager;
use codex_login::default_client::chatgpt_cloudflare_cookie_header;
use codex_login::default_client::create_client;
use codex_utils_plugins::plugin_service_routing::plugin_service_preview_enabled;
use codex_utils_plugins::plugin_service_routing::plugin_service_routing_cookie;
use anyhow::Context;
@@ -91,7 +91,9 @@ async fn chatgpt_get_request_with_timeout_inner<T: DeserializeOwned>(
.header(OAI_PRODUCT_SKU_HEADER, CODEX_PRODUCT_SKU)
.header("Content-Type", "application/json");
if matches!(routing, ChatgptRequestRouting::PluginService) && plugin_service_preview_enabled() {
if matches!(routing, ChatgptRequestRouting::PluginService)
&& config.features.enabled(Feature::PluginServicePreview)
{
let cloudflare_cookie = chatgpt_cloudflare_cookie_header(&url);
let existing_cookie_headers = cloudflare_cookie.as_deref().into_iter().collect::<Vec<_>>();
if let Some(routing_cookie) =
+2 -2
View File
@@ -18,10 +18,10 @@ pub use codex_core::connectors::list_accessible_connectors_from_mcp_tools_with_o
pub use codex_core::connectors::list_accessible_connectors_from_mcp_tools_with_options_and_status;
pub use codex_core::connectors::list_cached_accessible_connectors_from_mcp_tools;
pub use codex_core::connectors::with_app_enabled_state;
use codex_features::Feature;
use codex_login::AuthManager;
use codex_login::CodexAuth;
use codex_plugin::AppConnectorId;
use codex_utils_plugins::plugin_service_routing::plugin_service_preview_enabled;
const DIRECTORY_CONNECTORS_TIMEOUT: Duration = Duration::from_secs(60);
@@ -129,7 +129,7 @@ fn connector_directory_cache_context(
auth.get_chatgpt_user_id(),
auth.is_workspace_account(),
)
.plugin_service_preview(plugin_service_preview_enabled()),
.plugin_service_preview(config.features.enabled(Feature::PluginServicePreview)),
)
}
+5 -3
View File
@@ -16,7 +16,6 @@ use anyhow::Context;
use codex_login::CodexAuth;
use codex_protocol::mcp::McpServerInfo;
use codex_utils_plugins::mcp_connector::sanitize_name;
use codex_utils_plugins::plugin_service_routing::plugin_service_preview_enabled;
use serde::Deserialize;
use serde::Serialize;
use sha1::Digest;
@@ -31,12 +30,15 @@ pub struct CodexAppsToolsCacheKey {
pub(crate) plugin_service_preview: bool,
}
pub fn codex_apps_tools_cache_key(auth: Option<&CodexAuth>) -> CodexAppsToolsCacheKey {
pub fn codex_apps_tools_cache_key(
auth: Option<&CodexAuth>,
plugin_service_preview: bool,
) -> CodexAppsToolsCacheKey {
CodexAppsToolsCacheKey {
account_id: auth.and_then(CodexAuth::get_account_id),
chatgpt_user_id: auth.and_then(CodexAuth::get_chatgpt_user_id),
is_workspace_account: auth.is_some_and(CodexAuth::is_workspace_account),
plugin_service_preview: plugin_service_preview_enabled(),
plugin_service_preview,
}
}
@@ -1183,6 +1183,7 @@ fn server_metadata_preserves_tool_approval_policy() {
let mut config = crate::codex_apps_mcp_server_config(
"https://docs.example",
/*apps_mcp_product_sku*/ None,
/*plugin_service_preview*/ false,
);
config.environment_id = "remote".to_string();
config.default_tools_approval_mode = Some(AppToolApproval::Prompt);
+8 -5
View File
@@ -34,7 +34,6 @@ use codex_protocol::models::PermissionProfile;
use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::McpAuthStatus;
use codex_utils_plugins::plugin_service_routing::PLUGIN_SERVICE_PREVIEW_COOKIE;
use codex_utils_plugins::plugin_service_routing::plugin_service_preview_enabled;
use rmcp::model::ElicitationCapability;
use rmcp::model::ReadResourceRequestParams;
use rmcp::model::ReadResourceResult;
@@ -137,6 +136,8 @@ pub struct McpConfig {
/// ChatGPT auth is checked separately before a materialized host-owned Apps
/// server can be used.
pub apps_enabled: bool,
/// Whether built-in plugin-service requests should use preview routing.
pub plugin_service_preview: bool,
/// Whether model-visible MCP tool namespaces should keep the legacy
/// `mcp__` prefix.
pub prefix_mcp_tool_names: bool,
@@ -302,7 +303,7 @@ pub async fn read_mcp_resource(
PermissionProfile::default(),
runtime_context,
config.codex_home.clone(),
codex_apps_tools_cache_key(auth),
codex_apps_tools_cache_key(auth, config.plugin_service_preview),
config.prefix_mcp_tool_names,
config.client_elicitation_capability.clone(),
/*supports_openai_form_elicitation*/ false,
@@ -375,7 +376,7 @@ pub async fn collect_mcp_server_status_snapshot_with_detail(
PermissionProfile::default(),
runtime_context,
config.codex_home.clone(),
codex_apps_tools_cache_key(auth),
codex_apps_tools_cache_key(auth, config.plugin_service_preview),
config.prefix_mcp_tool_names,
config.client_elicitation_capability.clone(),
/*supports_openai_form_elicitation*/ false,
@@ -453,11 +454,12 @@ fn codex_apps_mcp_url_for_base_url(base_url: &str) -> String {
pub fn codex_apps_mcp_server_config(
chatgpt_base_url: &str,
apps_mcp_product_sku: Option<&str>,
plugin_service_preview: bool,
) -> McpServerConfig {
mcp_server_config_for_url(
codex_apps_mcp_url_for_base_url(chatgpt_base_url),
apps_mcp_product_sku,
plugin_service_preview_enabled(),
plugin_service_preview,
)
}
@@ -465,6 +467,7 @@ pub fn codex_apps_mcp_server_config(
pub fn hosted_plugin_runtime_mcp_server_config(
chatgpt_base_url: &str,
apps_mcp_product_sku: Option<&str>,
plugin_service_preview: bool,
) -> McpServerConfig {
let base_url = normalize_codex_apps_base_url(chatgpt_base_url);
let base_url = if base_url.contains("/backend-api") || base_url.contains("/api/codex") {
@@ -475,7 +478,7 @@ pub fn hosted_plugin_runtime_mcp_server_config(
mcp_server_config_for_url(
format!("{base_url}/ps/mcp"),
apps_mcp_product_sku,
plugin_service_preview_enabled(),
plugin_service_preview,
)
}
+17 -4
View File
@@ -31,6 +31,7 @@ fn test_mcp_config(codex_home: PathBuf) -> McpConfig {
codex_linux_sandbox_exe: None,
use_legacy_landlock: false,
apps_enabled: false,
plugin_service_preview: false,
prefix_mcp_tool_names: true,
client_elicitation_capability: ElicitationCapability::default(),
mcp_server_catalog: ResolvedMcpCatalog::default(),
@@ -131,7 +132,11 @@ fn tool_plugin_provenance_collects_app_and_mcp_sources() {
"alpha".to_string(),
McpPluginAttribution::new("alpha@test".to_string(), "alpha-plugin".to_string()),
/*plugin_order*/ 0,
codex_apps_mcp_server_config("https://alpha.example", /*apps_mcp_product_sku*/ None),
codex_apps_mcp_server_config(
"https://alpha.example",
/*apps_mcp_product_sku*/ None,
/*plugin_service_preview*/ false,
),
));
config.mcp_server_catalog = catalog.build();
config.plugin_capability_summaries = vec![
@@ -197,7 +202,11 @@ fn selected_mcp_attribution_does_not_join_an_unrelated_local_summary() {
"Executor GitHub".to_string(),
),
/*selection_order*/ 0,
codex_apps_mcp_server_config("https://github.example", /*apps_mcp_product_sku*/ None),
codex_apps_mcp_server_config(
"https://github.example",
/*apps_mcp_product_sku*/ None,
/*plugin_service_preview*/ false,
),
));
config.mcp_server_catalog = catalog.build();
config.plugin_capability_summaries = vec![PluginCapabilitySummary {
@@ -249,8 +258,11 @@ fn codex_apps_mcp_url_for_base_url_keeps_existing_paths() {
#[test]
fn codex_apps_server_config_uses_legacy_codex_apps_path() {
let config =
codex_apps_mcp_server_config("https://chatgpt.com", /*apps_mcp_product_sku*/ None);
let config = codex_apps_mcp_server_config(
"https://chatgpt.com",
/*apps_mcp_product_sku*/ None,
/*plugin_service_preview*/ false,
);
let url = match &config.transport {
McpServerTransportConfig::StreamableHttp { url, .. } => url,
_ => panic!("expected streamable http transport for codex apps"),
@@ -402,6 +414,7 @@ async fn effective_mcp_servers_preserve_runtime_servers() {
codex_apps_mcp_server_config(
&config.chatgpt_base_url,
config.apps_mcp_product_sku.as_deref(),
config.plugin_service_preview,
),
));
config.mcp_server_catalog = catalog.build();
@@ -850,6 +850,7 @@ remote_plugin = true
codex_home.path(),
&RemotePluginServiceConfig {
chatgpt_base_url: plugins.chatgpt_base_url.clone(),
plugin_service_preview: false,
},
Some(&auth),
)
+8
View File
@@ -104,6 +104,7 @@ pub struct PluginsConfigInput {
pub config_layer_stack: ConfigLayerStack,
pub plugins_enabled: bool,
pub remote_plugin_enabled: bool,
pub plugin_service_preview: bool,
pub chatgpt_base_url: String,
}
@@ -118,9 +119,15 @@ impl PluginsConfigInput {
config_layer_stack,
plugins_enabled,
remote_plugin_enabled,
plugin_service_preview: false,
chatgpt_base_url,
}
}
pub fn plugin_service_preview(mut self, plugin_service_preview: bool) -> Self {
self.plugin_service_preview = plugin_service_preview;
self
}
}
/// Inputs used to select endpoint-backed plugin install candidates.
@@ -219,6 +226,7 @@ struct ConfiguredMarketplaceUpgradeState {
fn remote_plugin_service_config(config: &PluginsConfigInput) -> RemotePluginServiceConfig {
RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
plugin_service_preview: config.plugin_service_preview,
}
}
+13 -11
View File
@@ -16,7 +16,6 @@ use codex_plugin::AppDeclaration;
use codex_plugin::PluginId;
use codex_plugin::app_connector_ids_from_declarations;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_plugins::plugin_service_routing::plugin_service_preview_enabled;
use codex_utils_plugins::plugin_service_routing::plugin_service_routing_cookie;
use reqwest::RequestBuilder;
use reqwest::header::COOKIE;
@@ -123,6 +122,7 @@ const REMOTE_INSTALLED_MARKETPLACE_DISPLAY_ORDER: [(&str, &str); 6] = [
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RemotePluginServiceConfig {
pub chatgpt_base_url: String,
pub plugin_service_preview: bool,
}
#[derive(Debug, Clone, PartialEq)]
@@ -824,7 +824,7 @@ pub async fn fetch_recommended_plugins(
let request = authenticated_request(client.get(&url), auth)?
.timeout(RECOMMENDED_PLUGINS_TIMEOUT)
.query(&[("scope", "GLOBAL")]);
let response: RecommendedPluginsResponse = send_and_decode(request, &url).await?;
let response: RecommendedPluginsResponse = send_and_decode(config, request, &url).await?;
Ok(recommended_plugins_mode(response))
}
@@ -1128,7 +1128,7 @@ pub async fn fetch_remote_plugin_skill_detail(
let url = remote_plugin_skill_detail_url(config, plugin_id, skill_name)?;
let client = build_reqwest_client();
let request = authenticated_request(client.get(&url), auth)?;
let response: RemotePluginSkillDetailResponse = send_and_decode(request, &url).await?;
let response: RemotePluginSkillDetailResponse = send_and_decode(config, request, &url).await?;
if response.plugin_id != plugin_id {
return Err(RemotePluginCatalogError::UnexpectedPluginId {
expected: plugin_id.to_string(),
@@ -1289,7 +1289,7 @@ pub async fn install_remote_plugin(
.query(&[("includeAppsNeedingAuth", "true")]),
auth,
)?;
let response: RemotePluginMutationResponse = send_and_decode(request, &url).await?;
let response: RemotePluginMutationResponse = send_and_decode(config, request, &url).await?;
if response.id != plugin_id {
return Err(RemotePluginCatalogError::UnexpectedPluginId {
expected: plugin_id.to_string(),
@@ -1327,7 +1327,7 @@ pub async fn uninstall_remote_plugin(
let url = format!("{base_url}/ps/plugins/{plugin_id}/uninstall");
let client = build_reqwest_client();
let request = authenticated_request(client.post(&url), auth)?;
let response: RemotePluginMutationResponse = send_and_decode(request, &url).await?;
let response: RemotePluginMutationResponse = send_and_decode(config, request, &url).await?;
if response.id != plugin_id {
return Err(RemotePluginCatalogError::UnexpectedPluginId {
expected: plugin_id.to_string(),
@@ -1744,7 +1744,7 @@ async fn get_remote_plugin_list_page(
if let Some(page_token) = page_token {
request = request.query(&[("pageToken", page_token)]);
}
send_and_decode(request, &url).await
send_and_decode(config, request, &url).await
}
async fn get_remote_shared_workspace_plugins_page(
@@ -1760,7 +1760,7 @@ async fn get_remote_shared_workspace_plugins_page(
if let Some(page_token) = page_token {
request = request.query(&[("pageToken", page_token)]);
}
send_and_decode(request, &url).await
send_and_decode(config, request, &url).await
}
async fn get_remote_plugin_installed_page(
@@ -1781,7 +1781,7 @@ async fn get_remote_plugin_installed_page(
if let Some(page_token) = page_token {
request = request.query(&[("pageToken", page_token)]);
}
send_and_decode(request, &url).await
send_and_decode(config, request, &url).await
}
async fn fetch_plugin_detail(
@@ -1797,7 +1797,7 @@ async fn fetch_plugin_detail(
if include_download_urls {
request = request.query(&[("includeDownloadUrls", true)]);
}
send_and_decode(request, &url).await
send_and_decode(config, request, &url).await
}
fn remote_plugin_skill_detail_url(
@@ -1842,10 +1842,11 @@ fn authenticated_request(
}
async fn send_and_decode<T: for<'de> Deserialize<'de>>(
config: &RemotePluginServiceConfig,
request: RequestBuilder,
url: &str,
) -> Result<T, RemotePluginCatalogError> {
let response = send_plugin_service_request(request)
let response = send_plugin_service_request(config, request)
.await
.map_err(|source| RemotePluginCatalogError::Request {
url: url.to_string(),
@@ -1868,9 +1869,10 @@ async fn send_and_decode<T: for<'de> Deserialize<'de>>(
}
pub(super) async fn send_plugin_service_request(
config: &RemotePluginServiceConfig,
request: RequestBuilder,
) -> Result<reqwest::Response, reqwest::Error> {
send_plugin_service_request_with_preview(request, plugin_service_preview_enabled()).await
send_plugin_service_request_with_preview(request, config.plugin_service_preview).await
}
async fn send_plugin_service_request_with_preview(
@@ -1,7 +1,6 @@
use super::RemotePluginDirectoryItem;
use super::RemotePluginServiceConfig;
use codex_login::CodexAuth;
use codex_utils_plugins::plugin_service_routing::plugin_service_preview_enabled;
use serde::Deserialize;
use serde::Serialize;
use std::path::Path;
@@ -28,7 +27,7 @@ impl RemotePluginCatalogCacheKey {
account_id: auth.get_account_id(),
chatgpt_user_id: auth.get_chatgpt_user_id(),
is_workspace_account: auth.is_workspace_account(),
plugin_service_preview: plugin_service_preview_enabled(),
plugin_service_preview: config.plugin_service_preview,
}
}
}
@@ -544,6 +544,7 @@ mod tests {
.await;
let config = RemotePluginServiceConfig {
chatgpt_base_url: format!("{}/backend-api", server.uri()),
plugin_service_preview: false,
};
let auth = CodexAuth::create_dummy_chatgpt_auth_for_testing();
+8 -6
View File
@@ -281,7 +281,7 @@ pub async fn delete_remote_plugin_share(
let url = format!("{base_url}/public/plugins/workspace/{remote_plugin_id}");
let client = build_reqwest_client();
let request = authenticated_request(client.delete(&url), auth)?;
send_and_expect_status(request, &url, &[StatusCode::NO_CONTENT]).await?;
send_and_expect_status(config, request, &url, &[StatusCode::NO_CONTENT]).await?;
if let Err(err) = local_paths::remove_plugin_share_local_path(codex_home, remote_plugin_id) {
warn!(
remote_plugin_id = %remote_plugin_id,
@@ -319,7 +319,8 @@ pub async fn update_remote_plugin_share_targets(
targets,
},
);
let response: RemotePluginShareUpdateTargetsResponse = send_and_decode(request, &url).await?;
let response: RemotePluginShareUpdateTargetsResponse =
send_and_decode(config, request, &url).await?;
Ok(RemotePluginShareUpdateTargetsResult {
principals: response.principals,
discoverability: response.discoverability,
@@ -384,7 +385,7 @@ async fn get_created_workspace_plugins_page(
if let Some(page_token) = page_token {
request = request.query(&[("pageToken", page_token)]);
}
send_and_decode(request, &url).await
send_and_decode(config, request, &url).await
}
async fn create_workspace_plugin_upload(
@@ -405,7 +406,7 @@ async fn create_workspace_plugin_upload(
plugin_id: remote_plugin_id,
},
);
send_and_decode(request, &url).await
send_and_decode(config, request, &url).await
}
async fn put_workspace_plugin_upload(
@@ -452,7 +453,7 @@ async fn finalize_workspace_plugin_upload(
};
let client = build_reqwest_client();
let request = authenticated_request(client.post(&url), auth)?.json(&body);
send_and_decode(request, &url).await
send_and_decode(config, request, &url).await
}
fn archive_filename(plugin_path: &Path) -> Result<String, RemotePluginCatalogError> {
@@ -489,11 +490,12 @@ fn archive_plugin_for_upload_with_limit(
}
async fn send_and_expect_status(
config: &RemotePluginServiceConfig,
request: RequestBuilder,
url_for_error: &str,
expected_statuses: &[StatusCode],
) -> Result<(), RemotePluginCatalogError> {
let response = send_plugin_service_request(request)
let response = send_plugin_service_request(config, request)
.await
.map_err(|source| RemotePluginCatalogError::Request {
url: url_for_error.to_string(),
@@ -25,6 +25,7 @@ use wiremock::matchers::query_param_is_missing;
fn test_config(server: &MockServer) -> RemotePluginServiceConfig {
RemotePluginServiceConfig {
chatgpt_base_url: format!("{}/backend-api", server.uri()),
plugin_service_preview: false,
}
}
+6
View File
@@ -581,6 +581,9 @@
"plugin_hooks": {
"type": "boolean"
},
"plugin_service_preview": {
"type": "boolean"
},
"plugin_sharing": {
"type": "boolean"
},
@@ -4892,6 +4895,9 @@
"plugin_hooks": {
"type": "boolean"
},
"plugin_service_preview": {
"type": "boolean"
},
"plugin_sharing": {
"type": "boolean"
},
+48
View File
@@ -5835,6 +5835,54 @@ async fn to_mcp_config_preserves_apps_feature_from_config() -> std::io::Result<(
Ok(())
}
#[tokio::test]
async fn plugin_service_preview_cli_override_reaches_plugin_service_consumers()
-> std::io::Result<()> {
let codex_home = TempDir::new()?;
let default_config = ConfigBuilder::default()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.loader_overrides(LoaderOverrides::without_managed_config_for_tests())
.build()
.await?;
let plugins_manager = PluginsManager::new(codex_home.path().to_path_buf());
assert!(
!default_config
.features
.enabled(Feature::PluginServicePreview)
);
assert!(!default_config.plugins_config_input().plugin_service_preview);
assert!(
!default_config
.to_mcp_config(&plugins_manager)
.await
.plugin_service_preview
);
let config = ConfigBuilder::default()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.loader_overrides(LoaderOverrides::without_managed_config_for_tests())
.cli_overrides(vec![(
"features.plugin_service_preview".to_string(),
TomlValue::Boolean(true),
)])
.build()
.await?;
assert!(config.features.enabled(Feature::PluginServicePreview));
assert!(config.plugins_config_input().plugin_service_preview);
assert!(
config
.to_mcp_config(&plugins_manager)
.await
.plugin_service_preview
);
Ok(())
}
#[tokio::test]
async fn to_mcp_config_flows_mcp_tool_prefix_from_feature() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
+2
View File
@@ -1478,6 +1478,7 @@ impl Config {
self.features.enabled(Feature::RemotePlugin),
self.chatgpt_base_url.clone(),
)
.plugin_service_preview(self.features.enabled(Feature::PluginServicePreview))
}
/// Applies managed MCP requirements to servers supplied by one plugin.
@@ -1565,6 +1566,7 @@ impl Config {
codex_linux_sandbox_exe: self.codex_linux_sandbox_exe.clone(),
use_legacy_landlock: self.features.use_legacy_landlock(),
apps_enabled: self.features.enabled(Feature::Apps),
plugin_service_preview: self.features.enabled(Feature::PluginServicePreview),
prefix_mcp_tool_names: self.prefix_mcp_tool_names(),
client_elicitation_capability: if self.features.enabled(Feature::AuthElicitation) {
ElicitationCapability {
+2 -3
View File
@@ -41,7 +41,6 @@ use codex_mcp::codex_apps_tools_cache_key;
use codex_mcp::compute_auth_statuses;
use codex_mcp::effective_mcp_servers;
use codex_mcp::tool_plugin_provenance;
use codex_utils_plugins::plugin_service_routing::plugin_service_preview_enabled;
const CONNECTORS_READY_TIMEOUT_ON_EMPTY_TOOLS: Duration = Duration::from_secs(30);
@@ -273,7 +272,7 @@ pub async fn list_accessible_connectors_from_mcp_tools_with_mcp_manager(
// one exists, but do not reintroduce the old hidden-local fallback.
McpRuntimeContext::new(environment_manager, config.cwd.to_path_buf()),
config.codex_home.to_path_buf(),
codex_apps_tools_cache_key(auth.as_ref()),
codex_apps_tools_cache_key(auth.as_ref(), mcp_config.plugin_service_preview),
mcp_config.prefix_mcp_tool_names,
mcp_config.client_elicitation_capability,
/*supports_openai_form_elicitation*/ false,
@@ -462,7 +461,7 @@ async fn cached_directory_connectors_for_tool_suggest_with_auth(
auth.get_chatgpt_user_id(),
is_workspace_account,
)
.plugin_service_preview(plugin_service_preview_enabled()),
.plugin_service_preview(config.features.enabled(Feature::PluginServicePreview)),
);
codex_connectors::cached_directory_connectors(&cache_context).unwrap_or_default()
+1
View File
@@ -140,6 +140,7 @@ impl McpManager {
codex_apps_mcp_server_config(
&mcp_config.chatgpt_base_url,
mcp_config.apps_mcp_product_sku.as_deref(),
mcp_config.plugin_service_preview,
),
));
} else {
+7 -1
View File
@@ -1353,7 +1353,13 @@ async fn install_host_owned_codex_apps_manager(session: &Session, turn_context:
},
),
turn_context.config.codex_home.to_path_buf(),
codex_mcp::codex_apps_tools_cache_key(auth.as_ref()),
codex_mcp::codex_apps_tools_cache_key(
auth.as_ref(),
turn_context
.config
.features
.enabled(codex_features::Feature::PluginServicePreview),
),
turn_context.config.prefix_mcp_tool_names(),
rmcp::model::ElicitationCapability::default(),
/*supports_openai_form_elicitation*/ false,
@@ -224,6 +224,7 @@ remote_plugin = true
codex_home.path(),
&RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
plugin_service_preview: false,
},
Some(&auth),
)
+1 -1
View File
@@ -356,7 +356,7 @@ impl Session {
turn_context.permission_profile(),
mcp_runtime_context,
config.codex_home.to_path_buf(),
codex_apps_tools_cache_key(auth.as_ref()),
codex_apps_tools_cache_key(auth.as_ref(), mcp_config.plugin_service_preview),
mcp_config.prefix_mcp_tool_names,
mcp_config.client_elicitation_capability,
self.services
+6 -1
View File
@@ -1179,7 +1179,12 @@ impl Session {
session_configuration.permission_profile(),
mcp_runtime_context,
config.codex_home.to_path_buf(),
codex_apps_tools_cache_key(auth),
codex_apps_tools_cache_key(
auth,
config
.features
.enabled(codex_features::Feature::PluginServicePreview),
),
config.prefix_mcp_tool_names(),
client_elicitation_capability,
sess.services
@@ -397,6 +397,7 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
let mut server = codex_mcp::codex_apps_mcp_server_config(
"https://selected.invalid",
/*apps_mcp_product_sku*/ None,
/*plugin_service_preview*/ false,
);
let CapabilityRootLocation::Environment { environment_id, .. } =
&selected_root.location;
+3
View File
@@ -32,6 +32,9 @@ impl McpServerContributor<Config> for HostedPluginRuntimeExtension {
config: Box::new(hosted_plugin_runtime_mcp_server_config(
&config.chatgpt_base_url,
config.apps_mcp_product_sku.as_deref(),
config
.features
.enabled(codex_features::Feature::PluginServicePreview),
)),
}]
})
+11
View File
@@ -189,6 +189,11 @@ pub enum Feature {
ComputerUse,
/// Temporary internal-only flag for PS-backed remote plugin catalog development.
RemotePlugin,
/// Route eligible plugin-service requests to the preview deployment.
///
/// This is a routing selector, not an authorization boundary. The gateway must only honor the
/// corresponding cookie for internal traffic.
PluginServicePreview,
/// Enable remote plugin sharing flows.
PluginSharing,
/// Removed compatibility flag retained as a no-op.
@@ -1143,6 +1148,12 @@ pub const FEATURES: &[FeatureSpec] = &[
stage: Stage::UnderDevelopment,
default_enabled: false,
},
FeatureSpec {
id: Feature::PluginServicePreview,
key: "plugin_service_preview",
stage: Stage::UnderDevelopment,
default_enabled: false,
},
FeatureSpec {
id: Feature::PluginSharing,
key: "plugin_sharing",
@@ -1,23 +1,9 @@
use std::ffi::OsStr;
/// Process signal set by an eligible host to opt plugin-service requests into preview routing.
pub const CODEX_PLUGIN_SERVICE_PREVIEW_ENV_VAR: &str = "CODEX_PLUGIN_SERVICE_PREVIEW";
const PLUGIN_SERVICE_PREVIEW_ENABLED_VALUE: &str = "1";
const PLUGIN_SERVICE_PREVIEW_COOKIE_NAME: &[u8] = b"oai-chat-plugin-service-preview";
/// Routing cookie added to eligible plugin-service requests.
pub const PLUGIN_SERVICE_PREVIEW_COOKIE: &str = "oai-chat-plugin-service-preview=true";
/// Returns whether the host opted this process into plugin-service preview routing.
///
/// The host owns employee eligibility. This signal is defense-in-depth routing, not an
/// authorization boundary; authentication and authorization remain the responsibility of the
/// existing request path and plugin-service.
pub fn plugin_service_preview_enabled() -> bool {
plugin_service_preview_enabled_from_value(
std::env::var_os(CODEX_PLUGIN_SERVICE_PREVIEW_ENV_VAR).as_deref(),
)
}
/// This cookie is intentionally public and untrusted. It selects a deployment after normal
/// authentication; the gateway must independently restrict preview routing to internal traffic.
pub const PLUGIN_SERVICE_PREVIEW_COOKIE: &str = "oai-chat-plugin-service-preview=true";
/// Rewrites plugin-service cookies so callers cannot override the process routing signal.
///
@@ -49,10 +35,6 @@ pub fn plugin_service_routing_cookie(
(!cookies.is_empty()).then(|| cookies.join(&b"; "[..]))
}
fn plugin_service_preview_enabled_from_value(value: Option<&OsStr>) -> bool {
value == Some(OsStr::new(PLUGIN_SERVICE_PREVIEW_ENABLED_VALUE))
}
fn trim_cookie_whitespace(mut value: &[u8]) -> &[u8] {
while value
.first()
@@ -1,25 +1,6 @@
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn preview_signal_requires_exact_enabled_value() {
for value in [
None,
Some(""),
Some("0"),
Some("true"),
Some(" 1"),
Some("1 "),
] {
assert!(!plugin_service_preview_enabled_from_value(
value.map(OsStr::new)
));
}
assert!(plugin_service_preview_enabled_from_value(Some(OsStr::new(
"1"
))));
}
#[test]
fn routing_cookie_is_disabled_by_default_and_cannot_be_enabled_by_caller() {
assert_eq!(