fix(plugins): close host capability gating gaps

This commit is contained in:
Casey Chow
2026-07-09 23:05:24 +00:00
parent ba60aff590
commit 44d2376f06
9 changed files with 320 additions and 10 deletions
@@ -350,6 +350,101 @@ async fn reprojects_cached_configured_and_fallback_plugins_for_host_capabilities
);
}
#[tokio::test]
async fn filters_unmaterialized_remote_plugins_by_fallback_host_capabilities() {
let codex_home = tempdir().expect("tempdir should succeed");
let marketplace_name = "remote-marketplace";
let plugin_name = "remote-plugin";
let plugin_id = format!("{plugin_name}@{marketplace_name}");
let malformed_plugin_name = "malformed-remote-plugin";
let malformed_plugin_id = format!("{malformed_plugin_name}@{marketplace_name}");
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": "git-subdir",
"url": "openai/remote-plugin",
"path": "plugins/remote-plugin"
}},
"requires": {{
"hostCapabilities": ["{HOST_CAPABILITY_INLINE_VISUALIZATION}"]
}}
}},
{{
"name": "{malformed_plugin_name}",
"source": {{
"source": "git-subdir",
"url": "openai/malformed-remote-plugin",
"path": "plugins/malformed-remote-plugin"
}},
"requires": {{
"hostCapabilities": "{HOST_CAPABILITY_INLINE_VISUALIZATION}"
}}
}}
]
}}
"#
),
);
write_file(
&codex_home.path().join(CONFIG_TOML_FILE),
&format!(
r#"[features]
plugins = true
[marketplaces.{marketplace_name}]
source_type = "git"
source = "/tmp/{marketplace_name}"
"#
),
);
let mut plugins = load_plugins_config(codex_home.path(), codex_home.path()).await;
let plugins_manager = PluginsManager::new(codex_home.path().to_path_buf());
let unsupported = list_discoverable_plugins(
&plugins_manager,
discovery_input(
plugins.clone(),
&[plugin_id.as_str(), malformed_plugin_id.as_str()],
&[],
&[],
),
/*auth*/ None,
)
.await;
assert_eq!(unsupported, Vec::new());
plugins
.host_capabilities
.insert(HOST_CAPABILITY_INLINE_VISUALIZATION.to_string());
let supported = list_discoverable_plugins(
&plugins_manager,
discovery_input(
plugins,
&[plugin_id.as_str(), malformed_plugin_id.as_str()],
&[],
&[],
),
/*auth*/ None,
)
.await;
assert_eq!(
supported
.into_iter()
.map(|plugin| plugin.id)
.collect::<Vec<_>>(),
vec![plugin_id]
);
}
#[tokio::test]
async fn reprojects_cached_skill_availability_for_current_config() {
let codex_home = tempdir().expect("tempdir should succeed");
@@ -206,13 +206,23 @@ async fn load_plugin_metadata(
)?;
let MarketplacePluginSource::Local { path: plugin_root } = &plugin.source else {
let required_host_capabilities = match plugin.manifest_fallback.as_ref() {
Some(fallback) => {
fallback
.parse_for_listing()
.ok_or_else(|| "invalid marketplace plugin manifest fallback".to_string())?
.requires
.host_capabilities
}
None => Vec::new(),
};
return Ok(Arc::new(ToolSuggestMetadataFragment {
config_name: plugin.id.clone(),
display_name: plugin.name.clone(),
description: prompt_safe_plugin_description(Some(
&remote_plugin_install_required_description(&plugin.source),
)),
required_host_capabilities: Vec::new(),
required_host_capabilities,
mcp_server_names: Vec::new(),
app_declarations: Vec::new(),
skill_inventory: None,