(ctx context.Context, input map[string]any, tc *tools.ToolContext)
| 102 | } |
| 103 | |
| 104 | func (t *TaskTool) Execute(ctx context.Context, input map[string]any, tc *tools.ToolContext) (any, error) { |
| 105 | action := GetStringParam(input, "action", "run") |
| 106 | |
| 107 | switch action { |
| 108 | case "list": |
| 109 | return t.listTasks() |
| 110 | case "status": |
| 111 | taskID := GetStringParam(input, "task_id", "") |
| 112 | if taskID == "" { |
| 113 | return NewClaudeErrorResponse(errors.New("task_id is required for status action")), nil |
| 114 | } |
| 115 | return t.getTaskStatus(taskID) |
| 116 | case "cancel": |
| 117 | taskID := GetStringParam(input, "task_id", "") |
| 118 | if taskID == "" { |
| 119 | return NewClaudeErrorResponse(errors.New("task_id is required for cancel action")), nil |
| 120 | } |
| 121 | return t.cancelTask(taskID) |
| 122 | case "run": |
| 123 | return t.runTask(ctx, input) |
| 124 | default: |
| 125 | return NewClaudeErrorResponse(fmt.Errorf("unknown action: %s", action)), nil |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | // listTasks 列出所有任务 |
| 130 | func (t *TaskTool) listTasks() (any, error) { |
no test coverage detected