execute

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnExhaustedAbortSession       = "abort_session"
	OnExhaustedSkipStep           = "skip_step"
	OnExhaustedContinueBestEffort = "continue_best_effort"
)
View Source
const (
	// InputKindText is a natural language constraint that performs boundary consumption.
	InputKindText = "text"
	// InputKindSoftStop Stops subsequent work at the step/fix boundary (does not kill immediately).
	InputKindSoftStop = "soft_stop"
	// InputKindBrief Tightens/rewrites the next agent brief (boundaries take effect).
	InputKindBrief = "brief"
	// InputKindSkipStep Requests that the current step be skipped on a boundary (interpreted by the executor policy).
	InputKindSkipStep = "skip_step"
)
View Source
const (
	// StepVerifyInherit represents step-level acceptance inheritance acceptance.step_verify.enabled.
	StepVerifyInherit = "inherit"
	// StepVerifyTrue forces step-level acceptance to be enabled.
	StepVerifyTrue = "true"
	// StepVerifyFalse forces step-level acceptance to be turned off.
	StepVerifyFalse = "false"
)

Variables

View Source
var ErrStepVerifyConfig = errors.New("config_error")

ErrStepVerifyConfig means effective_step_verify is true but the acceptance command is not runnable.

Functions

func BuildPrompt

func BuildPrompt(step domain.TodoItem, inputs []UserInput, repairing bool) string

BuildPrompt assembles a single-step execution prompt.

func BuildPromptWithBrowser added in v1.0.0

func BuildPromptWithBrowser(step domain.TodoItem, inputs []UserInput, repairing, headlessBrowser bool) string

BuildPromptWithBrowser allows tests/callers to toggle the headless browser constraint block.

func EffectiveStepVerify

func EffectiveStepVerify(todoStepVerify string, acceptance AcceptanceStepVerify) bool

EffectiveStepVerify by design §8.4 overlays todo.step_verify with acceptance defaults.

func MergeBriefs

func MergeBriefs(briefs []UserInput) string

MergeBriefs spells the brief input into the next step with the prompt prefix.

func ResolveStepVerify

func ResolveStepVerify(step domain.TodoItem, acceptance AcceptanceStepVerify) (run bool, commands []verify.Command, err error)

ResolveStepVerify determines whether the current step should run step-level acceptance and returns the set of commands that should be executed. ErrStepVerifyConfig is returned when effective is true but commands is empty or not runnable.

func StepSucceeded

func StepSucceeded(outcome RunOutcome, stepVerifyOK bool) bool

StepSucceeded applies the executor's non-negotiable success contract.

Types

type AcceptanceStepVerify

type AcceptanceStepVerify struct {
	Enabled  bool             `json:"enabled"`
	Commands []verify.Command `json:"commands"`
}

AcceptanceStepVerify corresponds to the step_verify section in acceptance.json.

type BoundaryDrain

type BoundaryDrain struct {
	Texts    []UserInput
	Briefs   []UserInput
	SoftStop bool
	SkipStep bool
}

BoundaryDrain is the classification result of performing a boundary Drain.

func ClassifyDrain

func ClassifyDrain(items []UserInput) BoundaryDrain

ClassifyDrain splits boundary input by kind.

type Executor

type Executor struct {
	MaxRepairs  int
	OnExhausted string
	InputQueue  *InputQueue
	Timeout     time.Duration
	// ExtraEnv KEY=VALUE pairs passed to every agent.Run (e.g. Playwright headless).
	ExtraEnv []string
	// HeadlessBrowser injects the browser constraint block into step prompts (default true when wired from ton).
	HeadlessBrowser bool
	// ResolveExhausted Optional: Override on_exhausted when step repair is exhausted (must still be in the policy space).
	ResolveExhausted func(ctx context.Context, step domain.TodoItem, configured string) string
}

Executor owns the sequential, step-level execution policy.

func (Executor) RunAll

func (e Executor) RunAll(
	ctx context.Context,
	session *domain.Session,
	todos domain.TodoList,
	agent backend.AgentBackend,
	hooks Hooks,
) (domain.TerminalStatus, domain.TodoList, error)

RunAll executes pending todos in their stored order and returns the terminal status plus partial todo state.

type ExhaustedDecision

type ExhaustedDecision struct {
	StepStatus       domain.TodoStatus
	ContinueSteps    bool
	RunSessionVerify bool
	TerminalHint     domain.TerminalStatus
}

ExhaustedDecision describes the orchestration actions after exhaustion of step-level repairs.

func Apply

func Apply(policy string, step domain.TodoItem) ExhaustedDecision

Apply gives fixed decisions after step-level repairs are exhausted based on the on_exhausted policy.

type Hooks

type Hooks struct {
	OnMilestone func(name string)
	OnEvent     func(event domain.AgentEvent)
	AfterStep   func(step domain.TodoItem)
	StepVerify  func(step domain.TodoItem) (bool, error)
}

Hooks exposes observation and validation points without coupling the executor to persistence or UI.

type InputQueue

type InputQueue struct {
	// contains filtered or unexported fields
}

InputQueue holds user input during execution; Drain is only called at step or Repair turn boundaries.

func (*InputQueue) Drain

func (q *InputQueue) Drain() []UserInput

Drain takes out all current inputs and clears the queue for unified consumption at the execution boundary.

func (*InputQueue) Enqueue

func (q *InputQueue) Enqueue(input UserInput)

Enqueue appends input in FIFO order and never injects it into the running agent halfway.

func (*InputQueue) KindCounts

func (q *InputQueue) KindCounts() map[string]int

KindCounts counts queued items by kind.

func (*InputQueue) Len

func (q *InputQueue) Len() int

Len returns the number of queued inputs that have not been consumed for TUI /status to display the working status.

func (*InputQueue) Peek

func (q *InputQueue) Peek() []UserInput

Peek returns a copy of the queue without consumption (for /queue and debugging).

func (*InputQueue) Summary

func (q *InputQueue) Summary() string

Summary generates a compact queue summary, such as "2 text · 1 brief · 1 skip_step".

type RunOutcome

type RunOutcome struct {
	ExitCode int
	TimedOut bool
	Err      error
}

RunOutcome captures process-level facts collected while running an agent.

type UserInput

type UserInput struct {
	Kind string
	Text string
}

UserInput is a user input or control signal that is temporarily stored during execution and waiting for boundary consumption.

func SplitDrain

func SplitDrain(items []UserInput) (texts []UserInput, softStop bool)

SplitDrain splits text constraints with soft-stop control signals (compatible with older callers).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL