Documentation
¶
Index ¶
- Variables
- func RenderPrompt(tmpl string, results map[string]string) (string, error)
- func Validate(w *Workflow) error
- type AgentRunner
- type ChannelSender
- type DAG
- type Engine
- func (e *Engine) Cancel(runID string) error
- func (e *Engine) ListRuns(ctx context.Context, limit int) ([]RunStatus, error)
- func (e *Engine) Resume(ctx context.Context, runID string) (*RunResult, error)
- func (e *Engine) Run(ctx context.Context, w *Workflow) (*RunResult, error)
- func (e *Engine) RunAsync(ctx context.Context, w *Workflow) (string, error)
- func (e *Engine) Shutdown()
- func (e *Engine) Status(ctx context.Context, runID string) (*RunStatus, error)
- type RunResult
- type RunStatus
- type StateStore
- func (s *StateStore) CompleteRun(ctx context.Context, runID string, status string, errMsg string) error
- func (s *StateStore) CreateRun(ctx context.Context, w *Workflow) (string, error)
- func (s *StateStore) CreateStepRun(ctx context.Context, runID string, step Step, renderedPrompt string) error
- func (s *StateStore) GetRunStatus(ctx context.Context, runID string) (*RunStatus, error)
- func (s *StateStore) GetStepResults(ctx context.Context, runID string) (map[string]string, error)
- func (s *StateStore) ListRuns(ctx context.Context, limit int) ([]RunStatus, error)
- func (s *StateStore) UpdateRunStatus(ctx context.Context, runID string, status string) error
- func (s *StateStore) UpdateStepStatus(ctx context.Context, runID string, stepID string, status string, result string, ...) error
- type Step
- type StepStatus
- type Workflow
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func RenderPrompt ¶
RenderPrompt substitutes {{stepID.result}} placeholders in a prompt template with actual results from previous steps. It returns an error if a referenced step has no result available.
Types ¶
type AgentRunner ¶
type AgentRunner interface {
Run(ctx context.Context, sessionKey string, prompt string) (string, error)
}
AgentRunner executes agent prompts (avoids import cycles with orchestration).
type ChannelSender ¶
type ChannelSender interface {
SendMessage(ctx context.Context, channel string, message string) error
}
ChannelSender sends results to communication channels.
type DAG ¶
type DAG struct {
// contains filtered or unexported fields
}
DAG represents a directed acyclic graph of workflow steps.
func NewDAG ¶
NewDAG builds a DAG from a slice of workflow steps. It returns an error if a circular dependency is detected.
func (*DAG) TopologicalSort ¶
TopologicalSort returns layers of step IDs that can be executed in parallel. Layer 0 contains steps with no dependencies, layer 1 contains steps whose dependencies are all in layer 0, and so on.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine orchestrates DAG-based workflow execution.
func NewEngine ¶
func NewEngine( runner AgentRunner, state *StateStore, sender ChannelSender, maxConcurrent int, defaultTimeout time.Duration, logger *zap.SugaredLogger, ) *Engine
NewEngine creates a new workflow execution engine.
func (*Engine) Run ¶
Run executes a workflow from start to finish synchronously. The context is detached from the parent to prevent cancellation when the originating request completes.
type RunResult ¶
type RunResult struct {
RunID string
WorkflowName string
Status string
StepResults map[string]string // stepID -> result
Error string
StartedAt time.Time
CompletedAt time.Time
}
RunResult holds the final result of a workflow execution.
type RunStatus ¶
type RunStatus struct {
RunID string
WorkflowName string
Status string
TotalSteps int
CompletedSteps int
StartedAt time.Time
StepStatuses []StepStatus
}
RunStatus holds the current status of a workflow execution.
type StateStore ¶
type StateStore struct {
// contains filtered or unexported fields
}
StateStore persists workflow execution state for resume capability.
func NewStateStore ¶
func NewStateStore(client *ent.Client, logger *zap.SugaredLogger) *StateStore
NewStateStore creates a new StateStore backed by the given ent client.
func (*StateStore) CompleteRun ¶
func (s *StateStore) CompleteRun(ctx context.Context, runID string, status string, errMsg string) error
CompleteRun marks a workflow run as finished with a final status and optional error message.
func (*StateStore) CreateStepRun ¶
func (s *StateStore) CreateStepRun(ctx context.Context, runID string, step Step, renderedPrompt string) error
CreateStepRun creates a new step run record for a workflow run.
func (*StateStore) GetRunStatus ¶
GetRunStatus returns the current status of a workflow run including all step statuses.
func (*StateStore) GetStepResults ¶
GetStepResults returns a map of stepID -> result for all completed steps.
func (*StateStore) ListRuns ¶
ListRuns returns the most recent workflow runs, ordered by start time descending.
func (*StateStore) UpdateRunStatus ¶
UpdateRunStatus updates the status of a workflow run.
type Step ¶
type Step struct {
ID string `yaml:"id"`
Agent string `yaml:"agent"` // executor | researcher | planner | memory-manager
Prompt string `yaml:"prompt"` // Go template with {{step-id.result}}
DependsOn []string `yaml:"depends_on"`
DeliverTo []string `yaml:"deliver_to"` // per-step delivery
Timeout time.Duration `yaml:"timeout"`
}
Step represents a single unit of work in a workflow.
type StepStatus ¶
StepStatus holds the current status of a single step.
type Workflow ¶
type Workflow struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Schedule string `yaml:"schedule"` // optional cron expression
DeliverTo []string `yaml:"deliver_to"` // optional result delivery targets
Steps []Step `yaml:"steps"`
}
Workflow represents a declared multi-step workflow.