请求需要响应
(self, event_type: str, payload: Dict[str, Any], depth: int)
| 181 | } |
| 182 | |
| 183 | def _handle_request(self, event_type: str, payload: Dict[str, Any], depth: int) -> Dict[str, Any]: |
| 184 | """请求需要响应""" |
| 185 | if event_type == "pre_action": |
| 186 | decision = self._handle_pre_tool_use(payload, depth) |
| 187 | if decision.get("action") == "block": |
| 188 | return {"decision": "block", "reason": decision.get("reason", "blocked by AHP")} |
| 189 | return {"decision": "allow", "metadata": {"reason": decision.get("reason", "")}} |
| 190 | # pre_prompt 和其他阻塞事件:默认允许 |
| 191 | return {"decision": "allow"} |
| 192 | |
| 193 | def dispatch(self, msg: Dict[str, Any]) -> Optional[Dict[str, Any]]: |
| 194 | method = msg.get("method") |
no test coverage detected