Record run input directory and retry failed runs with original inputs

This commit is contained in:
2026-10-09 14:23:21 +01:00
parent 42600f6961
commit 6bd0e28ce6
19 changed files with 507 additions and 22 deletions
+21 -2
View File
@@ -73,6 +73,9 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
f.BoolVar(&o.wait, "wait", false, "In JSON mode, wait for a terminal run state")
case "runs":
f.StringVar(&o.name, "pipeline", "", "Filter by exact pipeline name or ID")
case "retry":
f.StringVar(&o.key, "request-key", "", "Idempotency key (default: generated unique key)")
f.BoolVar(&o.wait, "wait", false, "Wait for the new run to finish")
}
f.Usage = func() {
fmt.Fprintf(a.Out, "Usage: pipelines %s\n", usage[command])
@@ -404,7 +407,7 @@ func (a App) Run(ctx context.Context, args []string) error {
}
}
return fmt.Errorf("template %q not found", key)
case "inspect", "cancel":
case "inspect", "cancel", "retry":
value, err := one()
if err != nil {
return err
@@ -417,10 +420,21 @@ func (a App) Run(ctx context.Context, args []string) error {
if command == "cancel" {
typeName = protocol.CancelRun
}
r, err := call(protocol.Message{Type: typeName, RunID: id})
key := ""
if command == "retry" {
typeName = protocol.RetryRun
key = o.key
if key == "" {
key = fmt.Sprintf("retry-%d-%d", os.Getpid(), time.Now().UnixNano())
}
}
r, err := call(protocol.Message{Type: typeName, RunID: id, RequestKey: key})
if err != nil {
return err
}
if command == "retry" {
return a.finishRun(ctx, r, o, call)
}
return a.output(r.RunDetail)
case "rpc":
path, err := one()
@@ -647,6 +661,11 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
if err != nil {
return err
}
return a.finishRun(ctx, r, o, call)
}
func (a App) finishRun(ctx context.Context, r protocol.Message, o *options, call callFunc) error {
var err error
if o.wait {
if r.RunDetail == nil {
return fmt.Errorf("server did not return run detail")
+2
View File
@@ -17,6 +17,7 @@ var usage = map[string]string{
"runs": "runs [--pipeline NAME] [--json]",
"inspect": "inspect <run-id> [--json]",
"cancel": "cancel <run-id> [--json]",
"retry": "retry <run-id> [--json] [--wait]",
"connection": "connection [--json]",
"ping": "ping [--json]",
"rpc": "rpc <request.json|->",
@@ -29,6 +30,7 @@ var notes = map[string]string{
"validate": "Uses the same server parser as submission. Does not persist or activate schedules. Structural validity does not prove runtime/tool availability.",
"submit": "This command is explicit approval to publish; schedules activate on acceptance. Managed drafts provide the name and base-version guard. --force never bypasses validation.",
"run": "Runs in your current directory. Supplied name/prompt start immediately; otherwise select a pipeline and send a multiline task with Ctrl+S. Stage tools are enabled automatically; no file list or RUN confirmation. Cancellation does not undo edits.",
"retry": "Start a new attempt of a failed run with the same initial input, directory, pipeline version, and edit scope. Original history is retained. Already-completed side effects are not undone.",
"rpc": "Accepts a JSON protocol envelope; '-' reads stdin. Every TUI server operation is available here too. Mutating commands are not dry runs.",
}
+1
View File
@@ -24,6 +24,7 @@ EXECUTE
runs List audited runs; --pipeline filters results
inspect <run-id> Inspect stages, outputs, errors and status
cancel <run-id> Cancel a run; changes are NOT rolled back
retry <run-id> Restart a failed run with its original input and directory
connection Server and public phone connection (no secrets)
ping Check the server connection
rpc <request.json|-> Send any protocol command (automation escape hatch)