mateclaw/mateclaw-server/src/main/java/vip/mate/tool/guard/ToolGuardResult.java
matevip 579d60125b Initial commit: MateClaw — Java + Vue 3 AI Assistant System
Full-stack AI assistant built on Spring AI Alibaba.
Features: ReAct Agent, Plan-and-Execute, MCP Protocol, Multi-Model, Multi-Channel.

Apache-2.0 License
2026-04-04 19:03:49 +08:00

39 lines
963 B
Java

package vip.mate.tool.guard;
/**
* 工具安全检查结果
*/
public record ToolGuardResult(
Action action,
String reason,
String matchedPattern
) {
public enum Action {
ALLOW,
BLOCK,
/** 需要用户审批后才能执行(执行前授权机制) */
NEEDS_APPROVAL
}
public static ToolGuardResult allow() {
return new ToolGuardResult(Action.ALLOW, null, null);
}
public static ToolGuardResult block(String reason, String matchedPattern) {
return new ToolGuardResult(Action.BLOCK, reason, matchedPattern);
}
public static ToolGuardResult needsApproval(String reason, String matchedPattern) {
return new ToolGuardResult(Action.NEEDS_APPROVAL, reason, matchedPattern);
}
public boolean isBlocked() {
return action == Action.BLOCK;
}
public boolean needsApproval() {
return action == Action.NEEDS_APPROVAL;
}
}