mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
## What changed - Support an optional cloud provider alongside executor plugins, refreshing its thread-scoped catalog at each regular turn when plugins are enabled. - Use cloud connector metadata for app attribution without starting cloud-declared MCP servers. - Scope cached catalogs to authentication and Apps availability. Retain the previous catalog on discovery failure within the same scope, clear stale catalogs on auth changes, and reject results completed under outdated credentials. - Add a cancellable regular-task startup phase that reconciles MCP before discovery and reapplies contributor state afterward without invalidating resource caches. ## Testing Add regression coverage for per-turn refresh, empty catalogs, discovery failures, plugin disabling, auth changes during discovery, MCP reconciliation and cancellation, and cloud app attribution alongside executor MCP tools. GitOrigin-RevId: 8469eb109ea316e21cbc4122c52ad8000caeef03
73 lines
2.3 KiB
Rust
73 lines
2.3 KiB
Rust
use codex_core::config::Config;
|
|
use codex_extension_api::ExtensionFuture;
|
|
use codex_extension_api::ExtensionRegistryBuilder;
|
|
use codex_extension_api::McpServerContribution;
|
|
use codex_extension_api::McpServerContributionContext;
|
|
use codex_extension_api::McpServerContributor;
|
|
use codex_mcp::CODEX_APPS_MCP_SERVER_NAME;
|
|
use codex_mcp::hosted_plugin_runtime_mcp_server_config;
|
|
|
|
mod cloud_plugin;
|
|
#[cfg(test)]
|
|
#[path = "event_stream_tests.rs"]
|
|
mod event_stream_tests;
|
|
mod plugin;
|
|
mod plugin_contributor;
|
|
mod plugin_contributor_state;
|
|
mod plugin_providers;
|
|
mod stream_manager;
|
|
|
|
pub use codex_core_plugins::PluginListQuery;
|
|
pub use codex_core_plugins::PluginProvider;
|
|
pub use codex_core_plugins::PluginProviderError;
|
|
pub use codex_core_plugins::PluginProviderFuture;
|
|
pub use codex_core_plugins::PluginProviderResult;
|
|
pub use plugin_contributor::install_plugin_providers;
|
|
pub use plugin_contributor::install_plugins;
|
|
pub use plugin_contributor_state::PluginsThreadState;
|
|
pub use plugin_providers::PluginProviders;
|
|
pub use stream_manager::McpEventStreamManager;
|
|
pub use stream_manager::McpEventStreamUpdate;
|
|
|
|
#[cfg(test)]
|
|
#[path = "stream_manager_tests.rs"]
|
|
mod stream_manager_tests;
|
|
|
|
struct HostedPluginRuntimeExtension;
|
|
|
|
impl McpServerContributor<Config> for HostedPluginRuntimeExtension {
|
|
fn id(&self) -> &'static str {
|
|
"hosted_plugin_runtime"
|
|
}
|
|
|
|
fn contribute<'a>(
|
|
&'a self,
|
|
context: McpServerContributionContext<'a, Config>,
|
|
) -> ExtensionFuture<'a, Vec<McpServerContribution>> {
|
|
Box::pin(async move {
|
|
let config = context.config();
|
|
let name = CODEX_APPS_MCP_SERVER_NAME.to_string();
|
|
if !config.features.enabled(codex_features::Feature::Apps) {
|
|
return vec![McpServerContribution::Remove { name }];
|
|
}
|
|
|
|
vec![McpServerContribution::HostedApps {
|
|
config: Box::new(hosted_plugin_runtime_mcp_server_config(
|
|
&config.chatgpt_base_url,
|
|
config.apps_mcp_product_sku.as_deref(),
|
|
context.originator(),
|
|
)),
|
|
protocol_mode: None,
|
|
}]
|
|
})
|
|
}
|
|
}
|
|
|
|
pub fn install(builder: &mut ExtensionRegistryBuilder<Config>) {
|
|
builder.mcp_server_contributor(std::sync::Arc::new(HostedPluginRuntimeExtension));
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "lib_tests.rs"]
|
|
mod tests;
|