pub struct ToolScope {
pub task_type: Option<String>,
/* private fields */
}Expand description
Materialised tool scope: a pre-compiled allow-list of fully-qualified tool ids.
At agent build time, glob patterns are resolved against the registered tool set
and stored as a HashSet<String>. Runtime admission is an O(1) lookup.
Fields§
§task_type: Option<String>Identifier of this scope (task-type name).
Implementations§
Source§impl ToolScope
impl ToolScope
Sourcepub fn full() -> Self
pub fn full() -> Self
The identity scope: admits every tool id. Used for the general default scope.
§Examples
use zeph_tools::scope::ToolScope;
let scope = ToolScope::full();
assert!(scope.admits("builtin:shell"));
assert!(scope.admits("mcp:any_server/any_tool"));Sourcepub fn try_compile<S: BuildHasher>(
task_type: impl Into<String>,
patterns: &[String],
registry_ids: &HashSet<String, S>,
strictness: PatternStrictness,
is_general_scope: bool,
) -> Result<(Self, Vec<ScopeWarning>), ScopeError>
pub fn try_compile<S: BuildHasher>( task_type: impl Into<String>, patterns: &[String], registry_ids: &HashSet<String, S>, strictness: PatternStrictness, is_general_scope: bool, ) -> Result<(Self, Vec<ScopeWarning>), ScopeError>
Compile a scope from glob patterns against the materialised registry.
§Errors
Returns ScopeError::DeadPattern when a strict-namespace glob matches zero ids,
ScopeError::AccidentallyFull when a pattern expands to the entire registry without
an explicit general opt-in, or ScopeError::InvalidPattern on invalid glob syntax.
Sourcepub fn admits(&self, qualified_tool_id: &str) -> bool
pub fn admits(&self, qualified_tool_id: &str) -> bool
Returns true when the given fully-qualified tool id is admitted by this scope.
§Examples
use zeph_tools::scope::ToolScope;
let scope = ToolScope::full();
assert!(scope.admits("builtin:shell"));Sourcepub fn admitted_ids(&self) -> Vec<&str>
pub fn admitted_ids(&self) -> Vec<&str>
Returns the list of admitted tool ids (excluding full scopes).
Useful for /scope list output and the scope_at_definition audit field.
Sourcepub fn patterns(&self) -> &[String]
pub fn patterns(&self) -> &[String]
The raw glob patterns this scope was compiled from (for re-resolution).
Sourcepub fn re_resolve<S: BuildHasher>(
&self,
registry_ids: &HashSet<String, S>,
) -> Self
pub fn re_resolve<S: BuildHasher>( &self, registry_ids: &HashSet<String, S>, ) -> Self
Re-resolve the scope against a new registry (called on dynamic tool registration).
Returns a new ToolScope with the updated admit set; warnings are logged but not
returned (non-fatal for provisional namespaces).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ToolScope
impl RefUnwindSafe for ToolScope
impl Send for ToolScope
impl Sync for ToolScope
impl Unpin for ToolScope
impl UnsafeUnpin for ToolScope
impl UnwindSafe for ToolScope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more