ControlTool 执行对运行中工具的控制
(callID, action, note string)
| 1366 | |
| 1367 | // ControlTool 执行对运行中工具的控制 |
| 1368 | func (a *Agent) ControlTool(callID, action, note string) error { |
| 1369 | // 记录入站控制事件 |
| 1370 | a.eventBus.EmitControl(&types.ControlToolControlEvent{ |
| 1371 | CallID: callID, |
| 1372 | Action: action, |
| 1373 | Note: note, |
| 1374 | }) |
| 1375 | |
| 1376 | err := a.controlRunningTool(callID, action) |
| 1377 | ok := err == nil |
| 1378 | reason := "" |
| 1379 | if err != nil { |
| 1380 | reason = err.Error() |
| 1381 | } |
| 1382 | |
| 1383 | // 输出响应事件 |
| 1384 | a.eventBus.EmitControl(&types.ControlToolControlResponseEvent{ |
| 1385 | CallID: callID, |
| 1386 | Action: action, |
| 1387 | OK: ok, |
| 1388 | Reason: reason, |
| 1389 | }) |
| 1390 | |
| 1391 | // 如果取消成功,推送取消进度事件 |
| 1392 | if ok && action == "cancel" { |
| 1393 | a.eventBus.EmitProgress(&types.ProgressToolCancelledEvent{ |
| 1394 | Call: a.snapshotToolCall(callID), |
| 1395 | Reason: "canceled", |
| 1396 | }) |
| 1397 | } |
| 1398 | |
| 1399 | return err |
| 1400 | } |
| 1401 | |
| 1402 | func (a *Agent) controlRunningTool(callID, action string) error { |
| 1403 | a.mu.RLock() |
no test coverage detected