@hlang-org/interpreter
In-process interpreter for hlang: evaluates an IGraph program into a live RxJS object graph, with no code generation. Version 1.0.1, 34 exports.
Classes
GraphError
Defined in: packages/ir/lib/index.d.ts:136
Thrown by planGraph when a graph violates hlang's rules.
Extends
Error
Constructors
Constructor
new GraphError(code, message): GraphError;Defined in: packages/ir/lib/index.d.ts:138
Parameters
| Parameter | Type |
|---|---|
code | GraphErrorCode |
message | string |
Returns
Overrides
Error.constructor
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
code | readonly | GraphErrorCode | packages/ir/lib/index.d.ts:137 |
NodeRegistry
Defined in: packages/interpreter/src/registry.ts:23
A mutable node registry.
Implements
Constructors
Constructor
new NodeRegistry(): NodeRegistry;Returns
Methods
codes()
codes(): readonly string[];Defined in: packages/interpreter/src/registry.ts:43
All registered codes, in insertion order.
Returns
readonly string[]
Implementation of
get()
get(code): NodeConstructor | undefined;Defined in: packages/interpreter/src/registry.ts:35
Return the constructor registered for code, or undefined.
Parameters
| Parameter | Type |
|---|---|
code | string |
Returns
NodeConstructor | undefined
Implementation of
has()
has(code): boolean;Defined in: packages/interpreter/src/registry.ts:39
Whether a constructor is registered for code.
Parameters
| Parameter | Type |
|---|---|
code | string |
Returns
boolean
Implementation of
register()
register(code, ctor): this;Defined in: packages/interpreter/src/registry.ts:30
Register a node class under code. Re-registering the same code replaces
the previous entry (last write wins), which keeps hot-reloading simple.
Parameters
| Parameter | Type |
|---|---|
code | string |
ctor | NodeConstructor |
Returns
this
Interfaces
ExecutionPlan
Defined in: packages/ir/lib/index.d.ts:125
A validated, backend-neutral program.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
connections | readonly | readonly PlannedConnection[] | Connections in graph order. | packages/ir/lib/index.d.ts:129 |
nodes | readonly | readonly PlannedNode[] | Nodes in graph order. | packages/ir/lib/index.d.ts:127 |
roots | readonly | readonly string[] | Node ids of the Readable roots, in graph order. Never empty. | packages/ir/lib/index.d.ts:131 |
IBizData
Defined in: packages/ir/lib/index.d.ts:26
Business data attached to a node; params is the user-facing config.
Indexable
[key: string]: unknownProperties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
flowId? | readonly | string | packages/ir/lib/index.d.ts:27 |
nodeId? | readonly | string | packages/ir/lib/index.d.ts:28 |
params? | readonly | Readonly<Record<string, ParamValue>> | packages/ir/lib/index.d.ts:29 |
IConnection
Defined in: packages/ir/lib/index.d.ts:53
A single connection. Direction is inverted from intuition and MUST be
preserved: Output is the upstream source (an O port), Input is the
downstream target (an I port). Wiring is Output.O(id).connect(Input.I(id)).
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
Input | readonly | IConnectionEndpoint | packages/ir/lib/index.d.ts:54 |
Output | readonly | IConnectionEndpoint | packages/ir/lib/index.d.ts:55 |
IConnectionEndpoint
Defined in: packages/ir/lib/index.d.ts:33
One endpoint of a connection, as serialized.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
name? | readonly | string | - | packages/ir/lib/index.d.ts:34 |
nodeId | readonly | string | - | packages/ir/lib/index.d.ts:36 |
portConf? | readonly | object | Port configuration. The port is identified by id (its name), e.g. "Input" / "Output" / "@node/error". Both portConf and the legacy portConfig spelling appear across fixtures; readers must accept either. | packages/ir/lib/index.d.ts:42 |
portConf.id | readonly | string | - | packages/ir/lib/index.d.ts:43 |
portConf.type? | readonly | string | - | packages/ir/lib/index.d.ts:44 |
portConfig? | readonly | Readonly<Record<string, unknown>> | - | packages/ir/lib/index.d.ts:46 |
type? | readonly | NodeKind | - | packages/ir/lib/index.d.ts:35 |
IDisposable
Defined in: packages/interpreter/src/types.ts:14
A cancellable subscription handle.
Extended by
Methods
dispose()
dispose(): void;Defined in: packages/interpreter/src/types.ts:15
Returns
void
IExecutionHandle
Defined in: packages/interpreter/src/types.ts:58
A handle to a running interpretation. Lets callers observe node errors and introspect the constructed graph, and tear the run down.
Extends
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
flowId | readonly | string | The flow id this run was scoped with. | packages/interpreter/src/types.ts:60 |
roots | readonly | readonly IRuntimeNode[] | The Readable (R) root nodes that were flow.run. At least one. | packages/interpreter/src/types.ts:62 |
Methods
dispose()
dispose(): void;Defined in: packages/interpreter/src/types.ts:15
Returns
void
Inherited from
getNode()
getNode(nodeId): IRuntimeNode | undefined;Defined in: packages/interpreter/src/types.ts:64
Resolve a constructed node instance by its graph nodeId.
Parameters
| Parameter | Type |
|---|---|
nodeId | string |
Returns
IRuntimeNode | undefined
onActivity()
onActivity(listener): IDisposable;Defined in: packages/interpreter/src/types.ts:71
Subscribe to output-port emissions across all nodes — the "living stream" signal. Fires each time a node pushes a message on a non-error output port.
Parameters
| Parameter | Type |
|---|---|
listener | (event) => void |
Returns
onError()
onError(listener): IDisposable;Defined in: packages/interpreter/src/types.ts:66
Subscribe to errors emitted by any node's @node/error port.
Parameters
| Parameter | Type |
|---|---|
listener | (event) => void |
Returns
IGraph
Defined in: packages/ir/lib/index.d.ts:88
The complete serialized graph.
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
connections | readonly | readonly IConnection[] | packages/ir/lib/index.d.ts:90 |
deps? | readonly | readonly IPackageInfo[] | packages/ir/lib/index.d.ts:89 |
nodeList | readonly | readonly INodeInfo[] | packages/ir/lib/index.d.ts:91 |
IInterpreterDeps
Defined in: packages/interpreter/src/interpreter.ts:32
Dependencies the interpreter needs, injected for testability.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
createFlow | readonly | FlowFactory | Produces a fresh runtime Flow. Injected so tests can supply fakes. | packages/interpreter/src/interpreter.ts:35 |
registry | readonly | INodeRegistry | - | packages/interpreter/src/interpreter.ts:33 |
IInterpretOptions
Defined in: packages/interpreter/src/types.ts:39
Options controlling interpretation.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
env? | readonly | string | Execution environment label passed to nodes. Defaults to 'prod'. | packages/interpreter/src/types.ts:46 |
flowId? | readonly | string | Flow identifier threaded into each node's construction options and used to scope the run. Defaults to a generated value when omitted. | packages/interpreter/src/types.ts:44 |
middleware? | readonly | Readonly<Record<string, unknown>> | Middleware object passed verbatim to every node (e.g. { logger }). Nodes read their own middleware keys. | packages/interpreter/src/types.ts:51 |
INodeActivityEvent
Defined in: packages/interpreter/src/types.ts:31
A node emitting on one of its output ports during execution — the signal behind the editor's "living stream" visuals. Fires each time a node pushes a message on a non-error output port.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
nodeId | readonly | string | Stable nodeId from the graph. | packages/interpreter/src/types.ts:33 |
portId | readonly | string | The output port name the message was sent on. | packages/interpreter/src/types.ts:35 |
INodeConstructionOptions
Defined in: packages/interpreter/src/runtime-contract.ts:71
Constructor options passed to every node, mirroring the runtime contract.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
config | readonly | Readonly<Record<string, unknown>> | - | packages/interpreter/src/runtime-contract.ts:76 |
env | readonly | string | - | packages/interpreter/src/runtime-contract.ts:74 |
flowId | readonly | string | - | packages/interpreter/src/runtime-contract.ts:73 |
middleware | readonly | Readonly<Record<string, unknown>> | - | packages/interpreter/src/runtime-contract.ts:75 |
nodeId | readonly | string | - | packages/interpreter/src/runtime-contract.ts:72 |
signal | readonly | IStopSignal | Fires when the flow is stopped; use to cancel long-lived work. | packages/interpreter/src/runtime-contract.ts:78 |
INodeErrorEvent
Defined in: packages/interpreter/src/types.ts:19
An error surfaced from a node's @node/error port during execution.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
error | readonly | unknown | The error payload the node sent on its error port. | packages/interpreter/src/types.ts:23 |
nodeId | readonly | string | Stable nodeId from the graph. | packages/interpreter/src/types.ts:21 |
INodeInfo
Defined in: packages/ir/lib/index.d.ts:63
A node entry in the graph's node list.
Indexable
[key: string]: unknownProperties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
bizData? | readonly | IBizData | - | packages/ir/lib/index.d.ts:70 |
code | readonly | string | Node type key. A backend resolves it to a runtime node class. | packages/ir/lib/index.d.ts:65 |
groupCode? | readonly | string | - | packages/ir/lib/index.d.ts:76 |
name | readonly | string | - | packages/ir/lib/index.d.ts:66 |
nodeId | readonly | string | Stable per-instance id used to correlate nodes and connections. | packages/ir/lib/index.d.ts:69 |
portInfo? | readonly | IPortInfo | - | packages/ir/lib/index.d.ts:71 |
position? | readonly | object | - | packages/ir/lib/index.d.ts:72 |
position.x | readonly | number | - | packages/ir/lib/index.d.ts:73 |
position.y | readonly | number | - | packages/ir/lib/index.d.ts:74 |
runtimeResource? | readonly | string | npm coordinate of the runtime implementation, e.g. "pkg@1.2.3". | packages/ir/lib/index.d.ts:78 |
type | readonly | NodeKind | - | packages/ir/lib/index.d.ts:67 |
INodeRegistry
Defined in: packages/interpreter/src/registry.ts:13
Read-only view of a node registry used during interpretation.
Methods
codes()
codes(): readonly string[];Defined in: packages/interpreter/src/registry.ts:19
All registered codes, in insertion order.
Returns
readonly string[]
get()
get(code): NodeConstructor | undefined;Defined in: packages/interpreter/src/registry.ts:15
Return the constructor registered for code, or undefined.
Parameters
| Parameter | Type |
|---|---|
code | string |
Returns
NodeConstructor | undefined
has()
has(code): boolean;Defined in: packages/interpreter/src/registry.ts:17
Whether a constructor is registered for code.
Parameters
| Parameter | Type |
|---|---|
code | string |
Returns
boolean
IPackageInfo
Defined in: packages/ir/lib/index.d.ts:82
A dependency descriptor (populated by the compiler; optional for interpret).
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
local? | readonly | boolean | packages/ir/lib/index.d.ts:85 |
name | readonly | string | packages/ir/lib/index.d.ts:83 |
version? | readonly | string | packages/ir/lib/index.d.ts:84 |
IPortInfo
Defined in: packages/ir/lib/index.d.ts:58
Port metadata carried on a node (the design-time port descriptors).
Properties
IRuntimeFlow
Defined in: packages/interpreter/src/runtime-contract.ts:89
A runtime Flow. run must be called with a Readable (R) root node.
Methods
run()
run(rootNode): void;Defined in: packages/interpreter/src/runtime-contract.ts:90
Parameters
| Parameter | Type |
|---|---|
rootNode | IRuntimeNode |
Returns
void
IRuntimeNode
Defined in: packages/interpreter/src/runtime-contract.ts:44
A runtime node instance (R, T, or W). Nodes expose I(name) / O(name)
accessors that resolve a previously attached port by name.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
id | readonly | string | - | packages/interpreter/src/runtime-contract.ts:45 |
type | readonly | symbol | Node kind symbol from runtime NODE_TYPE. Compared by reference. | packages/interpreter/src/runtime-contract.ts:47 |
Methods
E()
E(): IRuntimePort;Defined in: packages/interpreter/src/runtime-contract.ts:53
Resolve the error Output port (@node/error). Present on R and T only.
Returns
I()
I(name): IRuntimePort;Defined in: packages/interpreter/src/runtime-contract.ts:49
Resolve an Input port by name.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
O()
O(name): IRuntimePort;Defined in: packages/interpreter/src/runtime-contract.ts:51
Resolve an Output port by name.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
IRuntimePort
Defined in: packages/interpreter/src/runtime-contract.ts:26
A runtime port. Ports are RxJS Subjects under the hood: send is next,
receive is subscribe. We only depend on the wiring + messaging surface.
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
name | readonly | string | packages/interpreter/src/runtime-contract.ts:27 |
type | readonly | string | packages/interpreter/src/runtime-contract.ts:28 |
Methods
connect()
connect(port): IRuntimePort;Defined in: packages/interpreter/src/runtime-contract.ts:37
Wire this Output port to a downstream Input port. Throws unless O -> I.
Parameters
| Parameter | Type |
|---|---|
port | IRuntimePort |
Returns
receive()
receive(next): unknown;Defined in: packages/interpreter/src/runtime-contract.ts:35
Subscribe to messages on this port (RxJS subscribe).
The returned value is an RxJS Subscription; we treat it opaquely.
Parameters
| Parameter | Type |
|---|---|
next | (msg) => void |
Returns
unknown
send()
send(msg): void;Defined in: packages/interpreter/src/runtime-contract.ts:30
Push a message downstream (RxJS next).
Parameters
| Parameter | Type |
|---|---|
msg | unknown |
Returns
void
PlannedConnection
Defined in: packages/ir/lib/index.d.ts:120
source is an output (O) port; target is an input (I) port.
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
source | readonly | PlannedEndpoint | packages/ir/lib/index.d.ts:121 |
target | readonly | PlannedEndpoint | packages/ir/lib/index.d.ts:122 |
PlannedEndpoint
Defined in: packages/ir/lib/index.d.ts:115
One end of a planned connection.
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
nodeId | readonly | string | packages/ir/lib/index.d.ts:116 |
portId | readonly | string | packages/ir/lib/index.d.ts:117 |
PlannedNode
Defined in: packages/ir/lib/index.d.ts:108
A node to construct. config is passed to the node constructor.
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
code | readonly | string | packages/ir/lib/index.d.ts:110 |
config | readonly | Readonly<Record<string, unknown>> | packages/ir/lib/index.d.ts:112 |
kind | readonly | NodeKind | packages/ir/lib/index.d.ts:111 |
nodeId | readonly | string | packages/ir/lib/index.d.ts:109 |
Type Aliases
FlowFactory
type FlowFactory = () => IRuntimeFlow;Defined in: packages/interpreter/src/runtime-contract.ts:94
Factory that produces a fresh Flow instance.
Returns
GraphErrorCode
type GraphErrorCode =
| "duplicate-node-id"
| "invalid-node-kind"
| "unknown-node"
| "invalid-connection"
| "no-readable-root";Defined in: packages/ir/lib/index.d.ts:134
Machine-readable reasons a graph cannot be planned.
NodeConstructor
type NodeConstructor = new (opts) => IRuntimeNode;Defined in: packages/interpreter/src/runtime-contract.ts:86
A node class constructor. The registry maps an hlang code to one of these.
Concrete node classes extend the runtime's ReadableNode / TransformNode
/ WritableNode.
Parameters
| Parameter | Type |
|---|---|
opts | INodeConstructionOptions |
Returns
NodeKind
type NodeKind = "R" | "T" | "W";Defined in: packages/ir/lib/index.d.ts:11
The three hlang node kinds: Readable (source), Transform, Writable (sink).
ParamBag
type ParamBag = Readonly<Record<string, ParamValue>>;Defined in: packages/ir/lib/index.d.ts:24
A bag of node parameters (the params object under bizData).
ParamValue
type ParamValue =
| string
| number
| boolean
| null
| readonly ParamValue[]
| IParamObject;Defined in: packages/ir/lib/index.d.ts:15
Serialized parameter values carried in bizData.params.
StreamType
type StreamType = "I" | "O";Defined in: packages/interpreter/src/runtime-contract.ts:20
Stream direction of a port. Mirrors runtime STREAM_TYPE.
Variables
ERROR_PORT_NAME
const ERROR_PORT_NAME: "@node/error" = "@node/error";Defined in: packages/ir/lib/index.d.ts:13
The output port every Readable and Transform node exposes for errors.
Functions
interpret()
function interpret(
graph,
deps,
options?
): IExecutionHandle;Defined in: packages/interpreter/src/interpreter.ts:53
Interpret and run a graph. Returns a handle to the running flow.
Parameters
| Parameter | Type |
|---|---|
graph | IGraph |
deps | IInterpreterDeps |
options? | IInterpretOptions |
Returns
Throws
if the graph has no Readable (R) node, or references a code that
is not registered in the supplied registry.
planGraph()
function planGraph(graph): ExecutionPlan;Defined in: packages/ir/lib/index.d.ts:141
Validate graph and lower it to an ExecutionPlan.
Parameters
| Parameter | Type |
|---|---|
graph | IGraph |
Returns
Generated by TypeDoc from packages/interpreter/src at build time.