mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
aa2403e2eb
## Why `codex-core` was re-exporting APIs owned by sibling `codex-*` crates, which made downstream crates depend on `codex-core` as a proxy module instead of the actual owner crate. Removing those forwards makes crate boundaries explicit and lets leaf crates drop unnecessary `codex-core` dependencies. In this PR, this reduces the dependency on `codex-core` to `codex-login` in the following files: ``` codex-rs/backend-client/Cargo.toml codex-rs/mcp-server/tests/common/Cargo.toml ``` ## What - Remove `codex-rs/core/src/lib.rs` re-exports for symbols owned by `codex-login`, `codex-mcp`, `codex-rollout`, `codex-analytics`, `codex-protocol`, `codex-shell-command`, `codex-sandboxing`, `codex-tools`, and `codex-utils-path`. - Delete the `default_client` forwarding shim in `codex-rs/core`. - Update in-crate and downstream callsites to import directly from the owning `codex-*` crate. - Add direct Cargo dependencies where callsites now target the owner crate, and remove `codex-core` from `codex-rs/backend-client`.
59 lines
2.2 KiB
Rust
59 lines
2.2 KiB
Rust
use std::collections::BTreeSet;
|
|
use std::collections::HashMap;
|
|
|
|
use codex_protocol::models::DeveloperInstructions;
|
|
use codex_protocol::models::ResponseItem;
|
|
|
|
use crate::connectors;
|
|
use crate::plugins::PluginCapabilitySummary;
|
|
use crate::plugins::render_explicit_plugin_instructions;
|
|
use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME;
|
|
use codex_mcp::mcp_connection_manager::ToolInfo;
|
|
|
|
pub(crate) fn build_plugin_injections(
|
|
mentioned_plugins: &[PluginCapabilitySummary],
|
|
mcp_tools: &HashMap<String, ToolInfo>,
|
|
available_connectors: &[connectors::AppInfo],
|
|
) -> Vec<ResponseItem> {
|
|
if mentioned_plugins.is_empty() {
|
|
return Vec::new();
|
|
}
|
|
|
|
// Turn each explicit plugin mention into a developer hint that points the
|
|
// model at the plugin's visible MCP servers, enabled apps, and skill prefix.
|
|
mentioned_plugins
|
|
.iter()
|
|
.filter_map(|plugin| {
|
|
let available_mcp_servers = mcp_tools
|
|
.values()
|
|
.filter(|tool| {
|
|
tool.server_name != CODEX_APPS_MCP_SERVER_NAME
|
|
&& tool
|
|
.plugin_display_names
|
|
.iter()
|
|
.any(|plugin_name| plugin_name == &plugin.display_name)
|
|
})
|
|
.map(|tool| tool.server_name.clone())
|
|
.collect::<BTreeSet<String>>()
|
|
.into_iter()
|
|
.collect::<Vec<_>>();
|
|
let available_apps = available_connectors
|
|
.iter()
|
|
.filter(|connector| {
|
|
connector.is_enabled
|
|
&& connector
|
|
.plugin_display_names
|
|
.iter()
|
|
.any(|plugin_name| plugin_name == &plugin.display_name)
|
|
})
|
|
.map(connectors::connector_display_label)
|
|
.collect::<BTreeSet<String>>()
|
|
.into_iter()
|
|
.collect::<Vec<_>>();
|
|
render_explicit_plugin_instructions(plugin, &available_mcp_servers, &available_apps)
|
|
.map(DeveloperInstructions::new)
|
|
.map(ResponseItem::from)
|
|
})
|
|
.collect()
|
|
}
|