Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions codex-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion codex-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ members = [
"exec-server",
"execpolicy",
"execpolicy-legacy",
"ext/connectors",
"ext/extension-api",
"ext/goal",
"ext/guardian",
Expand Down
1 change: 0 additions & 1 deletion codex-rs/app-server/src/mcp_refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ mod tests {
analytics_events_client: codex_analytics::AnalyticsEventsClient::disabled(),
thread_manager: thread_manager.clone(),
goal_service: Arc::new(codex_goal_extension::GoalService::new()),
environment_manager: Arc::clone(&environment_manager),
thread_store: Arc::clone(&thread_store),
},
),
Expand Down
2 changes: 0 additions & 2 deletions codex-rs/app-server/src/request_processors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ use codex_connectors::AppInfo;
use codex_core::CodexThread;
use codex_core::CodexThreadSettingsOverrides;
use codex_core::ForkSnapshot;
use codex_core::McpManager;
use codex_core::NewThread;
#[cfg(test)]
use codex_core::SessionMeta;
Expand Down Expand Up @@ -335,7 +334,6 @@ use codex_core_plugins::PluginInstallError as CorePluginInstallError;
use codex_core_plugins::PluginInstallRequest;
use codex_core_plugins::PluginReadRequest;
use codex_core_plugins::PluginUninstallError as CorePluginUninstallError;
use codex_core_plugins::PluginsManager;
use codex_core_plugins::loader::load_plugin_apps;
use codex_core_plugins::loader::load_plugin_mcp_servers;
use codex_core_plugins::manifest::PluginManifestInterface;
Expand Down
89 changes: 47 additions & 42 deletions codex-rs/app-server/src/request_processors/apps_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ impl AppsRequestProcessor {
};
let mut config = self.load_latest_config(fallback_cwd).await?;

if let Some(thread) = thread {
if let Some(thread) = thread.as_ref() {
let _ = config
.features
.set_enabled(Feature::Apps, thread.enabled(Feature::Apps));
}

let auth = self.auth_manager.auth().await;
if !config
.features
Expand All @@ -86,11 +85,24 @@ impl AppsRequestProcessor {
}));
}

let mcp_projection = match thread.as_ref() {
Some(thread) => thread.project_mcp_config(&config).await,
None => {
let mcp_config = self
.thread_manager
.mcp_manager()
.runtime_config(&config)
.await;
let runtime_context = McpRuntimeContext::new(
self.thread_manager.environment_manager(),
config.cwd.to_path_buf(),
);
(mcp_config, runtime_context)
}
};

let request = request_id.clone();
let outgoing = Arc::clone(&self.outgoing);
let environment_manager = self.thread_manager.environment_manager();
let mcp_manager = self.thread_manager.mcp_manager();
let plugins_manager = self.thread_manager.plugins_manager();
let shutdown_token = self.shutdown_token.child_token();
tokio::spawn(async move {
tokio::select! {
Expand All @@ -100,9 +112,7 @@ impl AppsRequestProcessor {
request,
params,
config,
environment_manager,
mcp_manager,
plugins_manager,
mcp_projection,
) => {}
}
});
Expand All @@ -118,24 +128,12 @@ impl AppsRequestProcessor {
request_id: ConnectionRequestId,
params: AppsListParams,
config: Config,
environment_manager: Arc<EnvironmentManager>,
mcp_manager: Arc<McpManager>,
plugins_manager: Arc<PluginsManager>,
mcp_projection: (codex_mcp::McpConfig, codex_mcp::McpRuntimeContext),
) {
let retry_params = params.clone();
let retry_config = config.clone();
let retry_environment_manager = Arc::clone(&environment_manager);
let retry_mcp_manager = Arc::clone(&mcp_manager);
let retry_plugins_manager = Arc::clone(&plugins_manager);
let result = Self::apps_list_response(
&outgoing,
params,
config,
environment_manager,
mcp_manager,
plugins_manager,
)
.await;
let retry_mcp_projection = mcp_projection.clone();
let result = Self::apps_list_response(&outgoing, params, config, mcp_projection).await;
let should_retry = result
.as_ref()
.is_ok_and(|(_, codex_apps_ready)| !codex_apps_ready);
Expand All @@ -150,9 +148,7 @@ impl AppsRequestProcessor {
&outgoing,
retry_params,
retry_config,
retry_environment_manager,
retry_mcp_manager,
retry_plugins_manager,
retry_mcp_projection,
)
.await
{
Expand All @@ -165,9 +161,7 @@ impl AppsRequestProcessor {
outgoing: &Arc<OutgoingMessageSender>,
params: AppsListParams,
config: Config,
environment_manager: Arc<EnvironmentManager>,
mcp_manager: Arc<McpManager>,
plugins_manager: Arc<PluginsManager>,
mcp_projection: (codex_mcp::McpConfig, codex_mcp::McpRuntimeContext),
) -> Result<(AppsListResponse, bool), JSONRPCErrorError> {
let AppsListParams {
cursor,
Expand All @@ -183,13 +177,7 @@ impl AppsRequestProcessor {
None => 0,
};

let loaded_plugins = plugins_manager
.plugins_for_config(&config.plugins_config_input())
.await;
let connector_snapshot =
codex_connectors::ConnectorSnapshot::from_plugin_capability_summaries(
loaded_plugins.capability_summaries(),
);
let connector_snapshot = mcp_projection.0.connector_snapshot.clone();
let plugin_apps = connector_snapshot.connector_ids().to_vec();
let (mut accessible_connectors, mut all_connectors) = tokio::join!(
connectors::list_cached_accessible_connectors_from_mcp_tools(&config),
Expand All @@ -202,11 +190,12 @@ impl AppsRequestProcessor {
let accessible_config = config.clone();
let accessible_tx = tx.clone();
tokio::spawn(async move {
let result = connectors::list_accessible_connectors_from_mcp_tools_with_mcp_manager(
let (mcp_config, runtime_context) = mcp_projection;
let result = codex_core::connectors::list_accessible_connectors_from_mcp_config(
&accessible_config,
force_refetch,
Arc::clone(&environment_manager),
mcp_manager,
mcp_config,
runtime_context,
)
.await
.map_err(|err| format!("failed to load accessible apps: {err}"));
Expand Down Expand Up @@ -234,7 +223,11 @@ impl AppsRequestProcessor {

if accessible_connectors.is_some() || all_connectors.is_some() {
let merged = connectors::with_app_enabled_state(
merge_loaded_apps(all_connectors.as_deref(), accessible_connectors.as_deref()),
merge_loaded_apps(
all_connectors.as_deref(),
accessible_connectors.as_deref(),
&connector_snapshot,
),
&config,
);
if should_send_app_list_updated_notification(
Expand Down Expand Up @@ -293,7 +286,11 @@ impl AppsRequestProcessor {
accessible_connectors.as_deref()
};
let merged = connectors::with_app_enabled_state(
merge_loaded_apps(all_connectors_for_update, accessible_connectors_for_update),
merge_loaded_apps(
all_connectors_for_update,
accessible_connectors_for_update,
&connector_snapshot,
),
&config,
);
if should_send_app_list_updated_notification(
Expand Down Expand Up @@ -372,11 +369,19 @@ enum AppListLoadResult {
fn merge_loaded_apps(
all_connectors: Option<&[AppInfo]>,
accessible_connectors: Option<&[AppInfo]>,
connector_snapshot: &codex_connectors::ConnectorSnapshot,
) -> Vec<AppInfo> {
let all_connectors_loaded = all_connectors.is_some();
let all = all_connectors.map_or_else(Vec::new, <[AppInfo]>::to_vec);
let accessible = accessible_connectors.map_or_else(Vec::new, <[AppInfo]>::to_vec);
connectors::merge_connectors_with_accessible(all, accessible, all_connectors_loaded)
let mut merged =
connectors::merge_connectors_with_accessible(all, accessible, all_connectors_loaded);
for connector in &mut merged {
connector.plugin_display_names = connector_snapshot
.plugin_display_names_for_connector_id(&connector.id)
.to_vec();
}
merged
}

fn should_send_app_list_updated_notification(
Expand Down
Loading
Loading