Documentation
¶
Index ¶
- func DefaultEvaluator(ctx context.Context, condition string, input any) (bool, error)
- func DefaultInterpolator(ctx context.Context, templateStr string, data any) (string, error)
- func HTMLInterpolator(ctx context.Context, templateStr string, data any) (string, error)
- func LegacyInterpolator(ctx context.Context, templateStr string, data any) (string, error)
- type ConditionEvaluator
- type ContextTypeValidationError
- type ContextValidationError
- type Engine
- func (e *Engine) Inspect() ([]domain.Node, error)
- func (e *Engine) Navigate(ctx context.Context, currentState *domain.State, input any) (*domain.State, error)
- func (e *Engine) Render(ctx context.Context, currentState *domain.State) ([]domain.ActionRequest, bool, error)
- func (e *Engine) Signal(ctx context.Context, currentState *domain.State, signalName string) (*domain.State, error)
- func (e *Engine) Start(ctx context.Context, sessionID string, initialContext map[string]any) (*domain.State, error)
- type EngineOption
- type Interpolator
- type UnhandledToolError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultEvaluator ¶ added in v0.3.0
DefaultEvaluator implements the basic "condition: input == 'value'" logic.
func DefaultInterpolator ¶ added in v0.5.0
DefaultInterpolator uses Go's text/template — no HTML escaping. Suitable for CLI, plain text, and Markdown flows. For browser output, use HTMLInterpolator instead.
func HTMLInterpolator ¶ added in v0.7.16
HTMLInterpolator uses Go's html/template — escapes HTML characters automatically. Use this when the rendered output is sent directly to a browser (e.g., Chat UI / SSE). Inject it via: trellis.New(dir, trellis.WithInterpolator(runtime.HTMLInterpolator))
Types ¶
type ConditionEvaluator ¶ added in v0.3.0
ConditionEvaluator is a function that determines if a transition condition is met.
type ContextTypeValidationError ¶ added in v0.7.6
ContextTypeValidationError represents a failure to meet context schema requirements.
func (*ContextTypeValidationError) Error ¶ added in v0.7.6
func (e *ContextTypeValidationError) Error() string
type ContextValidationError ¶ added in v0.5.1
ContextValidationError represents a failure to meet context requirements.
func (*ContextValidationError) Error ¶ added in v0.5.1
func (e *ContextValidationError) Error() string
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the core state machine runner.
func NewEngine ¶
func NewEngine(loader ports.GraphLoader, evaluator ConditionEvaluator, interpolator Interpolator, opts ...EngineOption) *Engine
NewEngine creates a new engine with dependencies. The engine is immutable after creation. interpolator is optional; if nil, DefaultInterpolator (Standard Go Templates) is used.
func (*Engine) Inspect ¶ added in v0.3.0
Inspect returns a structured view of the entire graph by walking all nodes.
func (*Engine) Render ¶ added in v0.3.2
func (e *Engine) Render(ctx context.Context, currentState *domain.State) ([]domain.ActionRequest, bool, error)
Render calculates the presentation for the current state. It loads the node and generates actions (e.g. print text) but does NOT change state. It returns actions, isTerminal (true if no transitions), and error.
type EngineOption ¶ added in v0.5.1
type EngineOption func(*Engine)
EngineOption allows configuring the engine via functional options.
func WithContentConverter ¶ added in v0.7.17
func WithContentConverter(converter ports.ContentConverter) EngineOption
WithContentConverter configures an optional post-interpolation content transformer. The engine is agnostic of what this does — it could be Markdown-to-HTML, sanitization, etc.
func WithDefaultErrorNode ¶ added in v0.7.0
func WithDefaultErrorNode(nodeID string) EngineOption
WithDefaultErrorNode sets a global fallback node for tool errors.
func WithEntryNode ¶ added in v0.5.3
func WithEntryNode(nodeID string) EngineOption
WithEntryNode configures the initial node ID (default: "start").
func WithLifecycleHooks ¶ added in v0.5.1
func WithLifecycleHooks(hooks domain.LifecycleHooks) EngineOption
WithLifecycleHooks registers observability hooks.
func WithLogger ¶ added in v0.5.3
func WithLogger(logger *slog.Logger) EngineOption
WithLogger configures the structured logger for the engine.
type Interpolator ¶ added in v0.5.0
Interpolator is a function that replaces variables in a string with values from data.
type UnhandledToolError ¶ added in v0.5.1
UnhandledToolError represents a failure to handle a tool error. It provides structured context for debugging.
func (*UnhandledToolError) Error ¶ added in v0.5.1
func (e *UnhandledToolError) Error() string