node

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package node hosts the runtime-side primitives shared by every concrete graph node implementation: the per-type Builder registry (Factory) and the port declarations consumed by jsnode.

Concrete node implementations live in sub-packages and register their builder explicitly into a Factory; this package no longer keeps any global default registry, schema metadata, or BuildContext.

File layout:

factory.go  Factory + NodeBuilder
ports.go    RegisterPorts + PortsForType

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PortsForType

func PortsForType(nodeType string) (input, output []graph.Port)

PortsForType returns the ports previously registered for nodeType. The returned slices are nil when no registration exists, mirroring the "unknown type" branch in scriptnode (which falls back to generic input/output ports).

func RegisterPorts added in v0.2.3

func RegisterPorts(nodeType string, input, output []graph.Port)

RegisterPorts declares the input/output port shape for a node type. Safe for concurrent use. Re-registering a type overwrites the previous entry. Intended to be called from init() of the owning sub-package.

Types

type Factory

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

Factory maps node type strings to NodeBuilders and constructs node instances on demand. Factory is safe for concurrent use.

func NewFactory

func NewFactory() *Factory

NewFactory creates an empty Factory. Call RegisterBuilder (or the per-sub-package Register helpers like llmnode.Register, scriptnode.Register, knowledgenode.Register) to populate it before passing it to runner.New.

func (*Factory) Build

func (f *Factory) Build(def graph.NodeDefinition) (graph.Node, error)

Build constructs a single node from its declarative definition. The engine's two reserved types (__end__ and passthrough) are handled directly so callers never need to register them.

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 builder for the given node type. Re-registering the same type overwrites the previous entry.

func (*Factory) SetFallback

func (f *Factory) SetFallback(builder NodeBuilder)

SetFallback installs a builder that handles every node type for which no explicit builder is registered. Pass nil to clear.

type NodeBuilder

type NodeBuilder func(def graph.NodeDefinition) (graph.Node, error)

NodeBuilder constructs a graph.Node from its declarative definition. Build-time dependencies (LLM resolver, tool registry, script runtime, workspace, etc.) are captured by the closure that returns the builder — see graph/node/llmnode, graph/node/scriptnode, graph/node/knowledgenode.

Directories

Path Synopsis
Package knowledgenode implements the "knowledge" graph node and exposes a Register helper for binding it into a node.Factory.
Package knowledgenode implements the "knowledge" graph node and exposes a Register helper for binding it into a node.Factory.
Package llmnode implements the Go-native "llm" graph node and exposes a Register helper for binding it into a node.Factory.
Package llmnode implements the Go-native "llm" graph node and exposes a Register helper for binding it into a node.Factory.
Package scripts embeds all built-in JS node scripts via embed.FS.
Package scripts embeds all built-in JS node scripts via embed.FS.

Jump to

Keyboard shortcuts

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