@foresthubai/workflow-core 0.4.3 → 0.4.4

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 (120) hide show
  1. package/LICENSE +202 -202
  2. package/NOTICE +14 -14
  3. package/README.md +63 -63
  4. package/dist/api/deployment.d.ts +67 -0
  5. package/dist/api/deployment.d.ts.map +1 -0
  6. package/dist/api/deployment.js +6 -0
  7. package/dist/api/deployment.js.map +1 -0
  8. package/dist/api/engine.d.ts +744 -0
  9. package/dist/api/engine.d.ts.map +1 -0
  10. package/dist/api/engine.js +6 -0
  11. package/dist/api/engine.js.map +1 -0
  12. package/dist/api/index.d.ts +4 -0
  13. package/dist/api/index.d.ts.map +1 -1
  14. package/dist/api/workflow.d.ts +17 -1
  15. package/dist/api/workflow.d.ts.map +1 -1
  16. package/dist/channel/Channel.d.ts +1 -1
  17. package/dist/channel/Channel.d.ts.map +1 -1
  18. package/dist/channel/Channel.js +1 -1
  19. package/dist/channel/Channel.js.map +1 -1
  20. package/dist/channel/ChannelDefinition.d.ts.map +1 -1
  21. package/dist/channel/ChannelDefinition.js +22 -0
  22. package/dist/channel/ChannelDefinition.js.map +1 -1
  23. package/dist/channel/serialization.d.ts.map +1 -1
  24. package/dist/channel/serialization.js +6 -0
  25. package/dist/channel/serialization.js.map +1 -1
  26. package/dist/deploy/index.d.ts +5 -1
  27. package/dist/deploy/index.d.ts.map +1 -1
  28. package/dist/deploy/index.js +2 -1
  29. package/dist/deploy/index.js.map +1 -1
  30. package/dist/deploy/inputs.d.ts +26 -0
  31. package/dist/deploy/inputs.d.ts.map +1 -0
  32. package/dist/deploy/inputs.js +12 -0
  33. package/dist/deploy/inputs.js.map +1 -0
  34. package/dist/deploy/requirements.d.ts +24 -0
  35. package/dist/deploy/requirements.d.ts.map +1 -1
  36. package/dist/deploy/requirements.js +61 -0
  37. package/dist/deploy/requirements.js.map +1 -1
  38. package/dist/deploy/spec.d.ts +32 -0
  39. package/dist/deploy/spec.d.ts.map +1 -0
  40. package/dist/deploy/spec.js +343 -0
  41. package/dist/deploy/spec.js.map +1 -0
  42. package/dist/node/OutputNode.js +2 -2
  43. package/dist/node/OutputNode.js.map +1 -1
  44. package/package.json +2 -2
  45. package/src/api/deployment.ts +67 -0
  46. package/src/api/engine.ts +744 -0
  47. package/src/api/index.ts +26 -11
  48. package/src/api/workflow.ts +17 -1
  49. package/src/channel/Channel.ts +11 -11
  50. package/src/channel/ChannelDefinition.ts +98 -76
  51. package/src/channel/index.ts +6 -6
  52. package/src/channel/serialization.ts +74 -68
  53. package/src/deploy/index.ts +14 -1
  54. package/src/deploy/inputs.ts +41 -0
  55. package/src/deploy/requirements.test.ts +61 -61
  56. package/src/deploy/requirements.ts +156 -41
  57. package/src/deploy/spec.test.ts +226 -0
  58. package/src/deploy/spec.ts +379 -0
  59. package/src/diagnostics/__fixtures__/diagnosticFixtures.ts +158 -158
  60. package/src/diagnostics/diagnostics.test.ts +878 -878
  61. package/src/diagnostics/diagnostics.ts +936 -936
  62. package/src/diagnostics/index.ts +11 -11
  63. package/src/edge/Edge.ts +23 -23
  64. package/src/edge/EdgeDefinition.ts +45 -45
  65. package/src/edge/EdgeType.ts +19 -19
  66. package/src/edge/index.ts +8 -8
  67. package/src/edge/serialization.ts +83 -83
  68. package/src/expression/index.ts +4 -4
  69. package/src/expression/parser.ts +362 -362
  70. package/src/expression/types.ts +30 -30
  71. package/src/function/FunctionDeclaration.ts +54 -54
  72. package/src/function/index.ts +3 -3
  73. package/src/function/serialization.ts +40 -40
  74. package/src/globals.d.ts +9 -9
  75. package/src/id/index.ts +8 -8
  76. package/src/index.ts +22 -22
  77. package/src/memory/Memory.ts +15 -15
  78. package/src/memory/MemoryDefinition.ts +16 -16
  79. package/src/memory/MemoryFileDefinition.ts +37 -37
  80. package/src/memory/MemoryRegistry.ts +35 -35
  81. package/src/memory/VectorDatabaseDefinition.ts +21 -21
  82. package/src/memory/index.ts +8 -8
  83. package/src/memory/serialization.ts +47 -47
  84. package/src/migration/index.ts +4 -4
  85. package/src/migration/migrate.test.ts +44 -44
  86. package/src/migration/migrate.ts +58 -58
  87. package/src/migration/migrations.ts +24 -24
  88. package/src/migration/version.ts +9 -9
  89. package/src/model/LLMModelDefinition.ts +12 -12
  90. package/src/model/Model.ts +39 -39
  91. package/src/model/ModelDefinition.ts +15 -15
  92. package/src/model/ModelRegistry.ts +33 -33
  93. package/src/model/index.ts +7 -7
  94. package/src/model/serialization.ts +30 -30
  95. package/src/node/AgentNode.ts +82 -82
  96. package/src/node/DataNode.ts +41 -41
  97. package/src/node/FunctionNode.ts +76 -76
  98. package/src/node/InputNode.ts +185 -185
  99. package/src/node/LogicNode.ts +33 -33
  100. package/src/node/MqttNode.ts +127 -127
  101. package/src/node/Node.ts +61 -61
  102. package/src/node/NodeDefinition.ts +37 -37
  103. package/src/node/NodeRegistry.ts +85 -85
  104. package/src/node/OutputNode.ts +87 -87
  105. package/src/node/ToolNode.ts +32 -32
  106. package/src/node/TriggerNode.ts +272 -272
  107. package/src/node/constants.ts +16 -16
  108. package/src/node/index.ts +26 -26
  109. package/src/node/methods.ts +278 -278
  110. package/src/node/serialization.ts +544 -544
  111. package/src/parameter/OutputParameter.ts +68 -68
  112. package/src/parameter/Parameter.ts +243 -243
  113. package/src/parameter/index.ts +33 -33
  114. package/src/variable/Variable.ts +10 -10
  115. package/src/variable/index.ts +16 -16
  116. package/src/variable/operations.ts +106 -106
  117. package/src/workflow/Workflow.ts +41 -41
  118. package/src/workflow/index.ts +3 -3
  119. package/src/workflow/serialization.test.ts +240 -240
  120. package/src/workflow/serialization.ts +242 -242
@@ -1,158 +1,158 @@
1
- import type { Edge } from "../../edge";
2
- import type { NodeDefinition, NodeData } from "../../node";
3
- import type { DataType, Expression, Reference } from "../../api";
4
- import type { Channel } from "../../channel";
5
- import type { Memory } from "../../memory";
6
- import { NodeCategory } from "../../node";
7
- import type { Variable, DeclaredVariable, NodeOutputVariable } from "../../variable";
8
- import type { Diagnostic, DiagnosticCategory } from "../diagnostics";
9
-
10
- // ============================================================================
11
- // Variable builders
12
- // ============================================================================
13
-
14
- export function makeDeclaredVar(overrides: Partial<DeclaredVariable> = {}): Variable {
15
- return {
16
- kind: "declared",
17
- uid: "v1",
18
- name: "count",
19
- dataType: "int" as DataType,
20
- ...overrides,
21
- };
22
- }
23
-
24
- export function makeNodeOutputVar(overrides: Partial<NodeOutputVariable> = {}): Variable {
25
- return {
26
- kind: "node",
27
- nodeId: "n1",
28
- outputId: "output",
29
- name: "result",
30
- dataType: "int" as DataType,
31
- ...overrides,
32
- };
33
- }
34
-
35
- /** Build an `availableVariables` map from a list of `AvailableVariable` entries. */
36
- export function makeAvailableVars(vars: Variable[]): Record<string, Variable> {
37
- const map: Record<string, Variable> = {};
38
- for (const v of vars) {
39
- const key = v.kind === "declared" ? `declared:${v.uid}` : v.kind === "fnarg" ? `fnarg:${v.uid}` : `${v.nodeId}:${v.outputId}`;
40
- map[key] = v;
41
- }
42
- return map;
43
- }
44
-
45
- // ============================================================================
46
- // Expression / Reference builders
47
- // ============================================================================
48
-
49
- export function makeExpression(expression: string, dataType: DataType = "int", references: Reference[] = []): Expression {
50
- return { expression, references, dataType };
51
- }
52
-
53
- export function makeDeclaredRef(uid: string): Reference {
54
- return { srcId: "declared", varId: uid };
55
- }
56
-
57
- // ============================================================================
58
- // Edge builder
59
- // ============================================================================
60
-
61
- export function makeEdge(
62
- id: string,
63
- source: string,
64
- sourceHandle: string,
65
- target: string,
66
- targetHandle: string,
67
- overrides: Partial<Edge> = {},
68
- ): Edge {
69
- return {
70
- id,
71
- source,
72
- sourceHandle,
73
- target,
74
- targetHandle,
75
- type: "control",
76
- ...overrides,
77
- };
78
- }
79
-
80
- // ============================================================================
81
- // Channel builders
82
- // ============================================================================
83
-
84
- export function makeChannel(overrides: Partial<Channel> = {}): Channel {
85
- return {
86
- id: "ch1",
87
- label: "GPIO 4",
88
- type: "GPIOIN",
89
- arguments: {},
90
- ...overrides,
91
- };
92
- }
93
-
94
- export function makeChannels(channels: Channel[]): Record<string, Channel> {
95
- const map: Record<string, Channel> = {};
96
- for (const v of channels) map[v.id] = v;
97
- return map;
98
- }
99
-
100
- // ============================================================================
101
- // Memory builders
102
- // ============================================================================
103
-
104
- export function makeMemory(overrides: Partial<Memory> = {}): Memory {
105
- return {
106
- id: "mem1",
107
- label: "memory1",
108
- type: "MemoryFile",
109
- arguments: {},
110
- ...overrides,
111
- };
112
- }
113
-
114
- export function makeMemories(memories: Memory[]): Record<string, Memory> {
115
- const map: Record<string, Memory> = {};
116
- for (const m of memories) map[m.id] = m;
117
- return map;
118
- }
119
-
120
- // ============================================================================
121
- // Node instance builder — untyped escape hatch
122
- // ============================================================================
123
-
124
- /**
125
- * Build a minimal NodeData. Tests assert against the shape `computeNodeDiagnostics`
126
- * sees (arguments record + type discriminator), not against the strict per-type shapes,
127
- * so we widen to `NodeData` via unknown at the boundary.
128
- */
129
- export function makeNode(type: string, args: Record<string, unknown>, overrides: Record<string, unknown> = {}): NodeData {
130
- return { id: "n1", type, arguments: args, ...overrides } as unknown as NodeData;
131
- }
132
-
133
- // ============================================================================
134
- // Synthetic NodeDefinition builder
135
- // ============================================================================
136
-
137
- export function makeNodeDef(overrides: Partial<NodeDefinition> = {}): NodeDefinition {
138
- return {
139
- type: "Synthetic" as NodeDefinition["type"],
140
- label: "Synthetic Node",
141
- category: NodeCategory.Input,
142
- description: "Synthetic node used only in tests",
143
- parameters: [],
144
- ...overrides,
145
- };
146
- }
147
-
148
- // ============================================================================
149
- // Diagnostic assertion helpers
150
- // ============================================================================
151
-
152
- export function diagsOfCategory(diags: Diagnostic[], category: DiagnosticCategory): Diagnostic[] {
153
- return diags.filter((d) => d.category === category);
154
- }
155
-
156
- export function hasDiag(diags: Diagnostic[], predicate: (d: Diagnostic) => boolean): boolean {
157
- return diags.some(predicate);
158
- }
1
+ import type { Edge } from "../../edge";
2
+ import type { NodeDefinition, NodeData } from "../../node";
3
+ import type { DataType, Expression, Reference } from "../../api";
4
+ import type { Channel } from "../../channel";
5
+ import type { Memory } from "../../memory";
6
+ import { NodeCategory } from "../../node";
7
+ import type { Variable, DeclaredVariable, NodeOutputVariable } from "../../variable";
8
+ import type { Diagnostic, DiagnosticCategory } from "../diagnostics";
9
+
10
+ // ============================================================================
11
+ // Variable builders
12
+ // ============================================================================
13
+
14
+ export function makeDeclaredVar(overrides: Partial<DeclaredVariable> = {}): Variable {
15
+ return {
16
+ kind: "declared",
17
+ uid: "v1",
18
+ name: "count",
19
+ dataType: "int" as DataType,
20
+ ...overrides,
21
+ };
22
+ }
23
+
24
+ export function makeNodeOutputVar(overrides: Partial<NodeOutputVariable> = {}): Variable {
25
+ return {
26
+ kind: "node",
27
+ nodeId: "n1",
28
+ outputId: "output",
29
+ name: "result",
30
+ dataType: "int" as DataType,
31
+ ...overrides,
32
+ };
33
+ }
34
+
35
+ /** Build an `availableVariables` map from a list of `AvailableVariable` entries. */
36
+ export function makeAvailableVars(vars: Variable[]): Record<string, Variable> {
37
+ const map: Record<string, Variable> = {};
38
+ for (const v of vars) {
39
+ const key = v.kind === "declared" ? `declared:${v.uid}` : v.kind === "fnarg" ? `fnarg:${v.uid}` : `${v.nodeId}:${v.outputId}`;
40
+ map[key] = v;
41
+ }
42
+ return map;
43
+ }
44
+
45
+ // ============================================================================
46
+ // Expression / Reference builders
47
+ // ============================================================================
48
+
49
+ export function makeExpression(expression: string, dataType: DataType = "int", references: Reference[] = []): Expression {
50
+ return { expression, references, dataType };
51
+ }
52
+
53
+ export function makeDeclaredRef(uid: string): Reference {
54
+ return { srcId: "declared", varId: uid };
55
+ }
56
+
57
+ // ============================================================================
58
+ // Edge builder
59
+ // ============================================================================
60
+
61
+ export function makeEdge(
62
+ id: string,
63
+ source: string,
64
+ sourceHandle: string,
65
+ target: string,
66
+ targetHandle: string,
67
+ overrides: Partial<Edge> = {},
68
+ ): Edge {
69
+ return {
70
+ id,
71
+ source,
72
+ sourceHandle,
73
+ target,
74
+ targetHandle,
75
+ type: "control",
76
+ ...overrides,
77
+ };
78
+ }
79
+
80
+ // ============================================================================
81
+ // Channel builders
82
+ // ============================================================================
83
+
84
+ export function makeChannel(overrides: Partial<Channel> = {}): Channel {
85
+ return {
86
+ id: "ch1",
87
+ label: "GPIO 4",
88
+ type: "GPIOIN",
89
+ arguments: {},
90
+ ...overrides,
91
+ };
92
+ }
93
+
94
+ export function makeChannels(channels: Channel[]): Record<string, Channel> {
95
+ const map: Record<string, Channel> = {};
96
+ for (const v of channels) map[v.id] = v;
97
+ return map;
98
+ }
99
+
100
+ // ============================================================================
101
+ // Memory builders
102
+ // ============================================================================
103
+
104
+ export function makeMemory(overrides: Partial<Memory> = {}): Memory {
105
+ return {
106
+ id: "mem1",
107
+ label: "memory1",
108
+ type: "MemoryFile",
109
+ arguments: {},
110
+ ...overrides,
111
+ };
112
+ }
113
+
114
+ export function makeMemories(memories: Memory[]): Record<string, Memory> {
115
+ const map: Record<string, Memory> = {};
116
+ for (const m of memories) map[m.id] = m;
117
+ return map;
118
+ }
119
+
120
+ // ============================================================================
121
+ // Node instance builder — untyped escape hatch
122
+ // ============================================================================
123
+
124
+ /**
125
+ * Build a minimal NodeData. Tests assert against the shape `computeNodeDiagnostics`
126
+ * sees (arguments record + type discriminator), not against the strict per-type shapes,
127
+ * so we widen to `NodeData` via unknown at the boundary.
128
+ */
129
+ export function makeNode(type: string, args: Record<string, unknown>, overrides: Record<string, unknown> = {}): NodeData {
130
+ return { id: "n1", type, arguments: args, ...overrides } as unknown as NodeData;
131
+ }
132
+
133
+ // ============================================================================
134
+ // Synthetic NodeDefinition builder
135
+ // ============================================================================
136
+
137
+ export function makeNodeDef(overrides: Partial<NodeDefinition> = {}): NodeDefinition {
138
+ return {
139
+ type: "Synthetic" as NodeDefinition["type"],
140
+ label: "Synthetic Node",
141
+ category: NodeCategory.Input,
142
+ description: "Synthetic node used only in tests",
143
+ parameters: [],
144
+ ...overrides,
145
+ };
146
+ }
147
+
148
+ // ============================================================================
149
+ // Diagnostic assertion helpers
150
+ // ============================================================================
151
+
152
+ export function diagsOfCategory(diags: Diagnostic[], category: DiagnosticCategory): Diagnostic[] {
153
+ return diags.filter((d) => d.category === category);
154
+ }
155
+
156
+ export function hasDiag(diags: Diagnostic[], predicate: (d: Diagnostic) => boolean): boolean {
157
+ return diags.some(predicate);
158
+ }