(requestId: string, reason?: string)
| 71 | * 拒绝请求 |
| 72 | */ |
| 73 | const reject = async (requestId: string, reason?: string) => { |
| 74 | const request = pendingApprovals.value.get(requestId); |
| 75 | if (!request) { |
| 76 | console.warn(`Approval request ${requestId} not found`); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | // 记录到历史 |
| 81 | approvalHistory.value.push({ |
| 82 | ...request, |
| 83 | decision: "rejected", |
| 84 | reason, |
| 85 | decidedAt: Date.now(), |
| 86 | }); |
| 87 | |
| 88 | // 发送到后端 |
| 89 | const { getInstance } = useWebSocket(); |
| 90 | const ws = getInstance(); |
| 91 | if (ws) { |
| 92 | ws.send({ |
| 93 | type: "permission_decision", |
| 94 | payload: { |
| 95 | request_id: requestId, |
| 96 | decision: "reject", |
| 97 | reason, |
| 98 | }, |
| 99 | }); |
| 100 | } else { |
| 101 | console.error("WebSocket not connected, cannot send rejection decision"); |
| 102 | } |
| 103 | |
| 104 | // 从待审批列表中移除 |
| 105 | pendingApprovals.value.delete(requestId); |
| 106 | }; |
| 107 | |
| 108 | /** |
| 109 | * 获取指定消息的待审批请求 |
no test coverage detected