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

Method getTaskStatus

pkg/tools/builtin/task.go:158–190  ·  view source on GitHub ↗

getTaskStatus 获取任务状态

(taskID string)

Source from the content-addressed store, hash-verified

156
157// getTaskStatus 获取任务状态
158func (t *TaskTool) getTaskStatus(taskID string) (any, error) {
159 executor := GetGlobalTaskExecutor()
160 task, err := executor.GetTask(taskID)
161 if err != nil {
162 return NewClaudeErrorResponse(err), nil
163 }
164
165 response := map[string]any{
166 "ok": true,
167 "action": "status",
168 "task_id": task.TaskID,
169 "subagent": task.Subagent,
170 "model": task.Model,
171 "status": task.Status,
172 "start_time": task.StartTime.Unix(),
173 "duration": task.Duration.String(),
174 }
175
176 if task.Status == "completed" && task.Result != nil {
177 response["result"] = task.Result
178 }
179 if task.Error != "" {
180 response["error"] = task.Error
181 }
182 if task.Metadata != nil {
183 response["metadata"] = task.Metadata
184 }
185 if task.Status == "running" {
186 response["running_time"] = time.Since(task.StartTime).String()
187 }
188
189 return response, nil
190}
191
192// cancelTask 取消任务
193func (t *TaskTool) cancelTask(taskID string) (any, error) {

Callers 1

ExecuteMethod · 0.95

Calls 4

GetGlobalTaskExecutorFunction · 0.85
NewClaudeErrorResponseFunction · 0.85
GetTaskMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected