mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Honor layered configuration when loading plugins (#40954)
## What changed - Resolve plugin activation, MCP server policy, and marketplace definitions from the effective configuration stack, including system settings and trusted project overrides. - Load plugin skills independently for each working directory passed to `skills/list`. - Exclude project configuration from catalog requests whose `cwds` are omitted or empty. - Cache up to eight loaded plugin configurations with least-recently-used eviction so requests for different working directories can reuse their results. ## Testing - Cover layered plugin and MCP policy across trusted and untrusted projects. - Cover per-directory skill and plugin catalog results, cache reuse and eviction, and system-defined marketplaces. GitOrigin-RevId: cb68b2b1bdab1da48e05ca7562bc05014431fc71
This commit is contained in:
1 parent
7276d67081
commit
6ac012a0d4
18 files changed
+490
-132
No files matched your search
@@ -479,19 +479,12 @@ impl CatalogRequestProcessor {
|
||||
cwds
|
||||
};
|
||||
|
||||
let config = self.load_latest_config(/*fallback_cwd*/ None).await?;
|
||||
let skills_service = self.thread_manager.skills_service();
|
||||
let plugins_manager = self.thread_manager.plugins_manager();
|
||||
if force_reload && config.features.enabled(Feature::Plugins) {
|
||||
if force_reload {
|
||||
plugins_manager.clear_cache();
|
||||
skills_service.clear_cache();
|
||||
}
|
||||
// Plugin configuration is user-scoped; workspace skill rules are applied below.
|
||||
let plugins_input = config.plugins_config_input();
|
||||
let plugins = plugins_manager.plugins_for_config(&plugins_input).await;
|
||||
let effective_skill_roots = plugins.effective_plugin_skill_roots();
|
||||
let plugin_skill_snapshots =
|
||||
plugins_manager.plugin_skill_snapshots_for_config(&plugins_input);
|
||||
let fs = self
|
||||
.thread_manager
|
||||
.environment_manager()
|
||||
@@ -502,12 +495,11 @@ impl CatalogRequestProcessor {
|
||||
.map(|(index, cwd)| {
|
||||
let fs = fs.clone();
|
||||
let skills_request = &skills_request;
|
||||
let effective_skill_roots = effective_skill_roots.clone();
|
||||
let plugin_skill_snapshots = plugin_skill_snapshots.clone();
|
||||
let plugins_manager = Arc::clone(&plugins_manager);
|
||||
async move {
|
||||
let (cwd_abs, config_layer_stack) = match self.resolve_cwd_config(&cwd).await {
|
||||
let config = match self.load_latest_config(Some(cwd.clone())).await {
|
||||
Ok(resolved) => resolved,
|
||||
Err(message) => {
|
||||
Err(error) => {
|
||||
let error_path = cwd.clone();
|
||||
return (
|
||||
index,
|
||||
@@ -516,16 +508,20 @@ impl CatalogRequestProcessor {
|
||||
skills: Vec::new(),
|
||||
errors: vec![codex_app_server_protocol::SkillErrorInfo {
|
||||
path: error_path,
|
||||
message,
|
||||
message: error.message,
|
||||
}],
|
||||
},
|
||||
);
|
||||
}
|
||||
};
|
||||
let plugins_input = config.plugins_config_input();
|
||||
let plugins = plugins_manager.plugins_for_config(&plugins_input).await;
|
||||
let plugin_skill_snapshots =
|
||||
plugins_manager.plugin_skill_snapshots_for_config(&plugins_input);
|
||||
let skills_input = codex_skills_extension::HostSkillsLoadInput::new(
|
||||
cwd_abs.clone(),
|
||||
effective_skill_roots,
|
||||
config_layer_stack,
|
||||
config.cwd.clone(),
|
||||
plugins.effective_plugin_skill_roots(),
|
||||
config.config_layer_stack,
|
||||
)
|
||||
.with_plugin_skill_snapshots(plugin_skill_snapshots);
|
||||
let snapshot = skills_request
|
||||
|
||||
@@ -38,6 +38,7 @@ use codex_rmcp_client::OAuthDiscoveryTimeout;
|
||||
use codex_rmcp_client::StreamableHttpRedirectMode;
|
||||
use codex_rmcp_client::perform_oauth_login_silent;
|
||||
|
||||
mod local;
|
||||
mod search;
|
||||
|
||||
fn plugin_redirect_mode(plugin_root: &Path) -> StreamableHttpRedirectMode {
|
||||
@@ -557,7 +558,7 @@ impl PluginRequestProcessor {
|
||||
let include_local = marketplace_kinds.contains(&PluginListMarketplaceKind::Local);
|
||||
let include_vertical = marketplace_kinds.contains(&PluginListMarketplaceKind::Vertical);
|
||||
|
||||
let config = self.load_latest_config(/*fallback_cwd*/ None).await?;
|
||||
let config = self.load_catalog_config(&roots).await?;
|
||||
let empty_response = || PluginListResponse {
|
||||
marketplaces: Vec::new(),
|
||||
marketplace_load_errors: Vec::new(),
|
||||
@@ -815,7 +816,7 @@ impl PluginRequestProcessor {
|
||||
marketplaces: Vec::new(),
|
||||
marketplace_load_errors: Vec::new(),
|
||||
};
|
||||
let config = self.load_latest_config(/*fallback_cwd*/ None).await?;
|
||||
let config = self.load_catalog_config(&roots).await?;
|
||||
if !config.features.enabled(Feature::Plugins) {
|
||||
return Ok(empty_response());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
use super::*;
|
||||
|
||||
impl PluginRequestProcessor {
|
||||
pub(super) async fn load_catalog_config(
|
||||
&self,
|
||||
cwds: &[AbsolutePathBuf],
|
||||
) -> Result<Config, JSONRPCErrorError> {
|
||||
if cwds.is_empty() {
|
||||
self.config_manager
|
||||
.load_non_project_config()
|
||||
.await
|
||||
.map_err(|err| internal_error(format!("failed to reload config: {err}")))
|
||||
} else {
|
||||
self.load_latest_config(/*fallback_cwd*/ None).await
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,9 @@ impl PluginRequestProcessor {
|
||||
return Ok(empty_response());
|
||||
}
|
||||
|
||||
let config = self.load_latest_config(/*fallback_cwd*/ None).await?;
|
||||
let config = self
|
||||
.load_catalog_config(cwds.as_deref().unwrap_or_default())
|
||||
.await?;
|
||||
if !config.features.enabled(Feature::Plugins) {
|
||||
return Ok(empty_response());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user