MCPcopy Create free account
hub / github.com/astercloud/aster / ControlTool

Method ControlTool

pkg/agent/agent.go:1368–1400  ·  view source on GitHub ↗

ControlTool 执行对运行中工具的控制

(callID, action, note string)

Source from the content-addressed store, hash-verified

1366
1367// ControlTool 执行对运行中工具的控制
1368func (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
1402func (a *Agent) controlRunningTool(callID, action string) error {
1403 a.mu.RLock()

Callers 1

handleToolControlMethod · 0.80

Calls 5

controlRunningToolMethod · 0.95
snapshotToolCallMethod · 0.95
EmitControlMethod · 0.80
EmitProgressMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected