Documentation
¶
Overview ¶
Package node provides the Go-native LLM and Knowledge graph nodes.
Index ¶
- Constants
- func PortsForType(nodeType string) (input, output []graph.Port)
- func RegisterBuiltinSchemas(reg *SchemaRegistry)
- func RegisterDefaultBuilder(nodeType string, builder NodeBuilder)
- func RegisterDefaultSchema(schema NodeSchema)
- func RegisterFallbackBuilder(builder NodeBuilder)
- type BoardVarSpec
- type BuildContext
- type Factory
- func (f *Factory) Build(def graph.NodeDefinition) (graph.Node, error)
- func (f *Factory) Fallback() NodeBuilder
- func (f *Factory) RegisterBuilder(nodeType string, builder NodeBuilder)
- func (f *Factory) SetFallback(builder NodeBuilder)
- func (f *Factory) ValidateConsistency(schemas *SchemaRegistry) []string
- type FactoryOption
- func WithCommandRunner(cr workspace.CommandRunner) FactoryOption
- func WithLLMResolver(r llm.LLMResolver) FactoryOption
- func WithScriptFS(fsys fs.FS) FactoryOption
- func WithScriptRuntime(rt script.Runtime) FactoryOption
- func WithToolRegistry(tr *tool.Registry) FactoryOption
- func WithWorkspace(ws workspace.Workspace) FactoryOption
- type FieldSchema
- type LLMConfig
- type LLMNode
- func (n *LLMNode) Config() map[string]any
- func (n *LLMNode) ExecuteBoard(ctx graph.ExecutionContext, board *graph.Board) error
- func (n *LLMNode) ID() string
- func (n *LLMNode) InputPorts() []graph.Port
- func (n *LLMNode) OutputPorts() []graph.Port
- func (n *LLMNode) SetConfig(c map[string]any)
- func (n *LLMNode) Type() string
- type NodeBuilder
- type NodeSchema
- type PortSchema
- type RuntimeSpec
- type SchemaRegistry
- func (r *SchemaRegistry) All() []NodeSchema
- func (r *SchemaRegistry) Get(nodeType string) (NodeSchema, bool)
- func (r *SchemaRegistry) Len() int
- func (r *SchemaRegistry) Register(schema NodeSchema)
- func (r *SchemaRegistry) RegisterMany(schemas []NodeSchema)
- func (r *SchemaRegistry) Unregister(nodeType string)
- type SelectOption
Constants ¶
const ( VarResponse = "response" VarUsage = "usage" VarToolPending = "tool_pending" VarToolOutput = "tool_output" VarToolCalls = "__tool_calls" )
Board variable keys used by builtin node implementations (LLM, template, etc.).
Variables ¶
This section is empty.
Functions ¶
func PortsForType ¶
PortsForType returns the graph.Port slices for a registered node type, derived from the schema's PortSchema definitions. This is the single source of truth — jsnode and other implementations should call this instead of hardcoding port definitions.
func RegisterBuiltinSchemas ¶
func RegisterBuiltinSchemas(reg *SchemaRegistry)
func RegisterDefaultBuilder ¶
func RegisterDefaultBuilder(nodeType string, builder NodeBuilder)
RegisterDefaultBuilder is called by node packages in init() to register their node type builders.
func RegisterDefaultSchema ¶
func RegisterDefaultSchema(schema NodeSchema)
func RegisterFallbackBuilder ¶
func RegisterFallbackBuilder(builder NodeBuilder)
RegisterFallbackBuilder sets the fallback builder used when no explicit builder matches.
Types ¶
type BoardVarSpec ¶
type BoardVarSpec struct {
Key string `json:"key"`
Type string `json:"type"`
Desc string `json:"desc"`
Condition string `json:"condition,omitempty"`
}
BoardVarSpec describes a single board variable that a node reads or writes.
type BuildContext ¶
type BuildContext struct {
LLMResolver llm.LLMResolver
ToolRegistry *tool.Registry
ScriptRuntime script.Runtime
ScriptFS fs.FS
Workspace workspace.Workspace
CommandRunner workspace.CommandRunner
}
BuildContext provides runtime dependencies for node construction.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory manages NodeBuilder registration and constructs nodes from definitions.
func NewFactory ¶
func NewFactory(opts ...FactoryOption) *Factory
NewFactory creates a new Factory, copying from the default builder registry.
func (*Factory) Fallback ¶
func (f *Factory) Fallback() NodeBuilder
Fallback returns the current fallback builder (may be nil).
func (*Factory) RegisterBuilder ¶
func (f *Factory) RegisterBuilder(nodeType string, builder NodeBuilder)
RegisterBuilder registers a builder for a specific node type on this instance.
func (*Factory) SetFallback ¶
func (f *Factory) SetFallback(builder NodeBuilder)
SetFallback sets a builder that is tried when no explicit builder matches.
func (*Factory) ValidateConsistency ¶
func (f *Factory) ValidateConsistency(schemas *SchemaRegistry) []string
ValidateConsistency checks that every registered builder has a corresponding schema and vice versa. Returns a list of warning messages for any mismatches. Intended for startup-time diagnostics, not hot paths.
type FactoryOption ¶
type FactoryOption func(*Factory)
FactoryOption configures a Factory.
func WithCommandRunner ¶
func WithCommandRunner(cr workspace.CommandRunner) FactoryOption
func WithLLMResolver ¶
func WithLLMResolver(r llm.LLMResolver) FactoryOption
func WithScriptFS ¶
func WithScriptFS(fsys fs.FS) FactoryOption
func WithScriptRuntime ¶
func WithScriptRuntime(rt script.Runtime) FactoryOption
func WithToolRegistry ¶
func WithToolRegistry(tr *tool.Registry) FactoryOption
func WithWorkspace ¶
func WithWorkspace(ws workspace.Workspace) FactoryOption
type FieldSchema ¶
type FieldSchema struct {
Key string `json:"key"`
Label string `json:"label"`
Type string `json:"type"`
Required bool `json:"required,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
DefaultValue any `json:"default_value,omitempty"`
Options []SelectOption `json:"options,omitempty"`
}
FieldSchema describes a single configurable field of a node type.
type LLMConfig ¶
type LLMConfig struct {
SystemPrompt string `json:"system_prompt" yaml:"system_prompt"`
Model string `json:"model,omitempty" yaml:"model,omitempty"`
Temperature *float64 `json:"temperature,omitempty" yaml:"temperature,omitempty"`
MaxTokens int64 `json:"max_tokens,omitempty" yaml:"max_tokens,omitempty"`
OutputKey string `json:"output_key,omitempty" yaml:"output_key,omitempty"`
MessagesKey string `json:"messages_key,omitempty" yaml:"messages_key,omitempty"`
JSONMode bool `json:"json_mode,omitempty" yaml:"json_mode,omitempty"`
Thinking bool `json:"thinking,omitempty" yaml:"thinking,omitempty"`
QueryFallback bool `json:"query_fallback,omitempty" yaml:"query_fallback,omitempty"`
TrackSteps bool `json:"track_steps,omitempty" yaml:"track_steps,omitempty"`
ToolNames []string `json:"tool_names,omitempty" yaml:"tool_names,omitempty"`
}
LLMConfig configures an LLM graph node. Fields like SystemPrompt, OutputKey, MessagesKey, QueryFallback, and TrackSteps are graph-level board I/O concerns; the pure LLM call parameters are forwarded to llm.RoundConfig via the roundConfig() method.
type LLMNode ¶
type LLMNode struct {
// contains filtered or unexported fields
}
LLMNode is a Go-native graph node that calls an LLM, handles tool calls, and manages message history.
func NewLLMNode ¶
func NewLLMNode(id string, resolver llm.LLMResolver, toolReg *tool.Registry, config LLMConfig) *LLMNode
NewLLMNode creates a new LLM node.
func (*LLMNode) ExecuteBoard ¶
func (*LLMNode) InputPorts ¶
func (*LLMNode) OutputPorts ¶
type NodeBuilder ¶
type NodeBuilder func(def graph.NodeDefinition, bctx *BuildContext) (graph.Node, error)
NodeBuilder creates a graph.Node from its definition and build-time dependencies.
type NodeSchema ¶
type NodeSchema struct {
Type string `json:"type"`
Label string `json:"label"`
Icon string `json:"icon"`
Color string `json:"color"`
Category string `json:"category"`
Description string `json:"description"`
Fields []FieldSchema `json:"fields"`
InputPorts []PortSchema `json:"input_ports,omitempty"`
OutputPorts []PortSchema `json:"output_ports,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Runtime *RuntimeSpec `json:"runtime,omitempty"`
}
NodeSchema describes a node type for dynamic frontend rendering.
type PortSchema ¶
type PortSchema struct {
Name string `json:"name"`
Type string `json:"type"`
Required bool `json:"required,omitempty"`
Description string `json:"description,omitempty"`
}
PortSchema describes a typed port for frontend rendering.
type RuntimeSpec ¶
type RuntimeSpec struct {
BoardWrites []BoardVarSpec `json:"board_writes,omitempty"`
BoardReads []BoardVarSpec `json:"board_reads,omitempty"`
EdgeVars []BoardVarSpec `json:"edge_vars,omitempty"`
Notes []string `json:"notes,omitempty"`
}
RuntimeSpec describes the runtime behavior of a node type — what board variables it reads/writes, what condition variables it produces for downstream edges, and important behavioral notes. This information is returned by the schema(action=node_usage) tool to help the Builder understand how to correctly wire nodes together.
type SchemaRegistry ¶
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry is a thread-safe registry mapping node type strings to their schemas.
func NewSchemaRegistry ¶
func NewSchemaRegistry() *SchemaRegistry
func (*SchemaRegistry) All ¶
func (r *SchemaRegistry) All() []NodeSchema
func (*SchemaRegistry) Get ¶
func (r *SchemaRegistry) Get(nodeType string) (NodeSchema, bool)
func (*SchemaRegistry) Len ¶
func (r *SchemaRegistry) Len() int
func (*SchemaRegistry) Register ¶
func (r *SchemaRegistry) Register(schema NodeSchema)
func (*SchemaRegistry) RegisterMany ¶
func (r *SchemaRegistry) RegisterMany(schemas []NodeSchema)
func (*SchemaRegistry) Unregister ¶
func (r *SchemaRegistry) Unregister(nodeType string)
Unregister removes a node schema by type name.
type SelectOption ¶
SelectOption is a label-value pair for dropdown fields.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package scripts embeds all built-in JS node scripts via embed.FS.
|
Package scripts embeds all built-in JS node scripts via embed.FS. |