runtime

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binary added in v0.2.1

type Binary struct {
	Type string // MIME type (e.g., "image/png", "image/jpeg")
	Data []byte
}

Input/Output content is binary data (images, files, etc)

func (Binary) ContentType added in v0.2.1

func (b Binary) ContentType() string

func (Binary) HKT1 added in v0.2.1

func (Binary) HKT1(Gist)

type Cache

type Cache struct {
	Prompter
	// contains filtered or unexported fields
}

func NewCache

func NewCache(cache storage.Storage, workflow, job, step, hash string, p Prompter) *Cache

func (*Cache) Prompt

func (e *Cache) Prompt(ctx context.Context, in Event, opts ...chatter.Opt) (Event, error)

type CacheMetadata added in v0.2.4

type CacheMetadata struct {
	Key         string    `yaml:"key"`
	Workflow    string    `yaml:"workflow"`
	Job         string    `yaml:"job"`
	Step        string    `yaml:"step"`
	ContentType string    `yaml:"content_type"`
	Timestamp   time.Time `yaml:"timestamp"`
}

CacheMetadata represents the YAML front matter in cache files

type Emitter

type Emitter struct {
	Prompter
	// contains filtered or unexported fields
}

func NewEmitter

func NewEmitter(sink iosystem.Sink, prefix string, p Prompter) *Emitter

func (*Emitter) Prompt

func (e *Emitter) Prompt(ctx context.Context, in Event, opts ...chatter.Opt) (Event, error)

type Event

type Event struct {
	// Unique identity of the document
	Key iosystem.Key

	// Original workflow input
	Document Gist

	// Current input being processed
	Current Gist

	// Named step outputs
	Steps map[string]Gist
}

Event represents an event processed by the workflow.

func NewEvent

func NewEvent(key iosystem.Key, doc Gist) Event

type ForEach

type ForEach struct {
	Node *ast.ForeachStepNode
	// contains filtered or unexported fields
}

func NewForEach

func NewForEach(node *ast.ForeachStepNode, selector cel.Program) (*ForEach, error)

func (*ForEach) Config

func (f *ForEach) Config(jobs map[string]*Job) error

func (*ForEach) Prompt

func (f *ForEach) Prompt(ctx context.Context, in Event, opts ...chatter.Opt) (Event, error)

type Formatter

type Formatter interface {
	// Format converts Gist into serialized output.
	// Input: results from agent as Gist
	// Output: serialized data represented as Gist and its content type
	Format(Gist) (string, Gist, error)
}

Formatter serializes results into output format.

Use cases:

  • JSON: Structured arrays for downstream processing
  • JSONL: Streaming-friendly newline-delimited JSON
  • Text: Human-readable concatenation with custom delimiters

func NewFormatter

func NewFormatter(format *ast.FormatNode) (Formatter, error)

NewFormatter creates formatter based on AST format node. Returns appropriate formatter or error for unknown types.

type Gist

type Gist interface {
	HKT1(Gist)
	ContentType() string
}

Input/Output content

func ToGist

func ToGist(x any) (Gist, error)

type JSONFormatter

type JSONFormatter struct{}

JSONFormatter returns results as JSON array (default). Output: Go slice ([]any) that will be JSON-encoded downstream.

func NewJSONFormatter

func NewJSONFormatter() *JSONFormatter

NewJSONFormatter creates a JSON array formatter

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(results Gist) (string, Gist, error)

Format returns results as-is (already a Go array). Downstream JSON encoding will serialize it as [...].

type Job

type Job struct {
	Name  string
	Steps []Prompter
}

func NewJob

func NewJob(name string, steps []Prompter) *Job

func (*Job) Config

func (j *Job) Config(jobs map[string]*Job) error

func (*Job) Prompt

func (j *Job) Prompt(ctx context.Context, in Event, opts ...chatter.Opt) (Event, error)

type Json

type Json map[string]any

Input/Output content is JSON

func (Json) ContentType

func (Json) ContentType() string

func (Json) HKT1

func (Json) HKT1(Gist)

type List

type List []any

Input/Output content is a JSON array

func (List) ContentType

func (List) ContentType() string

func (List) HKT1

func (List) HKT1(Gist)

type Manifold

type Manifold struct {
	Node *ast.AgentNode
	// contains filtered or unexported fields
}

Manifold is an agent state machine bound with input/output event types.

func NewManifold

func NewManifold(node *ast.AgentNode, llm chatter.Chatter) (agt *Manifold, err error)

Create a new manifold instance

func (*Manifold) Config

func (agt *Manifold) Config(map[string]*Job) error

func (*Manifold) Prompt

func (agt *Manifold) Prompt(ctx context.Context, in Event, opt ...chatter.Opt) (Event, error)

Executes the agent with given input and returns the output

type Memento

type Memento struct {
	Prompter
	// contains filtered or unexported fields
}

Memento stores the output of the Prompter into a variable.

func NewMemento

func NewMemento(variable string, p Prompter) *Memento

func (*Memento) Prompt

func (m *Memento) Prompt(ctx context.Context, evt Event, opts ...chatter.Opt) (Event, error)

type Printer

type Printer struct {
	Prompter
}

func NewPrinter

func NewPrinter(p Prompter) *Printer

func (*Printer) Prompt

func (p *Printer) Prompt(ctx context.Context, evt Event, opts ...chatter.Opt) (Event, error)

type Prompter

type Prompter interface {
	Config(map[string]*Job) error
	Prompt(context.Context, Event, ...chatter.Opt) (Event, error)
}

type Repeater

type Repeater struct {
	Node *ast.RetryNode

	Prompter
	// contains filtered or unexported fields
}

func NewRepeater

func NewRepeater(node *ast.RetryNode, p Prompter) *Repeater

func (*Repeater) Config

func (r *Repeater) Config(jobs map[string]*Job) error

func (*Repeater) Prompt

func (r *Repeater) Prompt(ctx context.Context, evt Event, opts ...chatter.Opt) (Event, error)

type Router

type Router struct {
	Node       *ast.RouterStepNode
	Prompter   Prompter
	Conditions []cel.Program
	Routes     map[string]Prompter
	Default    Prompter
}

func NewRouter

func NewRouter(node *ast.RouterStepNode, prompter Prompter, conditions []cel.Program) *Router

func (*Router) Config

func (r *Router) Config(jobs map[string]*Job) error

func (*Router) Prompt

func (r *Router) Prompt(ctx context.Context, in Event, opts ...chatter.Opt) (Event, error)

type Shell

type Shell struct {
	Command string // Compiled template for the command
	Shell   string // Shell to use (sh, bash, zsh, etc.)
}

func NewShell

func NewShell(shell, command string) (*Shell, error)

func (*Shell) Config

func (s *Shell) Config(map[string]*Job) error

func (*Shell) Prompt

func (s *Shell) Prompt(ctx context.Context, in Event, opts ...chatter.Opt) (Event, error)

type Text

type Text string

Input/Output content is plain text

func (Text) ContentType

func (Text) ContentType() string

func (Text) HKT1

func (Text) HKT1(Gist)

type TextFormatter

type TextFormatter struct {
	Delimiter string
}

TextFormatter concatenates results with configurable delimiter. Useful for human-readable summaries or simple text aggregation.

func NewTextFormatter

func NewTextFormatter(delimiter string) *TextFormatter

NewTextFormatter creates a text formatter with custom delimiter

func (*TextFormatter) Format

func (f *TextFormatter) Format(results Gist) (string, Gist, error)

Format converts results to delimited text string. Non-string results are JSON-encoded first.

Jump to

Keyboard shortcuts

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