{"modulePath":"github.com/the-dev-tools/dev-tools/packages/server","version":"v0.0.0-20261108121446-820be1ff163d","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package node\n\n## Constants\n\n```go\nconst NodeVarPrefix = \"node\"\n```\nINFO: this is workaround for expr lang\n\n## Variables\n\n```go\nvar (\n\tErrVarGroupNotFound error = errors.New(\"group not found\")\n\tErrVarNodeNotFound  error = errors.New(\"node not found\")\n\tErrVarKeyNotFound   error = errors.New(\"key not found\")\n)\n```\n\n```go\nvar ErrNodeNotFound = errors.New(\"node not found\")\n```\n\n## Functions\n\n```go\nfunc AssertionError(expr string, values []string, status int, body []byte) error\n```\nAssertionError reports a failed assertion with what it checked and what the server answered. values are the variable paths the expression read with their actual values (\\`response.duration = 5120\\`). For a 2xx response only the values are shown: the body is left out because it can carry tokens and this error is printed to CI logs. For any other status the status and a one-line excerpt of the body come first (\"got 401: Invalid credentials\"), then the values, minus response.status, which the status already says.\n\n```go\nfunc BuildContextValue(varMap map[string]any) (*structpb.Value, error)\n```\nBuildContextValue converts a VarMap to a structpb.Value for JS execution context\n\n```go\nfunc BuildHandleExecutionEdgeMap(edgeMap mflow.EdgesMap, nodeID idwrap.IDWrap, handle mflow.EdgeHandle, targets []idwrap.IDWrap) mflow.EdgesMap\n```\nBuildHandleExecutionEdgeMap returns an edge map suitable for executing a sub-chain connected via the given handle. It rewrites the handle on nodeID to include only the provided targets so duplicate edges to downstream nodes do not participate in scheduling decisions.\n\n```go\nfunc BuildLoopExecutionEdgeMap(edgeMap mflow.EdgesMap, loopNodeID idwrap.IDWrap, loopTargets []idwrap.IDWrap) mflow.EdgesMap\n```\nBuildLoopExecutionEdgeMap returns an edge map suitable for executing loop bodies. It rewrites the loop handle to include only the provided entry targets so duplicate edges to downstream nodes do not participate in scheduling decisions.\n\nWhen the requested targets already match the existing loop edges, the original map is returned to avoid unnecessary allocations.\n\n```go\nfunc BuildPendingMap(predecessors map[idwrap.IDWrap][]idwrap.IDWrap) map[idwrap.IDWrap]uint32\n```\nBuildPendingMap constructs a PendingAtmoicMap compatible with the runner by counting predecessors for each node. Only entries with more than one predecessor are retained to match runner expectations.\n\n```go\nfunc CloneIterationLabels(labels []runner.IterationLabel) []runner.IterationLabel\n```\nCloneIterationLabels returns a defensive copy of iteration labels to avoid slice aliasing.\n\n```go\nfunc ClonePendingMap(src map[idwrap.IDWrap]uint32) map[idwrap.IDWrap]uint32\n```\nClonePendingMap makes a shallow copy of a PendingAtmoicMap. It returns nil when the source is empty to keep downstream checks simple.\n\n```go\nfunc DeepCopyValue(v any) any\n```\nDeepCopyValue creates a deep copy of any value\n\n```go\nfunc DeepCopyVarMap(req *FlowNodeRequest) map[string]any\n```\nDeepCopyVarMap creates a deep copy of the VarMap to prevent concurrent access issues\n\n```go\nfunc FilterLoopEntryNodes(edgeMap mflow.EdgesMap, loopTargets []idwrap.IDWrap) []idwrap.IDWrap\n```\nFilterLoopEntryNodes removes loop targets that are reachable from other loop targets, ensuring we only return the true entry nodes for a loop body. This prevents downstream nodes from being re-executed when the loop handle fan-out includes both the body head and interior nodes (can happen after noop pruning).\n\nIf filtering removes every target (e.g. due to a cycle), we fall back to the original slice so execution can still proceed.\n\n```go\nfunc ParseResultValue(result *structpb.Value) (map[string]interface{}, error)\n```\nParseResultValue converts a structpb.Value result from JS execution to a map\n\n```go\nfunc ReadNodeVar(a *FlowNodeRequest, name, key string) (interface{}, error)\n```\n\n```go\nfunc ReadNodeVarWithTracking(a *FlowNodeRequest, name, key string, tracker *tracking.VariableTracker) (interface{}, error)\n```\nReadNodeVarWithTracking reads a node variable with optional tracking\n\n```go\nfunc ReadVarRaw(a *FlowNodeRequest, key string) (interface{}, error)\n```\n\n```go\nfunc ReadVarRawWithTracking(a *FlowNodeRequest, key string, tracker *tracking.VariableTracker) (interface{}, error)\n```\nReadVarRawWithTracking reads a raw variable with optional tracking\n\n```go\nfunc WithCookies(vars map[string]any, client httpclient.HttpClient)\n```\nWithCookies adds the client's received cookies to a step's variables, unless the flow already defines a variable of that name.\n\n```go\nfunc WriteNodeVar(a *FlowNodeRequest, name string, key string, v interface{}) error\n```\n\n```go\nfunc WriteNodeVarBulk(a *FlowNodeRequest, name string, v map[string]interface{}) error\n```\n\n```go\nfunc WriteNodeVarBulkWithTracking(a *FlowNodeRequest, name string, v map[string]interface{}, tracker *tracking.VariableTracker) error\n```\nWriteNodeVarBulkWithTracking writes bulk node variables with optional tracking\n\n```go\nfunc WriteNodeVarRaw(a *FlowNodeRequest, name string, v interface{}) error\n```\n\n```go\nfunc WriteNodeVarRawWithTracking(a *FlowNodeRequest, name string, v interface{}, tracker *tracking.VariableTracker) error\n```\nWriteNodeVarRawWithTracking writes a raw node variable with optional tracking\n\n```go\nfunc WriteNodeVarWithTracking(a *FlowNodeRequest, name string, key string, v interface{}, tracker *tracking.VariableTracker) error\n```\nWriteNodeVarWithTracking writes a node variable with optional tracking\n\n```go\nfunc WriteVar(a *FlowNodeRequest, key string, v interface{})\n```\nWriteVar writes a top-level variable to the VarMap\n\n## Types\n\n```go\ntype BackgroundNode interface {\n\tRunsInBackground() bool\n}\n```\nBackgroundNode marks nodes that keep working after they return, such as a WebSocket connection that keeps reading messages. The runner hands them the flow's context instead of a per-node timeout, which would end that work as soon as the node returns. They bound their own start-up instead.\n\n```go\ntype EntryNode interface {\n\tFlowNode\n\tIsEntryNode() bool\n}\n```\nEntryNode marks a node as a valid flow entry point (no incoming edges expected). The runner collects all EntryNodes and starts them concurrently.\n\n```go\ntype FlowNode interface {\n\tGetID() idwrap.IDWrap\n\tGetName() string\n\n\t// TODO: will implement streaming in the future\n\tRunSync(ctx context.Context, req *FlowNodeRequest) FlowNodeResult\n\tRunAsync(ctx context.Context, req *FlowNodeRequest, resultChan chan FlowNodeResult)\n}\n```\n\n```go\ntype FlowNodeRequest struct {\n\tVarMap           map[string]any\n\tReadWriteLock    *sync.RWMutex\n\tNodeMap          map[idwrap.IDWrap]FlowNode\n\tEdgeSourceMap    mflow.EdgesMap\n\tTimeout          time.Duration\n\tLogPushFunc      LogPushFunc\n\tPendingAtmoicMap map[idwrap.IDWrap]uint32\n\tPendingMapMu     *sync.Mutex               // Thread-safe pending map across concurrent entry chains\n\tVariableTracker  *tracking.VariableTracker // Optional tracking for input/output data\n\tIterationContext *runner.IterationContext  // For hierarchical execution naming in loops\n\tExecutionID      idwrap.IDWrap             // Unique ID for this specific execution of the node\n\tLogger           *slog.Logger              // Optional structured logger for node diagnostics\n\n\t// LeanMode drops response bodies from node output so memory stays flat\n\t// across long load runs. Assertions still see the full response because\n\t// they are evaluated against it directly rather than through VarMap, but\n\t// downstream nodes cannot extract from a body that was not retained.\n\t// Off by default.\n\tLeanMode bool\n}\n```\n\n```go\ntype FlowNodeResult struct {\n\tNextNodeID []idwrap.IDWrap\n\tErr        error\n\t// SkipFinalStatus tells the runner not to create a final execution status.\n\t// Used by FOR/FOREACH nodes that handle their own iteration status logging.\n\tSkipFinalStatus bool\n\tAuxiliaryID     *idwrap.IDWrap\n}\n```\n\n```go\ntype ListenerEntry interface {\n\tEntryNode\n\tLoopCoordinator\n}\n```\nListenerEntry is an entry node that runs for the flow's lifetime, receiving events in a loop (e.g., WebSocket Connection). It implements LoopCoordinator so the runner doesn't apply per-node timeout.\n\n```go\ntype LogPushFunc func(status runner.FlowNodeStatus)\n```\n\n```go\ntype LoopCoordinator interface {\n\tIsLoopCoordinator() bool\n}\n```\nLoopCoordinator marks nodes that orchestrate loop execution.\n\n```go\ntype TriggerEntry interface {\n\tEntryNode\n\t// TriggerType returns a string identifier for the trigger kind (e.g., \"webhook\", \"queue\").\n\tTriggerType() string\n}\n```\nTriggerEntry is an entry node whose external event initiates the flow run. Examples: Webhook (HTTP request triggers flow), Queue (message triggers flow). The trigger payload is written to VarMap before downstream nodes execute.\n\n```go\ntype VariableIntrospector interface {\n\t// GetRequiredVariables returns variable references this node needs as input.\n\t// Each entry is a full variable path like \"nodeName.field\" or \"nodeName.response.body.id\"\n\tGetRequiredVariables() []string\n\n\t// GetOutputVariables returns variable paths this node will produce.\n\t// Each entry describes an output path like \"response.body\" or \"response.status\"\n\tGetOutputVariables() []string\n}\n```\nVariableIntrospector is an optional interface that nodes can implement to report what variables they require and what they output. This enables AI agents to understand node dependencies.\n\n","path":"github.com/the-dev-tools/dev-tools/packages/server/pkg/flow/node","name":"node","synopsis":"","isRedistributable":true}
