node

package
v0.0.0-...-bea47b1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultMaxResponseBytes int64 = 10 << 20 // 10 MiB

DefaultMaxResponseBytes caps how much of an HTTP response body is read.

Variables

View Source
var ErrDestinationBlocked = errors.New("outbound destination blocked by policy")

ErrDestinationBlocked is returned when an outbound request targets an address the OutboundPolicy does not allow (e.g. loopback, private ranges, or cloud metadata endpoints).

View Source
var ErrResponseTooLarge = errors.New("response body exceeds size limit")

ErrResponseTooLarge is returned when a response body exceeds the limit.

Functions

func CheckScheme

func CheckScheme(u *url.URL) error

CheckScheme rejects non-http(s) URLs with ErrDestinationBlocked.

func NewOutboundClient

func NewOutboundClient(p OutboundPolicy) *http.Client

NewOutboundClient returns an HTTP client that enforces the policy on every connection (for other node packages that make outbound requests).

func NewOutboundDialer

func NewOutboundDialer(p OutboundPolicy) func(ctx context.Context, network, addr string) (net.Conn, error)

NewOutboundDialer returns a dial function that enforces the policy (for non-HTTP protocols such as SMTP).

func ReadLimited

func ReadLimited(r io.Reader, limit int64) ([]byte, error)

ReadLimited reads at most limit bytes (limit < 0: unlimited) and fails with ErrResponseTooLarge beyond that.

Types

type AINode

type AINode struct{}

AINode represents a node that calls AI APIs (OpenAI, Anthropic, Gemini) Config:

  • "provider" (string) : "openai" | "anthropic" | "gemini"
  • "api_key" (string) : API key for the provider (prefer api_key_env in production)
  • "api_key_env" (string) : Environment variable name holding the API key
  • "model" (string) : Model name (e.g., "gpt-4", "claude-3-sonnet", "gemini-pro")
  • "prompt" (string) : Prompt template with {{.field}} syntax
  • "system_prompt" (string) : Optional system message
  • "temperature" (float) : Optional (0.0-2.0)
  • "max_tokens" (int) : Optional max response tokens
  • "result_key" (string) : Key to store AI response (default: "ai_response")

func (*AINode) Execute

func (n *AINode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

func (*AINode) Validate

func (n *AINode) Validate(config map[string]interface{}) error

type ConditionNode

type ConditionNode struct{}

ConditionNode evaluates a condition and returns a branch ("true" or "false").

Config:

  • "variable" (string) : key to read from the input JSON
  • "operator" (string) : ==, !=, >, <, >=, <=, contains, not_contains
  • "value" (any) : value to compare against

Output: {"branch": "true"} or {"branch": "false"} Original input fields are preserved alongside "branch" so downstream nodes can still read them without needing a transform step.

func (*ConditionNode) Execute

func (n *ConditionNode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

func (*ConditionNode) Validate

func (n *ConditionNode) Validate(config map[string]interface{}) error

type FunctionNode

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

FunctionNode executes user-registered functions

func NewFunctionNode

func NewFunctionNode() *FunctionNode

func (*FunctionNode) Execute

func (fn *FunctionNode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

Execute runs the specified function from the registry

func (*FunctionNode) SetRegistry

func (fn *FunctionNode) SetRegistry(registry RegistryInterface)

SetRegistry sets the registry that contains the functions

func (*FunctionNode) Validate

func (fn *FunctionNode) Validate(config map[string]interface{}) error

type HTTPNode

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

func NewHTTPNode

func NewHTTPNode() *HTTPNode

NewHTTPNode returns an HTTP node with the secure default OutboundPolicy.

func NewHTTPNodeWithPolicy

func NewHTTPNodeWithPolicy(p OutboundPolicy) *HTTPNode

NewHTTPNodeWithPolicy returns an HTTP node restricted by policy.

func (*HTTPNode) Execute

func (h *HTTPNode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

func (*HTTPNode) Validate

func (h *HTTPNode) Validate(config map[string]interface{}) error

type HumanTaskNode

type HumanTaskNode struct{}

HumanTaskNode pauses the workflow until a human Claim/Complete (or Advance). Config:

  • assignees []string
  • candidate_groups []string
  • claim_mode: "any" | "all" | "first" (default "any")
  • due_at: RFC3339 string (optional)
  • priority: number (optional)
  • execution_mode: typically "interactive" (steps are created WAITING)
  • timeout: duration string (optional, same as signal)

func (*HumanTaskNode) Execute

func (h *HumanTaskNode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

func (*HumanTaskNode) Validate

func (h *HumanTaskNode) Validate(config map[string]interface{}) error

type LogNode

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

LogNode writes a structured audit log entry and passes input downstream unchanged.

Config:

  • "message" (string, required) : log message
  • "level" (string, optional) : "info" | "warn" | "error" (default: "info")
  • "fields" (map, optional) : extra fixed fields to include in the log entry

Output: passes input JSON through unchanged (non-transforming, side-effect node)

func NewLogNode

func NewLogNode() *LogNode

func (*LogNode) Execute

func (n *LogNode) Execute(_ context.Context, config map[string]interface{}, input string) (string, error)

func (*LogNode) Validate

func (n *LogNode) Validate(config map[string]interface{}) error

type NotifyNode

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

NotifyNode sends an HTTP webhook / notification to a target URL. It supports Go template rendering in both the URL and the body, using the step's input JSON as template data.

Config:

  • "url" (string, required) : destination URL (can contain {{.field}} templates)
  • "method" (string, optional) : HTTP method, defaults to POST
  • "headers" (map, optional) : extra headers e.g. {"Authorization": "Bearer xyz"}
  • "body" (string, optional) : Go template for the request body If not set, the raw input JSON is forwarded.

Output: raw HTTP response body from the webhook endpoint

func NewNotifyNode

func NewNotifyNode() *NotifyNode

NewNotifyNode returns a notify node with the secure default OutboundPolicy (15s timeout).

func NewNotifyNodeWithPolicy

func NewNotifyNodeWithPolicy(p OutboundPolicy) *NotifyNode

NewNotifyNodeWithPolicy returns a notify node restricted by policy.

func (*NotifyNode) Execute

func (n *NotifyNode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

func (*NotifyNode) Validate

func (n *NotifyNode) Validate(config map[string]interface{}) error

type OutboundPolicy

type OutboundPolicy struct {
	// AllowPrivateNetworks permits loopback, RFC1918/ULA private, link-local
	// (including 169.254.169.254 metadata) and other non-public addresses.
	AllowPrivateNetworks bool
	// AllowedHosts are always reachable even when private: exact hostnames
	// ("billing.internal"), IPs, or CIDRs ("10.20.0.0/16").
	AllowedHosts []string
	// MaxResponseBytes caps response bodies; 0 means DefaultMaxResponseBytes,
	// negative means unlimited.
	MaxResponseBytes int64
	// Timeout is the whole-request timeout; 0 means 30s.
	Timeout time.Duration
}

OutboundPolicy controls which destinations the http and notify nodes may reach. The zero value is the secure default: only public internet addresses over http/https, 30s timeout, 10 MiB response cap.

Workflow definitions may come from untrusted sources (imported templates, tenant users), so by default nodes cannot be used to reach the host itself, the internal network, or cloud metadata services (SSRF).

func (OutboundPolicy) MaxResponseBytesOrDefault

func (p OutboundPolicy) MaxResponseBytesOrDefault() int64

MaxResponseBytes returns the effective response cap of a policy (negative = unlimited).

type RegistryInterface

type RegistryInterface interface {
	GetFunction(name string) (func(context.Context, map[string]interface{}) (map[string]interface{}, error), bool)
	ListFunctions() []string
}

RegistryInterface is the minimal interface FunctionNode needs from Registry

type SetVariableNode

type SetVariableNode struct{}

SetVariableNode injects or overwrites keys on the flowing JSON context and also persists them to durable execution variables when an engine is attached via context.

func (*SetVariableNode) Execute

func (n *SetVariableNode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

func (*SetVariableNode) Validate

func (n *SetVariableNode) Validate(config map[string]interface{}) error

type SignalNode

type SignalNode struct{}

SignalNode represents a point in the workflow that waits for external input (Signal). It returns a special status that causes the worker to pause execution for this path.

func (*SignalNode) Execute

func (s *SignalNode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

func (*SignalNode) Validate

func (s *SignalNode) Validate(config map[string]interface{}) error

type SubWorkflowEngine

type SubWorkflowEngine interface {
	StartWorkflow(ctx context.Context, namespace, workflowID string, input string) (string, error)
	GetExecutionStatus(ctx context.Context, namespace, execID string) (*models.Execution, error)
}

SubWorkflowEngine interface to avoid circular dependency

type SubWorkflowNode

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

func NewSubWorkflowNode

func NewSubWorkflowNode(e SubWorkflowEngine) *SubWorkflowNode

func (*SubWorkflowNode) Execute

func (s *SubWorkflowNode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

func (*SubWorkflowNode) SetEngine

func (s *SubWorkflowNode) SetEngine(e SubWorkflowEngine)

func (*SubWorkflowNode) Validate

func (s *SubWorkflowNode) Validate(config map[string]interface{}) error

type SwitchNode

type SwitchNode struct{}

SwitchNode routes execution to one of N branches based on the value of a field. Unlike ConditionNode (true/false only), SwitchNode supports any number of cases.

Config:

  • "variable" (string, required): the field name to read from input JSON
  • "cases" (map, required) : map of expected value -> branch label Example: {"premium": "branch-premium", "free": "branch-free"}
  • "default" (string, optional): branch label when no case matches (defaults to "default")

Output: JSON with "branch" set to the matched case label.

The DAG engine uses this to follow only the matching edge.

Usage in workflow edges:

{ "sourceId": "switch-node", "targetId": "handle-premium", "condition": "branch-premium" }
{ "sourceId": "switch-node", "targetId": "handle-free",    "condition": "branch-free"    }
{ "sourceId": "switch-node", "targetId": "handle-default", "condition": "default"        }

func (*SwitchNode) Execute

func (n *SwitchNode) Execute(_ context.Context, config map[string]interface{}, input string) (string, error)

func (*SwitchNode) Validate

func (n *SwitchNode) Validate(config map[string]interface{}) error

type TransformNode

type TransformNode struct{}

TransformNode reshapes or filters JSON data between two nodes.

Config:

  • "mapping" (map[string]string): maps output keys to Go template expressions Example: {"fullName": "{{.first_name}} {{.last_name}}", "email": "{{.email}}"}

Input: JSON object Output: new JSON object with keys defined by mapping

func (*TransformNode) Execute

func (n *TransformNode) Execute(_ context.Context, config map[string]interface{}, input string) (string, error)

func (*TransformNode) Validate

func (n *TransformNode) Validate(config map[string]interface{}) error

type WaitNode

type WaitNode struct{}

func (*WaitNode) Execute

func (w *WaitNode) Execute(ctx context.Context, config map[string]interface{}, input string) (string, error)

func (*WaitNode) Validate

func (w *WaitNode) Validate(config map[string]interface{}) error

Jump to

Keyboard shortcuts

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