templates

package
v0.0.0-...-b1df1f7 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLoadError

func IsLoadError(err error) bool

IsLoadError returns true when err represents aggregated template load failures.

func MakeKey

func MakeKey(name, version string) string

MakeKey produces the canonical map key for a template name/version pair.

func ValidateTemplate

func ValidateTemplate(tpl *Template) error

ValidateTemplate performs structural checks and returns a ValidationError when problems exist.

Types

type Entry

type Entry struct {
	Key         string
	Template    *Template
	SourcePath  string
	ContentHash string
	LoadedAt    time.Time
}

Entry captures a loaded template alongside bookkeeping data.

type ExecutableNode

type ExecutableNode struct {
	ID             string
	Type           NodeType
	Strategy       StrategyType
	BudgetMax      int
	ToolsAllowlist []string
	OnFail         *TemplateNodeFailure
	Metadata       map[string]interface{}
	DependsOn      []string
}

ExecutableNode represents a compiled template node ready for execution.

type ExecutablePlan

type ExecutablePlan struct {
	TemplateName    string
	TemplateVersion string
	Defaults        TemplateDefaults
	Nodes           map[string]ExecutableNode
	Order           []string
	Adjacency       map[string][]string
	Checksum        string
}

ExecutablePlan is a deterministic representation of a template ready for workflow execution.

func CompileTemplate

func CompileTemplate(tpl *Template) (*ExecutablePlan, error)

CompileTemplate converts a validated template into an ExecutablePlan.

type LoadError

type LoadError struct {
	Failures []string
}

LoadError aggregates template loading failures.

func (*LoadError) Error

func (e *LoadError) Error() string

Error implements the error interface.

type NodeType

type NodeType string

NodeType enumerates supported template node types.

const (
	NodeTypeSimple     NodeType = "simple"
	NodeTypeDAG        NodeType = "dag"
	NodeTypeSupervisor NodeType = "supervisor"
	NodeTypeCognitive  NodeType = "cognitive"
)

type Registry

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

Registry maintains an in-memory catalogue of templates loaded from disk.

func NewRegistry

func NewRegistry() *Registry

NewRegistry constructs an empty registry.

func (*Registry) Finalize

func (r *Registry) Finalize() error

Finalize resolves template inheritance/composition and re-validates the registry.

func (*Registry) Find

func (r *Registry) Find(name, version string) (Entry, bool)

Find attempts to locate a template entry by name and optional version. When version is empty, the first matching version (sorted by name/version) is returned.

func (*Registry) Get

func (r *Registry) Get(key string) (Entry, bool)

Get returns the template entry that matches the supplied key.

func (*Registry) List

func (r *Registry) List() []TemplateSummary

List summaries of all currently loaded templates.

func (*Registry) LoadDirectory

func (r *Registry) LoadDirectory(root string) error

LoadDirectory loads every YAML template under the provided directory.

type StrategyType

type StrategyType string

StrategyType enumerates supported execution strategies within templates.

const (
	StrategyReact          StrategyType = "react"
	StrategyChainOfThought StrategyType = "chain_of_thought"
	StrategyTreeOfThoughts StrategyType = "tree_of_thoughts"
	StrategyDebate         StrategyType = "debate"
	StrategyReflection     StrategyType = "reflection"
)

type Template

type Template struct {
	Name        string           `yaml:"name"`
	Description string           `yaml:"description"`
	Version     string           `yaml:"version"`
	Extends     []string         `yaml:"extends"`
	Defaults    TemplateDefaults `yaml:"defaults"`
	Nodes       []TemplateNode   `yaml:"nodes"`
	Edges       []TemplateEdge   `yaml:"edges"`
	Metadata    map[string]any   `yaml:"metadata"`
}

Template captures the raw user-defined workflow structure.

func LoadTemplate

func LoadTemplate(r io.Reader) (*Template, error)

LoadTemplate parses a template from the provided reader.

func LoadTemplateFromFile

func LoadTemplateFromFile(path string) (*Template, error)

LoadTemplateFromFile reads a YAML template from disk.

func (*Template) NodeByID

func (t *Template) NodeByID(id string) *TemplateNode

NodeByID returns a pointer to the node with the supplied ID, if present.

type TemplateDefaults

type TemplateDefaults struct {
	ModelTier       string `yaml:"model_tier"`
	BudgetAgentMax  int    `yaml:"budget_agent_max"`
	RequireApproval *bool  `yaml:"require_approval"`
}

TemplateDefaults define shared knobs applied to nodes when individual values are absent.

type TemplateEdge

type TemplateEdge struct {
	From string `yaml:"from"`
	To   string `yaml:"to"`
}

TemplateEdge expresses an explicit edge in the workflow graph.

type TemplateNode

type TemplateNode struct {
	ID             string               `yaml:"id"`
	Type           NodeType             `yaml:"type"`
	Strategy       StrategyType         `yaml:"strategy"`
	DependsOn      []string             `yaml:"depends_on"`
	BudgetMax      *int                 `yaml:"budget_max"`
	ToolsAllowlist []string             `yaml:"tools_allowlist"`
	OnFail         *TemplateNodeFailure `yaml:"on_fail"`
	Metadata       map[string]any       `yaml:"metadata"`
}

TemplateNode defines a workflow node within a template.

type TemplateNodeFailure

type TemplateNodeFailure struct {
	DegradeTo  StrategyType `yaml:"degrade_to"`
	Retry      int          `yaml:"retry"`
	EscalateTo NodeType     `yaml:"escalate_to"`
}

TemplateNodeFailure specifies backoff behaviour when a node fails.

type TemplateSummary

type TemplateSummary struct {
	Name        string
	Version     string
	Key         string
	ContentHash string
	SourcePath  string
}

TemplateSummary exposes lightweight information about a registered template.

type ValidationError

type ValidationError struct {
	Issues []ValidationIssue
}

ValidationError aggregates template validation failures.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) HasIssues

func (e *ValidationError) HasIssues() bool

HasIssues reports whether any validation problems were captured.

func (*ValidationError) Messages

func (e *ValidationError) Messages() []string

Messages returns just the human-readable text for each issue.

type ValidationIssue

type ValidationIssue struct {
	Code    string
	Message string
}

ValidationIssue captures a single validation failure with a stable code for metrics.

Jump to

Keyboard shortcuts

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