agent

package
v2.16.4 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: GPL-3.0 Imports: 61 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent is responsible for running the DAG and handling communication via the unix socket. The agent performs the following tasks: 1. Start the DAG. 2. Propagate a signal to the running processes. 3. Handle the HTTP request via the unix socket. 4. Write the log and status to the data store.

func New

func New(
	dagRunID string,
	dag *ir.DAG,
	logDir string,
	logFile string,
	drm runtime.Manager,
	dagRepository *persis.DAGRepository,
	opts Options,
) *Agent

New creates a new Agent.

func (*Agent) HandleHTTP

func (a *Agent) HandleHTTP(ctx context.Context) sock.HTTPHandlerFunc

HandleHTTP handles HTTP requests via unix socket.

func (*Agent) PrintSummary

func (a *Agent) PrintSummary(ctx context.Context)

func (*Agent) Run

func (a *Agent) Run(ctx context.Context) (runErr error)

Run setups the runner and runs the DAG.

func (*Agent) Signal

func (a *Agent) Signal(ctx context.Context, sig os.Signal)

Signal requests that running child processes stop.

func (*Agent) Status

func (a *Agent) Status(ctx context.Context) ir.DAGRunStatus

Status collects the current running status of the DAG and returns it.

type AgentDAGProgressDisplay added in v2.14.0

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

AgentDAGProgressDisplay renders an agent run as its decision timeline: one line per decision as it settles, a live line for what the agent is doing now, and a final line with the outcome.

Percent progress does not apply to an agent run: the number of turns is unknown in advance, an action may repeat, and a step the agent never picks was never pending work.

func NewAgentDAGProgressDisplay added in v2.14.0

func NewAgentDAGProgressDisplay(dag *ir.DAG) *AgentDAGProgressDisplay

NewAgentDAGProgressDisplay creates a progress display for an agent DAG.

func (*AgentDAGProgressDisplay) SetDAGRunInfo added in v2.14.0

func (p *AgentDAGProgressDisplay) SetDAGRunInfo(dagRunID, params string)

SetDAGRunInfo sets the DAG run ID and parameters.

func (*AgentDAGProgressDisplay) Start added in v2.14.0

func (p *AgentDAGProgressDisplay) Start()

Start begins the progress display.

func (*AgentDAGProgressDisplay) Stop added in v2.14.0

func (p *AgentDAGProgressDisplay) Stop()

Stop stops the progress display. Safe to call multiple times.

func (*AgentDAGProgressDisplay) UpdateNode added in v2.14.0

func (p *AgentDAGProgressDisplay) UpdateNode(node *ir.Node)

UpdateNode consumes node updates. The agent node carries the decision timeline; every other node marks which action is in flight.

func (*AgentDAGProgressDisplay) UpdateStatus added in v2.14.0

func (p *AgentDAGProgressDisplay) UpdateStatus(status *ir.DAGRunStatus)

UpdateStatus updates the overall DAG status.

type ArtifactFinalizer

type ArtifactFinalizer = runtime.ArtifactFinalizer

ArtifactFinalizer uploads or persists artifacts before the final terminal status is written.

type Options

type Options struct {
	// Dry is a dry-run mode. It does not execute the actual command.
	// Dry runs do not create persisted history.
	Dry bool
	// NoReuse bypasses manifest hits while retaining staged commits.
	NoReuse bool
	// RetryTarget is the persisted status to retry.
	// If it's specified the agent will execute the DAG with the same
	// configuration as the specified history.
	RetryTarget *ir.DAGRunStatus
	// ParentDAGRun is the dag-run reference of the parent dag-run.
	// It is required for sub dag-runs to identify the parent dag-run.
	ParentDAGRun ir.DAGRunRef
	// ProgressDisplay indicates if the progress display should be shown.
	// This is typically enabled for CLI execution in a TTY environment.
	ProgressDisplay bool
	// ExtraEnvs are additional execution-scoped env vars injected into the DAG run context.
	ExtraEnvs []string
	// WorkDir sets the existing per-run work directory.
	WorkDir string
	// WorkspaceSeed carries the workspace into inline child workflows.
	WorkspaceSeed *runtimeexec.WorkspaceSeed
	// StepRetry is the name of the step to retry, if specified.
	StepRetry string
	// IncludeDownstream resets the selected step and every reachable descendant.
	IncludeDownstream bool
	// RetryPath identifies a persisted child DAG step retry.
	RetryPath dagrun.RetryPath
	// WorkerID is the identifier of the worker executing this DAG run.
	// For distributed execution, this is set to the worker's ID.
	// For local execution, this defaults to "local".
	WorkerID string
	// StatusPusher is used to push status updates to a remote coordinator.
	// When nil, status is written to local filesystem via the run-state attempt.
	StatusPusher StatusPusher
	// SubWorkflowRunnerFactory creates a runner for child workflows.
	SubWorkflowRunnerFactory SubWorkflowRunnerFactory
	// LogWriterFactory is used to create log writers for step output.
	// When nil, logs are written to local filesystem.
	LogWriterFactory runctx.LogWriterFactory
	// QueuedRun indicates this execution is from a queued item.
	// When true, the agent will find the existing dag-run (created by enqueue)
	// instead of creating a new one. This is used for distributed execution
	// where the dag-run directory was already created by the scheduler.
	QueuedRun bool
	// AttemptID uses a caller-assigned attempt identifier when non-empty.
	AttemptID string
	// RunStateStore records execution state for this DAG run.
	RunStateStore runstate.Store
	// StateStore is the persistent state store shared across DAG runs.
	StateStore dagrun.StateStore
	// MaterializationStore coordinates build file materializations.
	MaterializationStore build.MaterializationStore
	// SecretStore resolves local registry refs and runtime profile secrets.
	SecretStore secretpkg.Store
	// SecretReferenceResolver resolves DAG-level registry refs.
	// When nil, SecretStore supplies the local resolver.
	SecretReferenceResolver providers.ReferenceResolver
	// ProfileStore resolves named runtime profiles.
	ProfileStore profilepkg.Store
	// ProfileResolver resolves inherited and selected runtime profile layers.
	ProfileResolver profilepkg.RuntimeResolver
	// ProfileName selects the runtime profile for this DAG run.
	ProfileName string
	// DAGDefinitionID identifies the persisted definition that started this run.
	DAGDefinitionID string
	// ServiceRegistry is the registry for service discovery.
	ServiceRegistry serviceregistry.ServiceRegistry
	// RootDAGRun is the root dag-run reference for sub-DAG runs.
	RootDAGRun ir.DAGRunRef
	// PeerConfig is the configuration for peer communication.
	PeerConfig config.Peer
	// TriggerType indicates how this DAG run was initiated.
	TriggerType ir.TriggerType
	// TriggerActor identifies the attributable actor that initiated the DAG run.
	TriggerActor string
	// ParallelItem is the value bound to ITEM for a parallel child run.
	ParallelItem string
	// DefaultExecMode is the server-level default execution mode.
	DefaultExecMode config.ExecutionMode
	// ScheduleTime is the RFC 3339 timestamp of when this run was scheduled.
	// Set by the scheduler for cron-triggered runs; empty for manual runs.
	ScheduleTime string
	// ArtifactDir is the per-run artifact directory when artifact storage is enabled.
	ArtifactDir string
	// DAGRunLogDir is the base log directory used for child DAG runs created by executors.
	DAGRunLogDir string
	// DAGRunArtifactDir is the base artifact directory used for child DAG runs created by executors.
	DAGRunArtifactDir string
	// ArtifactFinalizer persists artifacts before the final terminal status is written.
	ArtifactFinalizer ArtifactFinalizer
	// RemoteDAGLoader loads a DAG from a remote source when the local repository misses.
	// When nil, no remote fallback is attempted.
	RemoteDAGLoader RemoteDAGLoader
	// SocketServerFactory creates the local status/control transport.
	// When nil, the default Unix socket transport is used.
	SocketServerFactory SocketServerFactory
}

Options is the configuration for the Agent.

type ProgressReporter

type ProgressReporter interface {
	// Start begins the progress display
	Start()

	// Stop stops the progress display
	Stop()

	// UpdateNode updates the progress for a specific node
	UpdateNode(node *ir.Node)

	// UpdateStatus updates the overall DAG status
	UpdateStatus(status *ir.DAGRunStatus)

	// SetDAGRunInfo sets the DAG run ID and parameters
	SetDAGRunInfo(dagRunID, params string)
}

ProgressReporter is the interface for progress display implementations

type RemoteDAGLoader

type RemoteDAGLoader func(ctx context.Context, name string) (*ir.DAG, error)

RemoteDAGLoader loads a DAG definition from a remote source. Returns nil, nil when the remote source does not have the DAG.

type Sender

type Sender interface {
	Send(ctx context.Context, from string, to []string, subject, body string, attachments []string) error
}

Sender is a mailer interface.

type SenderFn

type SenderFn func(ctx context.Context, from string, to []string, subject, body string, attachments []string) error

SenderFn is a function type for sending reports.

type SimpleProgressDisplay

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

SimpleProgressDisplay provides a minimal inline progress display.

func NewSimpleProgressDisplay

func NewSimpleProgressDisplay(dag *ir.DAG) *SimpleProgressDisplay

NewSimpleProgressDisplay creates a new simple progress display.

func (*SimpleProgressDisplay) SetDAGRunInfo

func (p *SimpleProgressDisplay) SetDAGRunInfo(dagRunID, params string)

SetDAGRunInfo sets the DAG run ID and parameters.

func (*SimpleProgressDisplay) Start

func (p *SimpleProgressDisplay) Start()

Start begins the progress display.

func (*SimpleProgressDisplay) Stop

func (p *SimpleProgressDisplay) Stop()

Stop stops the progress display. Safe to call multiple times.

func (*SimpleProgressDisplay) UpdateNode

func (p *SimpleProgressDisplay) UpdateNode(node *ir.Node)

UpdateNode updates the progress for a specific node.

func (*SimpleProgressDisplay) UpdateStatus

func (p *SimpleProgressDisplay) UpdateStatus(status *ir.DAGRunStatus)

UpdateStatus updates the overall DAG status.

type SocketServer

type SocketServer interface {
	Serve(ctx context.Context, listen chan error) error
	Shutdown(ctx context.Context) error
}

SocketServer handles local status/control requests for a running DAG.

type SocketServerFactory

type SocketServerFactory func(addr string, handlerFunc sock.HTTPHandlerFunc) (SocketServer, error)

SocketServerFactory creates a local status/control transport.

type StatusPusher

type StatusPusher = runtime.StatusPusher

StatusPusher reports DAG run status outside the current execution process.

type SubWorkflowRunnerFactory

type SubWorkflowRunnerFactory func(ctx context.Context) (runtimeexec.SubWorkflowRunner, error)

SubWorkflowRunnerFactory creates a runner for child workflows.

Jump to

Keyboard shortcuts

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