@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,185 +1,185 @@
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
- export interface ReadPinNode extends NodeBase {
8
- type: "ReadPin";
9
- arguments: {
10
- pinReference: string | undefined;
11
- signalType: "digital" | "analog";
12
- output: OutputBinding;
13
- toolDescription?: string;
14
- };
15
- }
16
-
17
- export interface SerialReadNode extends NodeBase {
18
- type: "SerialRead";
19
- arguments: {
20
- portReference: string | undefined;
21
- prompt?: string;
22
- output: OutputBinding;
23
- };
24
- }
25
-
26
- // Retriever - provides RAG retrieval capability to agents
27
- export interface RetrieverNode extends NodeBase {
28
- type: "Retriever";
29
- arguments: {
30
- memoryReference: string;
31
- topK: number | undefined;
32
- query: Expression;
33
- output: OutputBinding;
34
- toolDescription?: string;
35
- };
36
- }
37
-
38
- // WebFetch - fetches a URL and returns extracted text
39
- export interface WebFetchNode extends NodeBase {
40
- type: "WebFetch";
41
- arguments: {
42
- url: Expression;
43
- maxChars: number | undefined;
44
- output: OutputBinding;
45
- };
46
- }
47
-
48
- export type InputNodeType = "ReadPin" | "SerialRead" | "Retriever" | "WebFetch";
49
- export type InputNode = ReadPinNode | SerialReadNode | RetrieverNode | WebFetchNode;
50
-
51
- // Node Definitions
52
-
53
- export const ReadPinNodeDefinition: NodeDefinition = {
54
- type: "ReadPin",
55
- label: "Read Pin",
56
- category: NodeCategory.Input,
57
- tags: [NodeTag.Pin],
58
- description: "Read data from a pin",
59
- outputs: [
60
- {
61
- id: "output",
62
- label: "Pin Value",
63
- type: "static",
64
- dataType: (args) => ((args as ReadPinNode["arguments"]).signalType === "digital" ? "bool" : "int"),
65
- },
66
- ],
67
- parameters: [
68
- {
69
- id: "pinReference",
70
- label: "Pin",
71
- description: "IO pin to read from",
72
- type: "channelSelect",
73
- channelType: (args) => ((args as ReadPinNode["arguments"]).signalType === "digital" ? ["GPIOIN"] : ["ADC"]),
74
- },
75
- {
76
- id: "signalType",
77
- label: "Signal Type",
78
- description: "Type of signal",
79
- type: "selection",
80
- default: "digital",
81
- options: [
82
- { value: "digital", label: "Digital" },
83
- { value: "analog", label: "Analog" },
84
- ],
85
- },
86
- {
87
- id: "toolDescription",
88
- label: "Tool Description",
89
- description: "Description shown to the agent when this node is wired as a tool",
90
- type: "string",
91
- multiline: true,
92
- activationRules: [{ type: "isToolInput" }],
93
- },
94
- ],
95
- };
96
-
97
- export const RetrieverNodeDefinition: NodeDefinition = {
98
- type: "Retriever",
99
- label: "Retriever",
100
- category: NodeCategory.Input,
101
- description: "Retrieves relevant documents from a knowledge base",
102
- outputs: [{ id: "output", label: "Retrieved Documents", type: "static", dataType: "string" }],
103
- parameters: [
104
- {
105
- id: "memoryReference",
106
- label: "Vector Database",
107
- description: "The vector database to search",
108
- type: "memorySelect",
109
- memoryType: ["VectorDatabase"],
110
- },
111
- {
112
- id: "topK",
113
- label: "Top K",
114
- description: "Number of results to retrieve",
115
- type: "int",
116
- default: 5,
117
- },
118
- {
119
- id: "query",
120
- label: "Query",
121
- description: "Search query expression",
122
- type: "expression",
123
- expressionType: "string",
124
- default: { expression: "", references: [], dataType: "string" },
125
- },
126
- {
127
- id: "toolDescription",
128
- label: "Tool Description",
129
- description: "Description shown to the agent when this node is wired as a tool",
130
- type: "string",
131
- multiline: true,
132
- activationRules: [{ type: "isToolInput" }],
133
- },
134
- ],
135
- };
136
-
137
- export const WebFetchNodeDefinition: NodeDefinition = {
138
- type: "WebFetch",
139
- label: "Web Fetch",
140
- category: NodeCategory.Input,
141
- description: "Fetches a URL and returns extracted text",
142
- outputs: [{ id: "output", label: "Fetched Text", type: "static", dataType: "string" }],
143
- parameters: [
144
- {
145
- id: "url",
146
- label: "URL",
147
- description: "URL to fetch (http or https)",
148
- type: "expression",
149
- expressionType: "string",
150
- default: { expression: "", references: [], dataType: "string" },
151
- },
152
- {
153
- id: "maxChars",
154
- label: "Max Characters",
155
- description: "Maximum characters of extracted text to return",
156
- type: "int",
157
- optional: true,
158
- },
159
- ],
160
- };
161
-
162
- export const SerialReadNodeDefinition: NodeDefinition = {
163
- type: "SerialRead",
164
- label: "Serial Read",
165
- category: NodeCategory.Input,
166
- tags: [NodeTag.Serial],
167
- description: "Read string from serial port",
168
- outputs: [{ id: "output", label: "Serial Data", type: "static", dataType: "string" }],
169
- parameters: [
170
- {
171
- id: "portReference",
172
- label: "Port",
173
- description: "Serial port to read from",
174
- type: "channelSelect",
175
- channelType: ["UART"],
176
- },
177
- {
178
- id: "prompt",
179
- label: "Input prompt",
180
- description: "Prompt for the serial read operation",
181
- type: "string",
182
- optional: true,
183
- },
184
- ],
185
- };
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
+ export interface ReadPinNode extends NodeBase {
8
+ type: "ReadPin";
9
+ arguments: {
10
+ pinReference: string | undefined;
11
+ signalType: "digital" | "analog";
12
+ output: OutputBinding;
13
+ toolDescription?: string;
14
+ };
15
+ }
16
+
17
+ export interface SerialReadNode extends NodeBase {
18
+ type: "SerialRead";
19
+ arguments: {
20
+ portReference: string | undefined;
21
+ prompt?: string;
22
+ output: OutputBinding;
23
+ };
24
+ }
25
+
26
+ // Retriever - provides RAG retrieval capability to agents
27
+ export interface RetrieverNode extends NodeBase {
28
+ type: "Retriever";
29
+ arguments: {
30
+ memoryReference: string;
31
+ topK: number | undefined;
32
+ query: Expression;
33
+ output: OutputBinding;
34
+ toolDescription?: string;
35
+ };
36
+ }
37
+
38
+ // WebFetch - fetches a URL and returns extracted text
39
+ export interface WebFetchNode extends NodeBase {
40
+ type: "WebFetch";
41
+ arguments: {
42
+ url: Expression;
43
+ maxChars: number | undefined;
44
+ output: OutputBinding;
45
+ };
46
+ }
47
+
48
+ export type InputNodeType = "ReadPin" | "SerialRead" | "Retriever" | "WebFetch";
49
+ export type InputNode = ReadPinNode | SerialReadNode | RetrieverNode | WebFetchNode;
50
+
51
+ // Node Definitions
52
+
53
+ export const ReadPinNodeDefinition: NodeDefinition = {
54
+ type: "ReadPin",
55
+ label: "Read Pin",
56
+ category: NodeCategory.Input,
57
+ tags: [NodeTag.Pin],
58
+ description: "Read data from a pin",
59
+ outputs: [
60
+ {
61
+ id: "output",
62
+ label: "Pin Value",
63
+ type: "static",
64
+ dataType: (args) => ((args as ReadPinNode["arguments"]).signalType === "digital" ? "bool" : "int"),
65
+ },
66
+ ],
67
+ parameters: [
68
+ {
69
+ id: "pinReference",
70
+ label: "Pin",
71
+ description: "IO pin to read from",
72
+ type: "channelSelect",
73
+ channelType: (args) => ((args as ReadPinNode["arguments"]).signalType === "digital" ? ["GPIOIN"] : ["ADC"]),
74
+ },
75
+ {
76
+ id: "signalType",
77
+ label: "Signal Type",
78
+ description: "Type of signal",
79
+ type: "selection",
80
+ default: "digital",
81
+ options: [
82
+ { value: "digital", label: "Digital" },
83
+ { value: "analog", label: "Analog" },
84
+ ],
85
+ },
86
+ {
87
+ id: "toolDescription",
88
+ label: "Tool Description",
89
+ description: "Description shown to the agent when this node is wired as a tool",
90
+ type: "string",
91
+ multiline: true,
92
+ activationRules: [{ type: "isToolInput" }],
93
+ },
94
+ ],
95
+ };
96
+
97
+ export const RetrieverNodeDefinition: NodeDefinition = {
98
+ type: "Retriever",
99
+ label: "Retriever",
100
+ category: NodeCategory.Input,
101
+ description: "Retrieves relevant documents from a knowledge base",
102
+ outputs: [{ id: "output", label: "Retrieved Documents", type: "static", dataType: "string" }],
103
+ parameters: [
104
+ {
105
+ id: "memoryReference",
106
+ label: "Vector Database",
107
+ description: "The vector database to search",
108
+ type: "memorySelect",
109
+ memoryType: ["VectorDatabase"],
110
+ },
111
+ {
112
+ id: "topK",
113
+ label: "Top K",
114
+ description: "Number of results to retrieve",
115
+ type: "int",
116
+ default: 5,
117
+ },
118
+ {
119
+ id: "query",
120
+ label: "Query",
121
+ description: "Search query expression",
122
+ type: "expression",
123
+ expressionType: "string",
124
+ default: { expression: "", references: [], dataType: "string" },
125
+ },
126
+ {
127
+ id: "toolDescription",
128
+ label: "Tool Description",
129
+ description: "Description shown to the agent when this node is wired as a tool",
130
+ type: "string",
131
+ multiline: true,
132
+ activationRules: [{ type: "isToolInput" }],
133
+ },
134
+ ],
135
+ };
136
+
137
+ export const WebFetchNodeDefinition: NodeDefinition = {
138
+ type: "WebFetch",
139
+ label: "Web Fetch",
140
+ category: NodeCategory.Input,
141
+ description: "Fetches a URL and returns extracted text",
142
+ outputs: [{ id: "output", label: "Fetched Text", type: "static", dataType: "string" }],
143
+ parameters: [
144
+ {
145
+ id: "url",
146
+ label: "URL",
147
+ description: "URL to fetch (http or https)",
148
+ type: "expression",
149
+ expressionType: "string",
150
+ default: { expression: "", references: [], dataType: "string" },
151
+ },
152
+ {
153
+ id: "maxChars",
154
+ label: "Max Characters",
155
+ description: "Maximum characters of extracted text to return",
156
+ type: "int",
157
+ optional: true,
158
+ },
159
+ ],
160
+ };
161
+
162
+ export const SerialReadNodeDefinition: NodeDefinition = {
163
+ type: "SerialRead",
164
+ label: "Serial Read",
165
+ category: NodeCategory.Input,
166
+ tags: [NodeTag.Serial],
167
+ description: "Read string from serial port",
168
+ outputs: [{ id: "output", label: "Serial Data", type: "static", dataType: "string" }],
169
+ parameters: [
170
+ {
171
+ id: "portReference",
172
+ label: "Port",
173
+ description: "Serial port to read from",
174
+ type: "channelSelect",
175
+ channelType: ["UART"],
176
+ },
177
+ {
178
+ id: "prompt",
179
+ label: "Input prompt",
180
+ description: "Prompt for the serial read operation",
181
+ type: "string",
182
+ optional: true,
183
+ },
184
+ ],
185
+ };
@@ -1,33 +1,33 @@
1
- import { NodeBase } from "./Node";
2
- import type { Expression } from "../api";
3
- import { NodeCategory } from "./constants";
4
- import { NodeDefinition } from "./NodeDefinition";
5
-
6
- export interface IfNode extends NodeBase {
7
- type: "If";
8
- arguments: {
9
- condition: Expression;
10
- };
11
- }
12
-
13
- export type LogicNodeType = "If";
14
- export type LogicNode = IfNode;
15
-
16
- // Node Definitions
17
-
18
- export const IfNodeDefinition: NodeDefinition = {
19
- type: "If",
20
- label: "If Condition Node",
21
- category: NodeCategory.Logic,
22
- description: "Conditional branching based on boolean expression",
23
- parameters: [
24
- {
25
- id: "condition",
26
- label: "Condition",
27
- description: "Boolean expression (e.g., ${Input_1.value} > 50)",
28
- type: "expression",
29
- expressionType: "bool",
30
- default: { expression: "", references: [], dataType: "bool" },
31
- },
32
- ],
33
- };
1
+ import { NodeBase } from "./Node";
2
+ import type { Expression } from "../api";
3
+ import { NodeCategory } from "./constants";
4
+ import { NodeDefinition } from "./NodeDefinition";
5
+
6
+ export interface IfNode extends NodeBase {
7
+ type: "If";
8
+ arguments: {
9
+ condition: Expression;
10
+ };
11
+ }
12
+
13
+ export type LogicNodeType = "If";
14
+ export type LogicNode = IfNode;
15
+
16
+ // Node Definitions
17
+
18
+ export const IfNodeDefinition: NodeDefinition = {
19
+ type: "If",
20
+ label: "If Condition Node",
21
+ category: NodeCategory.Logic,
22
+ description: "Conditional branching based on boolean expression",
23
+ parameters: [
24
+ {
25
+ id: "condition",
26
+ label: "Condition",
27
+ description: "Boolean expression (e.g., ${Input_1.value} > 50)",
28
+ type: "expression",
29
+ expressionType: "bool",
30
+ default: { expression: "", references: [], dataType: "bool" },
31
+ },
32
+ ],
33
+ };