Files
codex/codex-rs/core-plugins/src/recommended_plugin_install.rs
Matthew Zeng de7bbb0481 Hydrate recommended plugin metadata on selection (#39143)
## What changed

- Fetch recommendations from the Codex-specific `/ps/plugins/suggested/codex` endpoint and parse its compact response shape.
- Fetch the selected plugin's details before presenting an install request, using them to verify availability and populate connector metadata.
- Skip install elicitation when the selected recommendation is no longer available, and return a retryable response when its metadata cannot be verified.

## Testing

- Cover the new recommendation route and response shape.
- Cover metadata hydration for available plugins and rejection of unavailable plugins.

GitOrigin-RevId: 2b0e2d70572aae2b7cd8e458b42e9dd14be3dbaf
2026-08-18 05:42:39 +00:00

32 lines
1.0 KiB
Rust

use crate::PluginsConfigInput;
use crate::remote::RemotePluginCatalogError;
use codex_login::CodexAuth;
use codex_tools::DiscoverableTool;
pub async fn hydrate_selected_recommended_plugin_install_metadata(
config: &PluginsConfigInput,
auth: Option<&CodexAuth>,
mut tool: DiscoverableTool,
) -> Result<Option<DiscoverableTool>, RemotePluginCatalogError> {
let DiscoverableTool::Plugin(plugin) = &mut tool else {
return Ok(Some(tool));
};
let remote_plugin_id = plugin.remote_plugin_id.clone().ok_or_else(|| {
RemotePluginCatalogError::UnexpectedResponse(format!(
"recommended plugin `{}` is missing remote plugin identity",
plugin.id
))
})?;
let Some(app_connector_ids) = crate::remote::fetch_recommended_plugin_install_metadata(
&config.remote_plugin_service_config(),
auth,
&remote_plugin_id,
)
.await?
else {
return Ok(None);
};
plugin.app_connector_ids = app_connector_ids;
Ok(Some(tool))
}