dsl

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package dsl provides a YAML-based domain-specific language for defining AI agent teams and workflows without writing Go code.

DSL Overview

The DSL uses YAML files (typically named *.vega.yaml) to define:

  • Agents: AI assistants with specific roles and capabilities
  • Workflows: Multi-step processes that coordinate agents
  • Tools: Custom tool definitions with various implementations
  • Settings: Global configuration like rate limits and budgets

Basic Example

A simple .vega.yaml file:

name: My Team

agents:
  assistant:
    model: claude-sonnet-4-20250514
    system: You are a helpful assistant.

workflows:
  greet:
    inputs:
      name:
        type: string
        required: true
    steps:
      - assistant:
          send: "Hello, {{name}}!"
          save: greeting
    output: "{{greeting}}"

Using the DSL

Parse and execute a DSL file:

parser := dsl.NewParser()
doc, err := parser.ParseFile("team.vega.yaml")
if err != nil {
    log.Fatal(err)
}

interp, err := dsl.NewInterpreter(doc)
if err != nil {
    log.Fatal(err)
}
defer interp.Shutdown()

result, err := interp.Execute(ctx, "greet", map[string]any{
    "name": "World",
})

Expression Syntax

The DSL supports {{expression}} interpolation:

{{variable}}           - Simple variable reference
{{step1.field}}        - Nested field access
{{value | upper}}      - Filter/transform
{{name | default:anon}} - Filter with argument

Available filters: upper, lower, trim, default, lines, words, truncate, join

Control Flow

The DSL supports various control structures:

# Conditionals
- if: "{{approved}}"
  then:
    - agent: ...
  else:
    - agent: ...

# Loops
- for: item in items
  steps:
    - agent:
        send: "Process {{item}}"

# Repeat until condition
- repeat:
    max: 5
    until: "'done' in result"
    steps:
      - agent: ...

# Parallel execution
- parallel:
    - agent1: ...
    - agent2: ...

See the examples/ directory in the repository for complete examples.

Package dsl provides the Vega DSL parser and interpreter.

Index

Constants

View Source
const IrisAgentName = irisAgentName

IrisAgentName is the canonical name for the Iris meta-agent.

View Source
const MaxReactiveDepth = 2

MaxReactiveDepth is the maximum depth for reactive channel notifications to prevent infinite loops.

Variables

This section is empty.

Functions

func BuildTeamPrompt

func BuildTeamPrompt(system string, team []string, agentDescriptions map[string]string, blackboardEnabled bool) string

BuildTeamPrompt appends team delegation instructions to a system prompt. agentDescriptions is optional — if a member has a description it is shown. When blackboardEnabled is true, instructions about bb_read/bb_write/bb_list tools are appended.

func ChannelReactiveDepthFromContext added in v0.3.0

func ChannelReactiveDepthFromContext(ctx context.Context) int

ChannelReactiveDepthFromContext returns the current reactive depth from ctx.

func ContainsExpression

func ContainsExpression(s string) bool

ContainsExpression checks if a string contains expressions.

func ContextWithChannelReactiveDepth added in v0.3.0

func ContextWithChannelReactiveDepth(ctx context.Context, depth int) context.Context

ContextWithChannelReactiveDepth returns a new context with the given reactive depth.

func ExtractExpressions

func ExtractExpressions(s string) []string

ExtractExpressions finds all {{...}} expressions in a string.

func FormatDelegationContext

func FormatDelegationContext(dc *DelegationContext, message string) string

FormatDelegationContext wraps the original message with caller context as XML.

func InjectHera added in v0.4.0

func InjectHera(interp *Interpreter, cb *HeraCallbacks, extraTools ...string) error

InjectHera adds the Hera agent to the interpreter. It registers the meta-tools and then adds Hera as an agent. extraTools are additional tool names (e.g. scheduler tools) to include in Hera's tool list. They must already be registered on the interpreter.

func InjectIris added in v0.4.0

func InjectIris(interp *Interpreter, channelBackend ChannelBackend, extraTools ...string) error

InjectIris adds Iris to the interpreter. extraTools are additional tool names (e.g. memory tools) to include in Iris's tool list. They must already be registered on the interpreter.

func IsHeraTool added in v0.4.0

func IsHeraTool(name string) bool

IsHeraTool reports whether a tool name is one of Hera's meta-tools.

func IsIrisTool added in v0.4.0

func IsIrisTool(name string) bool

IsIrisTool reports whether a tool name is one of Iris's tools.

func NewBlackboardListTool

func NewBlackboardListTool(getGroup GroupResolver) tools.ToolDef

NewBlackboardListTool creates a tool that lists all keys on the team blackboard.

func NewBlackboardReadTool

func NewBlackboardReadTool(getGroup GroupResolver) tools.ToolDef

NewBlackboardReadTool creates a tool that reads a key from the team blackboard.

func NewBlackboardWriteTool

func NewBlackboardWriteTool(getGroup GroupResolver) tools.ToolDef

NewBlackboardWriteTool creates a tool that writes a key/value pair to the team blackboard.

func NewDelegateTool

func NewDelegateTool(sendFn SendFunc, teamResolver TeamResolver) tools.ToolDef

NewDelegateTool returns a tools.ToolDef for the delegate tool. sendFn is called when the tool is invoked to relay a message to another agent. teamResolver is called at invocation time to determine which agents the caller can delegate to; if it returns nil/empty, any agent name is accepted.

func NewDelegateToolWithOpts added in v0.4.0

func NewDelegateToolWithOpts(opts DelegateToolOpts) tools.ToolDef

NewDelegateToolWithOpts returns a delegate tool with full configuration. When a ChannelPeerResolver is provided, agents that share a channel with the caller are also allowed as delegation targets — not just explicit team members.

func RegisterChannelTools added in v0.3.0

func RegisterChannelTools(interp *Interpreter, backend ChannelBackend, onPost ChannelPostCallback, onReactive ChannelReactiveCallback)

RegisterChannelTools registers channel tools on the interpreter.

func RegisterDelegateTool

func RegisterDelegateTool(t *tools.Tools, sendFn SendFunc, teamResolver TeamResolver) bool

RegisterDelegateTool registers the delegate tool on the given Tools instance if it is not already registered. teamResolver is called at invocation time to determine which agents the caller can delegate to. Returns true if registration happened.

func RegisterDelegateToolWithOpts added in v0.4.0

func RegisterDelegateToolWithOpts(t *tools.Tools, opts DelegateToolOpts) bool

RegisterDelegateToolWithOpts registers the delegate tool with full options. Returns true if registration happened.

func RegisterHeraTools added in v0.4.0

func RegisterHeraTools(interp *Interpreter, cb *HeraCallbacks)

RegisterHeraTools registers Hera's meta-tools on the interpreter's global tool collection. The callbacks are optional — when nil, no persistence hooks fire.

func RegisterInboxTools added in v0.3.0

func RegisterInboxTools(interp *Interpreter, backend InboxBackend)

RegisterInboxTools registers the inbox tools on the interpreter. ask_iris is available to all agents. list_inbox and resolve_inbox are added to Iris's tool list by the caller.

func RegisterIrisTools added in v0.4.0

func RegisterIrisTools(interp *Interpreter, channelBackend ...ChannelBackend)

RegisterIrisTools registers Iris's tools on the interpreter's global tool collection. list_agents is registered only if not already present (Hera registers it when she's injected). channelBackend is optional — when provided, enables the check_status tool.

func RegisterSchedulerTools

func RegisterSchedulerTools(interp *Interpreter, backend SchedulerBackend)

RegisterSchedulerTools registers the four schedule-management tools on Hera's interpreter. Call this after InjectHera so the tools exist before Hera's tool list is finalised.

Types

type Agent

type Agent struct {
	Name          string          `yaml:"name"`
	DisplayName   string          `yaml:"display_name"`
	Title         string          `yaml:"title"`
	Avatar        string          `yaml:"avatar"`
	Extends       string          `yaml:"extends"`
	Model         string          `yaml:"model"`
	FallbackModel string          `yaml:"fallback_model"`
	System        string          `yaml:"system"`
	Temperature   *float64        `yaml:"temperature"`
	Budget        string          `yaml:"budget"` // e.g., "$0.50"
	Tools         []string        `yaml:"tools"`
	Knowledge     []string        `yaml:"knowledge"`
	Team          []string        `yaml:"team"`
	Supervision   *SupervisionDef `yaml:"supervision"`
	Retry         *RetryDef       `yaml:"retry"`
	Skills        *SkillsDef      `yaml:"skills"`
	Delegation    *DelegationDef  `yaml:"delegation"`
}

Agent represents an agent definition in the DSL.

func HeraAgent added in v0.4.0

func HeraAgent(defaultModel string) *Agent

HeraAgent returns the DSL agent definition for Hera.

func IrisAgent added in v0.4.0

func IrisAgent(defaultModel string) *Agent

IrisAgent returns the DSL agent definition for Iris.

type AgentTemplate added in v0.3.0

type AgentTemplate struct {
	Version     string   `json:"version" yaml:"version"`
	Name        string   `json:"name" yaml:"name"`
	DisplayName string   `json:"display_name,omitempty" yaml:"display_name,omitempty"`
	Title       string   `json:"title,omitempty" yaml:"title,omitempty"`
	Model       string   `json:"model" yaml:"model"`
	System      string   `json:"system" yaml:"system"`
	Tools       []string `json:"tools,omitempty" yaml:"tools,omitempty"`
	Team        []string `json:"team,omitempty" yaml:"team,omitempty"`
	ExportedBy  string   `json:"exported_by,omitempty" yaml:"exported_by,omitempty"`
	ExportedAt  string   `json:"exported_at,omitempty" yaml:"exported_at,omitempty"`
}

AgentTemplate is a portable agent definition for export/import across instances.

type ChannelBackend added in v0.3.0

type ChannelBackend interface {
	CreateChannel(id, name, description, createdBy string, team []string, mode string) error
	GetChannelByName(name string) (*ChannelInfo, error)
	ListAllChannels() ([]ChannelInfo, error)
	ListChannelsForAgent(agent string) ([]ChannelInfo, error)
	FindChannelForAgents(agent1, agent2 string) (channelID string, channelName string, err error)
	InsertChannelMessage(channelID, agent, role, content string, threadID *int64, metadata, sender string) (int64, error)
	RecentChannelMessages(channelID string, limit int) ([]ChannelMessage, error)
}

ChannelBackend is the interface for channel operations. Defined here so dsl/ does not import serve/.

type ChannelDef added in v0.4.0

type ChannelDef struct {
	Description string   `yaml:"description"`
	Team        []string `yaml:"team"`
	Mode        string   `yaml:"mode"` // "" (default) or "social"
}

ChannelDef defines a channel in the DSL.

type ChannelInfo added in v0.3.0

type ChannelInfo struct {
	ID   string
	Name string
	Team []string
}

ChannelInfo holds minimal channel data returned to dsl tools.

type ChannelMessage added in v0.3.0

type ChannelMessage struct {
	Agent   string
	Sender  string
	Content string
}

ChannelMessage holds a single message returned by RecentChannelMessages.

type ChannelPeerResolver added in v0.4.0

type ChannelPeerResolver func(callerAgent, targetAgent string) bool

ChannelPeerResolver checks whether two agents share a channel. Returns true if callerAgent and targetAgent are members of any common channel.

type ChannelPostCallback added in v0.3.0

type ChannelPostCallback func(channelName, agent, content string, msgID int64, threadID *int64)

ChannelPostCallback is called after an agent posts to a channel, so the server can publish SSE events to connected clients.

type ChannelReactiveCallback added in v0.3.0

type ChannelReactiveCallback func(channelName string, team []string, poster string, message string, depth int, triggerMsgID int64)

ChannelReactiveCallback is called after a post_to_channel so that other team members can be notified and optionally respond. triggerMsgID is the message that triggered the reaction, so agents can reply in-thread.

type Company added in v0.3.0

type Company struct {
	ID          string           `yaml:"id" json:"id"`
	Name        string           `yaml:"name" json:"name"`
	Description string           `yaml:"description,omitempty" json:"description,omitempty"`
	Location    string           `yaml:"location,omitempty" json:"location,omitempty"`
	LogoURL     string           `yaml:"logo_url,omitempty" json:"logo_url,omitempty"`
	AccentColor string           `yaml:"accent_color,omitempty" json:"accent_color,omitempty"`
	Siblings    []CompanySibling `yaml:"siblings,omitempty" json:"siblings,omitempty"`
}

Company represents the company identity for a Vega instance.

type CompanySibling added in v0.3.0

type CompanySibling struct {
	Name string `yaml:"name" json:"name"`
	URL  string `yaml:"url" json:"url"`
	Icon string `yaml:"icon,omitempty" json:"icon,omitempty"`
}

CompanySibling represents a sibling Vega instance for company switching.

type DelegateToolOpts added in v0.4.0

type DelegateToolOpts struct {
	SendFn              SendFunc
	TeamResolver        TeamResolver
	ChannelPeerResolver ChannelPeerResolver // optional — allows delegation to channel peers
}

DelegateToolOpts configures the delegate tool.

type DelegationContext

type DelegationContext struct {
	CallerAgent string
	Messages    []llm.Message
}

DelegationContext holds extracted caller context for enriched delegation.

func ExtractCallerContext

func ExtractCallerContext(callerProc *vega.Process, config *DelegationDef) *DelegationContext

ExtractCallerContext reads the last N messages from the caller process, optionally filtering by role. Returns nil if no messages match.

type DelegationDef

type DelegationDef struct {
	ContextWindow int      `yaml:"context_window"` // number of recent messages to forward
	IncludeRoles  []string `yaml:"include_roles"`  // filter by role (user, assistant, system)
	Blackboard    bool     `yaml:"blackboard"`     // enable shared blackboard for team
}

DelegationDef configures context-aware delegation for an agent.

type DelegationObserver added in v0.3.0

type DelegationObserver func(ctx context.Context, fromAgent, toAgent, message, response string)

DelegationObserver is called after each agent-to-agent delegation completes. It receives the caller agent name, target agent name, the delegation message, and the response. Implementations should not block.

type Document

type Document struct {
	Name        string                 `yaml:"name"`
	Description string                 `yaml:"description"`
	Agents      map[string]*Agent      `yaml:"agents"`
	Channels    map[string]*ChannelDef `yaml:"channels"`
	Workflows   map[string]*Workflow   `yaml:"workflows"`
	Tools       map[string]*ToolDef    `yaml:"tools"`
	Settings    *Settings              `yaml:"settings"`
	Company     *Company               `yaml:"company,omitempty"`
}

Document represents a parsed .vega.yaml file.

type ExecutionContext

type ExecutionContext struct {
	// Inputs are the workflow input values
	Inputs map[string]any

	// Variables holds step outputs and set values
	Variables map[string]any

	// CurrentStep is the index of the executing step
	CurrentStep int

	// LoopState for loop iterations
	LoopState *LoopState

	// StartTime is when execution began
	StartTime time.Time

	// Timeout for the entire workflow
	Timeout time.Duration
}

ExecutionContext holds state during workflow execution.

type GlobalSkillsDef

type GlobalSkillsDef struct {
	Directories []string `yaml:"directories"`
}

GlobalSkillsDef configures global skill settings.

type GroupResolver

type GroupResolver func(ctx context.Context) *vega.ProcessGroup

GroupResolver returns the team ProcessGroup for the calling process.

type HeraCallbacks added in v0.4.0

type HeraCallbacks struct {
	OnAgentCreated func(agent *Agent) error
	OnAgentDeleted func(name string)
	ChannelBackend ChannelBackend // optional — auto-creates channels for team leads
}

HeraCallbacks receives notifications when Hera creates or deletes agents. Serve mode uses this to persist composed agents to the database.

type InboxBackend added in v0.3.0

type InboxBackend interface {
	InsertInboxItem(fromAgent, subject, body, priority string) (int64, error)
	ListInboxItems(status string, limit int) ([]InboxItem, error)
	ResolveInboxItem(id int64, resolution string) error
}

InboxBackend is the interface that the store implements for inbox operations. Defined here so dsl/ does not import serve/.

type InboxItem added in v0.3.0

type InboxItem struct {
	ID         int64      `json:"id"`
	FromAgent  string     `json:"from_agent"`
	Subject    string     `json:"subject"`
	Body       string     `json:"body,omitempty"`
	Priority   string     `json:"priority"`
	Status     string     `json:"status"`
	Resolution string     `json:"resolution,omitempty"`
	CreatedAt  time.Time  `json:"created_at"`
	ResolvedAt *time.Time `json:"resolved_at,omitempty"`
}

InboxItem represents a message posted to Iris's inbox by another agent.

type Input

type Input struct {
	Type        string   `yaml:"type"`
	Description string   `yaml:"description"`
	Required    bool     `yaml:"required"`
	Default     any      `yaml:"default"`
	Enum        []string `yaml:"enum"`
	Min         *float64 `yaml:"min"`
	Max         *float64 `yaml:"max"`
}

Input defines a workflow input parameter.

type Interpreter

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

Interpreter executes DSL workflows.

func NewInterpreter

func NewInterpreter(doc *Document, opts ...InterpreterOption) (*Interpreter, error)

NewInterpreter creates a new interpreter for a document.

func (*Interpreter) AddAgent

func (i *Interpreter) AddAgent(name string, def *Agent) error

AddAgent adds and spawns a new agent at runtime.

func (*Interpreter) Agents

func (i *Interpreter) Agents() map[string]*vega.Process

Agents returns a copy of the active agent processes map.

func (*Interpreter) DispatchToAgent added in v0.3.0

func (i *Interpreter) DispatchToAgent(ctx context.Context, agentName string, message string) (string, error)

DispatchToAgent is a non-blocking variant of SendToAgent. It validates the agent exists, then spawns a goroutine that calls SendToAgent. On completion (or error), it posts an inbox item so Iris knows the work finished. Returns immediately with a confirmation message.

func (*Interpreter) Document

func (i *Interpreter) Document() *Document

Document returns the parsed DSL document.

func (*Interpreter) EnsureAgent

func (i *Interpreter) EnsureAgent(name string) (*vega.Process, error)

EnsureAgent ensures the named agent process is spawned and returns it. If the process already exists it is returned immediately; otherwise the agent is lazily spawned from its definition.

func (*Interpreter) Execute

func (i *Interpreter) Execute(ctx context.Context, name string, inputs map[string]any) (any, error)

Execute runs a workflow by name (alias for RunWorkflow).

func (*Interpreter) Orchestrator

func (i *Interpreter) Orchestrator() *vega.Orchestrator

Orchestrator returns the underlying orchestrator.

func (*Interpreter) RemoveAgent

func (i *Interpreter) RemoveAgent(name string) error

RemoveAgent stops and removes an agent at runtime.

func (*Interpreter) RemoveComposedAgents added in v0.4.0

func (i *Interpreter) RemoveComposedAgents()

RemoveComposedAgents kills and removes all agents that were NOT defined in the original YAML file and are not meta-agents (iris, hera). This restores the interpreter to its YAML-defined state after a reset.

func (*Interpreter) ResetAgent

func (i *Interpreter) ResetAgent(name string) error

ResetAgent kills the agent process and removes it from the active map, but preserves the agent definition so it respawns fresh on next use.

func (*Interpreter) RunWorkflow

func (i *Interpreter) RunWorkflow(ctx context.Context, name string, inputs map[string]any) (any, error)

RunWorkflow executes a workflow by name.

func (*Interpreter) SendToAgent

func (i *Interpreter) SendToAgent(ctx context.Context, agentName string, message string) (string, error)

SendToAgent sends a message to a specific agent and returns the response. If the calling context carries an event sink (from a streaming parent), SendToAgent uses streaming and forwards nested tool_start/tool_end events to the parent sink so the UI can display sub-agent activity in real time.

func (*Interpreter) SetChannelBackend added in v0.3.0

func (i *Interpreter) SetChannelBackend(b ChannelBackend, onPost func(channelName, agent, content string, msgID int64, threadID *int64))

SetChannelBackend sets the channel backend used by DispatchToAgent to post completion summaries to the agent's team channel.

func (*Interpreter) SetDelegationObserver added in v0.3.0

func (i *Interpreter) SetDelegationObserver(fn DelegationObserver)

SetDelegationObserver registers a callback that fires after each delegation.

func (*Interpreter) SetDispatchCompleteCallback added in v0.4.0

func (i *Interpreter) SetDispatchCompleteCallback(fn func(agentName string))

SetDispatchCompleteCallback registers a callback that fires when a dispatched agent finishes. The serve layer uses this to immediately send Iris an inbox triage prompt so the loop keeps moving without waiting for the heartbeat.

func (*Interpreter) SetDispatchStartCallback added in v0.4.0

func (i *Interpreter) SetDispatchStartCallback(fn func(agentName string))

SetDispatchStartCallback registers a callback that fires when a dispatched agent begins working. The serve layer uses this to show a busy indicator.

func (*Interpreter) SetInboxBackend added in v0.3.0

func (i *Interpreter) SetInboxBackend(b InboxBackend)

SetInboxBackend sets the inbox backend used by DispatchToAgent for posting completion notifications.

func (*Interpreter) SetMemoryInjector added in v0.3.0

func (i *Interpreter) SetMemoryInjector(fn func(proc *vega.Process, agentName string))

SetMemoryInjector sets a callback that injects memory into an agent process before sending messages. This gives agents access to their stored memories during delegated tasks, not just during direct chat.

func (*Interpreter) SetServerBaseURL added in v0.4.0

func (i *Interpreter) SetServerBaseURL(url string)

SetServerBaseURL sets the base URL of the Vega server so agents can construct workspace URLs for deliverables.

func (*Interpreter) Shutdown

func (i *Interpreter) Shutdown()

Shutdown stops all agents and disconnects MCP servers.

func (*Interpreter) SkillsLoader

func (i *Interpreter) SkillsLoader() *skills.Loader

SkillsLoader returns the global skills loader, or nil if none is configured.

func (*Interpreter) StreamToAgent

func (i *Interpreter) StreamToAgent(ctx context.Context, agentName string, message string) (*vega.ChatStream, error)

StreamToAgent sends a message to a specific agent and returns a ChatStream with structured events for real-time streaming and tool call visibility.

func (*Interpreter) Tools

func (i *Interpreter) Tools() *tools.Tools

Tools returns the tool registry.

type InterpreterOption

type InterpreterOption func(*Interpreter)

InterpreterOption configures the interpreter.

func WithLazySpawn

func WithLazySpawn() InterpreterOption

WithLazySpawn defers agent process creation until first use. Useful for serve mode where agents are only needed when workflows run.

type LoggingDef

type LoggingDef struct {
	Level string `yaml:"level"` // debug, info, warn, error
	File  string `yaml:"file"`
}

LoggingDef is DSL logging configuration.

type LoopState

type LoopState struct {
	Index int
	Count int
	Item  any
	First bool
	Last  bool
}

LoopState tracks loop iteration state.

type MCPDef

type MCPDef struct {
	Servers []MCPServerDef `yaml:"servers"`
}

MCPDef configures MCP servers.

type MCPServerDef

type MCPServerDef struct {
	Name         string            `yaml:"name"`
	Transport    string            `yaml:"transport"`
	Command      string            `yaml:"command"`
	Args         []string          `yaml:"args"`
	Env          map[string]string `yaml:"env"`
	URL          string            `yaml:"url"`
	Headers      map[string]string `yaml:"headers"`
	Timeout      string            `yaml:"timeout"`
	FromRegistry bool              `yaml:"-"` // resolved from registry, not serialized
}

MCPServerDef configures an individual MCP server.

type Parser

type Parser struct {
	// BaseDir for resolving relative paths
	BaseDir string
}

Parser parses .vega.yaml files.

func NewParser

func NewParser() *Parser

NewParser creates a new parser.

func (*Parser) Parse

func (p *Parser) Parse(data []byte) (*Document, error)

Parse parses YAML content into a Document.

func (*Parser) ParseFile

func (p *Parser) ParseFile(path string) (*Document, error)

ParseFile parses a .vega.yaml file.

type RateLimitDef

type RateLimitDef struct {
	RequestsPerMinute int `yaml:"requests_per_minute"`
	TokensPerMinute   int `yaml:"tokens_per_minute"`
}

RateLimitDef is DSL rate limit configuration.

type Repeat

type Repeat struct {
	Steps []Step `yaml:"steps"`
	Until string `yaml:"until"`
	Max   int    `yaml:"max"`
}

Repeat defines a repeat-until loop.

type RetryDef

type RetryDef struct {
	MaxAttempts int    `yaml:"max_attempts"`
	Backoff     string `yaml:"backoff"` // linear, exponential, constant
}

RetryDef is DSL retry configuration.

type ScheduledJob

type ScheduledJob struct {
	Name      string `json:"name"`
	Cron      string `json:"cron"`    // standard 5-field cron expression
	AgentName string `json:"agent"`   // agent to message on schedule
	Message   string `json:"message"` // message to send
	Enabled   bool   `json:"enabled"`
}

ScheduledJob describes a recurring agent trigger.

type SchedulerBackend

type SchedulerBackend interface {
	AddJob(job ScheduledJob) error
	RemoveJob(name string) error
	ListJobs() []ScheduledJob
}

SchedulerBackend is the interface that serve.Scheduler implements. Defined here so dsl/ does not import serve/.

type SendFunc

type SendFunc func(ctx context.Context, agent string, message string) (string, error)

SendFunc sends a message to a named agent and returns the response.

type Settings

type Settings struct {
	DefaultModel       string           `yaml:"default_model"`
	DefaultTemperature *float64         `yaml:"default_temperature"`
	Sandbox            string           `yaml:"sandbox"`
	Budget             string           `yaml:"budget"`
	Supervision        *SupervisionDef  `yaml:"supervision"`
	RateLimit          *RateLimitDef    `yaml:"rate_limit"`
	Logging            *LoggingDef      `yaml:"logging"`
	Tracing            *TracingDef      `yaml:"tracing"`
	MCP                *MCPDef          `yaml:"mcp"`
	Skills             *GlobalSkillsDef `yaml:"skills"`
}

Settings are global configuration.

type SkillsDef

type SkillsDef struct {
	Directories []string `yaml:"directories"`
	Include     []string `yaml:"include"`
	Exclude     []string `yaml:"exclude"`
	MaxActive   int      `yaml:"max_active"`
}

SkillsDef configures skills for an agent.

type Step

type Step struct {
	// Agent step fields
	Agent           string `yaml:"-"` // Extracted from key
	Action          string `yaml:"-"` // Extracted from key
	Send            string `yaml:"send"`
	Save            string `yaml:"save"`
	Timeout         string `yaml:"timeout"`
	Budget          string `yaml:"budget"`
	Retry           int    `yaml:"retry"`
	If              string `yaml:"if"`
	ContinueOnError bool   `yaml:"continue_on_error"`
	Format          string `yaml:"format"` // json, yaml, etc.

	// Control flow fields
	Condition string `yaml:"-"` // For if steps
	Then      []Step `yaml:"then"`
	Else      []Step `yaml:"else"`

	// Loop fields
	ForEach string  `yaml:"for"` // "item in items"
	Repeat  *Repeat `yaml:"repeat"`

	// Parallel fields
	Parallel []Step `yaml:"parallel"`

	// Sub-workflow fields
	Workflow string         `yaml:"workflow"`
	With     map[string]any `yaml:"with"`

	// Special fields
	Set    map[string]any `yaml:"set"`
	Return string         `yaml:"return"`
	Try    []Step         `yaml:"try"`
	Catch  []Step         `yaml:"catch"`

	// Raw for flexible parsing
	Raw map[string]any `yaml:"-"`
}

Step is a workflow step (can be various types). This uses a flexible structure to handle the natural language format.

type SupervisionDef

type SupervisionDef struct {
	Strategy    string `yaml:"strategy"` // restart, stop, escalate
	MaxRestarts int    `yaml:"max_restarts"`
	Window      string `yaml:"window"` // e.g., "10m"
}

SupervisionDef is DSL supervision configuration.

type TeamResolver added in v0.3.0

type TeamResolver func(ctx context.Context) []string

TeamResolver returns the team members for the calling agent from context. It is called at invocation time so that team changes are picked up dynamically.

type ToolDef

type ToolDef struct {
	Name           string      `yaml:"name"`
	Description    string      `yaml:"description"`
	Params         []ToolParam `yaml:"params"`
	Implementation *ToolImpl   `yaml:"implementation"`
	Include        []string    `yaml:"include"` // For loading from files
}

ToolDef is a DSL tool definition.

type ToolImpl

type ToolImpl struct {
	Type    string            `yaml:"type"` // http, exec, file_read, file_write, builtin
	Method  string            `yaml:"method"`
	URL     string            `yaml:"url"`
	Headers map[string]string `yaml:"headers"`
	Query   map[string]string `yaml:"query"`
	Body    any               `yaml:"body"`
	Command string            `yaml:"command"`
	Timeout string            `yaml:"timeout"`
}

ToolImpl defines tool implementation.

type ToolParam

type ToolParam struct {
	Name        string   `yaml:"name"`
	Type        string   `yaml:"type"`
	Description string   `yaml:"description"`
	Required    bool     `yaml:"required"`
	Default     any      `yaml:"default"`
	Enum        []string `yaml:"enum"`
}

ToolParam defines a tool parameter.

type TracingDef

type TracingDef struct {
	Enabled  bool   `yaml:"enabled"`
	Exporter string `yaml:"exporter"` // otlp, jaeger, json
	Endpoint string `yaml:"endpoint"`
}

TracingDef is DSL tracing configuration.

type ValidationError

type ValidationError struct {
	File    string
	Line    int
	Column  int
	Field   string
	Message string
	Hint    string
}

ValidationError provides detailed DSL validation errors.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type Workflow

type Workflow struct {
	Description string            `yaml:"description"`
	Inputs      map[string]*Input `yaml:"inputs"`
	Steps       []Step            `yaml:"steps"`
	Output      any               `yaml:"output"` // string or map
}

Workflow represents a workflow definition in the DSL.

Jump to

Keyboard shortcuts

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