Documentation
¶
Overview ¶
Package variable provides a typed variable system for the graph engine. It supports variable schemas, reference resolution, validation, and default value application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsRef ¶ added in v0.1.6
ContainsRef reports whether s contains at least one resolvable ${scope.name} reference (i.e. the content inside braces must have a dot-separated scope and name, matching what lookup actually resolves).
func ExtractRefs ¶
ExtractRefs returns all ${scope.name} references found in a string.
Types ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves ${scope.name} variable references in strings. It is not safe for concurrent use; use Clone to create independent copies for parallel branches.
func (*Resolver) Clone ¶
Clone creates an independent deep copy of this Resolver. All nested maps and slices are recursively copied so that parallel branches cannot mutate each other's state.
func (*Resolver) Resolve ¶
Resolve replaces all ${scope.name} references in template with actual values. References that cannot be resolved are left unchanged.
func (*Resolver) ResolveMap ¶
ResolveMap resolves all string values in a config map. Non-string values are passed through unchanged.
When a string value is exactly a single ${scope.name} reference (no surrounding text), the resolved value preserves the original type from the scope (e.g. float64, int, bool). This allows board variables to inject typed config values such as temperature.
type Schema ¶
type Schema struct {
Variables []Variable `json:"variables" yaml:"variables"`
}
Schema defines the input/output variable schema for an App or node.
func (*Schema) ApplyDefaults ¶
ApplyDefaults fills in default values for missing variables. Returns a new map; the original is not modified.
func (*Schema) RequiredNames ¶
RequiredNames returns the names of all required variables.
func (*Schema) ToJSONSchema ¶
ToJSONSchema converts the schema to a JSON Schema map (for LLM tool definitions).
type Variable ¶
type Variable struct {
Name string `json:"name" yaml:"name"`
Type Type `json:"type" yaml:"type"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
DefaultValue any `json:"default,omitempty" yaml:"default,omitempty"`
MaxLength int `json:"max_length,omitempty" yaml:"max_length,omitempty"`
Enum []any `json:"enum,omitempty" yaml:"enum,omitempty"`
ItemType Type `json:"item_type,omitempty" yaml:"item_type,omitempty"`
Properties []Variable `json:"properties,omitempty" yaml:"properties,omitempty"`
}
Variable represents a typed variable with metadata.
func (*Variable) ApplyDefault ¶
ApplyDefault returns the default value if value is nil.