feat: retry selected stage with input overrides
This commit is contained in:
+44
-5
@@ -37,7 +37,7 @@ type App struct {
|
||||
type options struct {
|
||||
harness string
|
||||
url, name, prompt, title, template, workspace, paths, key, opencode, model string
|
||||
retryMode string
|
||||
retryMode, retryStage, retryInputFile string
|
||||
option, feedback, evidence, actor string
|
||||
output string
|
||||
conflict string
|
||||
@@ -47,7 +47,7 @@ type options struct {
|
||||
keepSet bool
|
||||
all bool
|
||||
json, source, noOpen, yes, allow, createOnly, force, wait bool
|
||||
version, expected, limit, recoverySequence int
|
||||
version, expected, limit, recoverySequence, retryVisit int
|
||||
recoveryRun int64
|
||||
recoveryStage, resource string
|
||||
timeout, waitTimeout time.Duration
|
||||
@@ -164,6 +164,10 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
f.BoolVar(&o.wait, "wait", false, "Wait for the new run to finish")
|
||||
f.DurationVar(&o.waitTimeout, "wait-timeout", 0, "Client limit for --wait (0 waits until the run ends); independent of --timeout")
|
||||
f.StringVar(&o.retryMode, "mode", "resume", "Retry mode: resume failed stage or restart from entry")
|
||||
f.StringVar(&o.retryStage, "stage", "", "Retry this recorded stage (required when it was visited more than once)")
|
||||
f.IntVar(&o.retryVisit, "visit", 0, "1-based occurrence of --stage in the recorded execution")
|
||||
f.IntVar(&o.version, "version", 0, "Explicit published version of the same pipeline (default: source version)")
|
||||
f.StringVar(&o.retryInputFile, "input-file", "", "JSON object merged into the selected stage input; '-' reads stdin")
|
||||
case "cancel", "draft-delete":
|
||||
f.BoolVar(&o.yes, "yes", false, "Confirm this action without an interactive prompt")
|
||||
case "retention":
|
||||
@@ -991,14 +995,49 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
if key == "" {
|
||||
key = fmt.Sprintf("retry-%d-%d", os.Getpid(), time.Now().UnixNano())
|
||||
}
|
||||
var retryInput map[string]any
|
||||
if o.retryInputFile != "" {
|
||||
var data []byte
|
||||
if o.retryInputFile == "-" {
|
||||
input := a.In
|
||||
if input == nil {
|
||||
input = os.Stdin
|
||||
}
|
||||
data, err = io.ReadAll(io.LimitReader(input, 64*1024+1))
|
||||
} else {
|
||||
var file *os.File
|
||||
file, err = os.Open(o.retryInputFile)
|
||||
if err == nil {
|
||||
data, err = io.ReadAll(io.LimitReader(file, 64*1024+1))
|
||||
_ = file.Close()
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(data) > 64*1024 {
|
||||
return fmt.Errorf("retry input exceeds 65536 bytes")
|
||||
}
|
||||
if err := json.Unmarshal(data, &retryInput); err != nil {
|
||||
return fmt.Errorf("invalid retry input JSON: %w", err)
|
||||
}
|
||||
if retryInput == nil {
|
||||
return fmt.Errorf("retry input must be a JSON object")
|
||||
}
|
||||
}
|
||||
if o.retryVisit < 0 {
|
||||
return fmt.Errorf("--visit must be positive")
|
||||
}
|
||||
r, err := call(protocol.Message{Type: typeName, RunID: id, RequestKey: key, RetryMode: o.retryMode, RetryStage: o.retryStage, RetryVisit: o.retryVisit, RetryVersion: o.version, RetryInput: retryInput})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return a.finishRun(ctx, r, o, call)
|
||||
}
|
||||
r, err := call(protocol.Message{Type: typeName, RunID: id, RequestKey: key, RetryMode: o.retryMode})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if command == "retry" {
|
||||
return a.finishRun(ctx, r, o, call)
|
||||
}
|
||||
return a.output(r.RunDetail)
|
||||
case "decide":
|
||||
if len(pos) < 1 || len(pos) > 2 {
|
||||
|
||||
Reference in New Issue
Block a user