a6aff47117
A new registered stage type `human` (internal/stage/human.go) has no model,
agent, tools or configs: its required `prompt` block carries the operator
instructions and its non-error edges are the selectable options. It parses,
validates, renders, exports and imports like every other type (no parser
special-case, no config keys).
At runtime the runner parks the run instead of executing: the step and the run
persist `waiting` with self-contained {prompt, options} evidence, and the run
returns without starting later stages, capturing file diffs, scanning artifacts,
holding a goroutine/timer or applying a stage timeout. The wait is durable: a
restart leaves the waiting rows untouched (RecoverRuns excludes them) and a
rebuilt runtime over the same database still accepts the decision.
`pipelines decide <run-id> [stage] --option KEY [--feedback TEXT] [--json]` and
the TUI `c` picker resolve the decision from the pinned graph in one store
transaction, record the choice and feedback as the step's evidence and resume
along edges[KEY]. An unknown option is refused with the valid list, a stage that
is not waiting is refused, and a repeated decision for an already-decided visit
does not double-apply. Cancel and retry keep working while waiting and after a
decision; a human stage is never killed by a stage timeout or max_visits, and a
`notify` policy can fire an `on=waiting` event.
Docs: the authoring skill references (format.md, operations.md), docs/cli.md and
README describe the stage, the command and the TUI picker. Tests cover stage
validation, the parsing round-trip, the store transitions, a websocket wait/decide
integration, cancel/retry, waiting notifications and a persistence-layer rebuild
(second Open + newRunner over one database, no process restart).
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package tui
|
||
|
||
import (
|
||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||
"github.com/charmbracelet/lipgloss"
|
||
)
|
||
|
||
// Animation is driven by a local timer, never by extra server requests.
|
||
func (m Model) loading(label string) string {
|
||
return m.runSpinner.View() + " " + lipgloss.NewStyle().Foreground(themeMuted).Render(label)
|
||
}
|
||
|
||
func (m Model) progress(status string) string {
|
||
marker := "○"
|
||
color := themeMuted
|
||
switch status {
|
||
case "running":
|
||
return m.runSpinner.View() + " running"
|
||
case "completed", "succeeded", "done":
|
||
marker = "✓"
|
||
color = themeSuccess
|
||
case "failed":
|
||
marker = "✗"
|
||
color = themeError
|
||
case "interrupted":
|
||
marker = "!"
|
||
color = themeError
|
||
case "canceled":
|
||
marker = "−"
|
||
case protocol.RunStatusWaiting:
|
||
marker = "⏸"
|
||
color = themeAccent
|
||
}
|
||
return lipgloss.NewStyle().Foreground(color).Render(marker + " " + status)
|
||
}
|
||
|
||
func (m Model) stepProgressStatus(step protocol.RunStep) string {
|
||
status := step.Status
|
||
if status == "completed" {
|
||
if step.Outcome == "error" || step.Target == protocol.FailureEnd {
|
||
return "failed"
|
||
}
|
||
return "done"
|
||
}
|
||
// Never animate stale execution state in a terminal run.
|
||
if status == "running" && m.runDetail != nil && m.runDetail.Status != "running" && m.runDetail.Status != "queued" {
|
||
if m.runDetail.Status == "canceled" {
|
||
return "canceled"
|
||
}
|
||
return "interrupted"
|
||
}
|
||
return status
|
||
}
|