mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-13 11:13:43 +08:00
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
39 lines
963 B
Java
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;
|
|
}
|
|
}
|