workflow

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	From string
	To   string
}

Edge is a directed dependency: From's output is fed to To's prompt context.

type Result

type Result struct {
	Outputs map[string]string // role name → final assistant text
	Last    string            // output of the last role in topological order
}

Result is the outcome of a workflow run.

func Run

func Run(ctx context.Context, wf *Workflow, args string, deps RunDeps) (*Result, error)

Run executes the workflow with sibling parallelism. Roles whose dependencies have all completed launch concurrently; their child agents share the parent Provider's Pool, which is what actually serialises inflight LLM calls when the configured concurrency is 1.

On the first role error the run-context is cancelled and the runner drains. The first error is returned; later errors are logged.

type Role

type Role struct {
	Name           string
	Model          string   // optional override; "" = inherit parent
	AllowedTools   []string // optional restriction
	PromptTemplate *template.Template
}

Role describes one agent in the workflow.

type RunDeps

type RunDeps struct {
	// Providers is the full set of configured LLM endpoints, keyed by
	// the user-facing label (e.g. "qwen-fast"). Per-role `model:` in
	// the YAML names a key here. Must be non-empty.
	Providers map[string]*llm.Provider
	// DefaultProvider is the provider name a role falls back to when
	// its `model:` field is empty. Empty string = alphabetical-first.
	DefaultProvider string

	Bus                *bus.Bus
	Registry           *tools.Registry
	Perms              *permissions.Checker
	Cwd                string
	MaxTurns           int
	GlobalAgents       *atomic.Int64
	MaxAgents          int
	MaxDepth           int
	Depth              int
	Transcripts        *tools.Transcripts // optional; captures per-role histories
	Writer             *session.Writer    // optional; persists per-role messages with role's agent id
	GitAttribution     string
	GitAttributionName string
	WebFetchAllowHosts []string
	RestrictedRoots    []string
}

RunDeps is what the runner needs from the surrounding agent stack.

type Workflow

type Workflow struct {
	Name      string
	Roles     map[string]Role
	Edges     []Edge
	RoleOrder []string // topological order; populated by topoSort()
}

Workflow is a parsed declarative agent workflow.

func LoadByName

func LoadByName(cwd, name string) (*Workflow, error)

LoadByName resolves a workflow by name. Search order:

  1. ./.enso/workflows/<name>.md (project)
  2. ~/.enso/workflows/<name>.md (user)

func LoadFile

func LoadFile(path string) (*Workflow, error)

LoadFile reads and parses a workflow from disk. Returns (*Workflow, nil) on success. The workflow is pre-validated and topo-sorted so the runner can iterate `wf.RoleOrder` without further work.

func Parse

func Parse(displayName string, data []byte) (*Workflow, error)

Parse parses an in-memory workflow definition.

Jump to

Keyboard shortcuts

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