cancelTask 取消任务
(taskID string)
| 191 | |
| 192 | // cancelTask 取消任务 |
| 193 | func (t *TaskTool) cancelTask(taskID string) (any, error) { |
| 194 | executor := GetGlobalTaskExecutor() |
| 195 | task, err := executor.GetTask(taskID) |
| 196 | if err != nil { |
| 197 | return NewClaudeErrorResponse(err), nil |
| 198 | } |
| 199 | |
| 200 | if task.Status == "completed" || task.Status == "failed" { |
| 201 | return map[string]any{ |
| 202 | "ok": false, |
| 203 | "action": "cancel", |
| 204 | "task_id": taskID, |
| 205 | "status": task.Status, |
| 206 | "message": "Task already finished, cannot cancel", |
| 207 | }, nil |
| 208 | } |
| 209 | |
| 210 | return map[string]any{ |
| 211 | "ok": true, |
| 212 | "action": "cancel", |
| 213 | "task_id": taskID, |
| 214 | "message": "Cancel request sent", |
| 215 | "note": "Task cancellation is best-effort", |
| 216 | }, nil |
| 217 | } |
| 218 | |
| 219 | // runTask 启动任务 |
| 220 | func (t *TaskTool) runTask(ctx context.Context, input map[string]any) (any, error) { |
no test coverage detected