(requestId: string, reason?: string)
| 419 | * 拒绝工具执行 |
| 420 | */ |
| 421 | const rejectTool = (requestId: string, reason?: string): AgentExecutionResult => { |
| 422 | const approval = pendingApproval.value; |
| 423 | if (!approval || approval.id !== requestId) { |
| 424 | throw new Error("No pending approval or ID mismatch"); |
| 425 | } |
| 426 | |
| 427 | approvalStore.reject(requestId, reason); |
| 428 | pendingApproval.value = null; |
| 429 | isPaused.value = false; |
| 430 | isRunning.value = false; |
| 431 | |
| 432 | emitThink({ |
| 433 | stage: `工具被拒绝: ${approval.toolName}`, |
| 434 | reasoning: reason || "用户拒绝了敏感操作", |
| 435 | decision: "终止执行", |
| 436 | }); |
| 437 | |
| 438 | return { |
| 439 | status: "finished", |
| 440 | output: currentOutput.value + `\n\n[工具 ${approval.toolName} 被拒绝: ${reason || "用户拒绝"}]`, |
| 441 | history: history.value, |
| 442 | }; |
| 443 | }; |
| 444 | |
| 445 | /** |
| 446 | * 取消执行 |
nothing calls this directly
no test coverage detected