mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
07f04cc3c7
## Summary - Move plugin discoverable recommendation filtering from `codex-core` into `codex-core-plugins` behind `ToolSuggestPluginDiscoveryInput`. - Keep `codex-core` as a thin adapter from `Config` to the core-plugins API and back to `DiscoverablePluginInfo`. - Keep the existing discoverable allowlist private to the core-plugins implementation. ## Validation - `just fmt` - `just test -p codex-core list_tool_suggest_discoverable_plugins` - `git diff --check` - Read-only subagent review: no findings
57 lines
2.0 KiB
Rust
57 lines
2.0 KiB
Rust
use crate::config::Config;
|
|
use codex_config::types::ToolSuggestDiscoverableType;
|
|
use codex_core_plugins::PluginsManager;
|
|
use codex_core_plugins::ToolSuggestPluginDiscoveryInput;
|
|
use codex_login::CodexAuth;
|
|
use codex_tools::DiscoverablePluginInfo;
|
|
use std::collections::HashSet;
|
|
|
|
pub(crate) async fn list_tool_suggest_discoverable_plugins(
|
|
config: &Config,
|
|
plugins_manager: &PluginsManager,
|
|
auth: Option<&CodexAuth>,
|
|
loaded_plugin_app_connector_ids: &[String],
|
|
) -> anyhow::Result<Vec<DiscoverablePluginInfo>> {
|
|
let input = ToolSuggestPluginDiscoveryInput {
|
|
plugins: config.plugins_config_input(),
|
|
configured_plugin_ids: config
|
|
.tool_suggest
|
|
.discoverables
|
|
.iter()
|
|
.filter(|discoverable| discoverable.kind == ToolSuggestDiscoverableType::Plugin)
|
|
.map(|discoverable| discoverable.id.clone())
|
|
.collect::<HashSet<_>>(),
|
|
disabled_plugin_ids: config
|
|
.tool_suggest
|
|
.disabled_tools
|
|
.iter()
|
|
.filter(|disabled_tool| disabled_tool.kind == ToolSuggestDiscoverableType::Plugin)
|
|
.map(|disabled_tool| disabled_tool.id.clone())
|
|
.collect::<HashSet<_>>(),
|
|
loaded_plugin_app_connector_ids: loaded_plugin_app_connector_ids
|
|
.iter()
|
|
.cloned()
|
|
.collect::<HashSet<_>>(),
|
|
};
|
|
plugins_manager
|
|
.list_tool_suggest_discoverable_plugins(&input, auth)
|
|
.await
|
|
.map(|plugins| {
|
|
plugins
|
|
.into_iter()
|
|
.map(|plugin| DiscoverablePluginInfo {
|
|
id: plugin.id,
|
|
name: plugin.name,
|
|
description: plugin.description,
|
|
has_skills: plugin.has_skills,
|
|
mcp_server_names: plugin.mcp_server_names,
|
|
app_connector_ids: plugin.app_connector_ids,
|
|
})
|
|
.collect()
|
|
})
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "discoverable_tests.rs"]
|
|
mod tests;
|