node

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	engine.BranchingNode
	// contains filtered or unexported fields
}

Agent executes an LLM agent via llmproxy.

func NewAgent

func NewAgent(
	id string,
	name string,
	model string,
	instructions *string,
	answer workflow.OutputBinding,
	outputDecls []workflow.OutputDeclaration,
	memoryRefs []workflow.MemoryRef,
	maxTurns *int,
	toolDescription string,
	client engine.LlmClient,
	mem *memory.Manager,
) *Agent

NewAgent constructs a new Agent node. memoryRefs lists the memory files the LLM is permitted to access at runtime; `mem` is the engine-scoped manager that backs read/append/edit. Both may be empty/nil for agents without memory. toolDescription is only consulted when this agent is wired as a tool to another agent.

func (*Agent) AddTool

func (n *Agent) AddTool(t engine.ToolProvider)

AddTool registers a ToolProvider wired to this agent. Called by the builder when wiring tool edges.

func (*Agent) Execute

func (n *Agent) Execute(ctx context.Context, scope *engine.Scope) (string, error)

Execute invokes the agent and returns the next state.

func (*Agent) Outputs

func (n *Agent) Outputs() map[string]workflow.DataType

func (*Agent) Setup

func (n *Agent) Setup(_ context.Context) error

Setup is called by the builder after all edges (including tool edges) are wired but before Execute can fire. It materialises the llmproxy agent: tool list, response format, and full instructions are all fixed at this point.

func (*Agent) Tools

func (n *Agent) Tools() ([]llmproxy.FunctionTool, error)

Tools exposes this Agent as an LLM-callable tool. Following the llmproxy agent.AsTool convention, the tool accepts a single "prompt" string and returns the agent's final answer.

type FunctionCall

type FunctionCall struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

FunctionCall invokes a compiled engine.Function. It evaluates input bindings in the surrounding scope, runs the function and applies output bindings back to the surrounding scope.

func NewFunctionCall

func NewFunctionCall(id string, fn *engine.Function, inputBindings map[string]workflow.Expression, outputBindings map[string]workflow.OutputBinding, toolDescription string) (*FunctionCall, error)

NewFunctionCall builds a FunctionCall. Validates that every declared return has a matching output binding.

func (*FunctionCall) Execute

func (n *FunctionCall) Execute(ctx context.Context, scope *engine.Scope) (string, error)

func (*FunctionCall) Outputs

func (n *FunctionCall) Outputs() map[string]workflow.DataType

func (*FunctionCall) Tools

func (n *FunctionCall) Tools() ([]llmproxy.FunctionTool, error)

Tools exposes this function as an LLM-callable tool.

type If

type If struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

If evaluates a boolean condition and advances via the "true" or "false" port.

func NewIf

func NewIf(id string, condition workflow.Expression) *If

NewIf builds an If node.

func (*If) Execute

func (n *If) Execute(ctx context.Context, scope *engine.Scope) (string, error)

type MqttPublish

type MqttPublish struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

MqttPublish evaluates a value expression, encodes it as bare JSON according to the declared dataType, and publishes to the bound MQTT channel. Topic prefixing ({networkID}/{agentID}/) is the channel's job.

func NewMqttPublish

func NewMqttPublish(id string, ch *channel.MQTT, topic string, dataType workflow.DataType, value workflow.Expression, qos byte, retain bool) *MqttPublish

NewMqttPublish builds an MqttPublish bound to the given MQTT channel.

func (*MqttPublish) Execute

func (n *MqttPublish) Execute(_ context.Context, scope *engine.Scope) (string, error)

type ReadPin

type ReadPin struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

ReadPin reads a digital or analog value from a linked channel. Build picks one of the two pointers based on signalType; the other stays nil.

func NewReadPinAnalog

func NewReadPinAnalog(id string, binding workflow.OutputBinding, toolDescription string, adc *channel.ADC) *ReadPin

NewReadPinAnalog builds a ReadPin bound to an ADC channel.

func NewReadPinDigital

func NewReadPinDigital(id string, binding workflow.OutputBinding, toolDescription string, gpioin *channel.GPIOInput) *ReadPin

NewReadPinDigital builds a ReadPin bound to a GPIO input channel.

func (*ReadPin) Execute

func (r *ReadPin) Execute(ctx context.Context, scope *engine.Scope) (string, error)

func (*ReadPin) Outputs

func (r *ReadPin) Outputs() map[string]workflow.DataType

func (*ReadPin) Tools

func (r *ReadPin) Tools() ([]llmproxy.FunctionTool, error)

type Retriever

type Retriever struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

Retriever queries a RAG collection. In control-flow mode it evaluates the configured query expression against the scope and writes a formatted results string to the bound slot. As a tool, the LLM supplies the query directly and the output binding is bypassed — the tool returns the formatted string.

func NewRetriever

func NewRetriever(
	id string,
	collectionID string,
	topK int,
	query workflow.Expression,
	binding workflow.OutputBinding,
	toolDescription string,
	ret engine.Retriever,
) *Retriever

NewRetriever builds a Retriever. Fails the build path if rag is nil; tool path will fail at invocation time through the same nil check.

func (*Retriever) Execute

func (r *Retriever) Execute(ctx context.Context, scope *engine.Scope) (string, error)

func (*Retriever) Outputs

func (r *Retriever) Outputs() map[string]workflow.DataType

func (*Retriever) Tools

func (r *Retriever) Tools() ([]llmproxy.FunctionTool, error)

Tools exposes this retriever as an LLM-callable tool.

type SerialRead

type SerialRead struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

SerialRead blocks on a serial port until one line arrives, then emits it through the output binding and advances. The receive buffer is flushed first so pre-existing chatter doesn't satisfy the read; when prompt is non-empty it is written next, then the blocking read runs. The driver's Read steals from the broadcast path while it is in flight, so any concurrent OnSerialReceive trigger pauses for the duration.

func NewSerialRead

func NewSerialRead(id string, binding workflow.OutputBinding, prompt string, uart *channel.UART) *SerialRead

NewSerialRead builds a SerialRead bound to the given UART channel. prompt may be empty.

func (*SerialRead) Execute

func (r *SerialRead) Execute(ctx context.Context, scope *engine.Scope) (string, error)

func (*SerialRead) Outputs

func (r *SerialRead) Outputs() map[string]workflow.DataType

Outputs declares the single "output" slot — a string line. Returns it only if the binding is emit-mode (assign/discard don't materialize a variable).

type SerialWrite

type SerialWrite struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

SerialWrite evaluates a value expression and writes the resulting string to a UART channel. No terminator is appended — the caller's expression is responsible for any newline / framing.

func NewSerialWrite

func NewSerialWrite(id string, value workflow.Expression, uart *channel.UART) *SerialWrite

NewSerialWrite builds a SerialWrite bound to the given UART channel.

func (*SerialWrite) Execute

func (w *SerialWrite) Execute(_ context.Context, scope *engine.Scope) (string, error)

type SetVariable

type SetVariable struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

SetVariable evaluates an expression and assigns the result to a declared variable in the main scope.

func NewSetVariable

func NewSetVariable(id string, variable workflow.Reference, value workflow.Expression) *SetVariable

NewSetVariable builds a SetVariable node.

func (*SetVariable) Execute

func (n *SetVariable) Execute(ctx context.Context, scope *engine.Scope) (string, error)

type WebFetch

type WebFetch struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

WebFetch fetches an HTTP(S) URL and emits the cleaned page text. Evaluates the configured URL expression against the scope and writes the extracted text to the bound slot. Control-flow only — not exposed as an LLM tool.

func NewWebFetch

func NewWebFetch(id string, urlExpr workflow.Expression, maxChars int, binding workflow.OutputBinding) *WebFetch

NewWebFetch builds a WebFetch node. maxChars <= 0 falls back to the default cap.

func (*WebFetch) Execute

func (n *WebFetch) Execute(ctx context.Context, scope *engine.Scope) (string, error)

func (*WebFetch) Outputs

func (n *WebFetch) Outputs() map[string]workflow.DataType

type WebSearchTool

type WebSearchTool struct {
	engine.ToolNode
	// contains filtered or unexported fields
}

WebSearchTool exposes a web search engine as an LLM-callable tool. Tool-only — never participates in control flow, never emits a scope variable.

func NewWebSearchTool

func NewWebSearchTool(id string, provider websearch.Provider, maxResults int) *WebSearchTool

NewWebSearchTool builds a WebSearchTool node bound to the given provider. provider may be nil; the build path is expected to reject that case so a misconfigured engine fails at deploy rather than at tool-call time.

func (*WebSearchTool) Tools

func (n *WebSearchTool) Tools() ([]llmproxy.FunctionTool, error)

Tools exposes this node as `web_search(query, count?)` → string.

type WritePin

type WritePin struct {
	engine.LinearNode
	// contains filtered or unexported fields
}

WritePin writes a digital or analog value to a linked channel. Build picks exactly one of the three pointers; the others stay nil.

  • Digital → gpioout (binary)
  • Analog (PWM) → pwm (duty cycle in [0,1])
  • Analog (DAC) → dac (millivolts)

func NewWritePinDAC

func NewWritePinDAC(id string, value workflow.Expression, dac *channel.DAC) *WritePin

NewWritePinDAC builds a WritePin bound to a DAC output channel.

func NewWritePinDigital

func NewWritePinDigital(id string, value workflow.Expression, gpioout *channel.GPIOOutput) *WritePin

NewWritePinDigital builds a WritePin bound to a GPIO output channel.

func NewWritePinPWM

func NewWritePinPWM(id string, value workflow.Expression, pwm *channel.PWM) *WritePin

NewWritePinPWM builds a WritePin bound to a PWM output channel.

func (*WritePin) Execute

func (w *WritePin) Execute(_ context.Context, scope *engine.Scope) (string, error)

Execute evaluates the value expression and writes it through the linked channel. Digital coerces to bool; PWM expects a duty in [0,1]; DAC expects millivolts.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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