@foresthubai/workflow-core 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/LICENSE +202 -202
  2. package/NOTICE +14 -14
  3. package/README.md +63 -63
  4. package/dist/api/workflow.d.ts +2 -2
  5. package/dist/api/workflow.d.ts.map +1 -1
  6. package/package.json +1 -1
  7. package/src/api/index.ts +11 -11
  8. package/src/api/workflow.ts +607 -607
  9. package/src/channel/Channel.ts +11 -11
  10. package/src/channel/ChannelDefinition.ts +76 -76
  11. package/src/channel/index.ts +6 -6
  12. package/src/channel/serialization.ts +68 -68
  13. package/src/deploy/index.ts +1 -1
  14. package/src/deploy/requirements.test.ts +61 -61
  15. package/src/deploy/requirements.ts +41 -41
  16. package/src/diagnostics/__fixtures__/diagnosticFixtures.ts +158 -158
  17. package/src/diagnostics/diagnostics.test.ts +878 -878
  18. package/src/diagnostics/diagnostics.ts +936 -936
  19. package/src/diagnostics/index.ts +11 -11
  20. package/src/edge/Edge.ts +23 -23
  21. package/src/edge/EdgeDefinition.ts +45 -45
  22. package/src/edge/EdgeType.ts +19 -19
  23. package/src/edge/index.ts +8 -8
  24. package/src/edge/serialization.ts +83 -83
  25. package/src/expression/index.ts +4 -4
  26. package/src/expression/parser.ts +362 -362
  27. package/src/expression/types.ts +30 -30
  28. package/src/function/FunctionDeclaration.ts +54 -54
  29. package/src/function/index.ts +3 -3
  30. package/src/function/serialization.ts +40 -40
  31. package/src/globals.d.ts +9 -9
  32. package/src/id/index.ts +8 -8
  33. package/src/index.ts +22 -22
  34. package/src/memory/Memory.ts +15 -15
  35. package/src/memory/MemoryDefinition.ts +16 -16
  36. package/src/memory/MemoryFileDefinition.ts +37 -37
  37. package/src/memory/MemoryRegistry.ts +35 -35
  38. package/src/memory/VectorDatabaseDefinition.ts +21 -21
  39. package/src/memory/index.ts +8 -8
  40. package/src/memory/serialization.ts +47 -47
  41. package/src/migration/index.ts +4 -4
  42. package/src/migration/migrate.test.ts +44 -44
  43. package/src/migration/migrate.ts +58 -58
  44. package/src/migration/migrations.ts +24 -24
  45. package/src/migration/version.ts +9 -9
  46. package/src/model/LLMModelDefinition.ts +12 -12
  47. package/src/model/Model.ts +39 -39
  48. package/src/model/ModelDefinition.ts +15 -15
  49. package/src/model/ModelRegistry.ts +33 -33
  50. package/src/model/index.ts +7 -7
  51. package/src/model/serialization.ts +30 -30
  52. package/src/node/AgentNode.ts +82 -82
  53. package/src/node/DataNode.ts +41 -41
  54. package/src/node/FunctionNode.ts +76 -76
  55. package/src/node/InputNode.ts +185 -185
  56. package/src/node/LogicNode.ts +33 -33
  57. package/src/node/MqttNode.ts +127 -127
  58. package/src/node/Node.ts +61 -61
  59. package/src/node/NodeDefinition.ts +37 -37
  60. package/src/node/NodeRegistry.ts +85 -85
  61. package/src/node/OutputNode.ts +87 -87
  62. package/src/node/ToolNode.ts +32 -32
  63. package/src/node/TriggerNode.ts +272 -272
  64. package/src/node/constants.ts +16 -16
  65. package/src/node/index.ts +26 -26
  66. package/src/node/methods.ts +278 -278
  67. package/src/node/serialization.ts +544 -544
  68. package/src/parameter/OutputParameter.ts +68 -68
  69. package/src/parameter/Parameter.ts +243 -243
  70. package/src/parameter/index.ts +33 -33
  71. package/src/variable/Variable.ts +10 -10
  72. package/src/variable/index.ts +16 -16
  73. package/src/variable/operations.ts +106 -106
  74. package/src/workflow/Workflow.ts +41 -41
  75. package/src/workflow/index.ts +3 -3
  76. package/src/workflow/serialization.test.ts +240 -240
  77. package/src/workflow/serialization.ts +242 -242
@@ -1,127 +1,127 @@
1
- import { NodeBase } from "./Node";
2
- import type { Expression } from "../api";
3
- import { OutputBinding } from "../parameter";
4
- import { NodeCategory, NodeTag } from "./constants";
5
- import { NodeDefinition } from "./NodeDefinition";
6
-
7
- // MQTT Publish - publishes a single value to an MQTT topic
8
- export interface MqttPublishNode extends NodeBase {
9
- type: "MqttPublish";
10
- arguments: {
11
- channelReference: string;
12
- dataType: "int" | "float" | "bool" | "string";
13
- value: Expression;
14
- qos: "0" | "1" | "2";
15
- retain: boolean;
16
- };
17
- }
18
-
19
- // On MQTT Message - fires when a message is received on a subscribed topic
20
- export interface OnMqttMessageNode extends NodeBase {
21
- type: "OnMqttMessage";
22
- arguments: {
23
- channelReference: string;
24
- dataType: "int" | "float" | "bool" | "string";
25
- output: OutputBinding;
26
- };
27
- }
28
-
29
- export type MqttNodeType = "MqttPublish" | "OnMqttMessage";
30
- export type MqttNode = MqttPublishNode | OnMqttMessageNode;
31
-
32
- // Node Definitions
33
-
34
- export const MqttPublishNodeDefinition: NodeDefinition = {
35
- type: "MqttPublish",
36
- label: "MQTT Publish",
37
- category: NodeCategory.Output,
38
- tags: [NodeTag.Network],
39
- description: "Publish a value to an MQTT topic",
40
- parameters: [
41
- {
42
- id: "channelReference",
43
- label: "Channel",
44
- description: "MQTT channel to publish through",
45
- type: "channelSelect",
46
- channelType: ["MQTT"],
47
- },
48
- {
49
- id: "dataType",
50
- label: "Data Type",
51
- description: "Data type of the value to publish",
52
- type: "selection",
53
- options: [
54
- { value: "int", label: "Integer" },
55
- { value: "float", label: "Float" },
56
- { value: "bool", label: "Boolean" },
57
- { value: "string", label: "String" },
58
- ],
59
- default: "string",
60
- },
61
- {
62
- id: "value",
63
- label: "Value",
64
- description: "Value to publish",
65
- type: "expression",
66
- expressionType: (args) => (args as MqttPublishNode["arguments"]).dataType,
67
- default: { expression: "", references: [], dataType: "string" },
68
- },
69
- {
70
- id: "qos",
71
- label: "QoS",
72
- description: "Quality of Service level",
73
- type: "selection",
74
- options: [
75
- { value: "0", label: "0 - At most once" },
76
- { value: "1", label: "1 - At least once" },
77
- { value: "2", label: "2 - Exactly once" },
78
- ],
79
- default: "0",
80
- },
81
- {
82
- id: "retain",
83
- label: "Retain",
84
- description: "Whether the broker should retain the message",
85
- type: "bool",
86
- default: false,
87
- },
88
- ],
89
- };
90
-
91
- export const OnMqttMessageNodeDefinition: NodeDefinition = {
92
- type: "OnMqttMessage",
93
- label: "On MQTT Message",
94
- category: NodeCategory.Trigger,
95
- tags: [NodeTag.Network],
96
- description: "Fires when a message is received on a subscribed MQTT topic",
97
- outputs: [
98
- {
99
- id: "output",
100
- label: "Message Value",
101
- type: "static",
102
- dataType: (args) => (args as OnMqttMessageNode["arguments"]).dataType,
103
- },
104
- ],
105
- parameters: [
106
- {
107
- id: "channelReference",
108
- label: "Channel",
109
- description: "MQTT channel to subscribe through",
110
- type: "channelSelect",
111
- channelType: ["MQTT"],
112
- },
113
- {
114
- id: "dataType",
115
- label: "Data Type",
116
- description: "Expected data type of the received message value",
117
- type: "selection",
118
- options: [
119
- { value: "int", label: "Integer" },
120
- { value: "float", label: "Float" },
121
- { value: "bool", label: "Boolean" },
122
- { value: "string", label: "String" },
123
- ],
124
- default: "string",
125
- },
126
- ],
127
- };
1
+ import { NodeBase } from "./Node";
2
+ import type { Expression } from "../api";
3
+ import { OutputBinding } from "../parameter";
4
+ import { NodeCategory, NodeTag } from "./constants";
5
+ import { NodeDefinition } from "./NodeDefinition";
6
+
7
+ // MQTT Publish - publishes a single value to an MQTT topic
8
+ export interface MqttPublishNode extends NodeBase {
9
+ type: "MqttPublish";
10
+ arguments: {
11
+ channelReference: string;
12
+ dataType: "int" | "float" | "bool" | "string";
13
+ value: Expression;
14
+ qos: "0" | "1" | "2";
15
+ retain: boolean;
16
+ };
17
+ }
18
+
19
+ // On MQTT Message - fires when a message is received on a subscribed topic
20
+ export interface OnMqttMessageNode extends NodeBase {
21
+ type: "OnMqttMessage";
22
+ arguments: {
23
+ channelReference: string;
24
+ dataType: "int" | "float" | "bool" | "string";
25
+ output: OutputBinding;
26
+ };
27
+ }
28
+
29
+ export type MqttNodeType = "MqttPublish" | "OnMqttMessage";
30
+ export type MqttNode = MqttPublishNode | OnMqttMessageNode;
31
+
32
+ // Node Definitions
33
+
34
+ export const MqttPublishNodeDefinition: NodeDefinition = {
35
+ type: "MqttPublish",
36
+ label: "MQTT Publish",
37
+ category: NodeCategory.Output,
38
+ tags: [NodeTag.Network],
39
+ description: "Publish a value to an MQTT topic",
40
+ parameters: [
41
+ {
42
+ id: "channelReference",
43
+ label: "Channel",
44
+ description: "MQTT channel to publish through",
45
+ type: "channelSelect",
46
+ channelType: ["MQTT"],
47
+ },
48
+ {
49
+ id: "dataType",
50
+ label: "Data Type",
51
+ description: "Data type of the value to publish",
52
+ type: "selection",
53
+ options: [
54
+ { value: "int", label: "Integer" },
55
+ { value: "float", label: "Float" },
56
+ { value: "bool", label: "Boolean" },
57
+ { value: "string", label: "String" },
58
+ ],
59
+ default: "string",
60
+ },
61
+ {
62
+ id: "value",
63
+ label: "Value",
64
+ description: "Value to publish",
65
+ type: "expression",
66
+ expressionType: (args) => (args as MqttPublishNode["arguments"]).dataType,
67
+ default: { expression: "", references: [], dataType: "string" },
68
+ },
69
+ {
70
+ id: "qos",
71
+ label: "QoS",
72
+ description: "Quality of Service level",
73
+ type: "selection",
74
+ options: [
75
+ { value: "0", label: "0 - At most once" },
76
+ { value: "1", label: "1 - At least once" },
77
+ { value: "2", label: "2 - Exactly once" },
78
+ ],
79
+ default: "0",
80
+ },
81
+ {
82
+ id: "retain",
83
+ label: "Retain",
84
+ description: "Whether the broker should retain the message",
85
+ type: "bool",
86
+ default: false,
87
+ },
88
+ ],
89
+ };
90
+
91
+ export const OnMqttMessageNodeDefinition: NodeDefinition = {
92
+ type: "OnMqttMessage",
93
+ label: "On MQTT Message",
94
+ category: NodeCategory.Trigger,
95
+ tags: [NodeTag.Network],
96
+ description: "Fires when a message is received on a subscribed MQTT topic",
97
+ outputs: [
98
+ {
99
+ id: "output",
100
+ label: "Message Value",
101
+ type: "static",
102
+ dataType: (args) => (args as OnMqttMessageNode["arguments"]).dataType,
103
+ },
104
+ ],
105
+ parameters: [
106
+ {
107
+ id: "channelReference",
108
+ label: "Channel",
109
+ description: "MQTT channel to subscribe through",
110
+ type: "channelSelect",
111
+ channelType: ["MQTT"],
112
+ },
113
+ {
114
+ id: "dataType",
115
+ label: "Data Type",
116
+ description: "Expected data type of the received message value",
117
+ type: "selection",
118
+ options: [
119
+ { value: "int", label: "Integer" },
120
+ { value: "float", label: "Float" },
121
+ { value: "bool", label: "Boolean" },
122
+ { value: "string", label: "String" },
123
+ ],
124
+ default: "string",
125
+ },
126
+ ],
127
+ };
package/src/node/Node.ts CHANGED
@@ -1,61 +1,61 @@
1
- // Domain Node — the base shape every node variant builds on. NodeBase is the
2
- // generic, untyped-parameters shape used wherever a node is handled generically
3
- // (e.g. React Flow nodes); NodeData is the discriminated union over the
4
- // per-variant interfaces (InputNode, AgentNode, …) for strongly-typed work.
5
- // Mirrors how channel/memory/model keep their base shape in a same-named file and
6
- // leave index.ts as a pure barrel. The per-variant interfaces import NodeBase
7
- // from here directly, not via the barrel.
8
-
9
- import type { DataType } from "../api";
10
- import { InputNode, InputNodeType } from "./InputNode";
11
- import { OutputNode, OutputNodeType } from "./OutputNode";
12
- import { AgentNode, AgentNodeType } from "./AgentNode";
13
- import { LogicNode, LogicNodeType } from "./LogicNode";
14
- import { DataNode, DataNodeType } from "./DataNode";
15
- import { TriggerNode, TriggerNodeType } from "./TriggerNode";
16
- import { ToolNode, ToolNodeType } from "./ToolNode";
17
- import { FunctionCallNode, FunctionCallNodeType } from "./FunctionNode";
18
- import { MqttNode, MqttNodeType } from "./MqttNode";
19
-
20
- export type NodeOutput = { name: string; dataType: DataType };
21
- export type NodeType =
22
- | InputNodeType
23
- | OutputNodeType
24
- | AgentNodeType
25
- | LogicNodeType
26
- | DataNodeType
27
- | TriggerNodeType
28
- | ToolNodeType
29
- | FunctionCallNodeType
30
- | MqttNodeType;
31
-
32
- /**
33
- * NodeData represents the runtime data for a node in the workflow builder.
34
- * It is a union type of all specific node types, each with their own typed parameters.
35
- * Use this type when you need strong typing for a specific node.
36
- */
37
- export type NodeData = InputNode | OutputNode | AgentNode | LogicNode | DataNode | TriggerNode | ToolNode | FunctionCallNode | MqttNode;
38
-
39
- /**
40
- * Full domain node entity held on a {@link Canvas}: the {@link NodeData}
41
- * payload plus its canvas layout position, flattened. id/type/arguments/label
42
- * come from NodeData; only `position` is added. The editor projects this into
43
- * a React Flow node (adding the display type) at its store boundary.
44
- */
45
- export type Node = NodeData & { position: { x: number; y: number } };
46
-
47
- /**
48
- * NodeBase is a generic interface for all node instances.
49
- * It uses an untyped parameters record to allow generic parameter handling (e.g., in React Flow nodes).
50
- * Narrow to NodeData for specific node operations that require typed parameters.
51
- *
52
- * Per-output bindings (emit/assign/discard) live as flat entries inside `arguments`,
53
- * keyed by the output id — same namespace as parameter values. List output entries
54
- * (e.g. AgentNode's `outputDeclarations`) bundle their binding alongside their variable
55
- * declaration as OutputDeclaration[].
56
- */
57
- export interface NodeBase extends Record<string, unknown> {
58
- id: string; // Same as the React Flow node ID
59
- type: NodeType; // Node discriminator
60
- label?: string; // User-editable display label (falls back to nodeDefinition.label)
61
- }
1
+ // Domain Node — the base shape every node variant builds on. NodeBase is the
2
+ // generic, untyped-parameters shape used wherever a node is handled generically
3
+ // (e.g. React Flow nodes); NodeData is the discriminated union over the
4
+ // per-variant interfaces (InputNode, AgentNode, …) for strongly-typed work.
5
+ // Mirrors how channel/memory/model keep their base shape in a same-named file and
6
+ // leave index.ts as a pure barrel. The per-variant interfaces import NodeBase
7
+ // from here directly, not via the barrel.
8
+
9
+ import type { DataType } from "../api";
10
+ import { InputNode, InputNodeType } from "./InputNode";
11
+ import { OutputNode, OutputNodeType } from "./OutputNode";
12
+ import { AgentNode, AgentNodeType } from "./AgentNode";
13
+ import { LogicNode, LogicNodeType } from "./LogicNode";
14
+ import { DataNode, DataNodeType } from "./DataNode";
15
+ import { TriggerNode, TriggerNodeType } from "./TriggerNode";
16
+ import { ToolNode, ToolNodeType } from "./ToolNode";
17
+ import { FunctionCallNode, FunctionCallNodeType } from "./FunctionNode";
18
+ import { MqttNode, MqttNodeType } from "./MqttNode";
19
+
20
+ export type NodeOutput = { name: string; dataType: DataType };
21
+ export type NodeType =
22
+ | InputNodeType
23
+ | OutputNodeType
24
+ | AgentNodeType
25
+ | LogicNodeType
26
+ | DataNodeType
27
+ | TriggerNodeType
28
+ | ToolNodeType
29
+ | FunctionCallNodeType
30
+ | MqttNodeType;
31
+
32
+ /**
33
+ * NodeData represents the runtime data for a node in the workflow builder.
34
+ * It is a union type of all specific node types, each with their own typed parameters.
35
+ * Use this type when you need strong typing for a specific node.
36
+ */
37
+ export type NodeData = InputNode | OutputNode | AgentNode | LogicNode | DataNode | TriggerNode | ToolNode | FunctionCallNode | MqttNode;
38
+
39
+ /**
40
+ * Full domain node entity held on a {@link Canvas}: the {@link NodeData}
41
+ * payload plus its canvas layout position, flattened. id/type/arguments/label
42
+ * come from NodeData; only `position` is added. The editor projects this into
43
+ * a React Flow node (adding the display type) at its store boundary.
44
+ */
45
+ export type Node = NodeData & { position: { x: number; y: number } };
46
+
47
+ /**
48
+ * NodeBase is a generic interface for all node instances.
49
+ * It uses an untyped parameters record to allow generic parameter handling (e.g., in React Flow nodes).
50
+ * Narrow to NodeData for specific node operations that require typed parameters.
51
+ *
52
+ * Per-output bindings (emit/assign/discard) live as flat entries inside `arguments`,
53
+ * keyed by the output id — same namespace as parameter values. List output entries
54
+ * (e.g. AgentNode's `outputDeclarations`) bundle their binding alongside their variable
55
+ * declaration as OutputDeclaration[].
56
+ */
57
+ export interface NodeBase extends Record<string, unknown> {
58
+ id: string; // Same as the React Flow node ID
59
+ type: NodeType; // Node discriminator
60
+ label?: string; // User-editable display label (falls back to nodeDefinition.label)
61
+ }
@@ -1,37 +1,37 @@
1
- import { NodeType } from "./Node";
2
- import { NodeCategory, NodeTag } from "./constants";
3
- import { OutputParameter, Parameter } from "../parameter";
4
-
5
- /**
6
- * NodeDefinition describes static class-level node metadata.
7
- * Methods (getPorts) are optional and take no arguments for static port definitions.
8
- * Instance-dependent behavior lives in NodeBehavior.ts instead.
9
- */
10
- export interface NodeDefinition {
11
- type: NodeType; // Node discriminator
12
- label: string; // Human-readable, displayed name
13
- category: NodeCategory; // Category for grouping (e.g., 'Input', 'Output', 'Logic')
14
- description: string; // Description of what the node does
15
- parameters: Parameter[]; // Parameter definitions for the node.
16
- outputs?: OutputParameter[]; // Declarative output definitions — consumed by getNodeAvailableOutput() to compute a node's outputs
17
- tags?: NodeTag[]; // Cross-cutting subsystem labels (Network, Pin, Serial, ...)
18
- isUnremovable?: boolean; // Whether the node cannot be added or removed by a user
19
- isSingleton?: boolean; // Whether only one instance of this node can exist in a canvas
20
- canBranch?: boolean; // Whether the control output port may fan out to multiple branches (tool output ports are always multi-target)
21
- }
22
-
23
- // =============================================================================
24
- // PORT DEFINITIONS
25
- // =============================================================================
26
-
27
- // Port represents a connectable port of a node
28
- export interface Port {
29
- id: string;
30
- type: "control" | "tool";
31
- label?: string;
32
- }
33
-
34
- export interface PortDefinitions {
35
- input: Port[];
36
- output: Port[];
37
- }
1
+ import { NodeType } from "./Node";
2
+ import { NodeCategory, NodeTag } from "./constants";
3
+ import { OutputParameter, Parameter } from "../parameter";
4
+
5
+ /**
6
+ * NodeDefinition describes static class-level node metadata.
7
+ * Methods (getPorts) are optional and take no arguments for static port definitions.
8
+ * Instance-dependent behavior lives in NodeBehavior.ts instead.
9
+ */
10
+ export interface NodeDefinition {
11
+ type: NodeType; // Node discriminator
12
+ label: string; // Human-readable, displayed name
13
+ category: NodeCategory; // Category for grouping (e.g., 'Input', 'Output', 'Logic')
14
+ description: string; // Description of what the node does
15
+ parameters: Parameter[]; // Parameter definitions for the node.
16
+ outputs?: OutputParameter[]; // Declarative output definitions — consumed by getNodeAvailableOutput() to compute a node's outputs
17
+ tags?: NodeTag[]; // Cross-cutting subsystem labels (Network, Pin, Serial, ...)
18
+ isUnremovable?: boolean; // Whether the node cannot be added or removed by a user
19
+ isSingleton?: boolean; // Whether only one instance of this node can exist in a canvas
20
+ canBranch?: boolean; // Whether the control output port may fan out to multiple branches (tool output ports are always multi-target)
21
+ }
22
+
23
+ // =============================================================================
24
+ // PORT DEFINITIONS
25
+ // =============================================================================
26
+
27
+ // Port represents a connectable port of a node
28
+ export interface Port {
29
+ id: string;
30
+ type: "control" | "tool";
31
+ label?: string;
32
+ }
33
+
34
+ export interface PortDefinitions {
35
+ input: Port[];
36
+ output: Port[];
37
+ }
@@ -1,85 +1,85 @@
1
- import { ReadPinNodeDefinition, SerialReadNodeDefinition, RetrieverNodeDefinition, WebFetchNodeDefinition } from "./InputNode";
2
- import { AgentNodeDefinition } from "./AgentNode";
3
- import {
4
- DelayNodeDefinition,
5
- TickerNodeDefinition,
6
- AlarmNodeDefinition,
7
- OnFunctionCallNodeDefinition,
8
- OnStartupNodeDefinition,
9
- OnPinEdgeNodeDefinition,
10
- OnSerialReceiveNodeDefinition,
11
- OnThresholdNodeDefinition,
12
- } from "./TriggerNode";
13
- import { WebSearchToolNodeDefinition } from "./ToolNode";
14
- import { NodeType } from "./Node";
15
- import { NodeCategory } from "./constants";
16
- import { SerialWriteNodeDefinition, WritePinNodeDefinition } from "./OutputNode";
17
- import { IfNodeDefinition } from "./LogicNode";
18
- import { SetVariableNodeDefinition } from "./DataNode";
19
- import { MqttPublishNodeDefinition, OnMqttMessageNodeDefinition } from "./MqttNode";
20
- import { NodeDefinition } from "./NodeDefinition";
21
-
22
- /**
23
- * Central registry for all node definitions.
24
- */
25
- class NodeDefinitionRegistry {
26
- private nodes: Map<NodeType, NodeDefinition> = new Map();
27
- private initialized = false;
28
-
29
- initialize() {
30
- if (this.initialized) return;
31
-
32
- // Register all nodes
33
- this.register(ReadPinNodeDefinition);
34
- this.register(SerialReadNodeDefinition);
35
- this.register(WritePinNodeDefinition);
36
- this.register(SerialWriteNodeDefinition);
37
- this.register(AgentNodeDefinition);
38
- this.register(IfNodeDefinition);
39
- this.register(SetVariableNodeDefinition);
40
- // Register trigger nodes
41
- this.register(OnFunctionCallNodeDefinition);
42
- this.register(DelayNodeDefinition);
43
- this.register(TickerNodeDefinition);
44
- this.register(AlarmNodeDefinition);
45
- this.register(OnStartupNodeDefinition);
46
- this.register(OnPinEdgeNodeDefinition);
47
- this.register(OnSerialReceiveNodeDefinition);
48
- this.register(OnThresholdNodeDefinition);
49
- // Register tool nodes
50
- this.register(WebSearchToolNodeDefinition);
51
- // Register input tool nodes
52
- this.register(RetrieverNodeDefinition);
53
- this.register(WebFetchNodeDefinition);
54
- // Register MQTT nodes
55
- this.register(MqttPublishNodeDefinition);
56
- this.register(OnMqttMessageNodeDefinition);
57
-
58
- this.initialized = true;
59
- }
60
-
61
- private register(definition: NodeDefinition) {
62
- this.nodes.set(definition.type, definition);
63
- }
64
-
65
- getAll(): NodeDefinition[] {
66
- return Array.from(this.nodes.values());
67
- }
68
-
69
- getAllCategories(): NodeCategory[] {
70
- const categories = new Set(this.getAll().map((node) => node.category));
71
- return Array.from(categories).sort();
72
- }
73
-
74
- getByType(type: NodeType): NodeDefinition | undefined {
75
- return this.nodes.get(type);
76
- }
77
-
78
- getByCategory(category: NodeCategory): NodeDefinition[] {
79
- return this.getAll().filter((node) => node.category === category);
80
- }
81
- }
82
-
83
- // Create and initialize the registry
84
- export const NodeRegistry = new NodeDefinitionRegistry();
85
- NodeRegistry.initialize();
1
+ import { ReadPinNodeDefinition, SerialReadNodeDefinition, RetrieverNodeDefinition, WebFetchNodeDefinition } from "./InputNode";
2
+ import { AgentNodeDefinition } from "./AgentNode";
3
+ import {
4
+ DelayNodeDefinition,
5
+ TickerNodeDefinition,
6
+ AlarmNodeDefinition,
7
+ OnFunctionCallNodeDefinition,
8
+ OnStartupNodeDefinition,
9
+ OnPinEdgeNodeDefinition,
10
+ OnSerialReceiveNodeDefinition,
11
+ OnThresholdNodeDefinition,
12
+ } from "./TriggerNode";
13
+ import { WebSearchToolNodeDefinition } from "./ToolNode";
14
+ import { NodeType } from "./Node";
15
+ import { NodeCategory } from "./constants";
16
+ import { SerialWriteNodeDefinition, WritePinNodeDefinition } from "./OutputNode";
17
+ import { IfNodeDefinition } from "./LogicNode";
18
+ import { SetVariableNodeDefinition } from "./DataNode";
19
+ import { MqttPublishNodeDefinition, OnMqttMessageNodeDefinition } from "./MqttNode";
20
+ import { NodeDefinition } from "./NodeDefinition";
21
+
22
+ /**
23
+ * Central registry for all node definitions.
24
+ */
25
+ class NodeDefinitionRegistry {
26
+ private nodes: Map<NodeType, NodeDefinition> = new Map();
27
+ private initialized = false;
28
+
29
+ initialize() {
30
+ if (this.initialized) return;
31
+
32
+ // Register all nodes
33
+ this.register(ReadPinNodeDefinition);
34
+ this.register(SerialReadNodeDefinition);
35
+ this.register(WritePinNodeDefinition);
36
+ this.register(SerialWriteNodeDefinition);
37
+ this.register(AgentNodeDefinition);
38
+ this.register(IfNodeDefinition);
39
+ this.register(SetVariableNodeDefinition);
40
+ // Register trigger nodes
41
+ this.register(OnFunctionCallNodeDefinition);
42
+ this.register(DelayNodeDefinition);
43
+ this.register(TickerNodeDefinition);
44
+ this.register(AlarmNodeDefinition);
45
+ this.register(OnStartupNodeDefinition);
46
+ this.register(OnPinEdgeNodeDefinition);
47
+ this.register(OnSerialReceiveNodeDefinition);
48
+ this.register(OnThresholdNodeDefinition);
49
+ // Register tool nodes
50
+ this.register(WebSearchToolNodeDefinition);
51
+ // Register input tool nodes
52
+ this.register(RetrieverNodeDefinition);
53
+ this.register(WebFetchNodeDefinition);
54
+ // Register MQTT nodes
55
+ this.register(MqttPublishNodeDefinition);
56
+ this.register(OnMqttMessageNodeDefinition);
57
+
58
+ this.initialized = true;
59
+ }
60
+
61
+ private register(definition: NodeDefinition) {
62
+ this.nodes.set(definition.type, definition);
63
+ }
64
+
65
+ getAll(): NodeDefinition[] {
66
+ return Array.from(this.nodes.values());
67
+ }
68
+
69
+ getAllCategories(): NodeCategory[] {
70
+ const categories = new Set(this.getAll().map((node) => node.category));
71
+ return Array.from(categories).sort();
72
+ }
73
+
74
+ getByType(type: NodeType): NodeDefinition | undefined {
75
+ return this.nodes.get(type);
76
+ }
77
+
78
+ getByCategory(category: NodeCategory): NodeDefinition[] {
79
+ return this.getAll().filter((node) => node.category === category);
80
+ }
81
+ }
82
+
83
+ // Create and initialize the registry
84
+ export const NodeRegistry = new NodeDefinitionRegistry();
85
+ NodeRegistry.initialize();