()
| 102 | } |
| 103 | |
| 104 | func createHITLMiddleware() (*middleware.HumanInTheLoopMiddleware, error) { |
| 105 | return middleware.NewHumanInTheLoopMiddleware(&middleware.HumanInTheLoopMiddlewareConfig{ |
| 106 | // 配置需要审核的工具 |
| 107 | InterruptOn: map[string]any{ |
| 108 | "Bash": map[string]any{ |
| 109 | "message": "⚠️ Shell 命令执行需要审核,请确认命令安全性", |
| 110 | "allowed_decisions": []string{"approve", "reject", "edit"}, |
| 111 | }, |
| 112 | "Write": map[string]any{ |
| 113 | "message": "📝 文件写入操作需要审核", |
| 114 | "allowed_decisions": []string{"approve", "reject", "edit"}, |
| 115 | }, |
| 116 | "fs_delete": map[string]any{ |
| 117 | "message": "🗑️ 文件删除操作需要审核", |
| 118 | "allowed_decisions": []string{"approve", "reject"}, |
| 119 | }, |
| 120 | }, |
| 121 | // 智能审核处理器 |
| 122 | ApprovalHandler: smartApprovalHandler, |
| 123 | }) |
| 124 | } |
| 125 | |
| 126 | func smartApprovalHandler(ctx context.Context, req *middleware.ReviewRequest) ([]middleware.Decision, error) { |
| 127 | fmt.Println("\n" + strings.Repeat("=", 70)) |
no test coverage detected