Documentation
¶
Index ¶
- func NewWorkflowContext(ctx context.Context, input any) context.Context
- type Agent
- type AgentStep
- type Compiler
- type ForeachStep
- type Formatter
- type JSONFormatter
- type JSONLFormatter
- type Job
- type Retry
- type RouterStep
- type RunStep
- type Server
- type Step
- type TextFormatter
- type Workflow
- type WorkflowContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AgentStep ¶
AgentStep is a simple agent execution step
func (*AgentStep) GetOutputName ¶
GetOutputName returns the name to store output under
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler compiles AST to executable workflow
type ForeachStep ¶
type ForeachStep struct {
UsesAgent *Agent // Optional: agent to generate array
Selector cel.Program // Optional: CEL program to extract array
Job *Job // Job to execute for each item (resolved)
JobName string // Job name for resolution
OutputName string
Retry *Retry
Formatter Formatter // Output serialization format
}
ForeachStep executes a job for each item in an array
func (*ForeachStep) GetOutputName ¶
func (step *ForeachStep) GetOutputName() string
GetOutputName returns the name to store output under
type Formatter ¶ added in v0.1.11
type Formatter interface {
// Format converts array of results into serialized output.
// Input: results from foreach iterations ([]any)
// Output: serialized data (any) - typically string or []any
Format(results []any) (any, error)
}
Formatter serializes foreach results into output format. This is a CODEC for result serialization, NOT a reduce function.
Use cases:
- JSON: Structured arrays for downstream processing
- JSONL: Streaming-friendly newline-delimited JSON
- Text: Human-readable concatenation with custom delimiters
func NewFormatter ¶ added in v0.1.11
func NewFormatter(format *ast.FormatNode) (Formatter, error)
NewFormatter creates formatter based on AST format node. Returns appropriate formatter or error for unknown types.
type JSONFormatter ¶ added in v0.1.11
type JSONFormatter struct{}
JSONFormatter returns results as JSON array (default). Output: Go slice ([]any) that will be JSON-encoded downstream.
func NewJSONFormatter ¶ added in v0.1.11
func NewJSONFormatter() *JSONFormatter
NewJSONFormatter creates a JSON array formatter
type JSONLFormatter ¶ added in v0.1.11
type JSONLFormatter struct{}
JSONLFormatter returns results as newline-delimited JSON. Each result on separate line, suitable for streaming.
func NewJSONLFormatter ¶ added in v0.1.11
func NewJSONLFormatter() *JSONLFormatter
NewJSONLFormatter creates a JSONL formatter
type RouterStep ¶
type RouterStep struct {
Agent *Agent
OutputName string
RouteNodes []ast.RouteNode // For reference
Conditions []cel.Program // Compiled CEL expressions
Routes map[string]*Job // Resolved job references
DefaultJob string // Default job name
Default *Job // Resolved default job
Retry *Retry
}
RouterStep is a conditional routing step
func (*RouterStep) GetOutputName ¶
func (step *RouterStep) GetOutputName() string
GetOutputName returns the name to store output under
type RunStep ¶
type RunStep struct {
Command string // Compiled template for the command
Shell string // Shell to use (sh, bash, zsh, etc.)
OutputName string
Retry *Retry
}
RunStep executes a shell command
func (*RunStep) GetOutputName ¶
GetOutputName returns the name to store output under
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
active MCP server session
type Step ¶
type Step interface {
Prompt(ctx context.Context, opt ...chatter.Opt) error
GetOutputName() string
}
Step is an interface for executable steps
type TextFormatter ¶ added in v0.1.11
type TextFormatter struct {
Delimiter string
}
TextFormatter concatenates results with configurable delimiter. Useful for human-readable summaries or simple text aggregation.
func NewTextFormatter ¶ added in v0.1.11
func NewTextFormatter(delimiter string) *TextFormatter
NewTextFormatter creates a text formatter with custom delimiter
type Workflow ¶
type Workflow struct {
Name string
About string
Entrypoint string // Optional: default job name, or "main" if empty
Schema ast.SchemaNode
Jobs map[string]*Job
}
Workflow represents a compiled, executable workflow
type WorkflowContext ¶
type WorkflowContext struct {
// Input is the original workflow input
Input any
// State is a shared key-value store for workflow data
State map[string]any
// Steps holds named outputs from previous steps
Steps map[string]any
// Current is the most recent step output (for chaining)
Current any
}
WorkflowContext holds the execution state for a workflow
func GetWorkflowContext ¶
func GetWorkflowContext(ctx context.Context) *WorkflowContext
GetWorkflowContext extracts the workflow context from Go context
func (*WorkflowContext) Get ¶
func (c *WorkflowContext) Get(key string) (any, bool)
Get retrieves a value from the workflow state
func (*WorkflowContext) GetStepOutput ¶
func (c *WorkflowContext) GetStepOutput(name string) (any, bool)
GetStepOutput retrieves the output of a named step
func (*WorkflowContext) Set ¶
func (c *WorkflowContext) Set(key string, value any)
Set stores a value in the workflow state
func (*WorkflowContext) SetStepOutput ¶
func (c *WorkflowContext) SetStepOutput(name string, output any)
SetStepOutput stores the output of a named step
func (*WorkflowContext) ToMap ¶
func (c *WorkflowContext) ToMap() map[string]any
ToMap returns the full context as a map for template rendering