Documentation
¶
Overview ¶
Package flows reads, checks and writes workflows (spec_workflows_043): steps joined into a graph, in .agents/workflows/<name>.flow.yaml, beside the .md commands there.
Index ¶
- Constants
- Variables
- func CallLoops(all []Flow) map[string]string
- func Check(f Flow) []string
- func CheckExpr(expr string) error
- func CheckTemplate(text string) error
- func DataOf(text string) any
- func Delete(dir, name string) error
- func Eval(expr string, vars Vars) (ref.Val, error)
- func Fill(text string, vars Vars) (string, error)
- func FillValue(v any, vars Vars) (any, error)
- func Holds(expr string, vars Vars) (bool, error)
- func Inputs(f Flow, id string) []string
- func IsAgentType(t string) bool
- func IsFlow(file string) bool
- func IsGateway(t string) bool
- func List(expr string, vars Vars) ([]any, error)
- func ModeOf(f Flow) api.PermissionMode
- func ParseDuration(s string, def time.Duration) (time.Duration, error)
- func Pauses(t string) bool
- func Save(dir string, f Flow, previous string) (string, []string, error)
- func ValidName(name string) bool
- type Auth
- type Edge
- type Field
- type Flow
- type Form
- type Node
- type Pair
- type Position
- type Result
- type Retry
- type Vars
Constants ¶
const ( // Agent runs an agent on the step's instructions and its input. Agent = "agent" // Refine has an agent improve its input as the instructions say. Refine = "refine" // Script runs a skill's script, its input as its last argument. Script = "script" // Browser has an agent reach a goal with its browser tool. Browser = "browser" // Accumulate joins its inputs, each under its step's title. Accumulate = "accumulate" // Summarize has an agent sum up its input. Summarize = "summarize" // ReadFile reads a workspace file: its text is the step's output. ReadFile = "read_file" // SaveFile writes its input to a workspace file (asked first). SaveFile = "save_file" // Extract pulls named fields out of its input (a model, to a schema): // they're its data. Extract = "extract" // MCPCall calls a tool of an MCP server; A2ACall sends a message to a // remote agent (A2A); APICall makes an HTTP request (WF-14). MCPCall = "mcp_call" A2ACall = "a2a_call" APICall = "api_call" // Call runs another workflow on its input (BPMN's call activity). Call = "workflow" // HumanTask waits for a person to fill in its form (A2UI); Timer // waits for a time (WF-16). HumanTask = "human_task" Timer = "timer" // Exclusive takes its first link whose condition holds (else its // default); Inclusive every one (else its default); Parallel every // link. Each passes its input on. Exclusive = "exclusive" Inclusive = "inclusive" Parallel = "parallel" // Email and Data are shown, not run yet. Email = "email" Data = "data" )
A step's type.
const Suffix = ".flow.yaml"
Suffix ends a workflow's file name.
Variables ¶
var ErrUnknown = errors.New("no such workflow")
ErrUnknown means there's no workflow of that name.
var Methods = []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"}
Methods are an API call's HTTP methods.
var Modes = []api.PermissionMode{api.ModeAuto, api.ModeAcceptEdits, api.ModeDefault, api.ModeDontAsk, api.ModeBypass}
Modes are the permission modes a workflow can run in, auto first (the default). Plan isn't one: a workflow carries its steps out.
var Types = []string{Agent, Refine, Summarize, Extract, Accumulate, Browser, Script, ReadFile, SaveFile, MCPCall, A2ACall, APICall, Call, HumanTask, Timer, Exclusive, Inclusive, Parallel, Email, Data}
Types are the step types, in the order the palette shows them.
Functions ¶
func CallLoops ¶
CallLoops says which workflows call themselves, through others: for each workflow named in a loop, the loop ("a → b → a").
func Check ¶
Check says what doesn't hold in f: its name, its steps' types and settings, its edges, and loops.
func CheckTemplate ¶
CheckTemplate reports whether each {{ … }} in text is an expression.
func DataOf ¶
DataOf is the JSON in an answer, if it's JSON alone (a code fence around it allowed): an object or a list.
func Fill ¶
Fill replaces each {{ expression }} in text with its value: text as it is, anything else as JSON.
func FillValue ¶
FillValue is v (a map, a list, a string, or anything else as it is) with each string's templates filled in; a string that is one template alone takes the expression's value, not its text ("{{ steps.a.data }}" stays an object).
func IsAgentType ¶
IsAgentType reports whether a step type is run by an agent (a turn).
func ModeOf ¶
func ModeOf(f Flow) api.PermissionMode
ModeOf is the permission mode f's steps ask to run in: its mode, or auto.
func ParseDuration ¶
ParseDuration reads a Go duration ("90s", "5m"); "" is def.
Types ¶
type Auth ¶
type Auth struct {
// Type is bearer, basic, api_key or oauth2 (client credentials).
Type string `yaml:"type"`
// Token is a bearer token.
Token string `yaml:"token,omitempty"`
// Username and Password are basic auth's.
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
// Name, Value and In (header, the default, or query) are an API key's.
Name string `yaml:"name,omitempty"`
Value string `yaml:"value,omitempty"`
In string `yaml:"in,omitempty"`
// TokenURL, ClientID, ClientSecret, Scopes and Audience are OAuth2
// client credentials'.
TokenURL string `yaml:"token_url,omitempty"`
ClientID string `yaml:"client_id,omitempty"`
ClientSecret string `yaml:"client_secret,omitempty"`
Scopes []string `yaml:"scopes,omitempty"`
Audience string `yaml:"audience,omitempty"`
}
Auth is how an API call authenticates. Its values take templates and {secrets:key}.
type Edge ¶
type Edge struct {
From string `yaml:"from"`
To string `yaml:"to"`
// When is a condition (a CEL expression on output, input and steps);
// If one in plain English, judged by a model. Without either, the
// link is taken whenever its step succeeds.
When string `yaml:"when,omitempty"`
If string `yaml:"if,omitempty"`
// Default is taken when none of its step's conditional links is.
Default bool `yaml:"default,omitempty"`
// Error is taken when its step fails (instead of stopping the run),
// with the error as its input.
Error bool `yaml:"error,omitempty"`
// Label is what the canvas shows on it.
Label string `yaml:"label,omitempty"`
}
Edge carries a step's output to another.
func (Edge) Conditional ¶
Conditional reports whether a link has a condition.
type Field ¶
type Field struct {
Name string `yaml:"name"`
// Type is string (the default), number, boolean or list (of strings).
Type string `yaml:"type,omitempty"`
Description string `yaml:"description,omitempty"`
}
Field is a value an extract step pulls out.
type Flow ¶
type Flow struct {
// Name is its file's name without .flow.yaml: run as /name.
Name string `yaml:"-"`
Path string `yaml:"-"`
Description string `yaml:"description,omitempty"`
// Mode is the permission mode its steps run in (WF-21): auto when
// empty, and never looser than the workspace's.
Mode string `yaml:"mode,omitempty"`
Nodes []Node `yaml:"nodes"`
Edges []Edge `yaml:"edges,omitempty"`
Problem string `yaml:"-"`
}
Flow is a workflow file.
type Form ¶
Form is a human task's form, in A2UI v0.9's basic catalog: components (a flat list, one with id root) and data, the form's starting values; templates in either are filled as the step starts.
type Node ¶
type Node struct {
ID string `yaml:"id"`
Type string `yaml:"type"`
Title string `yaml:"title,omitempty"`
Position Position `yaml:"position"`
// Agent is the agent an agent, refine, summarize or browser step runs
// (none: the active one).
Agent string `yaml:"agent,omitempty"`
// Skills are given to the agent with the step's prompt.
Skills []string `yaml:"skills,omitempty"`
// Instructions are what the step is to do (a browser step's goal).
Instructions string `yaml:"instructions,omitempty"`
// Rules are rules the step's output must pass (judged, as after-agent
// gates are: spec_gates_041).
Rules []string `yaml:"rules,omitempty"`
// Skill and ScriptName are a script step's script; Args its arguments.
Skill string `yaml:"skill,omitempty"`
ScriptName string `yaml:"script,omitempty"`
Args []string `yaml:"args,omitempty"`
// Path is a read_file or save_file step's file, in the workspace.
Path string `yaml:"path,omitempty"`
// Fields are what an extract step pulls out.
Fields []Field `yaml:"fields,omitempty"`
// Server and Tool are an MCP call's; Arguments its arguments (string
// values take templates).
Server string `yaml:"server,omitempty"`
Tool string `yaml:"tool,omitempty"`
Arguments map[string]any `yaml:"arguments,omitempty"`
// URL is an API call's (or an A2A agent's, where its card is); Method,
// Query, Headers, Body (text) or JSON (a value: string values take
// templates) and Auth the request's. An A2A call's message is its
// instructions (its input when none); Headers go with its requests.
URL string `yaml:"url,omitempty"`
Method string `yaml:"method,omitempty"`
Query []Pair `yaml:"query,omitempty"`
Headers []Pair `yaml:"headers,omitempty"`
Body string `yaml:"body,omitempty"`
JSON any `yaml:"json,omitempty"`
Auth *Auth `yaml:"auth,omitempty"`
// Workflow is the workflow a call step runs.
Workflow string `yaml:"workflow,omitempty"`
// Form is a human task's form: A2UI v0.9 (components, and data, its
// starting values); its instructions are shown above it.
Form *Form `yaml:"form,omitempty"`
// Wait (a Go duration) or Until (a time, RFC 3339) is how long a
// timer waits; both take templates.
Wait string `yaml:"wait,omitempty"`
Until string `yaml:"until,omitempty"`
// ForEach (a CEL expression giving a list) runs the step once per
// item, Concurrency at a time (4 when unset), item and index in its
// templates (WF-15).
ForEach string `yaml:"for_each,omitempty"`
Concurrency int `yaml:"concurrency,omitempty"`
// Retry tries a failing step again; Timeout (a Go duration) stops a
// step that runs too long.
Retry *Retry `yaml:"retry,omitempty"`
Timeout string `yaml:"timeout,omitempty"`
}
Node is a step.
type Result ¶
Result is what a step produced: its text, and its data when it has some (JSON an agent answered with, an extract step's fields, an API's response).