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

Method cancelTask

pkg/tools/builtin/task.go:193–217  ·  view source on GitHub ↗

cancelTask 取消任务

(taskID string)

Source from the content-addressed store, hash-verified

191
192// cancelTask 取消任务
193func (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 启动任务
220func (t *TaskTool) runTask(ctx context.Context, input map[string]any) (any, error) {

Callers 1

ExecuteMethod · 0.95

Calls 3

GetGlobalTaskExecutorFunction · 0.85
NewClaudeErrorResponseFunction · 0.85
GetTaskMethod · 0.65

Tested by

no test coverage detected