mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Separate selected plugin identities from MCP contributions (#47939)
## Why Plugin identity and skill ownership need to be available independently of MCP data, including for plugins without servers or connectors. Hosted plugins have no executor root and should not own executor skills. ## What changed - Add `McpServerContributor::selected_plugins` to declare executor plugin identities with deferred MCP data. Let the host assign server attribution and precedence across contributors. - Represent hosted connectors with `HostedPluginConnectors` and make `SelectedPluginIdentity::selected_root_id` optional instead of assigning synthetic roots to hosted plugins. - Resolve executor contributions before reading hosted connectors, and clear stale hosted state on account changes before executor loading can wait. - Preserve connector declarations from disabled plugins so Apps can hide those connectors. ## Testing Add coverage for account changes while executor loading is pending. Update tests to verify hosted identities have no executor root and disabled plugins hide their connectors even when plugin IDs differ from root IDs. GitOrigin-RevId: e7f511264c5874c1b56d5f3e4a46820724046db0
This commit is contained in:
@@ -29,6 +29,8 @@ pub use approval_review::SynchronousApprovalReviewer;
|
||||
pub use context::TurnContextContributionInput;
|
||||
pub use mcp::McpServerContribution;
|
||||
pub use mcp::McpServerContributionContext;
|
||||
pub use mcp::SelectedPlugin;
|
||||
pub use mcp::SelectedPluginContribution;
|
||||
pub use mcp::SelectedPluginIdentity;
|
||||
pub use mcp::SelectedPluginSnapshot;
|
||||
pub use prompt::PromptFragment;
|
||||
@@ -69,14 +71,15 @@ pub type ExtensionFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
|
||||
|
||||
/// Extension contribution that resolves runtime MCP servers from host config.
|
||||
///
|
||||
/// Contributors run in registration order. Later contributions for the same
|
||||
/// Contributors run in registration order. Later ordinary server contributions for the same
|
||||
/// name replace earlier ones. Implementations must contribute only names they
|
||||
/// own and must apply any source-specific policy before returning a server.
|
||||
/// Thread-scoped resolution exposes the host-seeded thread inputs; global
|
||||
/// resolution exposes none and must not imply a local fallback. Thread inputs
|
||||
/// are frozen for the runtime and do not include lifecycle-contributor state.
|
||||
/// Auto-discovered plugin servers are resolved by the plugin manager. A
|
||||
/// thread-selected plugin contribution must carry its own package provenance.
|
||||
/// Auto-discovered plugin servers are resolved by the plugin manager. Declare
|
||||
/// executor plugins separately so the host attributes their MCP servers
|
||||
/// and connectors to the same identity as their other capabilities.
|
||||
pub trait McpServerContributor<C: Sync>: Send + Sync {
|
||||
/// Stable identity used for registration provenance and conflict diagnostics.
|
||||
fn id(&self) -> &'static str;
|
||||
@@ -85,6 +88,17 @@ pub trait McpServerContributor<C: Sync>: Send + Sync {
|
||||
&'a self,
|
||||
context: McpServerContributionContext<'a, C>,
|
||||
) -> ExtensionFuture<'a, Vec<McpServerContribution>>;
|
||||
|
||||
/// Declares executor plugins, including those without MCP servers or connectors. Each
|
||||
/// declaration identifies the plugin once; its deferred MCP data cannot change that identity.
|
||||
/// Return plugins in precedence order: across contributors in registration order, the first
|
||||
/// plugin wins if several provide the same server.
|
||||
fn selected_plugins<'a>(
|
||||
&'a self,
|
||||
_context: McpServerContributionContext<'a, C>,
|
||||
) -> ExtensionFuture<'a, Vec<SelectedPlugin<'a>>> {
|
||||
Box::pin(async { Vec::new() })
|
||||
}
|
||||
}
|
||||
|
||||
/// Extension contribution that adds prompt fragments during prompt assembly.
|
||||
|
||||
@@ -5,6 +5,7 @@ use codex_protocol::protocol::SessionSource;
|
||||
|
||||
use crate::ExtensionData;
|
||||
use crate::ExtensionDataInit;
|
||||
use crate::ExtensionFuture;
|
||||
|
||||
/// Input supplied while resolving MCP server contributions.
|
||||
///
|
||||
@@ -127,7 +128,7 @@ impl<'a, C> McpServerContributionContext<'a, C> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Validated plugin identities projected for the current set of selected roots.
|
||||
/// Selected plugin identities and executor roots whose skills must be hidden.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct SelectedPluginSnapshot {
|
||||
pub plugins: Vec<SelectedPluginIdentity>,
|
||||
@@ -135,11 +136,29 @@ pub struct SelectedPluginSnapshot {
|
||||
pub disabled_plugin_roots: Vec<String>,
|
||||
}
|
||||
|
||||
/// The configured identity of a plugin resolved from one selected root.
|
||||
/// The configured identity of a selected plugin and, when present, the root owning its skills.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SelectedPluginIdentity {
|
||||
/// Hosted plugins have no executor root and cannot own skills from an executor folder.
|
||||
pub selected_root_id: Option<String>,
|
||||
pub plugin_id: String,
|
||||
}
|
||||
|
||||
/// An executor plugin and its deferred MCP data. Callers that only need the identity can drop
|
||||
/// `mcp` without loading server or connector configuration. A plugin still owns its skills when
|
||||
/// it has no MCP data.
|
||||
pub struct SelectedPlugin<'a> {
|
||||
pub selected_root_id: String,
|
||||
pub plugin_id: String,
|
||||
pub mcp: ExtensionFuture<'a, SelectedPluginContribution>,
|
||||
}
|
||||
|
||||
/// MCP data attributed by the host to the plugin that declared it.
|
||||
#[derive(Clone)]
|
||||
pub struct SelectedPluginContribution {
|
||||
pub plugin_display_name: String,
|
||||
pub connector_ids: Vec<String>,
|
||||
pub servers: Vec<(String, McpServerConfig)>,
|
||||
}
|
||||
|
||||
/// One extension-owned overlay for the runtime MCP server configuration.
|
||||
@@ -164,17 +183,9 @@ pub enum McpServerContribution {
|
||||
/// Overrides the HTTP protocol mode, or uses the hosted Apps default when absent.
|
||||
protocol_mode: Option<crate::McpProtocolMode>,
|
||||
},
|
||||
/// Registers a server declared by a plugin selected for this thread.
|
||||
SelectedPlugin {
|
||||
name: String,
|
||||
plugin_id: String,
|
||||
plugin_display_name: String,
|
||||
selection_order: usize,
|
||||
config: Box<McpServerConfig>,
|
||||
},
|
||||
/// Records a plugin selected for this thread and any connector IDs it declares.
|
||||
SelectedPluginPackage {
|
||||
selected_root_id: String,
|
||||
/// Attributes Apps connectors to an account-hosted plugin. Plugins from executor folders must
|
||||
/// use `McpServerContributor::selected_plugins`, even if they only provide Apps connectors.
|
||||
HostedPluginConnectors {
|
||||
plugin_id: String,
|
||||
plugin_display_name: String,
|
||||
connector_ids: Vec<String>,
|
||||
|
||||
@@ -61,6 +61,8 @@ pub use contributors::PreviousWorldStateSection;
|
||||
pub use contributors::PromptFragment;
|
||||
pub use contributors::PromptSlot;
|
||||
pub use contributors::RenderedWorldStateFragment;
|
||||
pub use contributors::SelectedPlugin;
|
||||
pub use contributors::SelectedPluginContribution;
|
||||
pub use contributors::SelectedPluginIdentity;
|
||||
pub use contributors::SelectedPluginSnapshot;
|
||||
pub use contributors::SkillInvocationContributor;
|
||||
|
||||
Reference in New Issue
Block a user