pub struct PluginCondition {
pub server_ids: Option<HashSet<String>>,
pub tenant_ids: Option<HashSet<String>>,
pub tools: Option<HashSet<String>>,
pub prompts: Option<HashSet<String>>,
pub resources: Option<HashSet<String>>,
pub agents: Option<HashSet<String>>,
pub user_patterns: Option<Vec<String>>,
pub content_types: Option<Vec<String>>,
}Expand description
Condition for when a plugin should execute.
Narrows plugin scope to specific servers, tenants, tools, prompts, resources, or agents. All fields are optional — only specified fields participate in matching. Within a field, any match suffices (OR semantics). Across fields, all must match (AND semantics).
This is the legacy scoping mechanism. The unified routing system
(routes: in config) supersedes this — when routes are used,
conditions are ignored.
Mirrors Python’s PluginCondition in cpex/framework/models.py.
§Examples
use cpex_core::plugin::PluginCondition;
// Only run for specific tools on specific servers
let cond = PluginCondition {
server_ids: Some(vec!["server-1".into(), "server-2".into()].into_iter().collect()),
tools: Some(vec!["get_compensation".into()].into_iter().collect()),
..Default::default()
};
assert!(cond.server_ids.as_ref().unwrap().contains("server-1"));
assert!(cond.tools.as_ref().unwrap().contains("get_compensation"));Fields§
§server_ids: Option<HashSet<String>>Set of server IDs — plugin runs only on these servers.
tenant_ids: Option<HashSet<String>>Set of tenant IDs — plugin runs only for these tenants.
tools: Option<HashSet<String>>Set of tool names — plugin runs only for these tools.
prompts: Option<HashSet<String>>Set of prompt names — plugin runs only for these prompts.
resources: Option<HashSet<String>>Set of resource identifiers — plugin runs only for these resources.
agents: Option<HashSet<String>>Set of agent identifiers — plugin runs only for these agents.
user_patterns: Option<Vec<String>>User patterns (glob or regex) — plugin runs only for matching users.
content_types: Option<Vec<String>>Content types — plugin runs only for these content types.
Implementations§
Source§impl PluginCondition
impl PluginCondition
Sourcepub fn matches(&self, ctx: &MatchContext<'_>) -> bool
pub fn matches(&self, ctx: &MatchContext<'_>) -> bool
Whether this condition matches the given context.
A field that is None is treated as “any” (no restriction).
A Some(set) field matches if the given value is in the set
(exact match for ID-shaped fields; glob match via wildmatch
for user_patterns).
All specified fields must match — AND semantics within one condition.
Trait Implementations§
Source§impl Clone for PluginCondition
impl Clone for PluginCondition
Source§fn clone(&self) -> PluginCondition
fn clone(&self) -> PluginCondition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more