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

Method Resume

pkg/executionplan/executor.go:410–448  ·  view source on GitHub ↗

Resume 恢复执行(从当前步骤继续)

(ctx context.Context, plan *ExecutionPlan, toolCtx *tools.ToolContext)

Source from the content-addressed store, hash-verified

408
409// Resume 恢复执行(从当前步骤继续)
410func (e *Executor) Resume(ctx context.Context, plan *ExecutionPlan, toolCtx *tools.ToolContext) error {
411 // 找到第一个未完成的步骤
412 startIndex := -1
413 for i := range plan.Steps {
414 if plan.Steps[i].Status == StepStatusPending || plan.Steps[i].Status == StepStatusFailed {
415 startIndex = i
416 break
417 }
418 }
419
420 if startIndex == -1 {
421 // 所有步骤已完成
422 plan.Status = StatusCompleted
423 plan.UpdatedAt = time.Now()
424 return nil
425 }
426
427 // 重置失败步骤的状态
428 for i := startIndex; i < len(plan.Steps); i++ {
429 if plan.Steps[i].Status == StepStatusFailed || plan.Steps[i].Status == StepStatusSkipped {
430 plan.Steps[i].Status = StepStatusPending
431 plan.Steps[i].Error = ""
432 plan.Steps[i].Result = nil
433 }
434 }
435
436 // 重置计划状态以允许执行
437 // 如果需要审批,设置为已审批;否则设置为草稿
438 if plan.Options != nil && plan.Options.RequireApproval {
439 plan.Status = StatusApproved
440 plan.UserApproved = true
441 } else {
442 plan.Status = StatusDraft
443 }
444 plan.UpdatedAt = time.Now()
445
446 // 继续执行
447 return e.Execute(ctx, plan, toolCtx)
448}
449
450// Cancel 取消执行
451func (e *Executor) Cancel(plan *ExecutionPlan, reason string) {

Callers 2

TestResumeFunction · 0.95
TestResumeFromFailedFunction · 0.95

Calls 1

ExecuteMethod · 0.95

Tested by 2

TestResumeFunction · 0.76
TestResumeFromFailedFunction · 0.76