model

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReservedWorkflow  = "workflow"
	ReservedExecution = "execution"
	ReservedInput     = "input"
	ReservedOutput    = "output"
	ReservedEnv       = "env"
	ReservedLoop      = "loop"
	ReservedEvent     = "event"
)

Reserved participant names — cannot be used as participant identifiers.

Variables

ReservedNames is the full list of reserved participant name strings.

Functions

func IsReservedName

func IsReservedName(name string) bool

IsReservedName reports whether name is a reserved participant identifier.

Types

type Defaults

type Defaults struct {
	Timeout *Duration `yaml:"timeout,omitempty"`
	OnError string    `yaml:"onError,omitempty"`
	CWD     string    `yaml:"cwd,omitempty"`
}

Defaults holds global defaults applied to all participants when not overridden.

type Duration

type Duration struct {
	time.Duration
}

Duration wraps time.Duration and supports YAML unmarshaling of strings like "30s", "5m", "1h".

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler for Duration.

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler for Duration.

type FlowStep

type FlowStep struct {
	// Participant is set for a bare string step reference, e.g. `- stepA`.
	Participant string
	// Loop is set for a loop control construct, e.g. `- loop: {...}`.
	Loop *LoopStep
	// Parallel is set for a parallel construct, e.g. `- parallel: [...]`.
	Parallel *ParallelStep
	// If is set for a conditional branch, e.g. `- if: "expr"\n  then: [...]`.
	If *IfStep
	// Override is set for a participant invocation with overrides, e.g. `- stepA:\n  timeout: 30m`.
	Override *ParticipantOverrideStep
	// InlineParticipant is set when a full participant definition appears
	// inline inside the flow (has fields like `as` and `type`).
	InlineParticipant *Participant
	// Wait is set for a wait control construct, e.g. `- wait: {...}`.
	Wait *WaitStep
	// Set is set for a set control construct, e.g. `- set: {key: expr}`.
	Set *SetStep
}

FlowStep is a union type representing one item in the flow sequence. Exactly one field will be set after unmarshaling.

func (*FlowStep) UnmarshalYAML

func (f *FlowStep) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler for FlowStep. It inspects the node type and delegates to the appropriate sub-type.

type IfStep

type IfStep struct {
	Condition string     `yaml:"condition"`
	Then      []FlowStep `yaml:"then"`
	Else      []FlowStep `yaml:"else,omitempty"`
}

IfStep evaluates a CEL condition and routes to the then or else branch.

type InputField

type InputField struct {
	Type        string        `yaml:"type,omitempty"`
	Required    bool          `yaml:"required,omitempty"`
	Default     interface{}   `yaml:"default,omitempty"`
	Description string        `yaml:"description,omitempty"`
	Format      string        `yaml:"format,omitempty"`
	Enum        []interface{} `yaml:"enum,omitempty"`
	Minimum     *float64      `yaml:"minimum,omitempty"`
	Maximum     *float64      `yaml:"maximum,omitempty"`
	MinLength   *int          `yaml:"minLength,omitempty"`
	MaxLength   *int          `yaml:"maxLength,omitempty"`
	Pattern     string        `yaml:"pattern,omitempty"`
	Items       *InputField   `yaml:"items,omitempty"`
}

InputField describes a single workflow input parameter.

type LoopStep

type LoopStep struct {
	// As optionally renames the loop context variable (e.g. `as: attempt`).
	As    string      `yaml:"as,omitempty"`
	Until string      `yaml:"until,omitempty"`
	Max   interface{} `yaml:"max,omitempty"`
	Steps []FlowStep  `yaml:"steps"`
}

LoopStep repeats a set of steps until a condition is true or a max count is reached.

type ParallelStep

type ParallelStep struct {
	Steps []FlowStep
}

ParallelStep runs a set of participant steps concurrently.

type Participant

type Participant struct {
	Type    ParticipantType `yaml:"type"`
	As      string          `yaml:"as,omitempty"`
	When    string          `yaml:"when,omitempty"`
	Timeout *Duration       `yaml:"timeout,omitempty"`
	OnError string          `yaml:"onError,omitempty"`
	Retry   *RetryConfig    `yaml:"retry,omitempty"`
	CWD     string          `yaml:"cwd,omitempty"`
	Input   interface{}     `yaml:"input,omitempty"`
	Output  interface{}     `yaml:"output,omitempty"`

	// exec
	Run string `yaml:"run,omitempty"`

	// http
	URL     string            `yaml:"url,omitempty"`
	Method  string            `yaml:"method,omitempty"`
	Headers map[string]string `yaml:"headers,omitempty"`
	Body    interface{}       `yaml:"body,omitempty"`

	// workflow
	Path string `yaml:"path,omitempty"`

	// mcp
	Server string `yaml:"server,omitempty"`
	Tool   string `yaml:"tool,omitempty"`

	// emit
	Event     string      `yaml:"event,omitempty"`
	Payload   interface{} `yaml:"payload,omitempty"`
	Ack       bool        `yaml:"ack,omitempty"`
	OnTimeout string      `yaml:"onTimeout,omitempty"`
}

Participant defines a named step that can be referenced in the flow.

type ParticipantOverrideStep

type ParticipantOverrideStep struct {
	Participant string       `yaml:"-"`
	When        string       `yaml:"when,omitempty"`
	Timeout     *Duration    `yaml:"timeout,omitempty"`
	OnError     string       `yaml:"onError,omitempty"`
	Retry       *RetryConfig `yaml:"retry,omitempty"`
	Input       interface{}  `yaml:"input,omitempty"`
	Workflow    string       `yaml:"workflow,omitempty"`
}

ParticipantOverrideStep invokes a participant with optional per-invocation overrides.

type ParticipantType

type ParticipantType string

ParticipantType is the type of a participant.

const (
	ParticipantTypeExec     ParticipantType = "exec"
	ParticipantTypeHTTP     ParticipantType = "http"
	ParticipantTypeWorkflow ParticipantType = "workflow"
	ParticipantTypeMCP      ParticipantType = "mcp"
	ParticipantTypeEmit     ParticipantType = "emit"
)

type RetryConfig

type RetryConfig struct {
	Max     int      `yaml:"max"`
	Backoff Duration `yaml:"backoff,omitempty"`
	Factor  float64  `yaml:"factor,omitempty"`
}

RetryConfig defines retry behaviour for a participant.

type SetStep

type SetStep struct {
	// Values maps context keys to CEL expressions.
	Values map[string]string
}

SetStep assigns values to execution.context via CEL expressions.

type WaitStep

type WaitStep struct {
	Event     string    `yaml:"event,omitempty"`
	Match     string    `yaml:"match,omitempty"`
	Until     string    `yaml:"until,omitempty"`
	Poll      *Duration `yaml:"poll,omitempty"`
	Timeout   *Duration `yaml:"timeout,omitempty"`
	OnTimeout string    `yaml:"onTimeout,omitempty"`
}

WaitStep represents the `wait` control construct.

type Workflow

type Workflow struct {
	ID           string                 `yaml:"id,omitempty"`
	Name         string                 `yaml:"name,omitempty"`
	Version      interface{}            `yaml:"version,omitempty"`
	Defaults     *Defaults              `yaml:"defaults,omitempty"`
	Inputs       map[string]InputField  `yaml:"inputs,omitempty"`
	Participants map[string]Participant `yaml:"participants,omitempty"`
	Flow         []FlowStep             `yaml:"flow"`
	Output       *WorkflowOutput        `yaml:"output,omitempty"`
}

Workflow is the top-level structure of a duckflux workflow definition file.

type WorkflowOutput

type WorkflowOutput struct {
	// Expression is set when the output is a single string value.
	Expression string
	// Map is set when the output is a mapping of field names to CEL expressions.
	Map map[string]string
	// Schema is the optional schema->map style output (spec v0.2)
	Schema map[string]InputField
	// MapField used when output is provided as { schema: {...}, map: {...} }
	MapField map[string]string
}

WorkflowOutput defines the output of the workflow. It is either a single CEL expression string or a map of field → CEL expression.

func (WorkflowOutput) MarshalYAML

func (o WorkflowOutput) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler for WorkflowOutput.

func (*WorkflowOutput) UnmarshalYAML

func (o *WorkflowOutput) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler for WorkflowOutput.

Jump to

Keyboard shortcuts

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