ir

package
v2.22.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package ir defines the canonical serialized workflow representation, including normalized DAG definitions and persisted run snapshots. Authored YAML structures remain private to internal/spec.

Index

Constants

View Source
const (
	// AgentStepName is the reserved name of the synthesized step that drives
	// an agent DAG. It cannot be used as a step name or ID.
	AgentStepName = "__agent__"

	// LegacyAgentStepName is the name the synthesized agent step carried while
	// agent DAGs were called controller DAGs. Run status files written then
	// still name the step this way, so reading them keeps recognizing it.
	LegacyAgentStepName = "__controller__"

	// AskUserStepName is the reserved name and ID of the synthesized human task
	// an agent opens when it needs to ask a question no declared step
	// covers. It cannot be used as a step name or ID.
	//
	// The name is plain rather than underscore-wrapped because it is what an
	// operator types to answer:
	//
	//	dagu human-task complete <dag> --step ask_user --inputs-json '{"answer":"..."}'
	AskUserStepName = "ask_user"

	// AskUserAnswerField is the single form field an ask_user question collects.
	AskUserAnswerField = "answer"

	// DefaultAgentMaxIterations bounds the number of agent turns when
	// llm.max_tool_iterations is not set.
	DefaultAgentMaxIterations = 50

	// DefaultAgentMaxStepRuns caps how many times the agent may run a
	// single declared step within one DAG run.
	DefaultAgentMaxStepRuns = 5

	// DefaultAgentMaxQuestions caps how many questions an agent may put
	// to a person in one run. Each one suspends the run, so an unbounded
	// agent could pester someone indefinitely.
	DefaultAgentMaxQuestions = 5

	// DefaultAgentMaxContextTokens is the prompt size at which observation
	// aging starts.
	DefaultAgentMaxContextTokens = 200_000

	// DefaultAgentObservationMaxBytes bounds each tool result added to a
	// agent conversation.
	DefaultAgentObservationMaxBytes = 512 * 1024

	// DefaultAgentObservationKeepRecent is the number of tool results that
	// remain complete after observation aging starts.
	DefaultAgentObservationKeepRecent = 20
)
View Source
const (
	// TypeGraph runs dependency-aware steps in parallel where possible.
	TypeGraph = "graph"
	// TypeChain runs steps strictly in declaration order.
	TypeChain = "chain"
	// TypeAgent lets an LLM choose which step runs next until every task is complete.
	TypeAgent = "agent"
	// TypeBuild runs a graph while reusing verified file materializations.
	TypeBuild = "build"
)

Supported DAG execution types.

View Source
const (
	ParamDefTypeString  = "string"
	ParamDefTypeInteger = "integer"
	ParamDefTypeNumber  = "number"
	ParamDefTypeBoolean = "boolean"
)
View Source
const (
	// MaxLabelKeyLength is the maximum allowed length for label keys (63 chars).
	MaxLabelKeyLength = 63
	// MaxLabelValueLength is the maximum allowed length for label values (255 chars).
	MaxLabelValueLength = 255
)

Label validation constants.

View Source
const (
	// LabelKeyPatternStr is the regex pattern for valid label keys.
	// Allows alphanumeric, dash, underscore, dot. Must start with letter/number.
	LabelKeyPatternStr = `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`
	// LabelValuePatternStr is the regex pattern for valid label values.
	// Allows alphanumeric, dash, underscore, dot, slash. Must start with letter/number.
	LabelValuePatternStr = `^[a-zA-Z0-9][a-zA-Z0-9_./-]*$`
)

Label validation pattern strings (exported for use by other packages).

View Source
const (
	MailProviderGoogle    = "google"
	MailProviderMicrosoft = "microsoft"
	MailProviderIMAP      = "imap"
)

Mail account providers select default IMAP and SMTP servers.

View Source
const (
	MailSecurityTLS      = "tls"
	MailSecurityStartTLS = "starttls"
)

Mail server security modes. Every mail account connection uses TLS.

View Source
const (
	MailSearchDefaultLimit = 20
	MailSearchMinLimit     = 1
	MailSearchMaxLimit     = 50
)

mail.search returns between MailSearchMinLimit and MailSearchMaxLimit emails.

View Source
const (
	DAGRunConditionRunnable    = "Runnable"
	DAGRunConditionWorkerReady = "WorkerReady"

	DAGRunConditionStatusTrue    = "True"
	DAGRunConditionStatusFalse   = "False"
	DAGRunConditionStatusUnknown = "Unknown"

	DAGRunReasonNoMatchingWorker          = "NoMatchingWorker"
	DAGRunReasonNoAvailableWorker         = "NoAvailableWorker"
	DAGRunReasonWorkerDispatchUnavailable = "WorkerDispatchUnavailable"
)

The condition types that tell whether a queued DAG-run can start, their statuses, and the reasons recorded when no worker can take the run.

View Source
const (
	StepOutputSourceStdout = "stdout"
	StepOutputSourceStderr = "stderr"
	StepOutputSourceFile   = "file"

	StepOutputDecodeText = "text"
	StepOutputDecodeJSON = "json"
	StepOutputDecodeYAML = "yaml"

	StepDeclaredOutputTypeString = "string"
	StepDeclaredOutputTypeJSON   = "json"

	// StepDeclaredOutputSourceCapture marks an output published from the step's
	// captured output. An empty source means the step writes the value to
	// DAGU_OUTPUT_FILE.
	StepDeclaredOutputSourceCapture = "capture"
)
View Source
const (
	// ExecutorTypeDAG is the executor type for a sub DAG.
	ExecutorTypeDAG = "dag"

	// ExecutorTypeSubworkflow is the legacy executor type name for a sub DAG.
	ExecutorTypeSubworkflow = "subworkflow"

	// ExecutorTypeDAGEnqueue is the executor type for asynchronously queueing a sub DAG.
	ExecutorTypeDAGEnqueue = "dag_enqueue"

	// ExecutorTypeParallel is the executor type for parallel steps.
	ExecutorTypeParallel = "parallel"

	// ExecutorTypeForeach is the executor type for foreach steps.
	ExecutorTypeForeach = "foreach"

	// ExecutorTypeRouter is the executor type for router steps.
	ExecutorTypeRouter = "router"

	// ExecutorTypeAgent is the executor type for the synthesized step that
	// drives an agent DAG.
	ExecutorTypeAgent = "agent"

	// ExecutorTypeAction is the executor type for external Dagu actions.
	ExecutorTypeAction = "action"

	// ExecutorTypeOutputs is the executor type for publishing named outputs.
	ExecutorTypeOutputs = "outputs"

	// ExecutorTypeBrowser is the executor type for browser automation steps.
	ExecutorTypeBrowser = "browser"

	// ExecutorTypeComputer is the executor type for desktop automation steps.
	ExecutorTypeComputer = "computer"

	// ExecutorTypeXlsx is the executor type for workbook steps.
	ExecutorTypeXlsx = "xlsx"
)
View Source
const DAGNameMaxLen = 40

DAGNameMaxLen is the maximum supported DAG name length.

View Source
const (
	// DefaultAquaStandardRegistryRef is the last-resort aqua standard registry
	// commit, used only when the latest registry release cannot be resolved
	// and no previously resolved ref is cached on disk.
	DefaultAquaStandardRegistryRef = "080d723b75cd0ea7c2b2059bf6266d3ab39aa792"
)
View Source
const DefaultMaxConcurrent = 10

DefaultMaxConcurrent is the default maximum concurrent executions for parallel steps.

View Source
const DefaultMaxOutputSize = 1024 * 1024

DefaultMaxOutputSize is the default maximum captured step output size in bytes.

View Source
const ExecutorTypeChat = "chat"

ExecutorTypeChat is the executor type for chat steps.

View Source
const HarnessInheritedOptionsKey = "harness_inherited_options"

HarnessInheritedOptionsKey is the executor metadata key listing the DAG-level harness options merged into a step whose provider is chosen by a variable. Options the resolved provider cannot accept are dropped at run time.

View Source
const MaxExpansionConcurrency = 1000

MaxExpansionConcurrency is the maximum concurrency accepted by expansion constructs.

View Source
const ParallelItemVariable = "ITEM"

ParallelItemVariable is the special variable name that represents the current item in parallel execution

View Source
const ReservedEnvPrefix = "_DAGU_"

ReservedEnvPrefix marks environment variable names Dagu reserves for internal run transport. Names carrying it are never accepted from authored workflows and never cross a run boundary.

Variables

View Source
var (
	ErrNameTooLong                         = errors.New("name must be less than 40 characters")
	ErrNameInvalidChars                    = errors.New("name must only contain alphanumeric characters, dashes, dots, and underscores")
	ErrInvalidSchedule                     = errors.New("invalid schedule")
	ErrScheduleMustBeStringOrArray         = errors.New("schedule must be a string or an array of strings")
	ErrInvalidScheduleType                 = errors.New("invalid schedule type")
	ErrInvalidKeyType                      = errors.New("invalid key type")
	ErrExecutorConfigMustBeString          = errors.New("with/config key must be string")
	ErrDuplicateFunction                   = errors.New("duplicate function")
	ErrFuncParamsMismatch                  = errors.New("func params and args given to func command do not match")
	ErrInvalidStepData                     = errors.New("invalid step data")
	ErrStepNameRequired                    = errors.New("step name must be specified")
	ErrStepNameDuplicate                   = errors.New("step name must be unique")
	ErrStepNameTooLong                     = errors.New("step name must be at most 255 characters")
	ErrStepIDTooLong                       = errors.New("step ID must be at most 40 characters")
	ErrStepCommandIsRequired               = errors.New("step command is required")
	ErrStepCommandIsEmpty                  = errors.New("step command is empty")
	ErrStepCommandMustBeArrayOrString      = errors.New("step command must be an array of strings or a string")
	ErrInvalidParamValue                   = errors.New("invalid parameter value")
	ErrCallFunctionNotFound                = errors.New("call must specify a functions that exists")
	ErrNumberOfParamsMismatch              = errors.New("the number of parameters defined in the function does not match the number of parameters given")
	ErrRequiredParameterNotFound           = errors.New("required parameter not found")
	ErrScheduleKeyMustBeString             = errors.New("schedule key must be a string")
	ErrInvalidSignal                       = errors.New("invalid signal")
	ErrInvalidEnvValue                     = errors.New("env config should be map of strings or array of key=value formatted string")
	ErrArgsMustBeConvertibleToIntOrString  = errors.New("args must be convertible to either int or string")
	ErrExecutorTypeMustBeString            = errors.New("type value must be string")
	ErrExecutorConfigValueMustBeMap        = errors.New("with/config value must be a map")
	ErrExecutorHasInvalidKey               = errors.New("action config has invalid key")
	ErrExecutorConfigMustBeStringOrMap     = errors.New("action config must be string or map")
	ErrDotEnvMustBeStringOrArray           = errors.New("dotenv must be a string or an array of strings")
	ErrPreconditionMustBeArrayOrString     = errors.New("precondition must be a string or an array of strings")
	ErrPreconditionValueMustBeString       = errors.New("precondition value must be a string")
	ErrPreconditionHasInvalidKey           = errors.New("precondition has invalid key")
	ErrContinueOnOutputMustBeStringOrArray = errors.New("continueOn.Output must be a string or an array of strings")
	ErrContinueOnExitCodeMustBeIntOrArray  = errors.New("continueOn.ExitCode must be an int or an array of ints")
	ErrDependsMustBeStringOrArray          = errors.New("depends must be a string or an array of strings")
	ErrDependsNotAllowedInChainType        = errors.New("depends field is not allowed for DAGs with type 'chain'; use type 'graph' for explicit dependencies")
	ErrStepsMustBeArrayOrMap               = errors.New("steps must be an array or a map")
)

errors on building a DAG.

View Source
var (
	// ValidLabelKeyPattern validates label keys.
	ValidLabelKeyPattern = regexp.MustCompile(LabelKeyPatternStr)
	// ValidLabelValuePattern validates label values.
	ValidLabelValuePattern = regexp.MustCompile(LabelValuePatternStr)
)

Label validation patterns (compiled regex).

View Source
var (
	ErrInvalidRunRefFormat = errors.New("invalid dag-run reference format")
)
View Source
var ErrWorkerSelectorApproval = errors.New("DAG with approval steps cannot be dispatched to workers")

ErrWorkerSelectorApproval is returned when a worker selector is set on a DAG with approval steps, which must run locally.

Functions

func BuiltinCLIHarnessProviderNames

func BuiltinCLIHarnessProviderNames() []string

BuiltinCLIHarnessProviderNames returns the built-in CLI harness provider names.

func CalculateBackoffInterval

func CalculateBackoffInterval(interval time.Duration, backoff float64, maxInterval time.Duration, attemptCount int) time.Duration

CalculateBackoffInterval returns the delay for the given retry attempt. A non-positive backoff keeps the interval fixed.

func FormatWorkerSelector

func FormatWorkerSelector(selector map[string]string) string

FormatWorkerSelector renders a selector as {key: value, ...} with sorted keys, for messages that name the workers a run is waiting for.

func GenerateAttemptKey

func GenerateAttemptKey(rootName, rootID, dagName, dagRunID, attemptID string) string

GenerateAttemptKey creates a globally unique attempt identifier.

func InitializeDefaults

func InitializeDefaults(d *DAG)

InitializeDefaults exposes initializeDefaults for packages that prepare DAGs before execution.

func IsBuiltinCLIHarnessProvider

func IsBuiltinCLIHarnessProvider(name string) bool

IsBuiltinCLIHarnessProvider reports whether name selects a built-in CLI harness provider.

func IsDeniedWebhookForwardHeader

func IsDeniedWebhookForwardHeader(name string) bool

IsDeniedWebhookForwardHeader reports whether a webhook header must never be forwarded into DAG runtime params.

func IsEffectiveBuiltinCLIHarnessProvider added in v2.15.0

func IsEffectiveBuiltinCLIHarnessProvider(name string, defs HarnessDefinitions) bool

IsEffectiveBuiltinCLIHarnessProvider reports whether name resolves to a built-in provider after applying custom harness definitions.

func IsPersistedAgentStepName added in v2.15.0

func IsPersistedAgentStepName(name string) bool

IsPersistedAgentStepName reports whether a step name recorded in a run status identifies the synthesized step that drives an agent DAG. It accepts the legacy spelling, so it suits reading run history but not building or validating a DAG, where only the current name is ever synthesized.

func IsSynthesizedAgentStep added in v2.14.0

func IsSynthesizedAgentStep(name string) bool

IsSynthesizedAgentStep reports whether a step name belongs to the scaffolding an agent DAG is built with rather than to a declared action.

func IsValidWebhookHeaderToken

func IsValidWebhookHeaderToken(name string) bool

IsValidWebhookHeaderToken reports whether name matches the RFC 9110 token grammar used by HTTP header field names.

func MailMarks added in v2.18.0

func MailMarks() []string

MailMarks returns the flag changes mail.organize accepts.

func MailMoves added in v2.18.0

func MailMoves() []string

MailMoves returns the destinations mail.organize accepts.

func NewDAGRunID

func NewDAGRunID() (string, error)

NewDAGRunID returns a compact UUIDv7-derived DAG-run ID.

func NewValidationError

func NewValidationError(field string, value any, err error) error

NewValidationError wraps an error with field context so other packages can build LoadError instances.

func NormalizeBuiltinHarnessFlagKeys

func NormalizeBuiltinHarnessFlagKeys(cfg map[string]any) map[string]any

NormalizeBuiltinHarnessFlagKeys clones cfg and canonicalizes builtin harness flag aliases to kebab-case so equivalent keys merge predictably.

func NormalizeDAGRunConditions

func NormalizeDAGRunConditions(status *DAGRunStatus)

NormalizeDAGRunConditions clears runtime conditions from non-queued statuses.

func NormalizeWebhookForwardHeader

func NormalizeWebhookForwardHeader(name string) string

NormalizeWebhookForwardHeader canonicalizes a webhook header name for config validation and runtime matching.

func ParseCPULimit

func ParseCPULimit(value string) (int64, error)

ParseCPULimit parses Kubernetes-style CPU quantities into millicores.

func ParseMemoryLimit

func ParseMemoryLimit(value string) (int64, error)

ParseMemoryLimit parses Kubernetes-style memory quantities into bytes.

func RetryAgentOwnerWorkerID added in v2.14.0

func RetryAgentOwnerWorkerID(status *DAGRunStatus, stepRetry bool) string

RetryAgentOwnerWorkerID returns the execution host required by an agent session that will resume.

func ValidateDAGName

func ValidateDAGName(name string) error

ValidateDAGName validates a DAG name according to shared rules. Empty name is allowed because callers may provide one from context.

func ValidateDAGRunID

func ValidateDAGRunID(dagRunID string) error

ValidateDAGRunID validates a DAG-run identifier.

func ValidateLabel

func ValidateLabel(t Label) error

ValidateLabel validates a label's key and value format.

func ValidateLabels

func ValidateLabels(labels Labels) error

ValidateLabels validates all labels in the collection.

func ValidateWorkerSelector

func ValidateWorkerSelector(selector map[string]string) error

ValidateWorkerSelector checks a selector given for one run: every key must be a valid label key and every value a non-empty valid label value.

Types

type AgentInteraction added in v2.14.0

type AgentInteraction struct {
	ID                      string                 `json:"id"`
	Kind                    AgentInteractionKind   `json:"kind"`
	Status                  AgentInteractionStatus `json:"status"`
	Permission              string                 `json:"permission,omitempty"`
	Patterns                []string               `json:"patterns,omitempty"`
	AllowForSessionPatterns []string               `json:"allowForSessionPatterns,omitempty"`
	Questions               []AgentQuestion        `json:"questions,omitempty"`
	Decision                string                 `json:"decision,omitempty"`
	Answers                 [][]string             `json:"answers,omitempty"`
	Applied                 bool                   `json:"applied,omitempty"`
	CreatedAt               string                 `json:"createdAt,omitempty"`
	ExpiresAt               string                 `json:"expiresAt,omitempty"`
	RespondedAt             string                 `json:"respondedAt,omitempty"`
	RespondedBy             string                 `json:"respondedBy,omitempty"`
	RespondedByID           string                 `json:"respondedById,omitempty"`
}

AgentInteraction records an agent request and its durable response.

type AgentInteractionKind added in v2.14.0

type AgentInteractionKind string

AgentInteractionKind identifies input requested by a managed agent.

const (
	AgentInteractionPermission AgentInteractionKind = "permission"
	AgentInteractionQuestion   AgentInteractionKind = "question"
)

type AgentInteractionStatus added in v2.14.0

type AgentInteractionStatus string

AgentInteractionStatus describes whether requested input can still be answered.

const (
	AgentInteractionPending  AgentInteractionStatus = "pending"
	AgentInteractionAnswered AgentInteractionStatus = "answered"
	AgentInteractionRejected AgentInteractionStatus = "rejected"
)

type AgentPermissionGrant added in v2.14.0

type AgentPermissionGrant struct {
	Permission  string   `json:"permission"`
	Patterns    []string `json:"patterns"`
	GrantedAt   string   `json:"grantedAt,omitempty"`
	GrantedBy   string   `json:"grantedBy,omitempty"`
	GrantedByID string   `json:"grantedById,omitempty"`
}

AgentPermissionGrant is a permission scope approved for one Dagu session generation.

type AgentQuestion added in v2.14.0

type AgentQuestion struct {
	Header   string                `json:"header"`
	Question string                `json:"question"`
	Options  []AgentQuestionOption `json:"options,omitempty"`
	Multiple bool                  `json:"multiple,omitempty"`
	Custom   bool                  `json:"custom,omitempty"`
}

AgentQuestion is one question in a managed agent interaction.

type AgentQuestionOption added in v2.14.0

type AgentQuestionOption struct {
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
}

AgentQuestionOption is a selectable answer offered by an agent.

type AgentSession added in v2.14.0

type AgentSession struct {
	Provider           string                 `json:"provider"`
	ProviderVersion    string                 `json:"providerVersion,omitempty"`
	SessionID          string                 `json:"sessionId,omitempty"`
	Generation         int                    `json:"generation,omitempty"`
	Agent              string                 `json:"agent,omitempty"`
	Model              string                 `json:"model,omitempty"`
	Variant            string                 `json:"variant,omitempty"`
	OwnerWorkerID      string                 `json:"ownerWorkerId,omitempty"`
	HostInstanceID     string                 `json:"hostInstanceId,omitempty"`
	Directory          string                 `json:"directory,omitempty"`
	State              AgentSessionState      `json:"state"`
	LastError          string                 `json:"lastError,omitempty"`
	PromptSent         bool                   `json:"promptSent,omitempty"`
	PromptMessageID    string                 `json:"promptMessageId,omitempty"`
	RestartPending     bool                   `json:"restartPending,omitempty"`
	SessionOwned       bool                   `json:"sessionOwned,omitempty"`
	DiscardedSessionID string                 `json:"discardedSessionId,omitempty"`
	DiscardedOwned     bool                   `json:"discardedOwned,omitempty"`
	PermissionGrants   []AgentPermissionGrant `json:"permissionGrants,omitempty"`
	Usage              AgentUsage             `json:"usage,omitzero"`
	Interactions       []AgentInteraction     `json:"interactions,omitempty"`
	Events             []AgentSessionEvent    `json:"events,omitempty"`
}

AgentSession contains durable state required to display and resume a managed session.

func CloneAgentSession added in v2.14.0

func CloneAgentSession(session *AgentSession) *AgentSession

CloneAgentSession returns a detached copy safe for runtime handoff.

func (*AgentSession) StartNewGeneration added in v2.14.0

func (s *AgentSession) StartNewGeneration()

StartNewGeneration prepares the session to submit its prompt in a new provider session.

type AgentSessionEvent added in v2.14.0

type AgentSessionEvent struct {
	Sequence  int64    `json:"sequence"`
	ID        string   `json:"id"`
	Type      string   `json:"type"`
	Timestamp string   `json:"timestamp,omitempty"`
	Role      string   `json:"role,omitempty"`
	Content   string   `json:"content,omitempty"`
	Name      string   `json:"name,omitempty"`
	Status    string   `json:"status,omitempty"`
	Files     []string `json:"files,omitempty"`
	// Position is the operation's place in with.do, from 1, as the run
	// log counts; 0 for an event that is not one operation.
	Position int `json:"position,omitempty"`
	// Via is how an operation ran: "element" when a recording was replayed
	// by the window's elements, "screen" when it was replayed by the
	// pixels of the screen, "model", or "exact" for a check that read the
	// window's elements without a model.
	Via string `json:"via,omitempty"`
	// DurationMs and Tokens are what the operation took.
	DurationMs int64 `json:"durationMs,omitempty"`
	Tokens     int64 `json:"tokens,omitempty"`
}

AgentSessionEvent is one normalized item in a managed agent session timeline.

type AgentSessionResource added in v2.14.0

type AgentSessionResource struct {
	Provider      string `json:"provider"`
	SessionID     string `json:"sessionId"`
	Directory     string `json:"directory,omitempty"`
	OwnerWorkerID string `json:"ownerWorkerId,omitempty"`
	StepName      string `json:"stepName,omitempty"`
	Generation    int    `json:"generation,omitempty"`
}

AgentSessionResource identifies a Dagu-owned provider session retained by a DAG run.

func MergeAgentSessionResources added in v2.14.0

func MergeAgentSessionResources(resources []AgentSessionResource, nodes []*Node) []AgentSessionResource

MergeAgentSessionResources retains every Dagu-owned provider session observed by a DAG run.

type AgentSessionState added in v2.14.0

type AgentSessionState string

AgentSessionState describes the lifecycle of a managed coding-agent session.

const (
	AgentSessionStarting    AgentSessionState = "starting"
	AgentSessionRunning     AgentSessionState = "running"
	AgentSessionWaiting     AgentSessionState = "waiting"
	AgentSessionSucceeded   AgentSessionState = "succeeded"
	AgentSessionFailed      AgentSessionState = "failed"
	AgentSessionAborted     AgentSessionState = "aborted"
	AgentSessionUnavailable AgentSessionState = "unavailable"
)

type AgentTask added in v2.14.0

type AgentTask struct {
	// Name identifies the task. It is unique within the DAG.
	Name string `json:"name"`
	// Description states the completion criteria in natural language.
	Description string `json:"description,omitempty"`
}

AgentTask is a goal an Agent DAG must settle before the run concludes.

type AgentUsage added in v2.14.0

type AgentUsage struct {
	InputTokens     int64   `json:"inputTokens,omitempty"`
	OutputTokens    int64   `json:"outputTokens,omitempty"`
	ReasoningTokens int64   `json:"reasoningTokens,omitempty"`
	TotalTokens     int64   `json:"totalTokens,omitempty"`
	Cost            float64 `json:"cost,omitempty"`
}

AgentUsage contains aggregate model usage for a managed session.

type ApprovalConfig

type ApprovalConfig struct {
	// Prompt is the message displayed to the approver.
	Prompt string `json:"prompt,omitempty"`
	// Input is the list of expected input field names from the approver.
	Input []string `json:"input,omitempty"`
	// Required is the subset of Input fields that must be provided.
	Required []string `json:"required,omitempty"`
	// RewindTo is the step name or ID to restart from on push-back.
	// When empty, push-back re-executes the approval step itself.
	RewindTo string `json:"rewindTo,omitempty"`
}

ApprovalConfig configures the approval gate for a step. When a step has an ApprovalConfig, it pauses in Waiting state after execution completes, allowing a human to approve, push back (re-run with feedback), or reject.

type ArtifactsConfig

type ArtifactsConfig struct {
	Enabled bool   `json:"enabled"`
	Dir     string `json:"dir,omitempty"`
}

ArtifactsConfig controls DAG run artifact storage.

type AuthConfig

type AuthConfig struct {
	// Username for registry authentication
	Username string `json:"username,omitempty"`
	// Password for registry authentication
	Password string `json:"password,omitempty"`
	// Auth can be used instead of username/password for pre-encoded credentials
	// This should be base64(username:password)
	Auth string `json:"auth,omitempty"`
}

AuthConfig represents Docker registry authentication configuration. This is a simplified structure for user convenience that will be converted to Docker's registry.AuthConfig format when needed.

type BastionConfig

type BastionConfig struct {
	// Host is the bastion host address.
	Host string `json:"host,omitempty"`
	// Port is the bastion SSH port. Default is "22".
	Port string `json:"port,omitempty"`
	// User is the bastion SSH user.
	User string `json:"user,omitempty"`
	// Key is the path to the SSH private key for the bastion.
	Key string `json:"key,omitempty"`
	// Password is the SSH password for the bastion.
	Password string `json:"password,omitempty"`
}

BastionConfig contains the configuration for a bastion/jump host.

type BuildDecision

type BuildDecision string

BuildDecision records how an build node was satisfied.

const (
	BuildDecisionNone     BuildDecision = "none"
	BuildDecisionAlways   BuildDecision = "always"
	BuildDecisionExecute  BuildDecision = "execute"
	BuildDecisionReuse    BuildDecision = "reuse"
	BuildDecisionDeferred BuildDecision = "deferred"
)

type BuildExecution

type BuildExecution struct {
	Decision           BuildDecision `json:"decision"`
	Phase              BuildPhase    `json:"phase"`
	Reason             BuildReason   `json:"reason"`
	Detail             string        `json:"detail,omitempty"`
	Fingerprint        string        `json:"fingerprint,omitempty"`
	MaterializationKey string        `json:"materializationKey,omitempty"`
	ProducerRun        DAGRunRef     `json:"producerRun,omitzero"`
	ProducerAttemptID  string        `json:"producerAttemptId,omitempty"`
}

BuildExecution explains how an build node was satisfied.

type BuildPhase

type BuildPhase string

BuildPhase records the latest build lifecycle phase.

const (
	BuildPhasePrecondition BuildPhase = "precondition"
	BuildPhaseEvaluate     BuildPhase = "evaluate"
	BuildPhaseExecute      BuildPhase = "execute"
	BuildPhaseVerify       BuildPhase = "verify"
	BuildPhaseCommit       BuildPhase = "commit"
	BuildPhaseComplete     BuildPhase = "complete"
)

type BuildReason

type BuildReason string

BuildReason is a stable machine-readable explanation of a decision.

const (
	BuildReasonIneligible                  BuildReason = "ineligible"
	BuildReasonStoreUnavailable            BuildReason = "store_unavailable"
	BuildReasonEvaluationFailed            BuildReason = "evaluation_failed"
	BuildReasonCancelledBeforeDecision     BuildReason = "cancelled_before_decision"
	BuildReasonRecoveryFailed              BuildReason = "recovery_failed"
	BuildReasonUpstreamWouldExecute        BuildReason = "upstream_would_execute"
	BuildReasonInputMissing                BuildReason = "input_missing"
	BuildReasonControlDependencyRan        BuildReason = "control_dependency_ran"
	BuildReasonReuseDisabled               BuildReason = "reuse_disabled"
	BuildReasonManifestMissing             BuildReason = "manifest_missing"
	BuildReasonRecipeChanged               BuildReason = "recipe_changed"
	BuildReasonInputChanged                BuildReason = "input_changed"
	BuildReasonOutputMissing               BuildReason = "output_missing"
	BuildReasonOutputChanged               BuildReason = "output_changed"
	BuildReasonMatched                     BuildReason = "matched"
	BuildReasonInputChangedDuringExecution BuildReason = "input_changed_during_execution"
	BuildReasonPreconditionError           BuildReason = "precondition_error"
	BuildReasonPreconditionNotMet          BuildReason = "precondition_not_met"
)

type CommandEntry

type CommandEntry struct {
	// Command is the executable name or path.
	Command string `json:"command"`
	// Args contains the arguments for the command.
	Args []string `json:"args,omitempty"`
	// CmdWithArgs is the original command string for display purposes.
	CmdWithArgs string `json:"cmdWithArgs,omitempty"`
}

CommandEntry represents a single command in a multi-command step. Each entry contains a parsed command with its arguments.

func (CommandEntry) String

func (c CommandEntry) String() string

String returns a display string for the command entry.

type Condition

type Condition struct {
	Condition string `json:"condition,omitempty"` // Condition to evaluate
	Eval      string `json:"eval,omitempty"`      // Dynamic value to evaluate
	Expected  string `json:"expected,omitempty"`  // Expected value
	// ExpectedAny lists alternative expected values, of which any one matching
	// satisfies the condition. When set, it is used instead of Expected.
	ExpectedAny []string `json:"expectedAny,omitempty"`
	Negate      bool     `json:"negate,omitempty"` // Negate the condition result (run when condition does NOT match)
}

Condition describes a precondition command check or value match.

func (*Condition) ExpectedPatterns added in v2.18.0

func (c *Condition) ExpectedPatterns() []string

ExpectedPatterns returns the expected values a value match accepts, or nil for a command check.

func (*Condition) Validate

func (c *Condition) Validate() error

type ConditionResult

type ConditionResult struct {
	Condition
	Error string `json:"error,omitempty"`
}

ConditionResult records one condition definition and its latest evaluation error.

type Container

type Container struct {
	// Exec specifies an existing container name to exec into.
	// Mutually exclusive with Image.
	Exec string `yaml:"exec,omitempty"`
	// Name is the container name to use. If empty, Docker generates a random name.
	Name string `yaml:"name,omitempty"`
	// Image is the container image to use.
	Image string `yaml:"image,omitempty"`
	// PullPolicy is the policy to pull the image (e.g., "Always", "IfNotPresent").
	PullPolicy PullPolicy `yaml:"pull_policy,omitempty"`
	// Env specifies environment variables for the container.
	// Serialized to JSON so it can be restored when ReadDAG deserializes from
	// the stored DAGDefinition file.
	Env []string `yaml:"env,omitempty" json:"env,omitempty"` // List of environment variables in "key=value" format
	// EnvFile lists dotenv-syntax files to load into the container
	// environment. File variables have lower precedence than Env entries.
	// Serialized to JSON like Env for DAGDefinition persistence.
	EnvFile []string `yaml:"env_file,omitempty" json:"env_file,omitempty"`
	// Volumes specifies the volumes to mount in the container.
	Volumes []string `yaml:"volumes,omitempty"` // Map of volume names to volume definitions
	// User is the user to run the container as.
	User string `yaml:"user,omitempty"` // User to run the container as
	// WorkingDir is the working directory inside the container.
	WorkingDir string `yaml:"working_dir,omitempty"` // Working directory inside the container
	// Platform specifies the platform for the container (e.g., "linux/amd64").
	Platform string `yaml:"platform,omitempty"` // Platform for the container
	// Ports specifies the ports to expose from the container.
	Ports []string `yaml:"ports,omitempty"` // List of ports to expose
	// Network is the network configuration for the container.
	Network string `yaml:"network,omitempty"` // Network configuration for the container
	// KeepContainer is the flag to keep the container after the DAG run.
	KeepContainer bool `yaml:"keep_container,omitempty"` // Keep the container after the DAG run
	// Startup determines how the DAG-level container starts up.
	// One of: "keepalive" (default), "entrypoint", "command".
	Startup ContainerStartup `yaml:"startup,omitempty"`
	// Command is used when Startup == "command".
	Command []string `yaml:"command,omitempty"`
	// WaitFor determines readiness gate before steps run: "running" (default) or "healthy".
	WaitFor ContainerWaitFor `yaml:"wait_for,omitempty"`
	// LogPattern optionally waits for a regex to appear in container logs before proceeding.
	LogPattern string `yaml:"log_pattern,omitempty"`
	// RestartPolicy applies Docker restart policy for long-running containers ("no", "always", or "unless-stopped").
	RestartPolicy string `yaml:"restart_policy,omitempty"`
	// Healthcheck specifies a custom healthcheck for the container.
	// If specified with waitFor: healthy, this healthcheck is used instead of
	// relying on the image's built-in healthcheck.
	Healthcheck *Healthcheck `yaml:"healthcheck,omitempty"`
	// Shell specifies the shell wrapper for executing step commands.
	// When specified, all step commands are wrapped with this shell.
	// Format: ["/bin/bash", "-o", "errexit", "-o", "xtrace", "-c"]
	// The step command will be appended as the final argument.
	// Works in both exec mode and image mode.
	Shell []string `yaml:"shell,omitempty"`
}

Container defines the container configuration for the DAG.

func (Container) GetWorkingDir

func (ct Container) GetWorkingDir() string

GetWorkingDir returns the working directory inside the container

func (Container) IsExecMode

func (ct Container) IsExecMode() bool

IsExecMode returns true if this container is configured to exec into an existing container

type ContainerRuntime

type ContainerRuntime string

ContainerRuntime is the runtime used to launch or exec into a container.

const (
	ContainerRuntimeDocker ContainerRuntime = "docker"
	ContainerRuntimePodman ContainerRuntime = "podman"
)

func ParseContainerRuntime

func ParseContainerRuntime(raw string) (ContainerRuntime, error)

ParseContainerRuntime parses a container runtime from a raw string.

type ContainerStartup

type ContainerStartup string

ContainerStartup is an enum for DAG-level container startup modes.

const (
	StartupKeepalive  ContainerStartup = "keepalive"
	StartupEntrypoint ContainerStartup = "entrypoint"
	StartupCommand    ContainerStartup = "command"
)

type ContainerWaitFor

type ContainerWaitFor string

ContainerWaitFor is an enum for container readiness conditions.

const (
	WaitForRunning ContainerWaitFor = "running"
	WaitForHealthy ContainerWaitFor = "healthy"
)

type ContinueOn

type ContinueOn struct {
	Failure     bool     `json:"failure,omitempty"`     // Failure is the flag to continue to the next step on failure.
	Skipped     bool     `json:"skipped,omitempty"`     // Skipped is the flag to continue to the next step on skipped.
	ExitCode    []int    `json:"exitCode,omitempty"`    // ExitCode is the list of exit codes to continue to the next step.
	Output      []string `json:"output,omitempty"`      // Output is the list of output (stdout/stderr) to continue to the next step.
	MarkSuccess bool     `json:"markSuccess,omitempty"` // MarkSuccess is the flag to mark the step as success when the condition is met.
}

ContinueOn contains the conditions to continue on failure or skipped. Failure is the flag to continue to the next step on failure. Skipped is the flag to continue to the next step on skipped. A step can be skipped when the preconditions are not met. Then if the ContinueOn.Skip is set, the step will continue to the next step.

type DAG

type DAG struct {
	// WorkingDir is the working directory to run the DAG.
	// Default value is the directory of DAG file.
	// Relative paths are resolved at build time; variables are expanded at runtime.
	// Supports environment variable templates (e.g., ${MY_DIR}).
	WorkingDir string `json:"workingDir,omitempty"`
	// WorkingDirExplicit is true when WorkingDir was explicitly set in YAML,
	// base config, or via DefaultWorkingDir option. When false, WorkingDir
	// was auto-defaulted by the loader to the DAG file's parent directory.
	// Not serialized — runtime-only flag.
	WorkingDirExplicit bool `json:"-"`
	// Location is the absolute path to the DAG file and can be blank.
	Location string `json:"location,omitempty"`
	// SourceFile is the original DAG file path this run was loaded from.
	// Unlike Location, it is provenance-only and is preserved even when queued
	// execution clears or rewrites runtime locations.
	SourceFile string `json:"sourceFile,omitempty"`
	// Group is the group name of the DAG. This is optional.
	Group string `json:"group,omitempty"`
	// Name is the name of the DAG. The default is the filename without the extension.
	Name string `json:"name,omitempty"`
	// Type is the execution type. Default is graph.
	Type string `json:"type,omitempty"`
	// Tasks are the goals an agent DAG must satisfy before it concludes.
	// Only meaningful when Type is TypeAgent.
	Tasks []AgentTask `json:"tasks,omitempty"`
	// Shell is the default shell to use for all steps in this DAG.
	// If not specified, the system default shell is used.
	// Can be overridden at the step level.
	// Supports environment variable templates (e.g., ${MY_SHELL}).
	Shell string `json:"shell,omitempty"`
	// ShellArgs contains additional arguments to pass to the shell.
	// These are populated when Shell is specified as a string with arguments
	// (e.g., "bash -e") or as an array (e.g., ["bash", "-e"]).
	// Supports environment variable templates.
	ShellArgs []string `json:"shellArgs,omitempty"`
	// Dotenv is the path to the dotenv file. This is optional.
	Dotenv []string `json:"dotenv,omitempty"`
	// Labels contains the list of labels for the DAG. This is optional.
	Labels Labels `json:"labels,omitempty"`
	// Description is the description of the DAG. This is optional.
	Description string `json:"description,omitempty"`
	// Schedule configuration for starting, stopping, and restarting the DAG.
	Schedule []Schedule `json:"schedule,omitempty"`
	// StopSchedule contains the cron expressions for stopping the DAG.
	StopSchedule []Schedule `json:"stopSchedule,omitempty"`
	// RestartSchedule contains the cron expressions for restarting the DAG.
	RestartSchedule []Schedule `json:"restartSchedule,omitempty"`
	// SkipIfSuccessful indicates whether to skip the DAG if it was successful previously.
	// E.g., when the DAG has already been executed manually before the scheduled time.
	SkipIfSuccessful bool `json:"skipIfSuccessful,omitempty"`
	// CatchupWindow is the lookback horizon for missed cron intervals.
	// If set, enables catch-up on scheduler restart. If omitted, no catch-up.
	CatchupWindow time.Duration `json:"catchupWindow,omitempty"`
	// OverlapPolicy controls behavior when a new run is triggered while one is active.
	// Defaults to "skip". See OverlapPolicy constants for options.
	OverlapPolicy OverlapPolicy `json:"overlapPolicy,omitempty"`
	// Env contains a list of environment variables to be set before running the DAG.
	// Note: This field is evaluated at build time and may contain secrets.
	// It is excluded from JSON serialization to prevent secret leakage.
	Env []string `json:"-"`
	// Consts contains immutable values resolved while loading the DAG.
	Consts map[string]any `json:"consts,omitempty"`
	// EnvEvaluated reports whether Env is safe to reuse as resolved build env.
	EnvEvaluated bool `json:"-"`
	// RootEnvSpan locates the DAG's own root env entries in Env when loading
	// resolved them. Base-config entries come before it, and entries added for
	// a run, such as dotenv values, come after it.
	RootEnvSpan EnvSpan `json:"-"`
	// RuntimeResolved reports whether dotenv resolution is complete for Env.
	RuntimeResolved bool `json:"-"`
	// PresolvedBuildEnv stores resolved DAG/base-config env entries needed to
	// rebuild the DAG from persisted YAML during retry/restart paths.
	// It is serialized with dag.json because direct retry/restart cannot rely on
	// parent-process transport once the original process has exited.
	PresolvedBuildEnv map[string]string `json:"presolvedBuildEnv,omitempty"`
	// LogDir is the directory where the logs are stored.
	LogDir string `json:"logDir,omitempty"`
	// Artifacts config controls optional DAG run artifact storage.
	Artifacts *ArtifactsConfig `json:"artifacts,omitempty"`
	// LogOutput specifies how stdout and stderr are handled in log files.
	// Can be "separate" (default) for separate .out and .err files,
	// or "merged" for a single combined .log file.
	LogOutput LogOutputMode `json:"logOutput,omitempty"`
	// DefaultParams contains the default parameters to be passed to the DAG.
	DefaultParams string `json:"defaultParams,omitempty"`
	// ParamDefs contains ordered parameter metadata derived from DAG params.
	// It is exposed to the API for typed UI rendering and validation hints.
	ParamDefs []ParamDef `json:"paramDefs,omitempty"`
	// ParamSchema contains the resolved JSON Schema for schema-backed DAG params
	// when that schema is safe for direct UI form rendering.
	ParamSchema json.RawMessage `json:"paramSchema,omitempty"`
	// Params contains the list of parameters to be passed to the DAG.
	// Note: This field is evaluated at build time and may contain secrets.
	// It is excluded from JSON serialization to prevent secret leakage.
	Params []string `json:"-"`
	// ParamsJSON contains the JSON representation of the resolved parameters.
	// When params were supplied as JSON, the original payload is preserved.
	// Steps can consume this via the DAG_PARAMS_JSON environment variable.
	// Note: This field is evaluated at build time and may contain secrets.
	// It is excluded from JSON serialization to prevent secret leakage.
	ParamsJSON string `json:"-"`
	// Steps contains the list of steps in the DAG.
	Steps []Step `json:"steps,omitempty"`
	// HandlerOn contains the steps to be executed on different events.
	HandlerOn HandlerOn `json:"handlerOn,omitzero"`
	// Preconditions contains the conditions to be met before running the DAG.
	Preconditions []*Condition `json:"preconditions,omitempty"`
	// SMTP contains the SMTP configuration.
	// Excluded from JSON: may contain password.
	SMTP *SMTPConfig `json:"-"`
	// MailAccounts contains the mail accounts used by mail actions.
	// Excluded from JSON: may contain passwords and tokens.
	MailAccounts MailAccounts `json:"-"`
	// ErrorMail contains the mail configuration for errors.
	ErrorMail *MailConfig `json:"errorMail,omitempty"`
	// InfoMail contains the mail configuration for informational messages.
	InfoMail *MailConfig `json:"infoMail,omitempty"`
	// WaitMail contains the mail configuration for wait status.
	WaitMail *MailConfig `json:"waitMail,omitempty"`
	// MailOn contains the conditions to send mail.
	MailOn *MailOn `json:"mailOn,omitempty"`
	// Timeout specifies the maximum execution time of the DAG task.
	Timeout time.Duration `json:"timeout,omitempty"`
	// Delay is the delay before starting the DAG.
	Delay time.Duration `json:"delay,omitempty"`
	// RestartWait is the time to wait before restarting the DAG.
	RestartWait time.Duration `json:"restartWait,omitempty"`
	// MaxActiveSteps specifies the maximum concurrent steps to run in an execution.
	MaxActiveSteps int `json:"maxActiveSteps,omitempty"`
	// MaxActiveRuns specifies the maximum number of concurrent dag-runs.
	// DEPRECATED: This field is ignored for local (DAG-based) queues.
	// For concurrency control, define a global queue in config and use the 'queue' field.
	MaxActiveRuns int `json:"maxActiveRuns,omitempty"`
	// MaxCleanUpTime is the maximum time to wait for cleanup when the DAG is stopped.
	MaxCleanUpTime time.Duration `json:"maxCleanUpTime,omitempty"`
	// HistRetentionDays is the number of days to keep the history of dag-runs.
	HistRetentionDays int `json:"histRetentionDays,omitempty"`
	// HistRetentionRuns is the number of dag-runs to keep in history.
	HistRetentionRuns int `json:"histRetentionRuns,omitempty"`
	// Queue is the name of the queue to assign this DAG to.
	Queue string `json:"queue,omitempty"`
	// RetryPolicy controls automatic DAG-level retry behavior for failed runs.
	RetryPolicy *DAGRetryPolicy `json:"retryPolicy,omitempty"`
	// WorkerSelector defines labels required for worker selection in distributed execution.
	// If specified, the DAG will only run on workers with matching labels.
	WorkerSelector map[string]string `json:"workerSelector,omitempty"`
	// ForceLocal forces the DAG to run locally even when the server default is distributed.
	// Set by worker_selector: local in the DAG spec.
	ForceLocal bool `json:"forceLocal,omitempty"`
	// MaxOutputSize is the maximum size of step output to capture in bytes.
	// Default is 1MB. Output exceeding this will return an error.
	MaxOutputSize int `json:"maxOutputSize,omitempty"`
	// OTel contains the OpenTelemetry configuration for the DAG.
	OTel *OTelConfig `json:"otel,omitempty"`
	// BuildErrors contains any errors encountered while building the DAG.
	BuildErrors []error `json:"-"`
	// BuildWarnings contains non-fatal warnings detected while building the DAG.
	BuildWarnings []string `json:"-"`
	// LocalDAGs contains DAGs defined in the same file, keyed by DAG name
	LocalDAGs map[string]*DAG `json:"localDAGs,omitempty"`
	// YamlData contains the raw YAML data of the DAG.
	YamlData []byte `json:"yamlData,omitempty"`
	// BaseConfigData contains the raw base config YAML content.
	// This is used to propagate base config through distributed execution
	// and sub-DAG chains, so workers don't need local base config files.
	BaseConfigData []byte `json:"baseConfigData,omitempty"`
	// BaseConfigWorkspace identifies the workspace supplying base configuration.
	// An empty name selects global configuration; nil denotes unknown provenance.
	BaseConfigWorkspace *string `json:"baseConfigWorkspace,omitempty"`
	// Container contains the container definition for the DAG.
	Container *Container `json:"container,omitempty"`
	// RunConfig contains configuration for controlling user interactions during DAG runs.
	RunConfig *RunConfig `json:"runConfig,omitempty"`
	// Resources contains CPU and memory limits requested for this DAG run.
	Resources *Resources `json:"resources,omitempty"`
	// Webhook contains DAG-level webhook trigger behavior configuration.
	Webhook *WebhookConfig `json:"webhook,omitempty"`
	// RegistryAuths maps registry hostnames to authentication configs.
	// Optional: If not specified, falls back to DOCKER_AUTH_CONFIG or docker config.
	// Credentials are evaluated at runtime. Excluded from JSON: may contain passwords.
	RegistryAuths map[string]*AuthConfig `json:"-"`
	// SSH contains the default SSH configuration for the DAG.
	// Excluded from JSON: may contain password.
	SSH *SSHConfig `json:"-"`
	// S3 contains the default S3 configuration for the DAG.
	// Excluded from JSON: may contain credentials.
	S3 *S3Config `json:"-"`
	// LLM contains the default LLM configuration for the DAG.
	// Steps with type: chat inherit this configuration if they don't specify their own llm field.
	LLM *LLMConfig `json:"llm,omitempty"`
	// Redis contains the default Redis configuration for the DAG.
	// Steps with type: redis inherit this configuration.
	// Excluded from JSON: may contain password.
	Redis *RedisConfig `json:"-"`
	// Harness contains the default harness executor configuration for the DAG.
	// Steps with type: harness inherit this configuration.
	// Excluded from JSON: may contain API key references or provider-specific secrets.
	Harness *HarnessConfig `json:"-"`
	// Harnesses contains reusable custom harness definitions available to harness steps.
	// Excluded from JSON: derived from DAG/base config and rebuilt from YAML when needed.
	Harnesses HarnessDefinitions `json:"-"`
	// Kubernetes contains the default Kubernetes executor configuration for the DAG.
	// Steps with type: k8s or type: kubernetes inherit this configuration.
	// Excluded from JSON: may contain secret references.
	Kubernetes KubernetesConfig `json:"-"`
	// Secrets contains references to external secrets to be resolved at runtime.
	Secrets []secretref.Ref `json:"secrets,omitempty"`
	// Tools declares external CLI tools that must be installed before the DAG runs.
	Tools *ToolConfig `json:"tools,omitempty"`
}

DAG contains all information about a DAG.

func (*DAG) AgentMaxContextTokens added in v2.14.0

func (d *DAG) AgentMaxContextTokens() int

AgentMaxContextTokens returns the prompt size at which observation aging starts. Zero disables proactive aging.

func (*DAG) AgentMaxIterations added in v2.14.0

func (d *DAG) AgentMaxIterations() int

AgentMaxIterations returns the upper bound on agent turns for a single run.

func (*DAG) AgentObservationKeepRecent added in v2.14.0

func (d *DAG) AgentObservationKeepRecent() int

AgentObservationKeepRecent returns how many recent observations remain complete after aging starts. Zero disables observation aging.

func (*DAG) AgentObservationMaxBytes added in v2.14.0

func (d *DAG) AgentObservationMaxBytes() int

AgentObservationMaxBytes returns the maximum agent-facing size of one observation. Zero disables the size limit.

func (*DAG) AgentStep added in v2.14.0

func (d *DAG) AgentStep() *Step

AgentStep returns the synthesized agent step, or nil when the DAG is not an agent DAG.

func (*DAG) ApplyWorkerSelector

func (d *DAG) ApplyWorkerSelector(selector map[string]string) error

ApplyWorkerSelector replaces the DAG's worker selector for one run, also clearing worker_selector: local, under the same rule as the YAML key: a DAG with approval steps keeps running locally.

func (*DAG) ArtifactsEnabled

func (d *DAG) ArtifactsEnabled() bool

ArtifactsEnabled reports whether the DAG has artifact storage enabled.

func (*DAG) Clone

func (d *DAG) Clone() *DAG

Clone returns a DAG copy suitable for modifying top-level runtime state.

func (*DAG) FileName

func (d *DAG) FileName() string

FileName returns the filename of the DAG without the extension.

func (*DAG) GetName

func (d *DAG) GetName() string

GetName returns the name of the DAG. If the name is not set, it returns the default name (filename without extension).

func (*DAG) HasApprovalSteps

func (d *DAG) HasApprovalSteps() bool

HasApprovalSteps returns true if the DAG contains any steps that require human approval. DAGs with approval steps cannot be dispatched to workers because approval steps require local storage access.

func (*DAG) HasHumanTaskSteps

func (d *DAG) HasHumanTaskSteps() bool

HasHumanTaskSteps reports whether the DAG declares a human task. An agent DAG's synthesized ask_user task does not count: it is scaffolding every agent carries, and the agent declines to use it outside a root run, so counting it here would bar agents from being composed as child DAGs.

func (*DAG) HasLabel

func (d *DAG) HasLabel(label string) bool

HasLabel checks if the DAG has a label matching the given filter. Supports both simple labels ("production") and key-value filters ("env=prod").

func (*DAG) HasTag

func (d *DAG) HasTag(tag string) bool

HasTag checks if the DAG has a tag matching the given filter. Deprecated: use HasLabel.

func (*DAG) IsAgent added in v2.14.0

func (d *DAG) IsAgent() bool

IsAgent reports whether the DAG is driven by an LLM agent instead of a static dependency graph.

func (*DAG) NextRun

func (d *DAG) NextRun(now time.Time) time.Time

NextRun returns the next scheduled run time based on the DAG's schedules.

func (*DAG) ParamDeclarations

func (d *DAG) ParamDeclarations() map[string]any

ParamDeclarations returns named parameters that can be referenced through ${params.name}.

func (*DAG) ParamValues

func (d *DAG) ParamValues() map[string]any

ParamValues returns named runtime parameter values for ${params.name}.

func (*DAG) ParamsMap

func (d *DAG) ParamsMap() map[string]string

ParamsMap returns the parameters as a map.

func (*DAG) ProcGroup

func (d *DAG) ProcGroup() string

ProcGroup returns the name of the process group for this DAG. The process group name is used to identify and manage related DAG executions.

Returns:

  • If Queue is set: returns the Queue value
  • If Queue is empty: returns the DAG name as the default

The process group name is used by the process store to:

  1. Manage heartbeat files for active DAG runs
  2. Enforce concurrency limits (max concurrent runs) across DAGs in the same group

This allows the scheduler to control how many DAGs can run simultaneously within the same process group.

func (*DAG) RestoreUnpersistedFrom

func (d *DAG) RestoreUnpersistedFrom(src *DAG)

RestoreUnpersistedFrom copies into d every field that JSON serialization omits, taking its value from src. Fields recording the outcome of a build rather than configuration are left untouched.

A DAG decoded from persisted JSON is missing all of those fields, because they hold values deliberately kept off disk. Rebuilding the DAG from its source produces them again in src, and this carries them across. Adding a new omitted field to DAG therefore extends the restore automatically; a field that must not be restored belongs in buildOutcomeFields.

func (*DAG) String

func (d *DAG) String() string

String returns a formatted string representation of the DAG.

func (*DAG) SuspendFlagName

func (d *DAG) SuspendFlagName() string

SuspendFlagName returns the filename stem used by the file-based suspend flag system. This intentionally follows DAG file naming, not dag.Name.

func (*DAG) UnmarshalJSON

func (d *DAG) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes DAGs written by both the canonical labels field and the deprecated tags field used by older persisted dag.json files.

func (*DAG) Validate

func (d *DAG) Validate() error

Validate performs basic validation of the DAG structure. It collects all validation errors instead of returning on first error.

type DAGRetryPolicy

type DAGRetryPolicy struct {
	// Limit is the maximum number of retry attempts allowed.
	Limit int `json:"limit,omitempty"`
	// Interval is the base delay before retrying.
	Interval time.Duration `json:"interval,omitempty"`
	// IntervalSecStr preserves the original interval string representation.
	IntervalSecStr string `json:"intervalSecStr,omitempty"`
	// Backoff is the retry delay multiplier. Zero keeps a fixed interval.
	Backoff float64 `json:"backoff,omitempty"`
	// MaxInterval caps the computed retry delay.
	MaxInterval time.Duration `json:"maxInterval,omitempty"`
}

DAGRetryPolicy contains the retry policy for a DAG run.

type DAGRunCondition

type DAGRunCondition struct {
	Type      string `json:"type"`
	Status    string `json:"status"`
	Reason    string `json:"reason"`
	Message   string `json:"message"`
	CheckedAt string `json:"checkedAt"`
}

DAGRunCondition describes an observed runtime condition for a DAG-run.

func MergeDAGRunConditions

func MergeDAGRunConditions(conditions []DAGRunCondition, observations ...DAGRunCondition) []DAGRunCondition

MergeDAGRunConditions merges observations into a type-keyed current-state list.

func NewDAGRunCondition

func NewDAGRunCondition(conditionType, status, reason, message string, checkedAt time.Time) DAGRunCondition

NewDAGRunCondition creates a runtime condition for a DAG-run.

func NoAvailableWorkerConditions

func NoAvailableWorkerConditions(checkedAt time.Time) []DAGRunCondition

NoAvailableWorkerConditions are the conditions a run waits under when no healthy distributed worker exists at all.

func NoMatchingWorkerConditions

func NoMatchingWorkerConditions(checkedAt time.Time) []DAGRunCondition

NoMatchingWorkerConditions are the conditions a run waits under when no healthy worker carries the labels its selector requires. The scheduler's queue and the coordinator write the same pair, so a waiting run reads the same however it was dispatched.

type DAGRunOutputs

type DAGRunOutputs struct {
	Metadata OutputsMetadata   `json:"metadata"`
	Outputs  map[string]string `json:"outputs"`
}

DAGRunOutputs represents the full outputs file structure with metadata.

type DAGRunRef

type DAGRunRef struct {
	Name string `json:"name,omitempty"`
	ID   string `json:"id,omitempty"`
}

DAGRunRef identifies a DAG run.

func NewDAGRunRef

func NewDAGRunRef(name, runID string) DAGRunRef

NewDAGRunRef creates a DAG-run reference.

func ParseDAGRunRef

func ParseDAGRunRef(value string) (DAGRunRef, error)

ParseDAGRunRef parses a name:runId reference.

func (DAGRunRef) String

func (r DAGRunRef) String() string

String returns the reference in name:runId form.

func (DAGRunRef) Zero

func (r DAGRunRef) Zero() bool

Zero reports whether the reference is empty.

type DAGRunStatus

type DAGRunStatus struct {
	Root         DAGRunRef         `json:"root,omitzero"`
	Parent       DAGRunRef         `json:"parent,omitzero"`
	Name         string            `json:"name"`
	DAGRunID     string            `json:"dagRunId"`
	AttemptID    string            `json:"attemptId"`
	AttemptKey   string            `json:"attemptKey,omitempty"` // Globally unique attempt identifier
	ClaimKey     string            `json:"claimKey,omitempty"`   // Worker claim that executes this attempt
	Status       Status            `json:"status"`
	Conditions   []DAGRunCondition `json:"conditions,omitempty"`
	TriggerType  TriggerType       `json:"triggerType,omitempty"`
	TriggerActor string            `json:"triggerActor,omitempty"`
	// Resume marks a queued checkpoint resume. Retry planning honors it only
	// while the attempt is queued, so retries of finished runs reset as usual.
	Resume         bool                   `json:"resume,omitempty"`
	WorkerID       string                 `json:"workerId,omitempty"`
	PID            PID                    `json:"pid,omitempty"`
	PIDStartedAt   int64                  `json:"pidStartedAt,omitempty"`
	Nodes          []*Node                `json:"nodes,omitempty"`
	AgentSessions  []AgentSessionResource `json:"agentSessions,omitempty"`
	OnInit         *Node                  `json:"onInit,omitempty"`
	OnExit         *Node                  `json:"onExit,omitempty"`
	OnSuccess      *Node                  `json:"onSuccess,omitempty"`
	OnFailure      *Node                  `json:"onFailure,omitempty"`
	OnAbort        *Node                  `json:"onAbort,omitempty"`
	OnWait         *Node                  `json:"onWait,omitempty"`
	CreatedAt      int64                  `json:"createdAt,omitempty"`
	QueuedAt       string                 `json:"queuedAt,omitempty"`
	ScheduleTime   string                 `json:"scheduleTime,omitempty"`
	StartedAt      string                 `json:"startedAt,omitempty"`
	FinishedAt     string                 `json:"finishedAt,omitempty"`
	AutoRetryCount int                    `json:"autoRetryCount,omitempty"`
	AutoRetryLimit int                    `json:"autoRetryLimit,omitempty"`
	// AutoRetryInterval is stored as a duration snapshot for retry scanner decisions.
	AutoRetryInterval time.Duration `json:"autoRetryInterval,omitempty"`
	AutoRetryBackoff  float64       `json:"autoRetryBackoff,omitempty"`
	// AutoRetryMaxInterval is stored as a duration snapshot for retry scanner decisions.
	AutoRetryMaxInterval time.Duration `json:"autoRetryMaxInterval,omitempty"`
	ProcGroup            string        `json:"procGroup,omitempty"`
	DefinitionID         string        `json:"definitionId,omitempty"`
	// SuspendFlagName is retained for histories written before DefinitionID was introduced.
	SuspendFlagName    string                `json:"suspendFlagName,omitempty"`
	Log                string                `json:"log,omitempty"`
	WorkingDir         string                `json:"workingDir,omitempty"`
	ArchiveDir         string                `json:"archiveDir,omitempty"`
	Error              string                `json:"error,omitempty"`
	Params             string                `json:"params,omitempty"`
	ParamsList         []string              `json:"paramsList,omitempty"`
	ParallelItem       string                `json:"parallelItem,omitempty"`
	ProfileName        string                `json:"profileName,omitempty"`
	ProfileResolvedAt  string                `json:"profileResolvedAt,omitempty"`
	ProfileEntries     []RuntimeProfileEntry `json:"profileEntries,omitempty"`
	NoReuse            bool                  `json:"noReuse,omitempty"`
	PendingStepRetries []PendingStepRetry    `json:"pendingStepRetries"`
	Preconditions      []ConditionResult     `json:"preconditions,omitempty"`
	Labels             []string              `json:"labels,omitempty"`
	LeaseAt            int64                 `json:"leaseAt,omitempty"` // Unix millis; stamped by coordinator on observed run liveness
}

DAGRunStatus represents the complete execution state of a dag-run.

func InitialStatus

func InitialStatus(dag *DAG) DAGRunStatus

InitialStatus creates an initial Status object for the given DAG

func StatusFromJSON

func StatusFromJSON(s string) (*DAGRunStatus, error)

StatusFromJSON deserializes a JSON string into a Status object

func StoredStatus

func StoredStatus(st DAGRunStatus) DAGRunStatus

StoredStatus returns the status as a status file stores it: each node keeps an output repeated under its other output fields once. Reading it back with StatusFromJSON restores every field. The status passed in is not changed.

func (*DAGRunStatus) DAGDefinitionID added in v2.14.0

func (st *DAGRunStatus) DAGDefinitionID() string

DAGDefinitionID returns the persisted definition identity for this run.

func (*DAGRunStatus) DAGRun

func (st *DAGRunStatus) DAGRun() DAGRunRef

DAGRun returns a reference to the dag-run associated with this status

func (DAGRunStatus) EffectiveClaimKey

func (s DAGRunStatus) EffectiveClaimKey() string

EffectiveClaimKey returns ClaimKey, falling back to AttemptKey when no claim is recorded.

func (*DAGRunStatus) ErrorText added in v2.18.0

func (st *DAGRunStatus) ErrorText() string

ErrorText returns the error message for the run: the run-level error when present, otherwise the errors of failed steps and lifecycle handlers as "step: message" lines in run order. ANSI escape sequences are removed.

func (*DAGRunStatus) Errors

func (st *DAGRunStatus) Errors() []error

Errors returns a slice of errors for the current status

func (*DAGRunStatus) NodeByName

func (st *DAGRunStatus) NodeByName(name string) (*Node, error)

NodeByName returns the node with the specified name. For handlers, it matches on both the handler label (e.g., "onSuccess") and the step name within the handler.

func (*DAGRunStatus) NodesInRunOrder

func (st *DAGRunStatus) NodesInRunOrder() []*Node

NodesInRunOrder returns the run's step nodes together with the lifecycle handler nodes that were configured, ordered by when they run. Handlers that the DAG does not declare are omitted.

func (*DAGRunStatus) UnmarshalJSON

func (st *DAGRunStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps legacy onCancel and tags status files readable while normalizing canonical handler/metadata names in memory.

type EnvSpan added in v2.18.2

type EnvSpan struct {
	Start int
	End   int
}

EnvSpan is the half-open range [Start, End) of DAG.Env indexes.

type ErrorList

type ErrorList []error

ErrorList is just a list of errors. It is used to collect multiple errors in building a DAG.

func (ErrorList) Dedupe

func (e ErrorList) Dedupe() ErrorList

Dedupe returns the list with repeated occurrences of the same error value removed, keeping first positions. Distinct errors with equal messages are preserved; only identical instances collapse. Values of non-comparable dynamic types are kept as-is.

func (ErrorList) Error

func (e ErrorList) Error() string

Error implements the error interface. It returns a string with all the errors separated by a semicolon.

func (*ErrorList) ToStringList

func (e *ErrorList) ToStringList() []string

ToStringList returns the list of errors as a slice of strings.

func (ErrorList) Unwrap

func (e ErrorList) Unwrap() []error

Unwrap implements the errors.Unwrap interface.

type ExecutorConfig

type ExecutorConfig struct {
	// Type represents one of the registered executors.
	// See `executor.Register` in `internal/executor/executor.go`.
	Type   string         `json:"type,omitempty"`
	Config map[string]any `json:"config,omitempty"` // Config contains executor-specific configuration.
	// Metadata contains additional metadata for the executor that is not passed to the executor itself.
	// This is used internally for optimization purposes.
	Metadata map[string]any `json:"metadata,omitempty"`
}

ExecutorConfig contains the configuration for the executor.

func (ExecutorConfig) IsCommand

func (e ExecutorConfig) IsCommand() bool

IsCommand returns true if the executor is a command

func (ExecutorConfig) IsVerbatimScript

func (e ExecutorConfig) IsVerbatimScript() bool

IsVerbatimScript reports whether the executor receives the step script as written, without workflow value resolution. Such executors interpret the script text themselves and take workflow values through their config.

type ForeachBodyStepStatus

type ForeachBodyStepStatus struct {
	Name       string     `json:"name"`
	ID         string     `json:"id,omitempty"`
	Status     NodeStatus `json:"status"`
	Error      string     `json:"error,omitempty"`
	StartedAt  string     `json:"startedAt,omitempty"`
	FinishedAt string     `json:"finishedAt,omitempty"`
	RetryCount int        `json:"retryCount,omitempty"`
	Stdout     string     `json:"stdout,omitempty"`
	Stderr     string     `json:"stderr,omitempty"`
	// Foreach marks a body step that is itself a foreach, whose items live
	// in a nested directory.
	Foreach bool `json:"foreach,omitempty"`
}

ForeachBodyStepStatus records one body step of a foreach item. Stdout and Stderr are file names relative to the item's directory.

type ForeachConfig

type ForeachConfig struct {
	// Items is the static list of items to iterate.
	Items []any `json:"items,omitempty"`

	// ItemsExpr is a value-resolved expression that must produce a JSON array.
	ItemsExpr string `json:"itemsExpr,omitempty"`

	// As is the item alias exposed under the foreach namespace.
	As string `json:"as,omitempty"`

	// Key is an optional item key expression.
	Key string `json:"key,omitempty"`

	// MaxConcurrent is the maximum number of item bodies running at once.
	MaxConcurrent int `json:"maxConcurrent,omitempty"`

	// Steps is the item body graph.
	Steps []Step `json:"steps,omitempty"`

	// Collect maps output names to value-resolved expressions.
	Collect map[string]string `json:"collect,omitempty"`
}

ForeachConfig contains the configuration for inline item-body iteration.

type ForeachItemRef

type ForeachItemRef struct {
	Index int    `json:"index"`
	Key   string `json:"key"`
}

ForeachItemRef identifies one expanded item.

type ForeachItemStatus

type ForeachItemStatus struct {
	Index      int                     `json:"index"`
	Key        string                  `json:"key"`
	Status     NodeStatus              `json:"status"`
	Error      string                  `json:"error,omitempty"`
	StartedAt  string                  `json:"startedAt,omitempty"`
	FinishedAt string                  `json:"finishedAt,omitempty"`
	Steps      []ForeachBodyStepStatus `json:"steps"`
}

ForeachItemStatus records the body run of one foreach item. It is kept beside the item's body logs, outside the run status, so that a foreach over many items does not grow every status snapshot.

type ForeachItems

type ForeachItems struct {
	Total int              `json:"total"`
	Items []ForeachItemRef `json:"items"`
}

ForeachItems lists the items a foreach step expanded to. It is recorded before any item body runs, so a reader knows the total ahead of the results.

type HandlerOn

type HandlerOn struct {
	Init    *Step `json:"init,omitempty"`
	Failure *Step `json:"failure,omitempty"`
	Success *Step `json:"success,omitempty"`
	Abort   *Step `json:"abort,omitempty"`
	Exit    *Step `json:"exit,omitempty"`
	Wait    *Step `json:"wait,omitempty"`
}

HandlerOn contains the steps to be executed on different events in the DAG.

type HandlerType

type HandlerType string

HandlerType is the type of the handler.

const (
	HandlerOnInit    HandlerType = "onInit"
	HandlerOnSuccess HandlerType = "onSuccess"
	HandlerOnFailure HandlerType = "onFailure"
	HandlerOnAbort   HandlerType = "onAbort"
	HandlerOnExit    HandlerType = "onExit"
	HandlerOnWait    HandlerType = "onWait"
)

func (HandlerType) String

func (h HandlerType) String() string

type HarnessConfig

type HarnessConfig struct {
	// Config contains the primary provider selection and CLI flags.
	Config map[string]any `json:"-"`
	// Fallback contains ordered alternative provider configs tried on failure.
	Fallback []map[string]any `json:"-"`
}

HarnessConfig contains the default harness executor configuration for the DAG. Steps with type: harness inherit Config as their primary attempt and Fallback as ordered alternative provider configs.

type HarnessDefinition

type HarnessDefinition struct {
	Protocol          HarnessProtocol       `json:"protocol,omitempty"`
	Transport         HarnessTransport      `json:"transport,omitempty"`
	URL               string                `json:"url,omitempty"`
	CAFile            string                `json:"caFile,omitempty"`
	BearerSubprotocol bool                  `json:"bearerSubprotocol,omitempty"`
	Headers           map[string]string     `json:"headers,omitempty"`
	Cwd               string                `json:"cwd,omitempty"`
	Binary            string                `json:"binary,omitempty"`
	PrefixArgs        []string              `json:"prefixArgs,omitempty"`
	PromptMode        HarnessPromptMode     `json:"promptMode,omitempty"`
	PromptFlag        string                `json:"promptFlag,omitempty"`
	PromptPosition    HarnessPromptPosition `json:"promptPosition,omitempty"`
	FlagStyle         HarnessFlagStyle      `json:"flagStyle,omitempty"`
	OptionFlags       map[string]string     `json:"optionFlags,omitempty"`
}

HarnessDefinition describes how to invoke a CLI or connect to an ACP agent.

func CloneHarnessDefinition

func CloneHarnessDefinition(def *HarnessDefinition) *HarnessDefinition

CloneHarnessDefinition copies a definition without sharing mutable slices or maps.

func (*HarnessDefinition) IsRemote

func (d *HarnessDefinition) IsRemote() bool

IsRemote reports whether the definition connects to an ACP agent over the network.

func (*HarnessDefinition) ValidateConnection

func (d *HarnessDefinition) ValidateConnection() error

ValidateConnection checks the mutually exclusive local and remote launch settings. URL and cwd values with variable references are checked again after runtime variable resolution.

type HarnessDefinitions

type HarnessDefinitions map[string]*HarnessDefinition

HarnessDefinitions contains named reusable harness definitions. Nil values are used internally during base-config merge to delete inherited entries.

type HarnessFlagStyle

type HarnessFlagStyle string
const (
	HarnessFlagStyleGNULong    HarnessFlagStyle = "gnu_long"
	HarnessFlagStyleSingleDash HarnessFlagStyle = "single_dash"
)

type HarnessPromptMode

type HarnessPromptMode string
const (
	HarnessPromptModeArg   HarnessPromptMode = "arg"
	HarnessPromptModeFlag  HarnessPromptMode = "flag"
	HarnessPromptModeStdin HarnessPromptMode = "stdin"
)

type HarnessPromptPosition

type HarnessPromptPosition string
const (
	HarnessPromptPositionBeforeFlags HarnessPromptPosition = "before_flags"
	HarnessPromptPositionAfterFlags  HarnessPromptPosition = "after_flags"
)

type HarnessProtocol

type HarnessProtocol string

HarnessProtocol selects CLI invocation or an ACP connection.

const (
	HarnessProtocolCLI HarnessProtocol = "cli"
	HarnessProtocolACP HarnessProtocol = "acp"
)

type HarnessTransport

type HarnessTransport string

HarnessTransport selects the wire transport for an ACP connection.

const (
	HarnessTransportStdio     HarnessTransport = "stdio"
	HarnessTransportWebSocket HarnessTransport = "websocket"
	HarnessTransportHTTP      HarnessTransport = "http"
)

type Healthcheck

type Healthcheck struct {
	// Test is the command to run to check health. Must start with:
	// - ["NONE"] - disable healthcheck
	// - ["CMD", "command", "arg1", ...] - run command directly
	// - ["CMD-SHELL", "command"] - run command in shell
	Test []string `yaml:"test,omitempty"`
	// Interval is the time between health checks (e.g., "5s", "1m").
	Interval time.Duration `yaml:"interval,omitempty"`
	// Timeout is how long to wait for the health check to complete (e.g., "3s").
	Timeout time.Duration `yaml:"timeout,omitempty"`
	// StartPeriod is the grace period for the container to initialize (e.g., "10s").
	StartPeriod time.Duration `yaml:"start_period,omitempty"`
	// Retries is the number of consecutive failures needed to consider unhealthy.
	Retries int `yaml:"retries,omitempty"`
}

Healthcheck defines a custom health check for a container. This allows waitFor: healthy to work with images that don't have built-in healthchecks.

type HumanTaskConfig

type HumanTaskConfig struct {
	Prompt    string          `json:"prompt,omitempty"`
	Form      json.RawMessage `json:"form,omitempty"`
	Artifacts []string        `json:"artifacts,omitempty"`
	// PushBack lets the operator send the task back to an upstream step.
	// Nil means the task can only be completed.
	PushBack *HumanTaskPushBackConfig `json:"pushBack,omitempty"`
}

HumanTaskConfig defines the prompt, input form, artifact references, and push-back for a human task step.

type HumanTaskPushBackConfig added in v2.17.1

type HumanTaskPushBackConfig struct {
	// RewindTo is the name of the upstream step that runs again first.
	RewindTo string `json:"rewindTo"`
	// Form is the normalized feedback form. Empty means push-back accepts no
	// input.
	Form json.RawMessage `json:"form,omitempty"`
}

HumanTaskPushBackConfig defines where a human-task push-back rewinds and the feedback it accepts.

type InferredDependency

type InferredDependency struct {
	Step  string `json:"step"`
	Field string `json:"field,omitempty"`
}

InferredDependency records a producer step that a step-output reference made a dependency, and the field path holding that reference.

type KubernetesConfig

type KubernetesConfig map[string]any

KubernetesConfig contains default Kubernetes executor configuration for the DAG. It stores the raw executor config map so step-level overrides can be merged using executor-specific semantics during DAG build.

type LLMConfig

type LLMConfig struct {
	// Provider is the LLM provider (openai, anthropic, gemini, openrouter, local).
	// Used for single model config (backward compatible).
	Provider string `json:"provider,omitempty"`
	// Model is the model to use (e.g., gpt-4o, claude-sonnet-4-6).
	// Used for single model config (backward compatible).
	Model string `json:"model,omitempty"`
	// Models is an array of models for fallback support.
	// First model is primary, rest are tried in order if primary fails.
	// When set, Provider/Model fields are ignored.
	Models []ModelEntry `json:"models,omitempty"`
	// System is the default system prompt for sessions.
	System string `json:"system,omitempty"`
	// Temperature controls randomness (0.0-2.0).
	Temperature *float64 `json:"temperature,omitempty"`
	// MaxTokens is the maximum number of tokens to generate.
	MaxTokens *int `json:"maxTokens,omitempty"`
	// TopP is the nucleus sampling parameter.
	TopP *float64 `json:"topP,omitempty"`
	// BaseURL is a custom API endpoint.
	BaseURL string `json:"baseURL,omitempty"`
	// APIKeyName is the name of the environment variable containing the API key.
	// If not specified, the default environment variable for the provider is used.
	APIKeyName string `json:"apiKeyName,omitempty"`
	// Stream enables or disables streaming output.
	// Default is true.
	Stream *bool `json:"stream,omitempty"`
	// Thinking enables extended thinking/reasoning mode.
	// Provider-specific: Anthropic uses budget_tokens, OpenAI uses reasoning.effort,
	// Gemini uses thinkingLevel/thinkingBudget, OpenRouter normalizes across providers.
	Thinking *ThinkingConfig `json:"thinking,omitempty"`
	// Tools is a list of DAG names to use as callable tools.
	// Tool names, descriptions, and parameters are auto-discovered from DAG definitions.
	// Example: ["search-tool", "analyzer-tool"]
	Tools []string `json:"tools,omitempty"`
	// MaxToolIterations limits the number of tool calling rounds.
	// Default is 10 if not specified.
	MaxToolIterations *int `json:"maxToolIterations,omitempty"`
	// MaxContextTokens activates agent observation aging once a decision
	// prompt reaches this many tokens. Zero disables proactive aging.
	MaxContextTokens *int `json:"maxContextTokens,omitempty"`
	// ObservationMaxBytes limits the size of each agent observation. Zero
	// disables this limit.
	ObservationMaxBytes *int `json:"observationMaxBytes,omitempty"`
	// ObservationKeepRecent is the number of recent agent observations kept
	// in full after observation aging starts. Zero disables observation aging.
	ObservationKeepRecent *int `json:"observationKeepRecent,omitempty"`
	// WebSearch configures provider-native web search.
	WebSearch *WebSearchConfig `json:"webSearch,omitempty"`
}

LLMConfig contains the configuration for LLM-based executors.

func (*LLMConfig) GetMaxToolIterations

func (c *LLMConfig) GetMaxToolIterations() int

GetMaxToolIterations returns the maximum number of tool calling iterations. Default is 10 if not specified.

func (*LLMConfig) GetModels

func (c *LLMConfig) GetModels() []ModelEntry

GetModels returns the ordered list of models to try. If Models array is set, returns it. Otherwise, creates single-entry list from Provider/Model.

func (*LLMConfig) HasFallback

func (c *LLMConfig) HasFallback() bool

HasFallback returns true if there are multiple models configured.

func (*LLMConfig) HasTools

func (c *LLMConfig) HasTools() bool

HasTools returns true if tools are configured.

func (*LLMConfig) StreamEnabled

func (c *LLMConfig) StreamEnabled() bool

StreamEnabled returns true if streaming is enabled. Default is true if Stream is nil.

type LLMMessage

type LLMMessage struct {
	Role       LLMRole             `json:"role"`
	Content    string              `json:"content"`
	ToolCallID string              `json:"tool_call_id,omitempty"`
	ToolCalls  []ToolCall          `json:"tool_calls,omitempty"`
	Metadata   *LLMMessageMetadata `json:"metadata,omitempty"`
}

LLMMessage represents a persisted message in an LLM session.

func DeduplicateSystemMessages

func DeduplicateSystemMessages(messages []LLMMessage) []LLMMessage

DeduplicateSystemMessages keeps only the first system message.

type LLMMessageMetadata

type LLMMessageMetadata struct {
	Provider         string  `json:"provider,omitempty"`
	Model            string  `json:"model,omitempty"`
	PromptTokens     int     `json:"promptTokens,omitempty"`
	CompletionTokens int     `json:"completionTokens,omitempty"`
	TotalTokens      int     `json:"totalTokens,omitempty"`
	Cost             float64 `json:"cost,omitempty"`
}

LLMMessageMetadata contains metadata about an LLM API call.

type LLMRole

type LLMRole string

LLMRole represents the role of a message sender in a session.

const (
	LLMRoleSystem    LLMRole = "system"
	LLMRoleUser      LLMRole = "user"
	LLMRoleAssistant LLMRole = "assistant"
	LLMRoleTool      LLMRole = "tool"
)

LLM message role constants.

func ParseLLMRole

func ParseLLMRole(s string) (LLMRole, error)

ParseLLMRole validates and returns an LLMRole from a string. Returns error for invalid or empty role values.

type Label

type Label struct {
	Key   string `json:"key"`
	Value string `json:"value,omitempty"`
}

Label represents a key-value label with optional value. For backward compatibility, key-only labels have an empty Value.

func ParseLabel

func ParseLabel(s string) Label

ParseLabel parses a string into a Label. Supports "key=value" and "key" (key-only) formats. Both key and value are normalized to lowercase.

func (Label) IsZero

func (t Label) IsZero() bool

IsZero returns true if the label is empty.

func (Label) String

func (t Label) String() string

String returns the canonical string representation of the label. Format: "key=value" or "key" if value is empty.

type LabelFilter

type LabelFilter struct {
	Type  LabelFilterType
	Key   string
	Value string
}

LabelFilter represents a parsed filter condition.

func ParseLabelFilter

func ParseLabelFilter(s string) LabelFilter

ParseLabelFilter parses a filter string into LabelFilter. Formats:

  • "key" - matches any label with that key (KeyOnly)
  • "key=value" - matches exact key=value (Exact)
  • "!key" - matches if key does NOT exist (Negation)
  • "key*" or "key=value*" - matches using glob patterns (Wildcard)

func (LabelFilter) MatchesLabels

func (f LabelFilter) MatchesLabels(labels Labels) bool

MatchesLabels checks if a label collection matches this filter.

type LabelFilterType

type LabelFilterType int

LabelFilterType represents the type of label filter.

const (
	// LabelFilterTypeKeyOnly matches any label with the specified key (regardless of value).
	LabelFilterTypeKeyOnly LabelFilterType = iota
	// LabelFilterTypeExact matches labels with exact key=value.
	LabelFilterTypeExact
	// LabelFilterTypeNegation matches if the key does NOT exist.
	LabelFilterTypeNegation
	// LabelFilterTypeWildcard matches labels using glob patterns (* and ?).
	LabelFilterTypeWildcard
)

type Labels

type Labels []Label

Labels represents a collection of labels.

func NewLabels

func NewLabels(strs []string) Labels

NewLabels creates a Labels collection from a slice of strings.

func (Labels) Get

func (t Labels) Get(key string) []string

Get returns all values for a given key.

func (Labels) HasKey

func (t Labels) HasKey(key string) bool

HasKey checks if any label has the given key.

func (Labels) Keys

func (t Labels) Keys() []string

Keys returns all unique keys in the collection.

func (Labels) MarshalJSON

func (t Labels) MarshalJSON() ([]byte, error)

MarshalJSON serializes Labels as an array of strings for backward compatibility.

func (Labels) MatchesFilters

func (t Labels) MatchesFilters(filters []LabelFilter) bool

MatchesFilters checks if labels match all filters (AND logic).

func (Labels) Strings

func (t Labels) Strings() []string

Strings returns the labels as a slice of strings for API compatibility.

func (*Labels) UnmarshalJSON

func (t *Labels) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes Labels from an array of strings.

type LogOutputMode

type LogOutputMode string

LogOutputMode represents the mode for log output handling. It determines how stdout and stderr are written to log files.

const (
	// LogOutputSeparate keeps stdout and stderr in separate files (.out and .err).
	// This is the default behavior for backward compatibility.
	LogOutputSeparate LogOutputMode = "separate"

	// LogOutputMerged combines stdout and stderr into a single log file (.log).
	// Both streams are interleaved in the order they are written.
	LogOutputMerged LogOutputMode = "merged"
)

func EffectiveLogOutput

func EffectiveLogOutput(dag *DAG, step *Step) LogOutputMode

EffectiveLogOutput returns the effective log output mode for a step. Priority: step-level > DAG-level > default (LogOutputSeparate).

type MailAccount added in v2.18.0

type MailAccount struct {
	Provider string
	IMAP     *MailServer
	SMTP     *MailServer
	// Username is the login name; the account's address when not configured.
	Username string
	Password string
	OAuth    *oauthconfig.Config
}

MailAccount is a mailbox that mail actions read from and send through.

func (*MailAccount) Clone added in v2.18.0

func (a *MailAccount) Clone() *MailAccount

Clone returns a deep copy of the account.

func (*MailAccount) GmailAPI added in v2.18.2

func (a *MailAccount) GmailAPI() bool

GmailAPI reports whether the account reaches its mailbox through the Gmail API instead of IMAP and SMTP. Such an account has no servers.

type MailAccounts added in v2.18.0

type MailAccounts map[string]*MailAccount

MailAccounts maps lowercase email addresses to the accounts mail actions use.

func (MailAccounts) Clone added in v2.18.0

func (m MailAccounts) Clone() MailAccounts

Clone returns a deep copy of the accounts.

type MailConfig

type MailConfig struct {
	From       string   `json:"from,omitempty"`
	To         []string `json:"to,omitempty"`
	Prefix     string   `json:"prefix,omitempty"`
	AttachLogs bool     `json:"attachLogs,omitempty"`
}

MailConfig contains the mail configuration.

type MailOn

type MailOn struct {
	Failure bool `json:"failure,omitempty"`
	Success bool `json:"success,omitempty"`
	Wait    bool `json:"wait,omitempty"`
}

MailOn contains the conditions to send mail.

type MailServer added in v2.18.0

type MailServer struct {
	Host          string
	Port          string
	Security      string
	SkipTLSVerify bool
}

MailServer is the IMAP or SMTP server of a mail account.

type ModelEntry

type ModelEntry struct {
	// Provider is the LLM provider for this model.
	Provider string `json:"provider"`
	// Name is the model name (e.g., gpt-4o, claude-sonnet-4-6).
	Name string `json:"name"`
	// Temperature overrides the shared temperature for this model.
	Temperature *float64 `json:"temperature,omitempty"`
	// MaxTokens overrides the shared maxTokens for this model.
	MaxTokens *int `json:"maxTokens,omitempty"`
	// TopP overrides the shared topP for this model.
	TopP *float64 `json:"topP,omitempty"`
	// BaseURL is a custom API endpoint for this model.
	BaseURL string `json:"baseURL,omitempty"`
	// APIKeyName overrides the API key environment variable for this model.
	APIKeyName string `json:"apiKeyName,omitempty"`
}

ModelEntry represents a single model in the model array for fallback support. When multiple models are specified, they are tried in order until one succeeds.

type Node

type Node struct {
	Step                Step                 `json:"step,omitzero"`
	PreconditionResults []ConditionResult    `json:"-"`
	Stdout              string               `json:"stdout"` // standard output log file path
	Stderr              string               `json:"stderr"` // standard error log file path
	WorkingDir          string               `json:"workingDir,omitempty"`
	StartedAt           string               `json:"startedAt"`
	FinishedAt          string               `json:"finishedAt"`
	Status              NodeStatus           `json:"status"`
	RetriedAt           string               `json:"retriedAt,omitempty"`
	RetryCount          int                  `json:"retryCount,omitempty"`
	DoneCount           int                  `json:"doneCount,omitempty"`
	Repeated            bool                 `json:"repeated,omitempty"` // indicates if the node has been repeated
	SkippedByRetry      bool                 `json:"skippedByRetry,omitempty"`
	Error               string               `json:"error,omitempty"`
	StatusDetails       []NodeStatusDetail   `json:"statusDetails,omitempty"`
	Build               *BuildExecution      `json:"build,omitempty"`
	SubRuns             []SubDAGRun          `json:"children,omitempty"`
	SubRunsRepeated     []SubDAGRun          `json:"childrenRepeated,omitempty"` // repeated sub DAG runs
	OutputVariables     *collections.SyncMap `json:"outputVariables,omitempty"`
	OutputValue         *string              `json:"outputValue,omitempty"`
	OutputsValue        *string              `json:"outputsValue,omitempty"`
	StepOutputsValue    *string              `json:"stepOutputsValue,omitempty"`
	HumanTaskInput      json.RawMessage      `json:"humanTaskInput,omitempty"`
	// AgentState stores the goal progress of an agent DAG's agent
	// step, so a suspended run resumes with its task list intact.
	AgentState json.RawMessage `json:"agentState,omitempty"`
	// HumanTaskCompletedBy records who completed this human task.
	HumanTaskCompletedBy string `json:"humanTaskCompletedBy,omitempty"`
	// HumanTaskCompletedByID records the subject ID that completed this human task.
	HumanTaskCompletedByID string `json:"humanTaskCompletedById,omitempty"`
	// ApprovedAt records when this wait step was approved
	ApprovedAt string `json:"approvedAt,omitempty"`
	// ApprovalInputs stores key-value parameters provided during approval
	ApprovalInputs map[string]string `json:"approvalInputs,omitempty"`
	// ApprovedBy records who approved this wait step (username)
	ApprovedBy string `json:"approvedBy,omitempty"`
	// ApprovedByID records the subject ID that approved this wait step.
	ApprovedByID string `json:"approvedById,omitempty"`
	// RejectedAt records when this wait step was rejected
	RejectedAt string `json:"rejectedAt,omitempty"`
	// RejectedBy records who rejected this wait step (username)
	RejectedBy string `json:"rejectedBy,omitempty"`
	// RejectedByID records the subject ID that rejected this wait step.
	RejectedByID string `json:"rejectedById,omitempty"`
	// RejectionReason stores the optional reason for rejection
	RejectionReason string `json:"rejectionReason,omitempty"`
	// ApprovalIteration tracks how many times this step has been pushed back.
	ApprovalIteration int `json:"approvalIteration,omitempty"`
	// PushBackInputs stores the inputs from the last push-back.
	// These are injected as environment variables when the step re-executes.
	PushBackInputs map[string]string `json:"pushBackInputs,omitempty"`
	// PushBackHistory stores the chronological push-back inputs for this step.
	PushBackHistory []PushBackEntry `json:"pushBackHistory,omitempty"`
	// PushBackPreviousStdout stores the stdout log path from the execution that
	// was reset by the latest push-back.
	PushBackPreviousStdout string `json:"pushBackPreviousStdout,omitempty"`
	// ChatMessages stores the session messages for chat/LLM steps.
	// This field is populated during execution and synced via status updates
	// from workers.
	ChatMessages []LLMMessage `json:"chatMessages,omitempty"`
	// ToolDefinitions stores the tool definitions that were available to the LLM.
	// This enables debugging visibility into what tools and schemas were sent.
	ToolDefinitions []ToolDefinition `json:"toolDefinitions,omitempty"`
	// AgentSession stores managed coding-agent state for display and durable resume.
	AgentSession *AgentSession `json:"agentSession,omitempty"`
	// contains filtered or unexported fields
}

Node represents a DAG step with its execution state for persistence

func NewNodeFromStep

func NewNodeFromStep(step Step) *Node

NewNodeFromStep creates a new Node with default status values for the given step.

func NewNodesFromSteps

func NewNodesFromSteps(steps []Step) []*Node

NewNodesFromSteps converts a list of DAG steps to persistence Node objects.

func (Node) MarshalJSON

func (n Node) MarshalJSON() ([]byte, error)

MarshalJSON keeps runtime condition results inside the persisted step object.

func (*Node) UnmarshalJSON

func (n *Node) UnmarshalJSON(data []byte) error

UnmarshalJSON restores the step definition and its runtime condition results, and keeps agent state written under its legacy name readable.

type NodeStatus

type NodeStatus int

NodeStatus represents the canonical lifecycle phases for an individual node.

const (
	// Keep numeric values stable because NodeStatus is persisted in run status
	// snapshots and older files/tests depend on the historical encoding.
	NodeNotStarted         NodeStatus = 0
	NodeRunning            NodeStatus = 1
	NodeFailed             NodeStatus = 2
	NodeAborted            NodeStatus = 3
	NodeSucceeded          NodeStatus = 4
	NodeSkipped            NodeStatus = 5
	NodePartiallySucceeded NodeStatus = 6
	NodeWaiting            NodeStatus = 7
	NodeRejected           NodeStatus = 8
	NodeRetrying           NodeStatus = 9
)

func (NodeStatus) IsDone

func (s NodeStatus) IsDone() bool

IsDone checks if the node has completed (success, failure, skipped, aborted, rejected, or partially succeeded).

func (NodeStatus) IsSuccess

func (s NodeStatus) IsSuccess() bool

IsSuccess checks if the node status indicates a successful execution.

func (NodeStatus) IsWaiting

func (s NodeStatus) IsWaiting() bool

IsWaiting checks if the node status requires manual action before it can continue.

func (NodeStatus) String

func (s NodeStatus) String() string

String returns the canonical lowercase token for the node lifecycle phase.

type NodeStatusDetail

type NodeStatusDetail struct {
	Label  string     `json:"label"`
	Status NodeStatus `json:"status"`
}

NodeStatusDetail identifies an independently tracked execution within a node.

type OTelConfig

type OTelConfig struct {
	Enabled  bool              `json:"enabled,omitempty"`
	Endpoint string            `json:"endpoint,omitempty"`
	Headers  map[string]string `json:"headers,omitempty"`
	Insecure bool              `json:"insecure,omitempty"`
	Timeout  time.Duration     `json:"timeout,omitempty"`
	Resource map[string]any    `json:"resource,omitempty"`
}

OTelConfig contains the OpenTelemetry configuration.

type OutputsMetadata

type OutputsMetadata struct {
	DAGName     string `json:"dagName"`
	DAGRunID    string `json:"dagRunId"`
	AttemptID   string `json:"attemptId"`
	Status      string `json:"status"`
	CompletedAt string `json:"completedAt"`
	Params      string `json:"params,omitempty"`
}

OutputsMetadata contains execution context for the outputs.

type OverlapPolicy

type OverlapPolicy string

OverlapPolicy controls behavior when a new run is triggered while a previous run is still active.

const (
	// OverlapPolicySkip skips a new run if the previous is still running.
	OverlapPolicySkip OverlapPolicy = "skip"

	// OverlapPolicyAll queues all runs and executes them sequentially in chronological order.
	OverlapPolicyAll OverlapPolicy = "all"

	// OverlapPolicyLatest discards all but the most recent missed interval.
	OverlapPolicyLatest OverlapPolicy = "latest"
)

func ParseOverlapPolicy

func ParseOverlapPolicy(s string) (OverlapPolicy, error)

ParseOverlapPolicy parses a string into an OverlapPolicy. Empty string defaults to OverlapPolicySkip.

type PID

type PID int

PID represents a process ID for a running dag-run

func (PID) String

func (p PID) String() string

String returns the string representation of the PID, or an empty string if 0

type ParallelConfig

type ParallelConfig struct {
	// Variable is the name of a variable that contains the json array of items to process in parallel.
	Variable string `json:"variable,omitempty"`

	// Items is the array of items to process in parallel.
	// Can be a direct array or a reference to a variable containing an array.
	Items []ParallelItem `json:"items,omitempty"`

	// MaxConcurrent is the maximum number of parallel executions.
	// Default is 10 if not specified.
	MaxConcurrent int `json:"max_concurrent,omitempty"`
}

ParallelConfig contains the configuration for parallel execution of a step. MVP version supports basic parallel execution with max_concurrent control.

type ParallelItem

type ParallelItem struct {
	// Value is used for simple string items or variable references
	// E.g. "item1", "item2", "${ITEM_VAR}"
	Value string `json:"value,omitempty"`

	// Params is used for key-value pairs that will be passed as parameters
	// E.g. {"SOURCE": "s3://customers", "TYPE": "csv"}
	Params map[string]string `json:"params,omitempty"`
}

ParallelItem represents a single item to be processed in parallel. It can be either a simple value or a set of parameters.

type ParamDef

type ParamDef struct {
	Name        string   `json:"name,omitempty"`
	Type        string   `json:"type,omitempty"`
	Default     any      `json:"default,omitempty"`
	Description string   `json:"description,omitempty"`
	Required    bool     `json:"required,omitempty"`
	Enum        []any    `json:"enum,omitempty"`
	Minimum     *float64 `json:"minimum,omitempty"`
	Maximum     *float64 `json:"maximum,omitempty"`
	MinLength   *int     `json:"minLength,omitempty"`
	MaxLength   *int     `json:"maxLength,omitempty"`
	Pattern     *string  `json:"pattern,omitempty"`
}

ParamDef describes a single DAG parameter for API/UI consumers. Name is empty for positional parameters.

type ParamType

type ParamType int

ParamType identifies which field in Params is active

const (
	ParamTypeUnknown ParamType = iota
	ParamTypeString            // Simple map[string]string
	ParamTypeAny               // Rich map[string]any
	ParamTypeRaw               // Lazy json.RawMessage
)

func (ParamType) String

func (t ParamType) String() string

String returns the string representation of ParamType

type Params

type Params struct {
	// Simple params (backward compatible)
	Simple map[string]string `json:"simple,omitempty"`

	// Rich params with type preservation
	Rich map[string]any `json:"rich,omitempty"`

	// Raw params for lazy parsing
	Raw json.RawMessage `json:"raw,omitempty"`
}

Params holds parameter data in one of several formats Only one of Simple, Rich, or Raw should be non-nil

func NewRawParams

func NewRawParams(raw json.RawMessage) Params

NewRawParams creates params from json.RawMessage

func NewRichParams

func NewRichParams(data map[string]any) Params

NewRichParams creates params from map[string]any

func NewSimpleParams

func NewSimpleParams(data map[string]string) Params

NewSimpleParams creates params from map[string]string

func ParseParams

func ParseParams(input any) (Params, error)

ParseParams creates Params from any input type

func (*Params) AsStringMap

func (p *Params) AsStringMap() (map[string]string, error)

AsStringMap returns all parameters as map[string]string Non-string values are converted using fmt.Sprintf

func (*Params) IsEmpty

func (p *Params) IsEmpty() bool

IsEmpty returns true if no params are set

func (*Params) MarshalJSON

func (p *Params) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Params) Type

func (p *Params) Type() ParamType

Type returns which param type is active

func (*Params) UnmarshalJSON

func (p *Params) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type PendingStepRetry

type PendingStepRetry struct {
	StepName string        `json:"stepName"`
	Interval time.Duration `json:"interval"`
}

PendingStepRetry describes a step retry waiting to be scheduled.

func PendingStepRetriesFromStatus

func PendingStepRetriesFromStatus(status *DAGRunStatus) []PendingStepRetry

PendingStepRetriesFromStatus returns the persisted pending step retries when present and falls back to deriving them from node state for older statuses that predate the field.

func (PendingStepRetry) MarshalJSON

func (p PendingStepRetry) MarshalJSON() ([]byte, error)

MarshalJSON emits Interval as a Go duration string.

func (*PendingStepRetry) UnmarshalJSON

func (p *PendingStepRetry) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts current string durations and legacy numeric nanoseconds.

type PromptMessage

type PromptMessage struct {
	// Role is the message role (system, user, assistant, tool).
	Role LLMRole `json:"role,omitempty"`
	// Content is the message content. Supports variable substitution with ${VAR}.
	Content string `json:"content,omitempty"`
}

PromptMessage represents an authored message used to initialize an LLM session.

type PullPolicy

type PullPolicy int

PullPolicy defines image pull policy for a container execution

const (
	PullPolicyAlways PullPolicy = iota
	PullPolicyNever
	PullPolicyMissing
	PullPolicyFallback
)

func ParsePullPolicy

func ParsePullPolicy(raw any) (PullPolicy, error)

ParsePullPolicy parses a pull policy from a raw value.

func (PullPolicy) String

func (p PullPolicy) String() string

type PushBackEntry

type PushBackEntry struct {
	Iteration int               `json:"iteration"`
	By        string            `json:"by,omitempty"`
	ByID      string            `json:"byId,omitempty"`
	At        string            `json:"at,omitempty"`
	Inputs    map[string]string `json:"inputs,omitempty"`
	// Step names the step that requested the push-back.
	Step string `json:"step,omitempty"`
	// HumanTask reports that a human task requested the push-back. Its inputs
	// hold only declared feedback properties and reach every rewound step.
	HumanTask bool `json:"humanTask,omitempty"`
}

PushBackEntry records one push-back event for a step approval cycle.

type RedisConfig

type RedisConfig struct {
	// URL is the Redis connection URL (redis://user:pass@host:port/db).
	URL string `json:"url,omitempty"`
	// Host is the Redis host (alternative to URL).
	Host string `json:"host,omitempty"`
	// Port is the Redis port (default: 6379).
	Port int `json:"port,omitempty"`
	// Password is the authentication password.
	Password string `json:"password,omitempty"`
	// Username is the ACL username (Redis 6+).
	Username string `json:"username,omitempty"`
	// DB is the database number (0-15).
	DB int `json:"db,omitempty"`
	// TLS enables TLS connection.
	TLS bool `json:"tls,omitempty"`
	// TLSSkipVerify skips TLS certificate verification.
	TLSSkipVerify bool `json:"tlsSkipVerify,omitempty"`
	// Mode is the connection mode (standalone, sentinel, cluster).
	Mode string `json:"mode,omitempty"`
	// SentinelMaster is the sentinel master name.
	SentinelMaster string `json:"sentinelMaster,omitempty"`
	// SentinelAddrs is the list of sentinel addresses.
	SentinelAddrs []string `json:"sentinelAddrs,omitempty"`
	// ClusterAddrs is the list of cluster node addresses.
	ClusterAddrs []string `json:"clusterAddrs,omitempty"`
	// MaxRetries is the maximum number of retries.
	MaxRetries int `json:"maxRetries,omitempty"`
}

RedisConfig contains the default Redis configuration for the DAG. Steps with type: redis inherit this configuration.

type RepeatMode

type RepeatMode string

RepeatMode is the type for the repeat mode.

const (
	// RepeatModeWhile repeats the step while the condition is met.
	RepeatModeWhile RepeatMode = "while"
	// RepeatModeUntil repeats the step until the condition is met.
	RepeatModeUntil RepeatMode = "until"
)

type RepeatPolicy

type RepeatPolicy struct {
	// RepeatMode determines if and how the step should be repeated.
	// It can be 'while' or 'until'.
	RepeatMode RepeatMode `json:"repeatMode,omitempty"`
	// Interval is the time to wait between repeats.
	Interval time.Duration `json:"interval,omitempty"`
	// IntervalStr is the string representation of interval_sec for deferred evaluation.
	IntervalStr string `json:"intervalStr,omitempty"`
	// Limit is the maximum number of times to repeat the step.
	Limit int `json:"limit,omitempty"`
	// LimitStr is the string representation of the limit for deferred evaluation.
	LimitStr string `json:"limitStr,omitempty"`
	// Backoff is the exponential backoff multiplier (e.g., 2.0 for doubling).
	Backoff float64 `json:"backoff,omitempty"`
	// MaxInterval is the maximum interval cap for exponential backoff.
	MaxInterval time.Duration `json:"maxInterval,omitempty"`
	// MaxIntervalStr is the string representation of max_interval_sec for deferred evaluation.
	MaxIntervalStr string `json:"maxIntervalStr,omitempty"`
	// Condition is the condition object to be met for the repeat.
	Condition *Condition `json:"condition,omitempty"`
	// ExitCode is the list of exit codes that should trigger a repeat.
	ExitCode []int `json:"exitCode,omitempty"`
}

RepeatPolicy contains the repeat policy for a step.

func (*RepeatPolicy) UnmarshalJSON

func (r *RepeatPolicy) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for RepeatPolicy. It handles the legacy boolean repeat field and the new string repeat modes.

type ResourceLimits

type ResourceLimits struct {
	CPU    string `json:"cpu,omitempty"`
	Memory string `json:"memory,omitempty"`

	CPUMillis   int64 `json:"-"`
	MemoryBytes int64 `json:"-"`
}

ResourceLimits contains CPU and memory limits requested for a DAG run.

func NewResourceLimits

func NewResourceLimits(cpu, memory string) (*ResourceLimits, error)

NewResourceLimits validates authored resource limits and returns a normalized copy.

func (*ResourceLimits) UnmarshalJSON

func (r *ResourceLimits) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes authored limits and restores their normalized values.

type Resources

type Resources struct {
	Limits *ResourceLimits `json:"limits,omitempty"`
}

Resources contains resource requests for a DAG run.

func (*Resources) Clone

func (r *Resources) Clone() *Resources

Clone returns a deep copy of the resource configuration.

func (*Resources) HasLimits

func (r *Resources) HasLimits() bool

HasLimits reports whether at least one resource limit is configured.

type RetryPolicy

type RetryPolicy struct {
	// Limit is the number of retries allowed.
	Limit int `json:"limit,omitempty"`
	// Interval is the time to wait between retries.
	Interval time.Duration `json:"interval,omitempty"`
	// LimitStr is the string representation of the limit.
	LimitStr string `json:"limitStr,omitempty"`
	// IntervalSecStr is the string representation of the interval.
	IntervalSecStr string `json:"intervalSecStr,omitempty"`
	// ExitCodes is the list of exit codes that should trigger a retry.
	ExitCodes []int `json:"exitCode,omitempty"`
	// Backoff is the exponential backoff multiplier (e.g., 2.0 for doubling).
	Backoff float64 `json:"backoff,omitempty"`
	// MaxInterval is the maximum interval cap for exponential backoff.
	MaxInterval time.Duration `json:"maxInterval,omitempty"`
}

RetryPolicy contains the retry policy for a step.

type RouteEntry

type RouteEntry struct {
	Pattern string   `json:"pattern"` // Match pattern (exact or "re:regex")
	Targets []string `json:"targets"` // Step names to route to when pattern matches
}

RouteEntry represents a single routing rule.

type RouterConfig

type RouterConfig struct {
	Value  string       `json:"value"`  // Value expression to evaluate (e.g., "${STATUS}")
	Routes []RouteEntry `json:"routes"` // Ordered list of pattern → targets
}

RouterConfig contains routing configuration for router-type steps.

type RunConfig

type RunConfig struct {
	// DisableParamEdit when set to true, prevents users from editing parameters when starting a DAG.
	DisableParamEdit bool `json:"disableParamEdit,omitempty"`
	// DisableRunIdEdit when set to true, prevents users from specifying custom run IDs.
	DisableRunIdEdit bool `json:"disableRunIdEdit,omitempty"`
}

RunConfig contains configuration for controlling user interactions during DAG runs.

type RunStatus

type RunStatus struct {
	Name               string
	DAGRunID           string
	Params             string
	Outputs            map[string]string
	OutputValues       map[string]any
	Status             Status
	PreconditionNotMet bool `json:"-"`
	PendingStepRetries []PendingStepRetry
}

RunStatus is the result returned to parent DAG executors.

func (*RunStatus) MarshalJSON

func (r *RunStatus) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

type RuntimeProfileEntry

type RuntimeProfileEntry struct {
	Key  string `json:"key"`
	Kind string `json:"kind"`
}

RuntimeProfileEntry is non-secret metadata about a profile key injected into a run.

type S3Config

type S3Config struct {
	// Region is the AWS region (e.g., us-east-1).
	Region string `json:"region,omitempty"`
	// Endpoint is a custom S3-compatible endpoint URL.
	// Use this for S3-compatible services like MinIO, LocalStack, etc.
	Endpoint string `json:"endpoint,omitempty"`
	// AccessKeyID is the AWS access key ID.
	AccessKeyID string `json:"accessKeyId,omitempty"`
	// SecretAccessKey is the AWS secret access key.
	SecretAccessKey string `json:"secretAccessKey,omitempty"`
	// SessionToken is the AWS session token (for temporary credentials).
	SessionToken string `json:"sessionToken,omitempty"`
	// Profile is the AWS credentials profile name.
	Profile string `json:"profile,omitempty"`
	// ForcePathStyle enables path-style addressing (required for S3-compatible services).
	ForcePathStyle bool `json:"forcePathStyle,omitempty"`
	// DisableSSL disables SSL for the connection (for local testing only).
	DisableSSL bool `json:"disableSSL,omitempty"`
	// Bucket is the default S3 bucket name.
	// Can be overridden at the step level.
	Bucket string `json:"bucket,omitempty"`
}

S3Config contains the default S3 configuration for the DAG. This allows steps to inherit S3 settings without specifying them individually.

type SMTPConfig

type SMTPConfig struct {
	Host     string              `json:"host,omitempty"`
	Port     string              `json:"port,omitempty"`
	Username string              `json:"username,omitempty"`
	Password string              `json:"password,omitempty"`
	OAuth    *oauthconfig.Config `json:"oauth,omitempty"`
}

SMTPConfig contains the SMTP configuration.

type SSHConfig

type SSHConfig struct {
	// User is the SSH user.
	User string `json:"user,omitempty"`
	// Host is the SSH host.
	Host string `json:"host,omitempty"`
	// Port is the SSH port. Default is "22".
	Port string `json:"port,omitempty"`
	// Key is the path to the SSH private key.
	Key string `json:"key,omitempty"`
	// Password is the SSH password.
	Password string `json:"password,omitempty"`
	// StrictHostKey enables strict host key checking. Defaults to true.
	StrictHostKey bool `json:"strictHostKey,omitempty"`
	// KnownHostFile is the path to the known_hosts file. Defaults to ~/.ssh/known_hosts.
	KnownHostFile string `json:"knownHostFile,omitempty"`
	// Shell is the shell to use for remote command execution.
	// If not specified, commands are executed directly without shell wrapping.
	Shell string `json:"shell,omitempty"`
	// ShellArgs contains additional arguments that should be passed to the shell executable.
	ShellArgs []string `json:"shellArgs,omitempty"`
	// Timeout is the connection timeout duration (e.g., "30s", "1m"). Defaults to 30s.
	Timeout string `json:"timeout,omitempty"`
	// Bastion is the jump host / bastion server configuration for connecting to the target host.
	Bastion *BastionConfig `json:"bastion,omitempty"`
}

SSHConfig contains the SSH configuration for the DAG.

type Schedule

type Schedule struct {
	// Kind identifies the schedule type.
	Kind ScheduleKind `json:"kind,omitempty"`
	// Expression is the cron expression.
	Expression string `json:"expression,omitempty"`
	// At is the canonical RFC 3339 timestamp for one-off schedules.
	At string `json:"at,omitempty"`
	// Profile is the runtime profile name that activates this schedule.
	Profile string `json:"profile,omitempty"`
	// Parsed is the parsed cron schedule.
	Parsed cron.Schedule `json:"-"`
	// AtTime is the parsed one-off schedule time.
	AtTime time.Time `json:"-"`
	// Warnings contains non-fatal schedule warnings.
	Warnings []string `json:"warnings,omitempty"`
}

Schedule contains the cron expression and the parsed cron schedule.

func NewCronSchedule

func NewCronSchedule(expr string) (Schedule, error)

NewCronSchedule parses a cron schedule into its canonical representation.

func NewOneOffSchedule

func NewOneOffSchedule(at string) (Schedule, error)

NewOneOffSchedule parses a one-off timestamp into its canonical representation.

func ParseScheduleValue

func ParseScheduleValue(v any, opts ScheduleParseOptions) (Schedule, error)

ParseScheduleValue parses a YAML/JSON schedule entry into the canonical model.

func (Schedule) DisplayValue

func (s Schedule) DisplayValue() string

DisplayValue returns the user-facing schedule value.

func (Schedule) Fingerprint

func (s Schedule) Fingerprint() string

Fingerprint returns the canonical schedule fingerprint used for durable state.

func (Schedule) GetKind

func (s Schedule) GetKind() ScheduleKind

GetKind returns the normalized schedule kind.

func (Schedule) IsCron

func (s Schedule) IsCron() bool

IsCron reports whether the schedule is cron-based.

func (Schedule) IsOneOff

func (s Schedule) IsOneOff() bool

IsOneOff reports whether the schedule is a one-off timestamp.

func (Schedule) MarshalJSON

func (s Schedule) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Schedule) Next

func (s Schedule) Next(now time.Time) time.Time

Next returns the next metadata-derived run time for this schedule.

func (Schedule) OneOffTime

func (s Schedule) OneOffTime() (time.Time, bool)

OneOffTime returns the parsed one-off schedule time, if any.

func (*Schedule) UnmarshalJSON

func (s *Schedule) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. It also parses the cron expression to populate the Parsed field.

type ScheduleKind

type ScheduleKind string

ScheduleKind identifies the supported schedule types.

const (
	ScheduleKindCron ScheduleKind = "cron"
	ScheduleKindAt   ScheduleKind = "at"
)

type ScheduleParseOptions

type ScheduleParseOptions struct {
	AllowAt bool
}

ScheduleParseOptions controls which schedule kinds are accepted.

type Status

type Status int

Status represents the canonical lifecycle phases for a DAG execution.

const (
	NotStarted Status = iota
	Running
	Failed
	Aborted
	Succeeded
	Queued
	PartiallySucceeded
	Waiting
	Rejected
)

func (Status) IsActive

func (s Status) IsActive() bool

IsActive checks if the status is active (not yet completed). This includes running, queued, and waiting executions.

func (Status) IsSuccess

func (s Status) IsSuccess() bool

IsSuccess checks if the status indicates a successful execution.

func (Status) IsWaiting

func (s Status) IsWaiting() bool

IsWaiting checks if the status requires manual action before it can continue.

func (Status) String

func (s Status) String() string

String returns the canonical lowercase token used across APIs, logs, and environment variables.

type StatusBuilder

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

StatusBuilder creates DAG-run statuses for a DAG definition.

func NewStatusBuilder

func NewStatusBuilder(dag *DAG) *StatusBuilder

NewStatusBuilder returns a status builder for dag.

func (*StatusBuilder) Create

func (builder *StatusBuilder) Create(
	dagRunID string,
	status Status,
	pid int,
	startedAt time.Time,
	opts ...StatusOption,
) DAGRunStatus

Create builds a DAG-run status.

type StatusOption

type StatusOption func(*DAGRunStatus)

StatusOption configures a DAG-run status during construction.

func WithAgentSessions added in v2.14.0

func WithAgentSessions(resources []AgentSessionResource) StatusOption

WithAgentSessions carries Dagu-owned provider sessions across DAG-run attempts.

func WithArchiveDir

func WithArchiveDir(archiveDir string) StatusOption

WithArchiveDir sets the artifact archive directory.

func WithAttemptID

func WithAttemptID(attemptID string) StatusOption

WithAttemptID sets the attempt identifier.

func WithAutoRetryCount

func WithAutoRetryCount(autoRetryCount int) StatusOption

WithAutoRetryCount sets the current automatic retry count.

func WithConditions

func WithConditions(conditions []DAGRunCondition) StatusOption

WithConditions sets the current DAG-run conditions.

func WithCreatedAt

func WithCreatedAt(createdAt int64) StatusOption

WithCreatedAt sets the creation time, defaulting to the current time when zero.

func WithDAGDefinitionID added in v2.14.0

func WithDAGDefinitionID(id string) StatusOption

WithDAGDefinitionID records the stable identity of the persisted DAG definition.

func WithError

func WithError(err string) StatusOption

WithError sets the top-level error message.

func WithFinishedAt

func WithFinishedAt(finishedAt time.Time) StatusOption

WithFinishedAt sets the completion time.

func WithHierarchyRefs

func WithHierarchyRefs(root, parent DAGRunRef) StatusOption

WithHierarchyRefs sets the root and parent DAG-run references.

func WithLogFilePath

func WithLogFilePath(logFilePath string) StatusOption

WithLogFilePath sets the DAG-run log path.

func WithNoReuse

func WithNoReuse(disabled bool) StatusOption

WithNoReuse records whether manifest reuse is disabled.

func WithPIDStartedAt

func WithPIDStartedAt(startedAt int64) StatusOption

WithPIDStartedAt sets the operating-system process start time.

func WithParallelItem added in v2.14.0

func WithParallelItem(item string) StatusOption

WithParallelItem sets the value bound to ITEM for a parallel child run.

func WithPendingStepRetries

func WithPendingStepRetries(retries []PendingStepRetry) StatusOption

WithPendingStepRetries sets parent-managed step retries awaiting scheduling.

func WithPreconditionResults

func WithPreconditionResults(results []ConditionResult) StatusOption

WithPreconditionResults sets evaluated DAG-level preconditions.

func WithPreconditions

func WithPreconditions(conditions []*Condition) StatusOption

WithPreconditions initializes DAG-level precondition results.

func WithQueuedAt

func WithQueuedAt(formattedTime string) StatusOption

WithQueuedAt sets the time at which the run was queued.

func WithRuntimeProfile

func WithRuntimeProfile(name, resolvedAt string, entries []RuntimeProfileEntry) StatusOption

WithRuntimeProfile sets the selected runtime profile metadata.

func WithScheduleTime

func WithScheduleTime(formattedTime string) StatusOption

WithScheduleTime sets the scheduled execution time.

func WithTriggerActor

func WithTriggerActor(actor string) StatusOption

WithTriggerActor sets the attributable trigger actor.

func WithTriggerType

func WithTriggerType(triggerType TriggerType) StatusOption

WithTriggerType sets the run trigger type.

func WithWorkerID

func WithWorkerID(workerID string) StatusOption

WithWorkerID sets the worker identifier.

func WithWorkingDir

func WithWorkingDir(workingDir string) StatusOption

WithWorkingDir sets the effective DAG-run working directory.

type Step

type Step struct {
	// ID is the optional unique identifier for the step.
	ID string `json:"id,omitempty"`
	// Name is the name of the step.
	Name string `json:"name"`
	// Description is the description of the step. This is optional.
	Description string `json:"description,omitempty"`
	// Shell is the shell program to execute the command. This is optional.
	Shell string `json:"shell,omitempty"`
	// ShellPackages is the list of packages to install. This is used only when the shell is `nix-shell`.
	ShellPackages []string `json:"shellPackages,omitempty"`
	// ShellArgs is the list of arguments for the shell program.
	ShellArgs []string `json:"shellArgs,omitempty"`
	// Dir is the working directory for the step.
	Dir string `json:"dir,omitempty"`
	// ExecutorConfig contains the configuration for the executor.
	ExecutorConfig ExecutorConfig `json:"executorConfig,omitzero"`
	// CmdWithArgs is the command with arguments for display purposes.
	// Deprecated: Use Commands[0].CmdWithArgs instead. Kept for JSON backward compatibility.
	CmdWithArgs string `json:"cmdWithArgs,omitempty"`
	// CmdArgsSys is the command with arguments for the system.
	// Deprecated: Kept for JSON backward compatibility.
	CmdArgsSys string `json:"cmdArgsSys,omitempty"`
	// Command specifies only the command without arguments.
	// Deprecated: Use Commands field instead. Kept for JSON backward compatibility.
	Command string `json:"command,omitempty"`
	// ShellCmdArgs is the shell command with arguments.
	ShellCmdArgs string `json:"shellCmdArgs,omitempty"`
	// Script is the script to be executed.
	Script string `json:"script,omitempty"`
	// Args contains the arguments for the command.
	// Deprecated: Use Commands field instead. Kept for JSON backward compatibility.
	Args []string `json:"args,omitempty"`
	// Commands is the source of truth for commands to execute.
	// Each entry represents a command to be executed sequentially.
	// For single commands, this will contain exactly one entry.
	Commands []CommandEntry `json:"commands,omitempty"`
	// Stdin is the file whose contents are piped to the standard input.
	Stdin string `json:"stdin,omitempty"`
	// Stdout is the file to store the standard output.
	Stdout string `json:"stdout,omitempty"`
	// StdoutArtifact is the artifact-relative file path to store standard output.
	StdoutArtifact string `json:"stdoutArtifact,omitempty"`
	// StdoutOutputs maps standard output into the DAG/action outputs object.
	StdoutOutputs *StepOutputsConfig `json:"stdoutOutputs,omitempty"`
	// Stderr is the file to store the standard error.
	Stderr string `json:"stderr,omitempty"`
	// StderrArtifact is the artifact-relative file path to store standard error.
	StderrArtifact string `json:"stderrArtifact,omitempty"`
	// LogOutput specifies how stdout and stderr are handled in log files for this step.
	// Overrides the DAG-level LogOutput setting. Empty string means inherit from DAG.
	LogOutput LogOutputMode `json:"logOutput,omitempty"`
	// Output is the variable name to store captured stdout.
	Output string `json:"output,omitempty"`
	// StructuredOutput publishes post-processed step-scoped outputs for ${step.output.*} access.
	StructuredOutput map[string]StepOutputEntry `json:"structuredOutput,omitempty"`
	// OutputSchema validates stdout JSON before publishing step-scoped output.
	OutputSchema map[string]any `json:"outputSchema,omitzero"`
	// Outputs declares named step outputs.
	Outputs []StepOutputDeclaration `json:"outputs,omitempty"`
	// Inputs declares named regular-file inputs for build execution.
	Inputs []StepInputDeclaration `json:"inputs,omitempty"`
	// Dependencies declares DAG-local files required by the step.
	Dependencies []string `json:"dependencies,omitempty"`
	// Depends contains the list of step names to depend on.
	Depends []string `json:"depends,omitempty"`
	// InferredDepends lists producers derived from step-output references.
	// Entries order execution like Depends but are reported separately.
	InferredDepends []InferredDependency `json:"inferredDepends,omitempty"`
	// ExplicitlyNoDeps indicates the depends field was explicitly set to empty
	ExplicitlyNoDeps bool `json:"-"`
	// ContinueOn contains the conditions to continue on failure or skipped.
	ContinueOn ContinueOn `json:"continueOn,omitzero"`
	// RetryPolicy contains the retry policy for the step.
	RetryPolicy RetryPolicy `json:"retryPolicy,omitzero"`
	// RepeatPolicy contains the repeat policy for the step.
	RepeatPolicy RepeatPolicy `json:"repeatPolicy,omitzero"`
	// MailOnError is the flag to send mail on error.
	MailOnError bool `json:"mailOnError,omitempty"`
	// Preconditions contains the conditions to be met before running the step.
	Preconditions []*Condition `json:"preconditions,omitempty"`
	// SignalOnStop is the signal to send on stop.
	SignalOnStop string `json:"signalOnStop,omitempty"`
	// SubDAG contains the information about a sub DAG to be executed.
	SubDAG *SubDAG `json:"childDag,omitempty"`
	// WorkerSelector specifies required worker labels for execution.
	WorkerSelector map[string]string `json:"workerSelector,omitempty"`
	// Parallel contains the configuration for parallel execution.
	Parallel *ParallelConfig `json:"parallel,omitempty"`
	// Foreach contains the configuration for inline item-body iteration.
	Foreach *ForeachConfig `json:"foreach,omitempty"`
	// Env contains environment variables for the step.
	Env []string `json:"env,omitempty"`
	// Params contains parameters/inputs for the step.
	Params Params `json:"params,omitzero"`
	// Timeout specifies the maximum execution time for the step.
	// If set, this timeout takes precedence over the DAG-level timeout for this step.
	Timeout time.Duration `json:"timeout,omitempty"`
	// Container specifies the container configuration for this step.
	// If set, the step runs in its own container instead of the DAG-level container.
	// This uses the same configuration format as the DAG-level container field.
	Container *Container `json:"container,omitempty"`
	// LLM contains the configuration for LLM-based executors.
	// Used with explicit type: chat.
	LLM *LLMConfig `json:"llm,omitempty"`
	// Messages contains the session messages for chat executor.
	// Only used when type is "chat".
	Messages []PromptMessage `json:"messages,omitempty"`
	// Router contains the routing configuration for router-type steps.
	// Only used when type is "router".
	Router *RouterConfig `json:"router,omitempty"`
	// Approval configures a human approval gate after step execution.
	// When set, the step pauses in Waiting state after execution completes.
	Approval *ApprovalConfig `json:"approval,omitempty"`
	// HumanTask configures a processless step completed by a local operator.
	HumanTask *HumanTaskConfig `json:"humanTask,omitempty"`
}

Step contains the runtime information for a step in a DAG. A step is created from parsing a DAG file written in YAML. It marshals/unmarshals to/from JSON when it is saved in the execution history.

func NewAgentStep added in v2.14.0

func NewAgentStep(dag *DAG) Step

NewAgentStep builds the step that carries the agent's LLM config and task list. It is appended to an agent DAG at build time and is the node the runner drives the decision loop from.

func (*Step) AllDepends

func (s *Step) AllDepends() []string

AllDepends returns the explicit dependencies followed by the inferred ones, without duplicates.

func (Step) HasDeclaredOutputs

func (s Step) HasDeclaredOutputs() bool

HasDeclaredOutputs reports whether the step declares named outputs.

func (*Step) HasMultipleCommands

func (s *Step) HasMultipleCommands() bool

HasMultipleCommands returns true if the step has multiple commands to execute.

func (Step) HasOutputSchema

func (s Step) HasOutputSchema() bool

HasOutputSchema reports whether the step validates stdout JSON with an output schema.

func (Step) HasStdoutOutputs

func (s Step) HasStdoutOutputs() bool

HasStdoutOutputs reports whether stdout should publish DAG/action outputs.

func (Step) HasStructuredOutput

func (s Step) HasStructuredOutput() bool

HasStructuredOutput reports whether the step publishes object-form output.

func (Step) PathOutput

func (s Step) PathOutput() (StepOutputDeclaration, bool)

PathOutput returns the path-backed output and whether exactly one exists.

func (*Step) String

func (s *Step) String() string

String returns a formatted string representation of the step

func (*Step) UnmarshalJSON

func (s *Step) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for backward compatibility. It handles old JSON format where command/args fields were used instead of commands.

func (Step) UsesStructuredOutputSource

func (s Step) UsesStructuredOutputSource(source string) bool

UsesStructuredOutputSource reports whether any structured output entry reads from source.

func (Step) ValueOutputs

func (s Step) ValueOutputs() []StepOutputDeclaration

ValueOutputs returns declarations published through DAGU_OUTPUT_FILE.

type StepInputDeclaration

type StepInputDeclaration struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

StepInputDeclaration defines one named regular-file input.

type StepOutputDeclaration

type StepOutputDeclaration struct {
	Name string `json:"name"`
	Type string `json:"type,omitempty"`
	Path string `json:"path,omitempty"`
	// Source names the channel that publishes the value. An empty source means
	// the step writes the value to DAGU_OUTPUT_FILE.
	Source string `json:"source,omitempty"`
}

StepOutputDeclaration defines one named value or path-backed output.

type StepOutputEntry

type StepOutputEntry struct {
	// HasValue distinguishes literal/null values from source-based outputs.
	HasValue bool `json:"hasValue,omitempty"`
	// Value is the literal value to publish when HasValue is true.
	Value any `json:"value"`
	// From selects a runtime source to read from: stdout, stderr, or file.
	From string `json:"from,omitempty"`
	// Path is the file path used when From is file.
	Path string `json:"path,omitempty"`
	// Decode controls how the source content is decoded before selection.
	Decode string `json:"decode,omitempty"`
	// Select is an optional jq/gojq path applied after decode.
	Select string `json:"select,omitempty"`
}

StepOutputEntry defines one structured object-form output entry.

type StepOutputsConfig

type StepOutputsConfig struct {
	// Field writes the decoded stdout value to a single outputs field.
	Field string `json:"field,omitempty"`
	// Decode controls how stdout is decoded before writing outputs.
	Decode string `json:"decode,omitempty"`
	// Select is an optional jq/gojq path applied after decode.
	Select string `json:"select,omitempty"`
	// Fields maps individual outputs fields from stdout or literal values.
	Fields map[string]StepOutputEntry `json:"fields,omitempty"`
}

StepOutputsConfig defines how stdout is mapped into the DAG/action outputs object.

type SubDAG

type SubDAG struct {
	Name   string `json:"name,omitempty"`
	Params string `json:"params,omitempty"`
	// PassEnv selects parent environment values to hand to the child run.
	// Nil preserves the default of passing nothing beyond params.
	PassEnv *SubDAGPassEnv `json:"passEnv,omitempty"`
}

SubDAG contains information about a sub DAG to be executed.

type SubDAGPassEnv added in v2.17.0

type SubDAGPassEnv struct {
	// All passes the parent run's own environment values.
	All bool `json:"all,omitempty"`
	// Names lists the parent environment variables to pass.
	Names []string `json:"names,omitempty"`
}

SubDAGPassEnv describes which parent environment values a sub DAG run receives beyond its own definition.

type SubDAGRun

type SubDAGRun struct {
	DAGRunID     string `json:"dagRunId,omitempty"`
	Params       string `json:"params,omitempty"`
	ParallelItem string `json:"parallelItem,omitempty"`
	// DAGName is the name of the executed sub-DAG.
	// For chat tool calls, this is the tool DAG name.
	// This field enables UI drill-down when step.call is not set.
	DAGName string `json:"dagName,omitempty"`
}

SubDAGRun represents a sub DAG run associated with a node

type ThinkingConfig

type ThinkingConfig struct {
	// Enabled activates thinking mode for supported models.
	Enabled bool `json:"enabled,omitempty"`
	// Effort controls reasoning depth: none, minimal, low, medium, high,
	// xhigh, max. Each provider maps a level it lacks to its nearest one.
	Effort ThinkingEffort `json:"effort,omitempty"`
	// BudgetTokens sets explicit token budget (provider-specific).
	// For Anthropic: minimum 1024, max 128K.
	// For Gemini 2.5: range 128-32768.
	BudgetTokens *int `json:"budgetTokens,omitempty"`
	// IncludeInOutput includes thinking blocks in stdout.
	// Default is false for consistency across providers.
	IncludeInOutput bool `json:"includeInOutput,omitempty"`
}

ThinkingConfig contains configuration for extended thinking/reasoning.

type ThinkingEffort

type ThinkingEffort string

ThinkingEffort represents the reasoning depth level for thinking mode.

const (
	ThinkingEffortNone    ThinkingEffort = "none"
	ThinkingEffortMinimal ThinkingEffort = "minimal"
	ThinkingEffortLow     ThinkingEffort = "low"
	ThinkingEffortMedium  ThinkingEffort = "medium"
	ThinkingEffortHigh    ThinkingEffort = "high"
	ThinkingEffortXHigh   ThinkingEffort = "xhigh"
	ThinkingEffortMax     ThinkingEffort = "max"
)

ThinkingEffort constants for reasoning/thinking depth, from least to most.

func ParseThinkingEffort

func ParseThinkingEffort(s string) (ThinkingEffort, error)

ParseThinkingEffort validates and returns a ThinkingEffort from a string. Returns empty string for empty input (no effort specified). Returns error for invalid effort values.

type ToolCall

type ToolCall struct {
	ID       string           `json:"id"`
	Type     string           `json:"type"`
	Function ToolCallFunction `json:"function"`
}

ToolCall represents an LLM's request to call a tool.

type ToolCallFunction

type ToolCallFunction struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

ToolCallFunction contains the details of a function call.

type ToolConfig

type ToolConfig struct {
	Provider string        `json:"provider,omitempty"`
	Registry *ToolRegistry `json:"registry,omitempty"`
	Packages []ToolPackage `json:"packages,omitempty"`
}

ToolConfig declares external CLI tools required by a DAG run.

type ToolDefinition

type ToolDefinition struct {
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Parameters  map[string]any `json:"parameters,omitempty"`
}

ToolDefinition represents a tool that was available to the LLM.

type ToolPackage

type ToolPackage struct {
	Name     string   `json:"name,omitempty"`
	Package  string   `json:"package"`
	Version  string   `json:"version"`
	Commands []string `json:"commands,omitempty"`
	Registry string   `json:"registry,omitempty"`
	// Digest pins the sha256 of the downloaded artifact for the platform the
	// DAG runs on, in "sha256:<64 hex>" form. The install fails when the
	// artifact hash recorded for this package does not match.
	Digest string `json:"digest,omitempty"`
}

ToolPackage declares one aqua package and optional command names Dagu should expose.

type ToolRegistry

type ToolRegistry struct {
	Name      string `json:"name,omitempty"`
	Type      string `json:"type,omitempty"`
	RepoOwner string `json:"repoOwner,omitempty"`
	RepoName  string `json:"repoName,omitempty"`
	Ref       string `json:"ref,omitempty"`
	Path      string `json:"path,omitempty"`
}

ToolRegistry identifies the aqua registry used to resolve tool packages.

type ToolResult

type ToolResult struct {
	// ToolCallID is the ID of the tool call this result corresponds to.
	ToolCallID string `json:"tool_call_id"`
	// Name is the name of the tool that was executed.
	Name string `json:"name"`
	// Content is the result content from the tool execution.
	Content string `json:"content"`
	// Error contains any error message if the tool execution failed.
	Error string `json:"error,omitempty"`
}

ToolResult represents the result of a tool execution.

type TriggerType

type TriggerType int

TriggerType represents how a DAG run was initiated.

const (
	TriggerTypeUnknown TriggerType = iota
	TriggerTypeScheduler
	TriggerTypeManual
	TriggerTypeWebhook
	TriggerTypeSubDAG
	TriggerTypeRetry
	TriggerTypeCatchUp
)

func ParseTriggerType

func ParseTriggerType(s string) TriggerType

ParseTriggerType parses a string into a TriggerType.

func (TriggerType) String

func (t TriggerType) String() string

String returns the canonical lowercase token for the trigger type.

type ValidationError

type ValidationError struct {
	Field string
	Value any
	Err   error
}

ValidationError represents an error in a specific field of the configuration

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

type WebSearchConfig

type WebSearchConfig struct {
	// Enabled activates provider-native web search.
	Enabled bool `json:"enabled,omitempty"`
	// MaxUses limits search invocations per request.
	MaxUses *int `json:"maxUses,omitempty"`
	// AllowedDomains restricts results to these domains (Anthropic only).
	AllowedDomains []string `json:"allowedDomains,omitempty"`
	// BlockedDomains excludes results from these domains (Anthropic only).
	BlockedDomains []string `json:"blockedDomains,omitempty"`
	// UserLocation localizes search results.
	UserLocation *WebSearchUserLocation `json:"userLocation,omitempty"`
}

WebSearchConfig contains configuration for provider-native web search.

type WebSearchUserLocation

type WebSearchUserLocation struct {
	City     string `json:"city,omitempty"`
	Region   string `json:"region,omitempty"`
	Country  string `json:"country,omitempty"`
	Timezone string `json:"timezone,omitempty"`
}

WebSearchUserLocation provides approximate location for search localization.

type WebhookConfig

type WebhookConfig struct {
	// ForwardHeaders is the allowlist of request headers to expose to
	// webhook-triggered DAG runs via the WEBHOOK_HEADERS runtime variable.
	ForwardHeaders []string `json:"forwardHeaders,omitempty"`
}

WebhookConfig contains DAG-level webhook trigger behavior.

Jump to

Keyboard shortcuts

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