Enforce runtime report contracts and recoverable session exports

This commit is contained in:
2026-10-20 16:02:38 +01:00
parent 1d9cb80cdb
commit fdf0369ede
36 changed files with 1636 additions and 177 deletions
+6 -2
View File
@@ -34,6 +34,7 @@ type App struct {
In io.Reader
}
type options struct {
outputFormat string
harness string
url, name, prompt, title, template, workspace, paths, key, opencode, model string
retryMode, retryStage, retryInputFile string
@@ -147,6 +148,7 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
f.IntVar(&o.version, "version", 0, "Version to run (default: latest)")
f.StringVar(&o.model, "model", "", "Override the model for every stage of this run (PROVIDER/MODEL)")
f.StringVar(&o.notifyMode, "notify", "auto", "Notifications for this run: auto (pipeline), on, or off")
f.StringVar(&o.outputFormat, "output-format", "", "Require a server-written report: html or markdown")
o.stageModels = stageModelFlags{}
f.Var(o.stageModels, "stage-model", "Override one stage's model; repeatable (STAGE=PROVIDER/MODEL); beats --model")
f.BoolVar(&o.wait, "wait", false, "In JSON mode, wait for a terminal run state")
@@ -587,6 +589,8 @@ func (a App) Run(ctx context.Context, args []string) error {
}
_, err = fmt.Fprintln(a.Out, strings.Join(statusview.Lines(response.Status), "\n"))
return err
case "repair-session-export":
return a.repairSessionExport(pos, call, o.json)
case "debug":
value, err := one()
if err != nil {
@@ -1309,7 +1313,7 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
if o.wait || o.key != "" || o.version > 0 {
return fmt.Errorf("--wait, --request-key and --version require --json")
}
_, err := tea.NewProgram(tui.NewRun(ctx, o.url, tui.RunOptions{Pipeline: o.name, Prompt: o.prompt, Title: o.title, Workspace: workspace, Yes: o.yes, AllowTools: o.allow, WritePaths: paths, Model: o.model, StageModels: o.stageModels, NotifyMode: o.notifyMode}), tea.WithContext(ctx), tea.WithAltScreen()).Run()
_, err := tea.NewProgram(tui.NewRun(ctx, o.url, tui.RunOptions{Pipeline: o.name, Prompt: o.prompt, Title: o.title, Workspace: workspace, Yes: o.yes, AllowTools: o.allow, WritePaths: paths, Model: o.model, StageModels: o.stageModels, NotifyMode: o.notifyMode, OutputFormat: o.outputFormat}), tea.WithContext(ctx), tea.WithAltScreen()).Run()
return err
}
if o.name == "" || strings.TrimSpace(o.prompt) == "" {
@@ -1331,7 +1335,7 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
if key == "" {
key = fmt.Sprintf("cli-%d-%d", os.Getpid(), time.Now().UnixNano())
}
r, err := call(protocol.Message{Type: protocol.RunPipeline, PipelineID: p.ID, Version: version, RequestKey: key, Workspace: workspace, Title: o.title, Input: map[string]any{"prompt": o.prompt}, AllowTools: o.allow, WritePaths: paths, Model: o.model, StageModels: o.stageModels, NotifyMode: o.notifyMode})
r, err := call(protocol.Message{Type: protocol.RunPipeline, PipelineID: p.ID, Version: version, RequestKey: key, Workspace: workspace, Title: o.title, Input: map[string]any{"prompt": o.prompt}, AllowTools: o.allow, WritePaths: paths, Model: o.model, StageModels: o.stageModels, NotifyMode: o.notifyMode, OutputFormat: o.outputFormat})
if err != nil {
return err
}