use super::Agent;
use crate::channel::Channel;
impl<C: Channel> Agent<C> {
pub(super) fn handle_scope_command_as_string(&self, args: &str) -> String {
let mut parts = args.split_whitespace();
let subcmd = parts.next().unwrap_or("list");
match subcmd {
"list" => {
let cfg = &self.runtime.config.security.capability_scopes;
if cfg.scopes.is_empty() {
return "No capability scopes configured.".to_owned();
}
let mut out = String::from("Capability scopes:\n");
for (name, scope) in &cfg.scopes {
use std::fmt::Write as _;
let _ = writeln!(out, " [{name}] patterns={}", scope.patterns.len());
}
out
}
"reset" => {
let default = self
.runtime
.config
.security
.capability_scopes
.default_scope
.clone();
format!(
"Scope reset to default ('{default}'). Use ScopedToolExecutor::set_scope_for_task at runtime to apply."
)
}
other => format!("Unknown /scope subcommand: {other}. Use: list, reset"),
}
}
}