diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 1cb0222c..21d3512e 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -810,6 +810,15 @@ plugin/app capability summaries, inject available-skill/available-plugin/plugin instructions, parse plugin/app mentions, record app/plugin invocation telemetry, or filter MCP tools through Codex app connectors. +The tool-suggestion marketplace layer is now cold as well. `tool_suggest` is +never exposed in model-turn tool config, its core handler and discoverable +plugin scan were deleted, MCP startup/refresh passes empty plugin provenance, +session/thread state no longer carries `PluginsManager`, and the old +session-level explicit connector selection cache was removed because it only +served app/plugin suggestion bookkeeping. The remaining plugin code is now a +public Codex product library/CLI surface, not a live session organ; judge it as +the next removable husk, not as keeper spine. + The Phase 6 freshness slice is landed. It exposes read-only `thread/epiphany/freshness` from live retrieval summaries plus graph frontier/churn state and, for loaded threads, watcher-backed invalidation diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 300910e5..5c06fb44 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 262c056e..1ff2884a 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -281,4 +281,12 @@ rejected_paths: current_status: summary: The Codex starvation pass has five typing receipts, thirty-eight processor/foundation cuts, a real physical extraction in `epiphany-codex-bridge`, a root `epiphany-state-model` crate for durable Epiphany state, a source-grounded Codex auth spine inventory, the native `epiphany-openai-adapter` document boundary, a buildable Codex auth/model wrapper in `epiphany-openai-codex-spine`, the first native runtime caller in `epiphany-openai-runtime`, native heartbeat launch planning/job opening in `epiphany-core`, native state-update contract/validation/application in `epiphany-core`, native exact retrieval path matching in `epiphany-core`, and the route-facing mutation/view/coordinator projection services in `epiphany-codex-bridge`. `codex-protocol` no longer defines the durable `Epiphany*` state structs; it re-exports the native model for legacy rollout/API compatibility while `epiphany-core` imports the native model directly. `epiphany-core` now has no direct vendored Codex dependency: pressure derivation accepts native `EpiphanyTokenUsageSnapshot`, Codex rollout replay moved to `codex-core::epiphany_rollout`, and exact retrieval search uses Epiphany-owned workspace walking/path scoring instead of `codex-file-search`. The bridge owns Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval/indexing projection, result projection, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, mutation service update/promote/role-accept/reorient-accept/role-launch/reorient-launch/job-launch/job-interrupt application, live-state projection, pressure/pre-compaction rendering, freshness/reorientation projection, CRRC/coordinator/role-board projection, watcher invalidation adaptation, full `thread/epiphany/view` response construction, freshness/context/graph-query response construction, role/reorient result response construction, distill/propose patch-response construction, coordinator status/view construction, and acceptance/evidence signal helpers. Vendored app-server no longer retains root Epiphany modules; `codex_message_processor.rs` still contains route dispatch, JSON-RPC response shaping, watcher registration/snapshotting calls, and notification emission, but its root no longer imports the evacuated Epiphany policy/protocol registry or owns the watcher invalidation manager. Codex product surfaces for apps, skills, plugins, marketplace, and external agent config import are now inert in the app-server compatibility path: list routes return empty lists, mutation/detail/import routes report disabled, `externalAgentConfig/detect` returns no import candidates, helper/import modules and stale implementation-shape tests were deleted, runtime feature enablement no longer supports `apps` or `plugins`, config writes no longer emit plugin-toggle analytics, plugin/skill cache invalidation on config writes is gone, plugin startup warmups and app-list refreshes were removed, and app-server no longer directly depends on `codex-plugin`, `codex-chatgpt`, or `codex-core-plugins`. `Config::to_mcp_config` now keeps user-declared MCP servers but no longer accepts `PluginsManager`, folds plugin MCP servers into the runtime, enables Codex apps, enables skill MCP dependency install, or advertises plugin capability summaries; `TurnContext::apps_enabled()` now returns false so model turns cannot awaken Codex Apps through ChatGPT auth or feature flags; session startup and per-turn context no longer load skills, turns receive an empty `SkillLoadOutcome`, internal `Op::ListSkills` returns empty compatibility entries without loading config layers, plugin roots, skill files, or conversion helpers, the Codex skill watcher has been collapsed to a no-op marker with no file watcher, skill-root registration, cache-clear task, or `SkillsUpdateAvailable` session listener, model turns no longer run skill mention collection, skill env-var prompts, skill MCP dependency installation, skill instruction injection, or implicit skill invocation analytics from shell tools, and the turn prompt/router path no longer loads plugin/app capability summaries, injects available-skill/available-plugin/plugin instruction fragments, parses plugin/app mentions, records app/plugin invocation telemetry, or filters MCP tools through Codex app connectors. `codex_message_processor.rs` is about 9,637 lines; root `message_processor.rs` is about 1,292 lines after the external-agent/config-product cuts; `epiphany_read_routes.rs` is about 579 lines after the full view and read-response extractions; `epiphany_mutation_routes.rs` is about 694 lines after route-load/notification helper cuts and product-surface starvation; `epiphany_state_helpers.rs` is down to a 19-line rollout-state loader; and `codex_thread.rs` is about 1,425 lines after state-update law moved native. `epiphany-openai-adapter` defines CultCache `DatabaseEntry` request/event/receipt/auth-status documents with no Codex app-server or generic JSON dependency. `epiphany-openai-codex-spine` owns all direct Codex auth/model-transport imports for the native OpenAI path: it exposes `default_codex_home` and `auth_manager`, projects `AuthManager` / `CodexAuth` into typed `EpiphanyOpenAiAdapterStatus`, maps typed `EpiphanyOpenAiModelRequest` into Codex API `ResponsesApiRequest`, resolves auth/provider through keeper Codex crates, opens HTTP Responses streams through `codex-api`, maps deltas / completion into typed stream events and receipts, and no longer directly depends on `codex-app-server-protocol` just to name auth mode. `epiphany-openai-runtime` no longer depends directly on `codex-login`; it writes OpenAI status/request/stream-event/receipt records plus runtime sessions/jobs/results/events into `epiphany-core::runtime_spine_cache`, can emit the assistant text artifact for legacy result consumers, is now the default executor for startup-only repo birth specialists, and now has `run-worker` to load a durable `EpiphanyRuntimeWorkerLaunchRequest`, call the typed OpenAI runtime through the spine, persist typed `EpiphanyRuntimeRoleWorkerResult` / `EpiphanyRuntimeReorientWorkerResult` documents, and complete the original heartbeat/specialist runtime job without Codex worker execution; `codex exec` survives only as explicit fallback in repo-birth startup. `epiphany-mvp-coordinator` now invokes `epiphany-openai-runtime run-worker` for launched runtime job ids and no longer creates a second coordinator-owned shadow runtime job/result as a compensator. `epiphany-core::plan_runtime_spine_heartbeat_launch` validates launch contracts/conflicts and projects durable job bindings/runtime links; `epiphany-core::open_runtime_spine_heartbeat_job` owns the initialize-runtime/ensure-session/create-job sequence and now persists `EpiphanyRuntimeWorkerLaunchRequest` CultCache records keyed by runtime job id, with indexed kind/contract fields plus MessagePack-encoded typed launch documents instead of discarding work intent after queue receipt creation; `roleResult` and `reorientResult` now prefer typed worker result documents and fall back only to generic job summaries for older receipts; `epiphany-core::EpiphanyStateUpdate`, `epiphany_state_update_validation_errors`, and `apply_epiphany_state_update` own state-update document shape and mutation law while `codex-core` calls them for compatibility. Vendored `CodexThread::epiphany_launch_job` is now mostly revision check, persistence validation, launch request handoff, and rollout/session writeback for the compatibility route. Vendored `codex-core` no longer has `epiphany_distillation`, `epiphany_promotion`, `epiphany_proposal`, or `epiphany_retrieval` husk modules; it re-exports native surfaces from `epiphany-core` directly, and now owns only the real Codex rollout adapter because it is a host seam. `epiphany-runtime-spine` advertises OpenAI adapter status/model-request/stream-event/receipt CultNet schemas and mutation contracts, so the native caller now has a real storage route instead of only JSON-RPC. MCP itself is correctly JSON at its protocol edge; the target is typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON. The current OpenAI spine still pulls `codex-api` and a large transport dependency stack, so its next cut is dependency starvation after richer live callers move. + latest_cut: > + The Codex tool-suggestion marketplace path is cold: `tool_suggest` is no + longer exposed in model-turn tool config, its core handler and + discoverable-plugin scan were deleted, MCP startup/refresh uses empty plugin + provenance, session/thread state no longer carries `PluginsManager`, and + the explicit connector-selection cache was removed because it only served + app/plugin suggestion bookkeeping. The remaining plugin module is now a + public Codex product/CLI husk to judge next, not live session machinery. next_action: Continue starving coordinator/runtime execution and operator surfaces off app-server JSON-RPC and out of `codex_message_processor.rs`; keep the vestigial Codex organ narrowed to subscription auth/model transport. diff --git a/vendor/codex/codex-rs/core/src/codex_delegate.rs b/vendor/codex/codex-rs/core/src/codex_delegate.rs index 631c8397..ce330203 100644 --- a/vendor/codex/codex-rs/core/src/codex_delegate.rs +++ b/vendor/codex/codex-rs/core/src/codex_delegate.rs @@ -80,7 +80,6 @@ pub(crate) async fn run_codex_thread_interactive( models_manager, environment_manager: Arc::clone(&parent_session.services.environment_manager), skills_manager: Arc::clone(&parent_session.services.skills_manager), - plugins_manager: Arc::clone(&parent_session.services.plugins_manager), mcp_manager: Arc::clone(&parent_session.services.mcp_manager), skills_watcher: Arc::clone(&parent_session.services.skills_watcher), conversation_history: initial_history.unwrap_or(InitialHistory::New), diff --git a/vendor/codex/codex-rs/core/src/connectors.rs b/vendor/codex/codex-rs/core/src/connectors.rs index cfec9a20..950337cf 100644 --- a/vendor/codex/codex-rs/core/src/connectors.rs +++ b/vendor/codex/codex-rs/core/src/connectors.rs @@ -1,42 +1,29 @@ use std::collections::HashMap; -use std::collections::HashSet; -use std::sync::Arc; use std::sync::LazyLock; use std::sync::Mutex as StdMutex; use std::time::Duration; use std::time::Instant; -use anyhow::Context; use async_channel::unbounded; pub use codex_app_server_protocol::AppBranding; pub use codex_app_server_protocol::AppInfo; pub use codex_app_server_protocol::AppMetadata; -use codex_connectors::AllConnectorsCacheKey; -use codex_connectors::DirectoryListResponse; use codex_exec_server::EnvironmentManager; use codex_exec_server::EnvironmentManagerArgs; use codex_exec_server::ExecServerRuntimePaths; use codex_login::token_data::TokenData; use codex_protocol::protocol::SandboxPolicy; -use codex_tools::DiscoverableTool; use rmcp::model::ToolAnnotations; use serde::Deserialize; -use serde::de::DeserializeOwned; use tracing::warn; use crate::config::Config; use crate::config_loader::AppsRequirementsToml; -use crate::mcp::McpManager; -use crate::plugins::PluginsManager; -use crate::plugins::list_tool_suggest_discoverable_plugins; use crate::session::INITIAL_SUBMIT_ID; use codex_config::types::AppToolApproval; use codex_config::types::AppsConfigToml; -use codex_config::types::ToolSuggestDiscoverableType; -use codex_features::Feature; use codex_login::AuthManager; use codex_login::CodexAuth; -use codex_login::default_client::create_client; use codex_login::default_client::originator; use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; use codex_mcp::McpConnectionManager; @@ -48,7 +35,6 @@ use codex_mcp::compute_auth_statuses; use codex_mcp::with_codex_apps_mcp; const CONNECTORS_READY_TIMEOUT_ON_EMPTY_TOOLS: Duration = Duration::from_secs(30); -const DIRECTORY_CONNECTORS_TIMEOUT: Duration = Duration::from_secs(60); #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub(crate) struct AppToolPolicy { @@ -114,32 +100,6 @@ pub(crate) async fn list_accessible_and_enabled_connectors_from_manager( .collect() } -pub(crate) async fn list_tool_suggest_discoverable_tools_with_auth( - config: &Config, - auth: Option<&CodexAuth>, - accessible_connectors: &[AppInfo], -) -> anyhow::Result> { - let directory_connectors = - list_directory_connectors_for_tool_suggest_with_auth(config, auth).await?; - let connector_ids = tool_suggest_connector_ids(config).await; - let discoverable_connectors = - codex_connectors::filter::filter_tool_suggest_discoverable_connectors( - directory_connectors, - accessible_connectors, - &connector_ids, - originator().value.as_str(), - ) - .into_iter() - .map(DiscoverableTool::from); - let discoverable_plugins = list_tool_suggest_discoverable_plugins(config) - .await? - .into_iter() - .map(DiscoverableTool::from); - Ok(discoverable_connectors - .chain(discoverable_plugins) - .collect()) -} - pub async fn list_cached_accessible_connectors_from_mcp_tools( config: &Config, ) -> Option> { @@ -161,23 +121,6 @@ pub async fn list_cached_accessible_connectors_from_mcp_tools( }) } -pub(crate) fn refresh_accessible_connectors_cache_from_mcp_tools( - config: &Config, - auth: Option<&CodexAuth>, - mcp_tools: &HashMap, -) { - if !config.features.enabled(Feature::Apps) { - return; - } - - let cache_key = accessible_connectors_cache_key(config, auth); - let accessible_connectors = codex_connectors::filter::filter_disallowed_connectors( - accessible_connectors_from_mcp_tools(mcp_tools), - originator().value.as_str(), - ); - write_cached_accessible_connectors(cache_key, &accessible_connectors); -} - pub async fn list_accessible_connectors_from_mcp_tools_with_options( config: &Config, force_refetch: bool, @@ -228,16 +171,12 @@ pub async fn list_accessible_connectors_from_mcp_tools_with_environment_manager( }); } let cache_key = accessible_connectors_cache_key(config, auth.as_ref()); - let plugins_manager = Arc::new(PluginsManager::new(config.codex_home.to_path_buf())); - let mcp_manager = McpManager::new(Arc::clone(&plugins_manager)); - let tool_plugin_provenance = mcp_manager.tool_plugin_provenance(config).await; if !force_refetch && let Some(cached_connectors) = read_cached_accessible_connectors(&cache_key) { let cached_connectors = codex_connectors::filter::filter_disallowed_connectors( cached_connectors, originator().value.as_str(), ); - let cached_connectors = with_app_plugin_sources(cached_connectors, &tool_plugin_provenance); return Ok(AccessibleConnectorsStatus { connectors: cached_connectors, codex_apps_ready: true, @@ -339,8 +278,6 @@ pub async fn list_accessible_connectors_from_mcp_tools_with_environment_manager( if codex_apps_ready || !accessible_connectors.is_empty() { write_cached_accessible_connectors(cache_key, &accessible_connectors); } - let accessible_connectors = - with_app_plugin_sources(accessible_connectors, &tool_plugin_provenance); Ok(AccessibleConnectorsStatus { connectors: accessible_connectors, codex_apps_ready, @@ -403,113 +340,6 @@ fn write_cached_accessible_connectors( }); } -async fn tool_suggest_connector_ids(config: &Config) -> HashSet { - let mut connector_ids = PluginsManager::new(config.codex_home.to_path_buf()) - .plugins_for_config(config) - .await - .capability_summaries() - .iter() - .flat_map(|plugin| plugin.app_connector_ids.iter()) - .map(|connector_id| connector_id.0.clone()) - .collect::>(); - connector_ids.extend( - config - .tool_suggest - .discoverables - .iter() - .filter(|discoverable| discoverable.kind == ToolSuggestDiscoverableType::Connector) - .map(|discoverable| discoverable.id.clone()), - ); - connector_ids -} - -async fn list_directory_connectors_for_tool_suggest_with_auth( - config: &Config, - auth: Option<&CodexAuth>, -) -> anyhow::Result> { - if !config.features.enabled(Feature::Apps) { - return Ok(Vec::new()); - } - - let token_data = if let Some(auth) = auth { - auth.get_token_data().ok() - } else { - let auth_manager = - AuthManager::shared_from_config(config, /*enable_codex_api_key_env*/ false); - auth_manager - .auth() - .await - .and_then(|auth| auth.get_token_data().ok()) - }; - let Some(token_data) = token_data else { - return Ok(Vec::new()); - }; - - let account_id = match token_data.account_id.as_deref() { - Some(account_id) if !account_id.is_empty() => account_id, - _ => return Ok(Vec::new()), - }; - let access_token = token_data.access_token.clone(); - let account_id = account_id.to_string(); - let is_workspace_account = token_data.id_token.is_workspace_account(); - let cache_key = AllConnectorsCacheKey::new( - config.chatgpt_base_url.clone(), - Some(account_id.clone()), - token_data.id_token.chatgpt_user_id.clone(), - is_workspace_account, - ); - - codex_connectors::list_all_connectors_with_options( - cache_key, - is_workspace_account, - /*force_refetch*/ false, - |path| { - let access_token = access_token.clone(); - let account_id = account_id.clone(); - async move { - chatgpt_get_request_with_token::( - config, - path, - access_token.as_str(), - account_id.as_str(), - ) - .await - } - }, - ) - .await -} - -async fn chatgpt_get_request_with_token( - config: &Config, - path: String, - access_token: &str, - account_id: &str, -) -> anyhow::Result { - let client = create_client(); - let url = format!("{}{}", config.chatgpt_base_url, path); - let response = client - .get(&url) - .bearer_auth(access_token) - .header("chatgpt-account-id", account_id) - .header("Content-Type", "application/json") - .timeout(DIRECTORY_CONNECTORS_TIMEOUT) - .send() - .await - .context("failed to send request")?; - - if response.status().is_success() { - response - .json() - .await - .context("failed to parse JSON response") - } else { - let status = response.status(); - let body = response.text().await.unwrap_or_default(); - anyhow::bail!("request failed with status {status}: {body}"); - } -} - pub(crate) fn accessible_connectors_from_mcp_tools( mcp_tools: &HashMap, ) -> Vec { @@ -556,18 +386,6 @@ pub fn with_app_enabled_state(mut connectors: Vec, config: &Config) -> connectors } -pub fn with_app_plugin_sources( - mut connectors: Vec, - tool_plugin_provenance: &ToolPluginProvenance, -) -> Vec { - for connector in &mut connectors { - connector.plugin_display_names = tool_plugin_provenance - .plugin_display_names_for_connector_id(connector.id.as_str()) - .to_vec(); - } - connectors -} - pub(crate) fn app_tool_policy( config: &Config, connector_id: Option<&str>, diff --git a/vendor/codex/codex-rs/core/src/mcp.rs b/vendor/codex/codex-rs/core/src/mcp.rs index a74adf17..b3dd0c99 100644 --- a/vendor/codex/codex-rs/core/src/mcp.rs +++ b/vendor/codex/codex-rs/core/src/mcp.rs @@ -1,20 +1,16 @@ use std::collections::HashMap; -use std::sync::Arc; use crate::config::Config; -use crate::plugins::PluginsManager; use codex_config::McpServerConfig; use codex_login::CodexAuth; -use codex_mcp::ToolPluginProvenance; use codex_mcp::configured_mcp_servers; use codex_mcp::effective_mcp_servers; -use codex_mcp::tool_plugin_provenance as collect_tool_plugin_provenance; #[derive(Clone)] pub struct McpManager; impl McpManager { - pub fn new(_plugins_manager: Arc) -> Self { + pub fn new() -> Self { Self } @@ -31,9 +27,4 @@ impl McpManager { let mcp_config = config.to_mcp_config(); effective_mcp_servers(&mcp_config, auth) } - - pub async fn tool_plugin_provenance(&self, config: &Config) -> ToolPluginProvenance { - let mcp_config = config.to_mcp_config(); - collect_tool_plugin_provenance(&mcp_config) - } } diff --git a/vendor/codex/codex-rs/core/src/mcp_tool_call.rs b/vendor/codex/codex-rs/core/src/mcp_tool_call.rs index 82bbc7ca..5028ba97 100644 --- a/vendor/codex/codex-rs/core/src/mcp_tool_call.rs +++ b/vendor/codex/codex-rs/core/src/mcp_tool_call.rs @@ -611,16 +611,7 @@ async fn maybe_track_codex_app_used( let (connector_id, app_name) = metadata .map(|metadata| (metadata.connector_id, metadata.app_name)) .unwrap_or((None, None)); - let invocation_type = if let Some(connector_id) = connector_id.as_deref() { - let mentioned_connector_ids = sess.get_connector_selection().await; - if mentioned_connector_ids.contains(connector_id) { - InvocationType::Explicit - } else { - InvocationType::Implicit - } - } else { - InvocationType::Implicit - }; + let invocation_type = InvocationType::Implicit; let tracking = build_track_events_context( turn_context.model_info.slug.clone(), diff --git a/vendor/codex/codex-rs/core/src/plugins/discoverable.rs b/vendor/codex/codex-rs/core/src/plugins/discoverable.rs deleted file mode 100644 index 6492bcb1..00000000 --- a/vendor/codex/codex-rs/core/src/plugins/discoverable.rs +++ /dev/null @@ -1,102 +0,0 @@ -use anyhow::Context; -use std::collections::HashSet; -use tracing::warn; - -use super::OPENAI_BUNDLED_MARKETPLACE_NAME; -use super::OPENAI_CURATED_MARKETPLACE_NAME; -use super::PluginCapabilitySummary; -use super::PluginsManager; -use crate::config::Config; -use codex_config::types::ToolSuggestDiscoverableType; -use codex_features::Feature; -use codex_tools::DiscoverablePluginInfo; - -const TOOL_SUGGEST_DISCOVERABLE_PLUGIN_ALLOWLIST: &[&str] = &[ - "github@openai-curated", - "notion@openai-curated", - "slack@openai-curated", - "gmail@openai-curated", - "google-calendar@openai-curated", - "google-drive@openai-curated", - "linear@openai-curated", - "figma@openai-curated", - "computer-use@openai-bundled", -]; - -const TOOL_SUGGEST_DISCOVERABLE_MARKETPLACE_ALLOWLIST: &[&str] = &[ - OPENAI_BUNDLED_MARKETPLACE_NAME, - OPENAI_CURATED_MARKETPLACE_NAME, -]; - -pub(crate) async fn list_tool_suggest_discoverable_plugins( - config: &Config, -) -> anyhow::Result> { - if !config.features.enabled(Feature::Plugins) { - return Ok(Vec::new()); - } - - let plugins_manager = PluginsManager::new(config.codex_home.to_path_buf()); - let configured_plugin_ids = config - .tool_suggest - .discoverables - .iter() - .filter(|discoverable| discoverable.kind == ToolSuggestDiscoverableType::Plugin) - .map(|discoverable| discoverable.id.as_str()) - .collect::>(); - let marketplaces = plugins_manager - .list_marketplaces_for_config(config, &[]) - .context("failed to list plugin marketplaces for tool suggestions")? - .marketplaces; - let mut discoverable_plugins = Vec::::new(); - for marketplace in marketplaces { - let marketplace_name = marketplace.name; - if !TOOL_SUGGEST_DISCOVERABLE_MARKETPLACE_ALLOWLIST.contains(&marketplace_name.as_str()) { - continue; - } - - for plugin in marketplace.plugins { - if plugin.installed - || (!TOOL_SUGGEST_DISCOVERABLE_PLUGIN_ALLOWLIST.contains(&plugin.id.as_str()) - && !configured_plugin_ids.contains(plugin.id.as_str())) - { - continue; - } - - let plugin_id = plugin.id.clone(); - - match plugins_manager - .read_plugin_detail_for_marketplace_plugin(config, &marketplace_name, plugin) - .await - { - Ok(plugin) => { - let plugin: PluginCapabilitySummary = plugin.into(); - discoverable_plugins.push(DiscoverablePluginInfo { - id: plugin.config_name, - name: plugin.display_name, - description: plugin.description, - has_skills: plugin.has_skills, - mcp_server_names: plugin.mcp_server_names, - app_connector_ids: plugin - .app_connector_ids - .into_iter() - .map(|connector_id| connector_id.0) - .collect(), - }); - } - Err(err) => { - warn!("failed to load discoverable plugin suggestion {plugin_id}: {err:#}") - } - } - } - } - discoverable_plugins.sort_by(|left, right| { - left.name - .cmp(&right.name) - .then_with(|| left.id.cmp(&right.id)) - }); - Ok(discoverable_plugins) -} - -#[cfg(test)] -#[path = "discoverable_tests.rs"] -mod tests; diff --git a/vendor/codex/codex-rs/core/src/plugins/discoverable_tests.rs b/vendor/codex/codex-rs/core/src/plugins/discoverable_tests.rs deleted file mode 100644 index c5f8e692..00000000 --- a/vendor/codex/codex-rs/core/src/plugins/discoverable_tests.rs +++ /dev/null @@ -1,329 +0,0 @@ -use super::*; -use crate::plugins::PluginInstallRequest; -use crate::plugins::test_support::load_plugins_config; -use crate::plugins::test_support::write_curated_plugin; -use crate::plugins::test_support::write_curated_plugin_sha; -use crate::plugins::test_support::write_file; -use crate::plugins::test_support::write_openai_curated_marketplace; -use crate::plugins::test_support::write_plugins_feature_config; -use codex_tools::DiscoverablePluginInfo; -use codex_utils_absolute_path::AbsolutePathBuf; -use pretty_assertions::assert_eq; -use tempfile::tempdir; -use tracing::Level; -use tracing_subscriber::fmt::format::FmtSpan; -use tracing_test::internal::MockWriter; - -#[tokio::test] -async fn list_tool_suggest_discoverable_plugins_returns_uninstalled_curated_plugins() { - let codex_home = tempdir().expect("tempdir should succeed"); - let curated_root = crate::plugins::curated_plugins_repo_path(codex_home.path()); - write_openai_curated_marketplace(&curated_root, &["sample", "slack"]); - write_plugins_feature_config(codex_home.path()); - - let config = load_plugins_config(codex_home.path()).await; - let discoverable_plugins = list_tool_suggest_discoverable_plugins(&config) - .await - .unwrap(); - - assert_eq!( - discoverable_plugins, - vec![DiscoverablePluginInfo { - id: "slack@openai-curated".to_string(), - name: "slack".to_string(), - description: Some( - "Plugin that includes skills, MCP servers, and app connectors".to_string(), - ), - has_skills: true, - mcp_server_names: vec!["sample-docs".to_string()], - app_connector_ids: vec!["connector_calendar".to_string()], - }] - ); -} - -#[tokio::test] -async fn list_tool_suggest_discoverable_plugins_deduplicates_allowlisted_configured_plugin() { - let codex_home = tempdir().expect("tempdir should succeed"); - let plugin_id = TOOL_SUGGEST_DISCOVERABLE_PLUGIN_ALLOWLIST - .iter() - .copied() - .find(|plugin_id| { - plugin_id - .rsplit_once('@') - .is_some_and(|(_plugin_name, marketplace_name)| { - marketplace_name == OPENAI_BUNDLED_MARKETPLACE_NAME - }) - }) - .expect("allowlist should include a bundled plugin"); - let (plugin_name, marketplace_name) = plugin_id - .rsplit_once('@') - .expect("plugin id should include a marketplace"); - let marketplace_root = codex_home - .path() - .join(format!(".tmp/marketplaces/{marketplace_name}")); - write_file( - &marketplace_root.join(".agents/plugins/marketplace.json"), - &format!( - r#"{{ - "name": "{marketplace_name}", - "plugins": [ - {{"name": "{plugin_name}", "source": {{"source": "local", "path": "./plugins/{plugin_name}"}}}} - ] -}} -"# - ), - ); - write_curated_plugin(&marketplace_root, plugin_name); - write_file( - &codex_home.path().join(crate::config::CONFIG_TOML_FILE), - &format!( - r#"[features] -plugins = true - -[marketplaces.{marketplace_name}] -source_type = "git" -source = "/tmp/{marketplace_name}" - -[tool_suggest] -discoverables = [{{ type = "plugin", id = "{plugin_id}" }}] -"# - ), - ); - - let config = load_plugins_config(codex_home.path()).await; - let discoverable_plugins = list_tool_suggest_discoverable_plugins(&config) - .await - .unwrap(); - - assert_eq!(discoverable_plugins.len(), 1); - assert_eq!(discoverable_plugins[0].id, plugin_id); -} - -#[tokio::test] -async fn list_tool_suggest_discoverable_plugins_ignores_missing_allowlisted_plugin() { - let codex_home = tempdir().expect("tempdir should succeed"); - let curated_root = crate::plugins::curated_plugins_repo_path(codex_home.path()); - write_openai_curated_marketplace(&curated_root, &["slack"]); - let marketplace_name = TOOL_SUGGEST_DISCOVERABLE_PLUGIN_ALLOWLIST - .iter() - .copied() - .filter_map(|plugin_id| plugin_id.rsplit_once('@')) - .find(|(_plugin_name, marketplace_name)| { - *marketplace_name == OPENAI_BUNDLED_MARKETPLACE_NAME - }) - .map(|(_plugin_name, marketplace_name)| marketplace_name) - .expect("allowlist should include a bundled plugin"); - let marketplace_root = codex_home - .path() - .join(format!(".tmp/marketplaces/{marketplace_name}")); - write_file( - &marketplace_root.join(".agents/plugins/marketplace.json"), - &format!( - r#"{{ - "name": "{marketplace_name}", - "plugins": [ - {{"name": "sample", "source": {{"source": "local", "path": "./plugins/sample"}}}} - ] -}} -"# - ), - ); - write_file( - &codex_home.path().join(crate::config::CONFIG_TOML_FILE), - &format!( - r#"[features] -plugins = true - -[marketplaces.{marketplace_name}] -source_type = "git" -source = "/tmp/{marketplace_name}" -"# - ), - ); - - let config = load_plugins_config(codex_home.path()).await; - let discoverable_plugins = list_tool_suggest_discoverable_plugins(&config) - .await - .unwrap(); - - assert_eq!(discoverable_plugins.len(), 1); - assert_eq!(discoverable_plugins[0].id, "slack@openai-curated"); -} - -#[tokio::test] -async fn list_tool_suggest_discoverable_plugins_returns_empty_when_plugins_feature_disabled() { - let codex_home = tempdir().expect("tempdir should succeed"); - let curated_root = crate::plugins::curated_plugins_repo_path(codex_home.path()); - write_openai_curated_marketplace(&curated_root, &["slack"]); - write_file( - &codex_home.path().join(crate::config::CONFIG_TOML_FILE), - r#"[features] -plugins = false -"#, - ); - - let config = load_plugins_config(codex_home.path()).await; - let discoverable_plugins = list_tool_suggest_discoverable_plugins(&config) - .await - .unwrap(); - - assert_eq!(discoverable_plugins, Vec::::new()); -} - -#[tokio::test] -async fn list_tool_suggest_discoverable_plugins_normalizes_description() { - let codex_home = tempdir().expect("tempdir should succeed"); - let curated_root = crate::plugins::curated_plugins_repo_path(codex_home.path()); - write_openai_curated_marketplace(&curated_root, &["slack"]); - write_plugins_feature_config(codex_home.path()); - write_file( - &curated_root.join("plugins/slack/.codex-plugin/plugin.json"), - r#"{ - "name": "slack", - "description": " Plugin\n with extra spacing " -}"#, - ); - - let config = load_plugins_config(codex_home.path()).await; - let discoverable_plugins = list_tool_suggest_discoverable_plugins(&config) - .await - .unwrap(); - - assert_eq!( - discoverable_plugins, - vec![DiscoverablePluginInfo { - id: "slack@openai-curated".to_string(), - name: "slack".to_string(), - description: Some("Plugin with extra spacing".to_string()), - has_skills: true, - mcp_server_names: vec!["sample-docs".to_string()], - app_connector_ids: vec!["connector_calendar".to_string()], - }] - ); -} - -#[tokio::test] -async fn list_tool_suggest_discoverable_plugins_omits_installed_curated_plugins() { - let codex_home = tempdir().expect("tempdir should succeed"); - let curated_root = crate::plugins::curated_plugins_repo_path(codex_home.path()); - write_openai_curated_marketplace(&curated_root, &["slack"]); - write_curated_plugin_sha(codex_home.path()); - write_plugins_feature_config(codex_home.path()); - - PluginsManager::new(codex_home.path().to_path_buf()) - .install_plugin(PluginInstallRequest { - plugin_name: "slack".to_string(), - marketplace_path: AbsolutePathBuf::try_from( - curated_root.join(".agents/plugins/marketplace.json"), - ) - .expect("marketplace path"), - }) - .await - .expect("plugin should install"); - - let refreshed_config = load_plugins_config(codex_home.path()).await; - let discoverable_plugins = list_tool_suggest_discoverable_plugins(&refreshed_config) - .await - .unwrap(); - - assert_eq!(discoverable_plugins, Vec::::new()); -} - -#[tokio::test] -async fn list_tool_suggest_discoverable_plugins_includes_configured_plugin_ids() { - let codex_home = tempdir().expect("tempdir should succeed"); - let curated_root = crate::plugins::curated_plugins_repo_path(codex_home.path()); - write_openai_curated_marketplace(&curated_root, &["sample"]); - write_file( - &codex_home.path().join(crate::config::CONFIG_TOML_FILE), - r#"[features] -plugins = true - -[tool_suggest] -discoverables = [{ type = "plugin", id = "sample@openai-curated" }] -"#, - ); - - let config = load_plugins_config(codex_home.path()).await; - let discoverable_plugins = list_tool_suggest_discoverable_plugins(&config) - .await - .unwrap(); - - assert_eq!( - discoverable_plugins, - vec![DiscoverablePluginInfo { - id: "sample@openai-curated".to_string(), - name: "sample".to_string(), - description: Some( - "Plugin that includes skills, MCP servers, and app connectors".to_string(), - ), - has_skills: true, - mcp_server_names: vec!["sample-docs".to_string()], - app_connector_ids: vec!["connector_calendar".to_string()], - }] - ); -} - -#[tokio::test] -async fn list_tool_suggest_discoverable_plugins_does_not_reload_marketplace_per_plugin() { - let codex_home = tempdir().expect("tempdir should succeed"); - let curated_root = crate::plugins::curated_plugins_repo_path(codex_home.path()); - write_openai_curated_marketplace( - &curated_root, - &["slack", "build-ios-apps", "life-science-research"], - ); - write_plugins_feature_config(codex_home.path()); - - let too_long_prompt = "x".repeat(129); - for plugin_name in ["build-ios-apps", "life-science-research"] { - write_file( - &curated_root.join(format!("plugins/{plugin_name}/.codex-plugin/plugin.json")), - &format!( - r#"{{ - "name": "{plugin_name}", - "description": "Plugin that includes skills, MCP servers, and app connectors", - "interface": {{ - "defaultPrompt": "{too_long_prompt}" - }} -}}"# - ), - ); - } - - let config = load_plugins_config(codex_home.path()).await; - let buffer: &'static std::sync::Mutex> = - Box::leak(Box::new(std::sync::Mutex::new(Vec::new()))); - let subscriber = tracing_subscriber::fmt() - .with_level(true) - .with_ansi(false) - .with_max_level(Level::WARN) - .with_span_events(FmtSpan::NONE) - .with_writer(MockWriter::new(buffer)) - .finish(); - let _guard = tracing::subscriber::set_default(subscriber); - - let discoverable_plugins = list_tool_suggest_discoverable_plugins(&config) - .await - .unwrap(); - - assert_eq!(discoverable_plugins.len(), 1); - assert_eq!(discoverable_plugins[0].id, "slack@openai-curated"); - - let logs = String::from_utf8(buffer.lock().expect("buffer lock").clone()) - .expect("utf8 logs") - .replace('\\', "/"); - assert_eq!(logs.matches("ignoring interface.defaultPrompt").count(), 2); - let normalized_logs = logs.replace('\\', "/"); - assert_eq!( - normalized_logs - .matches("build-ios-apps/.codex-plugin/plugin.json") - .count(), - 1 - ); - assert_eq!( - normalized_logs - .matches("life-science-research/.codex-plugin/plugin.json") - .count(), - 1 - ); -} diff --git a/vendor/codex/codex-rs/core/src/plugins/mod.rs b/vendor/codex/codex-rs/core/src/plugins/mod.rs index 7cf9bc0e..5992b3f8 100644 --- a/vendor/codex/codex-rs/core/src/plugins/mod.rs +++ b/vendor/codex/codex-rs/core/src/plugins/mod.rs @@ -1,6 +1,5 @@ use codex_config::types::McpServerConfig; -mod discoverable; mod installed_marketplaces; mod manager; mod marketplace_add; @@ -22,7 +21,6 @@ pub use codex_plugin::validate_plugin_segment; pub type LoadedPlugin = codex_plugin::LoadedPlugin; pub type PluginLoadOutcome = codex_plugin::PluginLoadOutcome; -pub(crate) use discoverable::list_tool_suggest_discoverable_plugins; pub use installed_marketplaces::INSTALLED_MARKETPLACES_DIR; pub use installed_marketplaces::marketplace_install_root; pub use manager::ConfiguredMarketplace; diff --git a/vendor/codex/codex-rs/core/src/session/mcp.rs b/vendor/codex/codex-rs/core/src/session/mcp.rs index ce79d684..4f94446b 100644 --- a/vendor/codex/codex-rs/core/src/session/mcp.rs +++ b/vendor/codex/codex-rs/core/src/session/mcp.rs @@ -211,11 +211,6 @@ impl Session { let auth = self.services.auth_manager.auth().await; let config = self.get_config().await; let mcp_config = config.to_mcp_config(); - let tool_plugin_provenance = self - .services - .mcp_manager - .tool_plugin_provenance(config.as_ref()) - .await; let mcp_servers = with_codex_apps_mcp(mcp_servers, auth.as_ref(), &mcp_config); let auth_statuses = compute_auth_statuses(mcp_servers.iter(), store_mode).await; { @@ -240,7 +235,7 @@ impl Session { ), config.codex_home.to_path_buf(), codex_apps_tools_cache_key(auth.as_ref()), - tool_plugin_provenance, + ToolPluginProvenance::default(), ) .await; { diff --git a/vendor/codex/codex-rs/core/src/session/mod.rs b/vendor/codex/codex-rs/core/src/session/mod.rs index d71809a9..0c822991 100644 --- a/vendor/codex/codex-rs/core/src/session/mod.rs +++ b/vendor/codex/codex-rs/core/src/session/mod.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::collections::HashSet; use std::fmt::Debug; use std::path::Path; use std::path::PathBuf; @@ -59,6 +58,7 @@ use codex_login::default_client::originator; use codex_mcp::McpConnectionManager; use codex_mcp::McpRuntimeEnvironment; use codex_mcp::ToolInfo; +use codex_mcp::ToolPluginProvenance; use codex_mcp::codex_apps_tools_cache_key; #[cfg(test)] use codex_models_manager::collaboration_mode_presets::CollaborationModesConfig; @@ -255,7 +255,6 @@ use crate::guardian::GuardianReviewSessionManager; use crate::mcp::McpManager; use crate::memories; use crate::network_policy_decision::execpolicy_network_rule_amendment; -use crate::plugins::PluginsManager; use crate::rollout::RolloutRecorder; use crate::rollout::RolloutRecorderParams; use crate::rollout::map_session_init_error; @@ -371,7 +370,6 @@ pub(crate) struct CodexSpawnArgs { pub(crate) models_manager: Arc, pub(crate) environment_manager: Arc, pub(crate) skills_manager: Arc, - pub(crate) plugins_manager: Arc, pub(crate) mcp_manager: Arc, pub(crate) skills_watcher: Arc, pub(crate) conversation_history: InitialHistory, @@ -427,7 +425,6 @@ impl Codex { models_manager, environment_manager, skills_manager, - plugins_manager, mcp_manager, skills_watcher, conversation_history, @@ -613,7 +610,6 @@ impl Codex { conversation_history, session_source_clone, skills_manager, - plugins_manager, mcp_manager.clone(), skills_watcher, agent_control, @@ -1031,27 +1027,6 @@ impl Session { } } - // Merges connector IDs into the session-level explicit connector selection. - pub(crate) async fn merge_connector_selection( - &self, - connector_ids: HashSet, - ) -> HashSet { - let mut state = self.state.lock().await; - state.merge_connector_selection(connector_ids) - } - - // Returns the connector IDs currently selected for this session. - pub(crate) async fn get_connector_selection(&self) -> HashSet { - let state = self.state.lock().await; - state.get_connector_selection() - } - - // Clears connector IDs that were accumulated for explicit selection. - pub(crate) async fn clear_connector_selection(&self) { - let mut state = self.state.lock().await; - state.clear_connector_selection(); - } - async fn record_initial_history(&self, conversation_history: InitialHistory) { let turn_context = self.new_default_turn().await; let is_subagent = { diff --git a/vendor/codex/codex-rs/core/src/session/session.rs b/vendor/codex/codex-rs/core/src/session/session.rs index 0f193c3a..a9bdeea7 100644 --- a/vendor/codex/codex-rs/core/src/session/session.rs +++ b/vendor/codex/codex-rs/core/src/session/session.rs @@ -266,7 +266,6 @@ impl Session { initial_history: InitialHistory, session_source: SessionSource, skills_manager: Arc, - plugins_manager: Arc, mcp_manager: Arc, skills_watcher: Arc, agent_control: AgentControl, @@ -733,7 +732,6 @@ impl Session { guardian_rejection_circuit_breaker: Mutex::new(Default::default()), runtime_handle: tokio::runtime::Handle::current(), skills_manager, - plugins_manager: Arc::clone(&plugins_manager), mcp_manager: Arc::clone(&mcp_manager), skills_watcher, agent_control, @@ -832,7 +830,6 @@ impl Session { required_mcp_servers.sort(); let enabled_mcp_server_count = mcp_servers.values().filter(|server| server.enabled).count(); let required_mcp_server_count = required_mcp_servers.len(); - let tool_plugin_provenance = mcp_manager.tool_plugin_provenance(config.as_ref()).await; { let mut cancel_guard = sess.services.mcp_startup_cancellation_token.lock().await; cancel_guard.cancel(); @@ -855,7 +852,7 @@ impl Session { ), config.codex_home.to_path_buf(), codex_apps_tools_cache_key(auth), - tool_plugin_provenance, + ToolPluginProvenance::default(), ) .instrument(info_span!( "session_init.mcp_manager_init", diff --git a/vendor/codex/codex-rs/core/src/session/tests.rs b/vendor/codex/codex-rs/core/src/session/tests.rs index 7a42728b..8226e2a1 100644 --- a/vendor/codex/codex-rs/core/src/session/tests.rs +++ b/vendor/codex/codex-rs/core/src/session/tests.rs @@ -3165,7 +3165,7 @@ async fn session_new_fails_when_zsh_fork_enabled_without_zsh_path() { let (tx_event, _rx_event) = async_channel::unbounded(); let (agent_status_tx, _agent_status_rx) = watch::channel(AgentStatus::PendingInit); let plugins_manager = Arc::new(PluginsManager::new(config.codex_home.to_path_buf())); - let mcp_manager = Arc::new(McpManager::new(Arc::clone(&plugins_manager))); + let mcp_manager = Arc::new(McpManager::new()); let skills_manager = Arc::new(SkillsManager::new( config.codex_home.clone(), /*bundled_skills_enabled*/ true, @@ -3277,7 +3277,7 @@ pub(crate) async fn make_session_and_context() -> (Session, TurnContext) { let state = SessionState::new(session_configuration.clone()); let plugins_manager = Arc::new(PluginsManager::new(config.codex_home.to_path_buf())); - let mcp_manager = Arc::new(McpManager::new(Arc::clone(&plugins_manager))); + let mcp_manager = Arc::new(McpManager::new()); let skills_manager = Arc::new(SkillsManager::new( config.codex_home.clone(), /*bundled_skills_enabled*/ true, @@ -3483,7 +3483,7 @@ async fn make_session_with_config_and_rx( let (tx_event, rx_event) = async_channel::unbounded(); let (agent_status_tx, _agent_status_rx) = watch::channel(AgentStatus::PendingInit); let plugins_manager = Arc::new(PluginsManager::new(config.codex_home.to_path_buf())); - let mcp_manager = Arc::new(McpManager::new(Arc::clone(&plugins_manager))); + let mcp_manager = Arc::new(McpManager::new()); let skills_manager = Arc::new(SkillsManager::new( config.codex_home.clone(), /*bundled_skills_enabled*/ true, @@ -4589,7 +4589,7 @@ pub(crate) async fn make_session_and_context_with_dynamic_tools_and_rx( let state = SessionState::new(session_configuration.clone()); let plugins_manager = Arc::new(PluginsManager::new(config.codex_home.to_path_buf())); - let mcp_manager = Arc::new(McpManager::new(Arc::clone(&plugins_manager))); + let mcp_manager = Arc::new(McpManager::new()); let skills_manager = Arc::new(SkillsManager::new( config.codex_home.clone(), /*bundled_skills_enabled*/ true, diff --git a/vendor/codex/codex-rs/core/src/session/tests/guardian_tests.rs b/vendor/codex/codex-rs/core/src/session/tests/guardian_tests.rs index 22db9f39..38cba37d 100644 --- a/vendor/codex/codex-rs/core/src/session/tests/guardian_tests.rs +++ b/vendor/codex/codex-rs/core/src/session/tests/guardian_tests.rs @@ -742,7 +742,7 @@ async fn guardian_subagent_does_not_inherit_parent_exec_policy_rules() { config.codex_home.clone(), /*bundled_skills_enabled*/ true, )); - let mcp_manager = Arc::new(McpManager::new(Arc::clone(&plugins_manager))); + let mcp_manager = Arc::new(McpManager::new()); let skills_watcher = Arc::new(SkillsWatcher::noop()); let CodexSpawnOk { codex, .. } = Codex::spawn(CodexSpawnArgs { diff --git a/vendor/codex/codex-rs/core/src/state/service.rs b/vendor/codex/codex-rs/core/src/state/service.rs index f93a44d7..0d283650 100644 --- a/vendor/codex/codex-rs/core/src/state/service.rs +++ b/vendor/codex/codex-rs/core/src/state/service.rs @@ -10,7 +10,6 @@ use crate::exec_policy::ExecPolicyManager; use crate::guardian::GuardianRejection; use crate::guardian::GuardianRejectionCircuitBreaker; use crate::mcp::McpManager; -use crate::plugins::PluginsManager; use crate::skills_watcher::SkillsWatcher; use crate::tools::code_mode::CodeModeService; use crate::tools::network_approval::NetworkApprovalService; @@ -57,7 +56,6 @@ pub(crate) struct SessionServices { pub(crate) guardian_rejection_circuit_breaker: Mutex, pub(crate) runtime_handle: Handle, pub(crate) skills_manager: Arc, - pub(crate) plugins_manager: Arc, pub(crate) mcp_manager: Arc, pub(crate) skills_watcher: Arc, pub(crate) agent_control: AgentControl, diff --git a/vendor/codex/codex-rs/core/src/state/session.rs b/vendor/codex/codex-rs/core/src/state/session.rs index 70a83e25..d3fa7fe4 100644 --- a/vendor/codex/codex-rs/core/src/state/session.rs +++ b/vendor/codex/codex-rs/core/src/state/session.rs @@ -4,7 +4,6 @@ use codex_protocol::models::PermissionProfile; use codex_protocol::models::ResponseItem; use codex_sandboxing::policy_transforms::merge_permission_profiles; use std::collections::HashMap; -use std::collections::HashSet; use crate::context_manager::ContextManager; use crate::session::PreviousTurnSettings; @@ -30,7 +29,6 @@ pub(crate) struct SessionState { previous_turn_settings: Option, /// Startup prewarmed session prepared during session initialization. pub(crate) startup_prewarm: Option, - pub(crate) active_connector_selection: HashSet, pub(crate) pending_session_start_source: Option, epiphany_state: Option, granted_permissions: Option, @@ -49,7 +47,6 @@ impl SessionState { dependency_env: HashMap::new(), previous_turn_settings: None, startup_prewarm: None, - active_connector_selection: HashSet::new(), pending_session_start_source: None, epiphany_state: None, granted_permissions: None, @@ -192,25 +189,6 @@ impl SessionState { self.startup_prewarm.take() } - // Adds connector IDs to the active set and returns the merged selection. - pub(crate) fn merge_connector_selection(&mut self, connector_ids: I) -> HashSet - where - I: IntoIterator, - { - self.active_connector_selection.extend(connector_ids); - self.active_connector_selection.clone() - } - - // Returns the current connector selection tracked on session state. - pub(crate) fn get_connector_selection(&self) -> HashSet { - self.active_connector_selection.clone() - } - - // Removes all currently tracked connector selections. - pub(crate) fn clear_connector_selection(&mut self) { - self.active_connector_selection.clear(); - } - pub(crate) fn set_pending_session_start_source( &mut self, value: Option, @@ -252,7 +230,3 @@ fn merge_rate_limit_fields( } snapshot } - -#[cfg(test)] -#[path = "session_tests.rs"] -mod tests; diff --git a/vendor/codex/codex-rs/core/src/state/session_tests.rs b/vendor/codex/codex-rs/core/src/state/session_tests.rs deleted file mode 100644 index 5e90cc88..00000000 --- a/vendor/codex/codex-rs/core/src/state/session_tests.rs +++ /dev/null @@ -1,162 +0,0 @@ -use super::*; -use crate::session::tests::make_session_configuration_for_tests; -use codex_protocol::protocol::CreditsSnapshot; -use codex_protocol::protocol::RateLimitWindow; -use pretty_assertions::assert_eq; - -#[tokio::test] -// Verifies connector merging deduplicates repeated IDs. -async fn merge_connector_selection_deduplicates_entries() { - let session_configuration = make_session_configuration_for_tests().await; - let mut state = SessionState::new(session_configuration); - let merged = state.merge_connector_selection([ - "calendar".to_string(), - "calendar".to_string(), - "drive".to_string(), - ]); - - assert_eq!( - merged, - HashSet::from(["calendar".to_string(), "drive".to_string()]) - ); -} - -#[tokio::test] -// Verifies clearing connector selection removes all saved IDs. -async fn clear_connector_selection_removes_entries() { - let session_configuration = make_session_configuration_for_tests().await; - let mut state = SessionState::new(session_configuration); - state.merge_connector_selection(["calendar".to_string()]); - - state.clear_connector_selection(); - - assert_eq!(state.get_connector_selection(), HashSet::new()); -} - -#[tokio::test] -async fn set_rate_limits_defaults_limit_id_to_codex_when_missing() { - let session_configuration = make_session_configuration_for_tests().await; - let mut state = SessionState::new(session_configuration); - - state.set_rate_limits(RateLimitSnapshot { - limit_id: None, - limit_name: None, - primary: Some(RateLimitWindow { - used_percent: 12.0, - window_minutes: Some(60), - resets_at: Some(100), - }), - secondary: None, - credits: None, - plan_type: None, - rate_limit_reached_type: None, - }); - - assert_eq!( - state - .latest_rate_limits - .as_ref() - .and_then(|v| v.limit_id.clone()), - Some("codex".to_string()) - ); -} - -#[tokio::test] -async fn set_rate_limits_defaults_to_codex_when_limit_id_missing_after_other_bucket() { - let session_configuration = make_session_configuration_for_tests().await; - let mut state = SessionState::new(session_configuration); - - state.set_rate_limits(RateLimitSnapshot { - limit_id: Some("codex_other".to_string()), - limit_name: Some("codex_other".to_string()), - primary: Some(RateLimitWindow { - used_percent: 20.0, - window_minutes: Some(60), - resets_at: Some(200), - }), - secondary: None, - credits: None, - plan_type: None, - rate_limit_reached_type: None, - }); - state.set_rate_limits(RateLimitSnapshot { - limit_id: None, - limit_name: None, - primary: Some(RateLimitWindow { - used_percent: 30.0, - window_minutes: Some(60), - resets_at: Some(300), - }), - secondary: None, - credits: None, - plan_type: None, - rate_limit_reached_type: None, - }); - - assert_eq!( - state - .latest_rate_limits - .as_ref() - .and_then(|v| v.limit_id.clone()), - Some("codex".to_string()) - ); -} - -#[tokio::test] -async fn set_rate_limits_carries_credits_and_plan_type_from_codex_to_codex_other() { - let session_configuration = make_session_configuration_for_tests().await; - let mut state = SessionState::new(session_configuration); - - state.set_rate_limits(RateLimitSnapshot { - limit_id: Some("codex".to_string()), - limit_name: Some("codex".to_string()), - primary: Some(RateLimitWindow { - used_percent: 10.0, - window_minutes: Some(60), - resets_at: Some(100), - }), - secondary: None, - credits: Some(CreditsSnapshot { - has_credits: true, - unlimited: false, - balance: Some("50".to_string()), - }), - plan_type: Some(codex_protocol::account::PlanType::Plus), - rate_limit_reached_type: None, - }); - - state.set_rate_limits(RateLimitSnapshot { - limit_id: Some("codex_other".to_string()), - limit_name: None, - primary: Some(RateLimitWindow { - used_percent: 30.0, - window_minutes: Some(120), - resets_at: Some(200), - }), - secondary: None, - credits: None, - plan_type: None, - rate_limit_reached_type: None, - }); - - assert_eq!( - state.latest_rate_limits, - Some(RateLimitSnapshot { - limit_id: Some("codex_other".to_string()), - limit_name: None, - primary: Some(RateLimitWindow { - used_percent: 30.0, - window_minutes: Some(120), - resets_at: Some(200), - }), - secondary: None, - credits: Some(CreditsSnapshot { - has_credits: true, - unlimited: false, - balance: Some("50".to_string()), - }), - plan_type: Some(codex_protocol::account::PlanType::Plus), - rate_limit_reached_type: None, - }) - ); -} diff --git a/vendor/codex/codex-rs/core/src/tasks/mod.rs b/vendor/codex/codex-rs/core/src/tasks/mod.rs index b9621d8f..b8186038 100644 --- a/vendor/codex/codex-rs/core/src/tasks/mod.rs +++ b/vendor/codex/codex-rs/core/src/tasks/mod.rs @@ -246,7 +246,6 @@ impl Session { task: T, ) { self.abort_all_tasks(TurnAbortReason::Replaced).await; - self.clear_connector_selection().await; self.start_task(turn_context, input, task).await; } diff --git a/vendor/codex/codex-rs/core/src/thread_manager.rs b/vendor/codex/codex-rs/core/src/thread_manager.rs index 87cfbe29..19683987 100644 --- a/vendor/codex/codex-rs/core/src/thread_manager.rs +++ b/vendor/codex/codex-rs/core/src/thread_manager.rs @@ -3,7 +3,6 @@ use crate::agent::AgentControl; use crate::codex_thread::CodexThread; use crate::config::Config; use crate::mcp::McpManager; -use crate::plugins::PluginsManager; use crate::rollout::RolloutRecorder; use crate::rollout::truncation; use crate::session::Codex; @@ -167,7 +166,6 @@ pub(crate) struct ThreadManagerState { models_manager: Arc, environment_manager: Arc, skills_manager: Arc, - plugins_manager: Arc, mcp_manager: Arc, skills_watcher: Arc, session_source: SessionSource, @@ -208,11 +206,7 @@ impl ThreadManager { let codex_home = config.codex_home.clone(); let restriction_product = session_source.restriction_product(); let (thread_created_tx, _) = broadcast::channel(THREAD_CREATED_CHANNEL_CAPACITY); - let plugins_manager = Arc::new(PluginsManager::new_with_restriction_product( - codex_home.to_path_buf(), - restriction_product, - )); - let mcp_manager = Arc::new(McpManager::new(Arc::clone(&plugins_manager))); + let mcp_manager = Arc::new(McpManager::new()); let skills_manager = Arc::new(SkillsManager::new_with_restriction_product( codex_home, config.bundled_skills_enabled(), @@ -230,7 +224,6 @@ impl ThreadManager { ), environment_manager, skills_manager, - plugins_manager, mcp_manager, skills_watcher, auth_manager, @@ -282,11 +275,7 @@ impl ThreadManager { }; let (thread_created_tx, _) = broadcast::channel(THREAD_CREATED_CHANNEL_CAPACITY); let restriction_product = SessionSource::Exec.restriction_product(); - let plugins_manager = Arc::new(PluginsManager::new_with_restriction_product( - codex_home.clone(), - restriction_product, - )); - let mcp_manager = Arc::new(McpManager::new(Arc::clone(&plugins_manager))); + let mcp_manager = Arc::new(McpManager::new()); let skills_manager = Arc::new(SkillsManager::new_with_restriction_product( skills_codex_home, /*bundled_skills_enabled*/ true, @@ -304,7 +293,6 @@ impl ThreadManager { )), environment_manager, skills_manager, - plugins_manager, mcp_manager, skills_watcher, auth_manager, @@ -329,10 +317,6 @@ impl ThreadManager { self.state.skills_manager.clone() } - pub fn plugins_manager(&self) -> Arc { - self.state.plugins_manager.clone() - } - pub fn mcp_manager(&self) -> Arc { self.state.mcp_manager.clone() } @@ -888,7 +872,6 @@ impl ThreadManagerState { models_manager: Arc::clone(&self.models_manager), environment_manager: Arc::clone(&self.environment_manager), skills_manager: Arc::clone(&self.skills_manager), - plugins_manager: Arc::clone(&self.plugins_manager), mcp_manager: Arc::clone(&self.mcp_manager), skills_watcher: Arc::clone(&self.skills_watcher), conversation_history: initial_history, diff --git a/vendor/codex/codex-rs/core/src/tools/handlers/mod.rs b/vendor/codex/codex-rs/core/src/tools/handlers/mod.rs index f9d719fb..c17da43b 100644 --- a/vendor/codex/codex-rs/core/src/tools/handlers/mod.rs +++ b/vendor/codex/codex-rs/core/src/tools/handlers/mod.rs @@ -13,7 +13,6 @@ mod request_user_input; mod shell; mod test_sync; mod tool_search; -mod tool_suggest; mod unavailable_tool; pub(crate) mod unified_exec; mod view_image; @@ -48,7 +47,6 @@ pub use shell::ShellCommandHandler; pub use shell::ShellHandler; pub use test_sync::TestSyncHandler; pub use tool_search::ToolSearchHandler; -pub use tool_suggest::ToolSuggestHandler; pub use unavailable_tool::UnavailableToolHandler; pub(crate) use unavailable_tool::unavailable_tool_message; pub use unified_exec::UnifiedExecHandler; diff --git a/vendor/codex/codex-rs/core/src/tools/handlers/tool_suggest.rs b/vendor/codex/codex-rs/core/src/tools/handlers/tool_suggest.rs deleted file mode 100644 index 5c51c90d..00000000 --- a/vendor/codex/codex-rs/core/src/tools/handlers/tool_suggest.rs +++ /dev/null @@ -1,263 +0,0 @@ -use std::collections::HashSet; - -use codex_app_server_protocol::AppInfo; -use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; -use codex_rmcp_client::ElicitationAction; -use codex_tools::DiscoverableTool; -use codex_tools::DiscoverableToolAction; -use codex_tools::DiscoverableToolType; -use codex_tools::TOOL_SUGGEST_TOOL_NAME; -use codex_tools::ToolSuggestArgs; -use codex_tools::ToolSuggestResult; -use codex_tools::all_suggested_connectors_picked_up; -use codex_tools::build_tool_suggestion_elicitation_request; -use codex_tools::filter_tool_suggest_discoverable_tools_for_client; -use codex_tools::verified_connector_suggestion_completed; -use rmcp::model::RequestId; -use tracing::warn; - -use crate::connectors; -use crate::function_tool::FunctionCallError; -use crate::tools::context::FunctionToolOutput; -use crate::tools::context::ToolInvocation; -use crate::tools::context::ToolPayload; -use crate::tools::handlers::parse_arguments; -use crate::tools::registry::ToolHandler; -use crate::tools::registry::ToolKind; - -pub struct ToolSuggestHandler; - -impl ToolHandler for ToolSuggestHandler { - type Output = FunctionToolOutput; - - fn kind(&self) -> ToolKind { - ToolKind::Function - } - - #[expect( - clippy::await_holding_invalid_type, - reason = "tool suggestion discovery reads through the session-owned manager guard" - )] - async fn handle(&self, invocation: ToolInvocation) -> Result { - let ToolInvocation { - payload, - session, - turn, - call_id, - .. - } = invocation; - - let arguments = match payload { - ToolPayload::Function { arguments } => arguments, - _ => { - return Err(FunctionCallError::Fatal(format!( - "{TOOL_SUGGEST_TOOL_NAME} handler received unsupported payload" - ))); - } - }; - - let args: ToolSuggestArgs = parse_arguments(&arguments)?; - let suggest_reason = args.suggest_reason.trim(); - if suggest_reason.is_empty() { - return Err(FunctionCallError::RespondToModel( - "suggest_reason must not be empty".to_string(), - )); - } - if args.action_type != DiscoverableToolAction::Install { - return Err(FunctionCallError::RespondToModel( - "tool suggestions currently support only action_type=\"install\"".to_string(), - )); - } - if args.tool_type == DiscoverableToolType::Plugin - && turn.app_server_client_name.as_deref() == Some("codex-tui") - { - return Err(FunctionCallError::RespondToModel( - "plugin tool suggestions are not available in codex-tui yet".to_string(), - )); - } - - let auth = session.services.auth_manager.auth().await; - let manager = session.services.mcp_connection_manager.read().await; - let mcp_tools = manager.list_all_tools().await; - drop(manager); - let accessible_connectors = connectors::with_app_enabled_state( - connectors::accessible_connectors_from_mcp_tools(&mcp_tools), - &turn.config, - ); - let discoverable_tools = connectors::list_tool_suggest_discoverable_tools_with_auth( - &turn.config, - auth.as_ref(), - &accessible_connectors, - ) - .await - .map(|discoverable_tools| { - filter_tool_suggest_discoverable_tools_for_client( - discoverable_tools, - turn.app_server_client_name.as_deref(), - ) - }) - .map_err(|err| { - FunctionCallError::RespondToModel(format!( - "tool suggestions are unavailable right now: {err}" - )) - })?; - - let tool = discoverable_tools - .into_iter() - .find(|tool| tool.tool_type() == args.tool_type && tool.id() == args.tool_id) - .ok_or_else(|| { - FunctionCallError::RespondToModel(format!( - "tool_id must match one of the discoverable tools exposed by {TOOL_SUGGEST_TOOL_NAME}" - )) - })?; - - let request_id = RequestId::String(format!("tool_suggestion_{call_id}").into()); - let params = build_tool_suggestion_elicitation_request( - CODEX_APPS_MCP_SERVER_NAME, - session.conversation_id.to_string(), - turn.sub_id.clone(), - &args, - suggest_reason, - &tool, - ); - let response = session - .request_mcp_server_elicitation(turn.as_ref(), request_id, params) - .await; - let user_confirmed = response - .as_ref() - .is_some_and(|response| response.action == ElicitationAction::Accept); - - let completed = if user_confirmed { - verify_tool_suggestion_completed(&session, &turn, &tool, auth.as_ref()).await - } else { - false - }; - - if completed && let DiscoverableTool::Connector(connector) = &tool { - session - .merge_connector_selection(HashSet::from([connector.id.clone()])) - .await; - } - - let content = serde_json::to_string(&ToolSuggestResult { - completed, - user_confirmed, - tool_type: args.tool_type, - action_type: args.action_type, - tool_id: tool.id().to_string(), - tool_name: tool.name().to_string(), - suggest_reason: suggest_reason.to_string(), - }) - .map_err(|err| { - FunctionCallError::Fatal(format!( - "failed to serialize {TOOL_SUGGEST_TOOL_NAME} response: {err}" - )) - })?; - - Ok(FunctionToolOutput::from_text(content, Some(true))) - } -} - -async fn verify_tool_suggestion_completed( - session: &crate::session::session::Session, - turn: &crate::session::turn_context::TurnContext, - tool: &DiscoverableTool, - auth: Option<&codex_login::CodexAuth>, -) -> bool { - match tool { - DiscoverableTool::Connector(connector) => refresh_missing_suggested_connectors( - session, - turn, - auth, - std::slice::from_ref(&connector.id), - connector.id.as_str(), - ) - .await - .is_some_and(|accessible_connectors| { - verified_connector_suggestion_completed(connector.id.as_str(), &accessible_connectors) - }), - DiscoverableTool::Plugin(plugin) => { - session.reload_user_config_layer().await; - let config = session.get_config().await; - let completed = verified_plugin_suggestion_completed( - plugin.id.as_str(), - config.as_ref(), - session.services.plugins_manager.as_ref(), - ); - let _ = refresh_missing_suggested_connectors( - session, - turn, - auth, - &plugin.app_connector_ids, - plugin.id.as_str(), - ) - .await; - completed - } - } -} - -#[expect( - clippy::await_holding_invalid_type, - reason = "connector cache refresh reads through the session-owned manager guard" -)] -async fn refresh_missing_suggested_connectors( - session: &crate::session::session::Session, - turn: &crate::session::turn_context::TurnContext, - auth: Option<&codex_login::CodexAuth>, - expected_connector_ids: &[String], - tool_id: &str, -) -> Option> { - if expected_connector_ids.is_empty() { - return Some(Vec::new()); - } - - let manager = session.services.mcp_connection_manager.read().await; - let mcp_tools = manager.list_all_tools().await; - let accessible_connectors = connectors::with_app_enabled_state( - connectors::accessible_connectors_from_mcp_tools(&mcp_tools), - &turn.config, - ); - if all_suggested_connectors_picked_up(expected_connector_ids, &accessible_connectors) { - return Some(accessible_connectors); - } - - match manager.hard_refresh_codex_apps_tools_cache().await { - Ok(mcp_tools) => { - let accessible_connectors = connectors::with_app_enabled_state( - connectors::accessible_connectors_from_mcp_tools(&mcp_tools), - &turn.config, - ); - connectors::refresh_accessible_connectors_cache_from_mcp_tools( - &turn.config, - auth, - &mcp_tools, - ); - Some(accessible_connectors) - } - Err(err) => { - warn!( - "failed to refresh codex apps tools cache after tool suggestion for {tool_id}: {err:#}" - ); - None - } - } -} - -fn verified_plugin_suggestion_completed( - tool_id: &str, - config: &crate::config::Config, - plugins_manager: &crate::plugins::PluginsManager, -) -> bool { - plugins_manager - .list_marketplaces_for_config(config, &[]) - .ok() - .into_iter() - .flat_map(|outcome| outcome.marketplaces) - .flat_map(|marketplace| marketplace.plugins.into_iter()) - .any(|plugin| plugin.id == tool_id && plugin.installed) -} - -#[cfg(test)] -#[path = "tool_suggest_tests.rs"] -mod tests; diff --git a/vendor/codex/codex-rs/core/src/tools/handlers/tool_suggest_tests.rs b/vendor/codex/codex-rs/core/src/tools/handlers/tool_suggest_tests.rs deleted file mode 100644 index 77ab793d..00000000 --- a/vendor/codex/codex-rs/core/src/tools/handlers/tool_suggest_tests.rs +++ /dev/null @@ -1,45 +0,0 @@ -use super::*; -use crate::plugins::PluginInstallRequest; -use crate::plugins::PluginsManager; -use crate::plugins::test_support::load_plugins_config; -use crate::plugins::test_support::write_curated_plugin_sha; -use crate::plugins::test_support::write_openai_curated_marketplace; -use crate::plugins::test_support::write_plugins_feature_config; -use codex_utils_absolute_path::AbsolutePathBuf; -use tempfile::tempdir; - -#[tokio::test] -async fn verified_plugin_suggestion_completed_requires_installed_plugin() { - let codex_home = tempdir().expect("tempdir should succeed"); - let curated_root = crate::plugins::curated_plugins_repo_path(codex_home.path()); - write_openai_curated_marketplace(&curated_root, &["sample"]); - write_curated_plugin_sha(codex_home.path()); - write_plugins_feature_config(codex_home.path()); - - let config = load_plugins_config(codex_home.path()).await; - let plugins_manager = PluginsManager::new(codex_home.path().to_path_buf()); - - assert!(!verified_plugin_suggestion_completed( - "sample@openai-curated", - &config, - &plugins_manager, - )); - - plugins_manager - .install_plugin(PluginInstallRequest { - plugin_name: "sample".to_string(), - marketplace_path: AbsolutePathBuf::try_from( - curated_root.join(".agents/plugins/marketplace.json"), - ) - .expect("marketplace path"), - }) - .await - .expect("plugin should install"); - - let refreshed_config = load_plugins_config(codex_home.path()).await; - assert!(verified_plugin_suggestion_completed( - "sample@openai-curated", - &refreshed_config, - &plugins_manager, - )); -} diff --git a/vendor/codex/codex-rs/core/src/tools/spec.rs b/vendor/codex/codex-rs/core/src/tools/spec.rs index 220a079a..154d0a43 100644 --- a/vendor/codex/codex-rs/core/src/tools/spec.rs +++ b/vendor/codex/codex-rs/core/src/tools/spec.rs @@ -91,7 +91,6 @@ pub(crate) fn build_specs_with_discoverable_tools( use crate::tools::handlers::ShellHandler; use crate::tools::handlers::TestSyncHandler; use crate::tools::handlers::ToolSearchHandler; - use crate::tools::handlers::ToolSuggestHandler; use crate::tools::handlers::UnavailableToolHandler; use crate::tools::handlers::UnifiedExecHandler; use crate::tools::handlers::ViewImageHandler; @@ -163,7 +162,6 @@ pub(crate) fn build_specs_with_discoverable_tools( .cloned() .collect::>(); let mut tool_search_handler = None; - let tool_suggest_handler = Arc::new(ToolSuggestHandler); let code_mode_handler = Arc::new(CodeModeExecuteHandler); let code_mode_wait_handler = Arc::new(CodeModeWaitHandler); let js_repl_handler = Arc::new(JsReplHandler); @@ -271,9 +269,7 @@ pub(crate) fn build_specs_with_discoverable_tools( builder.register_handler(handler.name, tool_search_handler.clone()); } } - ToolHandlerKind::ToolSuggest => { - builder.register_handler(handler.name, tool_suggest_handler.clone()); - } + ToolHandlerKind::ToolSuggest => {} ToolHandlerKind::UnifiedExec => { builder.register_handler(handler.name, unified_exec_handler.clone()); } diff --git a/vendor/codex/codex-rs/tools/src/tool_config.rs b/vendor/codex/codex-rs/tools/src/tool_config.rs index 7f68f1e9..e343ef05 100644 --- a/vendor/codex/codex-rs/tools/src/tool_config.rs +++ b/vendor/codex/codex-rs/tools/src/tool_config.rs @@ -146,9 +146,9 @@ impl ToolsConfig { features.enabled(Feature::DefaultModeRequestUserInput); let include_search_tool = model_info.supports_search_tool && features.enabled(Feature::ToolSearch); - let include_tool_suggest = features.enabled(Feature::ToolSuggest) - && features.enabled(Feature::Apps) - && features.enabled(Feature::Plugins); + // Epiphany keeps Codex for subscription auth/model routing, not for + // app/plugin marketplace discovery inside model turns. + let include_tool_suggest = false; let include_original_image_detail = can_request_original_image_detail(model_info); // API-key auth bypasses Codex backend entitlement/tool normalization, so // callers must confirm ChatGPT auth before exposing the built-in tool.