zeph_commands/handlers/
policy.rs1use std::future::Future;
7use std::pin::Pin;
8
9use crate::context::CommandContext;
10use crate::{CommandError, CommandHandler, CommandOutput, SlashCategory};
11
12pub struct PolicyCommand;
16
17impl CommandHandler<CommandContext<'_>> for PolicyCommand {
18 fn name(&self) -> &'static str {
19 "/policy"
20 }
21
22 fn description(&self) -> &'static str {
23 "Inspect policy status or dry-run evaluation"
24 }
25
26 fn args_hint(&self) -> &'static str {
27 "[status|check <tool> [args_json]]"
28 }
29
30 fn category(&self) -> SlashCategory {
31 SlashCategory::Advanced
32 }
33
34 fn feature_gate(&self) -> Option<&'static str> {
35 Some("policy-enforcer")
36 }
37
38 fn handle<'a>(
39 &'a self,
40 ctx: &'a mut CommandContext<'_>,
41 args: &'a str,
42 ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
43 Box::pin(async move {
44 let result = ctx.agent.handle_policy(args).await?;
45 if result.is_empty() {
46 Ok(CommandOutput::Silent)
47 } else {
48 Ok(CommandOutput::Message(result))
49 }
50 })
51 }
52}