@foresthubai/workflow-core 0.4.3 → 0.4.5
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.
- package/LICENSE +202 -202
- package/NOTICE +14 -14
- package/README.md +63 -63
- package/dist/api/deployment.d.ts +74 -0
- package/dist/api/deployment.d.ts.map +1 -0
- package/dist/api/deployment.js +6 -0
- package/dist/api/deployment.js.map +1 -0
- package/dist/api/engine.d.ts +744 -0
- package/dist/api/engine.d.ts.map +1 -0
- package/dist/api/engine.js +6 -0
- package/dist/api/engine.js.map +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/workflow.d.ts +25 -9
- package/dist/api/workflow.d.ts.map +1 -1
- package/dist/channel/Channel.d.ts +1 -1
- package/dist/channel/Channel.d.ts.map +1 -1
- package/dist/channel/Channel.js +3 -1
- package/dist/channel/Channel.js.map +1 -1
- package/dist/channel/ChannelDefinition.d.ts.map +1 -1
- package/dist/channel/ChannelDefinition.js +24 -0
- package/dist/channel/ChannelDefinition.js.map +1 -1
- package/dist/channel/index.d.ts.map +1 -1
- package/dist/channel/index.js +2 -0
- package/dist/channel/index.js.map +1 -1
- package/dist/channel/serialization.d.ts.map +1 -1
- package/dist/channel/serialization.js +8 -0
- package/dist/channel/serialization.js.map +1 -1
- package/dist/deploy/index.d.ts +5 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/index.js +4 -1
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/inputs.d.ts +26 -0
- package/dist/deploy/inputs.d.ts.map +1 -0
- package/dist/deploy/inputs.js +4 -0
- package/dist/deploy/inputs.js.map +1 -0
- package/dist/deploy/requirements.d.ts +24 -0
- package/dist/deploy/requirements.d.ts.map +1 -1
- package/dist/deploy/requirements.js +63 -0
- package/dist/deploy/requirements.js.map +1 -1
- package/dist/deploy/spec.d.ts +27 -0
- package/dist/deploy/spec.d.ts.map +1 -0
- package/dist/deploy/spec.js +352 -0
- package/dist/deploy/spec.js.map +1 -0
- package/dist/diagnostics/__fixtures__/diagnosticFixtures.d.ts.map +1 -1
- package/dist/diagnostics/__fixtures__/diagnosticFixtures.js +2 -0
- package/dist/diagnostics/__fixtures__/diagnosticFixtures.js.map +1 -1
- package/dist/diagnostics/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics/diagnostics.js +2 -0
- package/dist/diagnostics/diagnostics.js.map +1 -1
- package/dist/diagnostics/index.d.ts.map +1 -1
- package/dist/diagnostics/index.js +2 -0
- package/dist/diagnostics/index.js.map +1 -1
- package/dist/edge/Edge.d.ts.map +1 -1
- package/dist/edge/Edge.js +2 -0
- package/dist/edge/Edge.js.map +1 -1
- package/dist/edge/EdgeDefinition.d.ts.map +1 -1
- package/dist/edge/EdgeDefinition.js +2 -0
- package/dist/edge/EdgeDefinition.js.map +1 -1
- package/dist/edge/EdgeType.d.ts.map +1 -1
- package/dist/edge/EdgeType.js +2 -0
- package/dist/edge/EdgeType.js.map +1 -1
- package/dist/edge/index.d.ts.map +1 -1
- package/dist/edge/index.js +2 -2
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/serialization.d.ts.map +1 -1
- package/dist/edge/serialization.js +2 -0
- package/dist/edge/serialization.js.map +1 -1
- package/dist/expression/index.d.ts.map +1 -1
- package/dist/expression/index.js +2 -0
- package/dist/expression/index.js.map +1 -1
- package/dist/expression/parser.d.ts.map +1 -1
- package/dist/expression/parser.js +2 -0
- package/dist/expression/parser.js.map +1 -1
- package/dist/expression/types.d.ts.map +1 -1
- package/dist/expression/types.js +2 -0
- package/dist/expression/types.js.map +1 -1
- package/dist/function/FunctionDeclaration.d.ts.map +1 -1
- package/dist/function/FunctionDeclaration.js +2 -0
- package/dist/function/FunctionDeclaration.js.map +1 -1
- package/dist/function/index.d.ts.map +1 -1
- package/dist/function/index.js +2 -0
- package/dist/function/index.js.map +1 -1
- package/dist/function/serialization.d.ts.map +1 -1
- package/dist/function/serialization.js +2 -0
- package/dist/function/serialization.js.map +1 -1
- package/dist/id/index.d.ts.map +1 -1
- package/dist/id/index.js +2 -0
- package/dist/id/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/Memory.d.ts.map +1 -1
- package/dist/memory/Memory.js +2 -0
- package/dist/memory/Memory.js.map +1 -1
- package/dist/memory/MemoryDefinition.d.ts.map +1 -1
- package/dist/memory/MemoryDefinition.js +2 -0
- package/dist/memory/MemoryDefinition.js.map +1 -1
- package/dist/memory/MemoryFileDefinition.d.ts.map +1 -1
- package/dist/memory/MemoryFileDefinition.js +2 -0
- package/dist/memory/MemoryFileDefinition.js.map +1 -1
- package/dist/memory/MemoryRegistry.d.ts.map +1 -1
- package/dist/memory/MemoryRegistry.js +2 -0
- package/dist/memory/MemoryRegistry.js.map +1 -1
- package/dist/memory/VectorDatabaseDefinition.d.ts.map +1 -1
- package/dist/memory/VectorDatabaseDefinition.js +2 -0
- package/dist/memory/VectorDatabaseDefinition.js.map +1 -1
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +2 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/serialization.d.ts.map +1 -1
- package/dist/memory/serialization.js +2 -0
- package/dist/memory/serialization.js.map +1 -1
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +2 -0
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/migrate.d.ts.map +1 -1
- package/dist/migration/migrate.js +2 -0
- package/dist/migration/migrate.js.map +1 -1
- package/dist/migration/migrations.d.ts.map +1 -1
- package/dist/migration/migrations.js +2 -0
- package/dist/migration/migrations.js.map +1 -1
- package/dist/migration/version.d.ts.map +1 -1
- package/dist/migration/version.js +2 -0
- package/dist/migration/version.js.map +1 -1
- package/dist/model/LLMModelDefinition.d.ts.map +1 -1
- package/dist/model/LLMModelDefinition.js +2 -0
- package/dist/model/LLMModelDefinition.js.map +1 -1
- package/dist/model/Model.d.ts.map +1 -1
- package/dist/model/Model.js +2 -13
- package/dist/model/Model.js.map +1 -1
- package/dist/model/ModelDefinition.d.ts.map +1 -1
- package/dist/model/ModelDefinition.js +2 -0
- package/dist/model/ModelDefinition.js.map +1 -1
- package/dist/model/ModelRegistry.d.ts.map +1 -1
- package/dist/model/ModelRegistry.js +2 -0
- package/dist/model/ModelRegistry.js.map +1 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +2 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/serialization.d.ts.map +1 -1
- package/dist/model/serialization.js +2 -0
- package/dist/model/serialization.js.map +1 -1
- package/dist/node/AgentNode.d.ts.map +1 -1
- package/dist/node/AgentNode.js +2 -0
- package/dist/node/AgentNode.js.map +1 -1
- package/dist/node/DataNode.d.ts.map +1 -1
- package/dist/node/DataNode.js +2 -0
- package/dist/node/DataNode.js.map +1 -1
- package/dist/node/FunctionNode.d.ts.map +1 -1
- package/dist/node/FunctionNode.js +2 -0
- package/dist/node/FunctionNode.js.map +1 -1
- package/dist/node/InputNode.d.ts.map +1 -1
- package/dist/node/InputNode.js +2 -0
- package/dist/node/InputNode.js.map +1 -1
- package/dist/node/LogicNode.d.ts.map +1 -1
- package/dist/node/LogicNode.js +2 -0
- package/dist/node/LogicNode.js.map +1 -1
- package/dist/node/MqttNode.d.ts.map +1 -1
- package/dist/node/MqttNode.js +2 -0
- package/dist/node/MqttNode.js.map +1 -1
- package/dist/node/Node.d.ts.map +1 -1
- package/dist/node/Node.js +2 -7
- package/dist/node/Node.js.map +1 -1
- package/dist/node/NodeDefinition.d.ts.map +1 -1
- package/dist/node/NodeDefinition.js +2 -0
- package/dist/node/NodeDefinition.js.map +1 -1
- package/dist/node/NodeRegistry.d.ts.map +1 -1
- package/dist/node/NodeRegistry.js +2 -0
- package/dist/node/NodeRegistry.js.map +1 -1
- package/dist/node/OutputNode.d.ts.map +1 -1
- package/dist/node/OutputNode.js +4 -2
- package/dist/node/OutputNode.js.map +1 -1
- package/dist/node/ToolNode.d.ts.map +1 -1
- package/dist/node/ToolNode.js +2 -0
- package/dist/node/ToolNode.js.map +1 -1
- package/dist/node/TriggerNode.d.ts.map +1 -1
- package/dist/node/TriggerNode.js +2 -0
- package/dist/node/TriggerNode.js.map +1 -1
- package/dist/node/constants.d.ts.map +1 -1
- package/dist/node/constants.js +2 -0
- package/dist/node/constants.js.map +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/methods.d.ts.map +1 -1
- package/dist/node/methods.js +2 -0
- package/dist/node/methods.js.map +1 -1
- package/dist/node/serialization.d.ts.map +1 -1
- package/dist/node/serialization.js +33 -13
- package/dist/node/serialization.js.map +1 -1
- package/dist/parameter/OutputParameter.d.ts.map +1 -1
- package/dist/parameter/OutputParameter.js +2 -0
- package/dist/parameter/OutputParameter.js.map +1 -1
- package/dist/parameter/Parameter.d.ts.map +1 -1
- package/dist/parameter/Parameter.js +2 -0
- package/dist/parameter/Parameter.js.map +1 -1
- package/dist/parameter/index.d.ts.map +1 -1
- package/dist/parameter/index.js +2 -0
- package/dist/parameter/index.js.map +1 -1
- package/dist/variable/Variable.d.ts.map +1 -1
- package/dist/variable/Variable.js +2 -0
- package/dist/variable/Variable.js.map +1 -1
- package/dist/variable/index.d.ts.map +1 -1
- package/dist/variable/index.js +2 -3
- package/dist/variable/index.js.map +1 -1
- package/dist/variable/operations.d.ts.map +1 -1
- package/dist/variable/operations.js +2 -0
- package/dist/variable/operations.js.map +1 -1
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +2 -0
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +2 -0
- package/dist/workflow/index.js.map +1 -1
- package/dist/workflow/serialization.d.ts.map +1 -1
- package/dist/workflow/serialization.js +2 -4
- package/dist/workflow/serialization.js.map +1 -1
- package/package.json +2 -2
- package/src/api/deployment.ts +74 -0
- package/src/api/engine.ts +744 -0
- package/src/api/index.ts +29 -11
- package/src/api/workflow.ts +25 -9
- package/src/channel/Channel.ts +14 -11
- package/src/channel/ChannelDefinition.ts +101 -76
- package/src/channel/index.ts +9 -6
- package/src/channel/serialization.ts +77 -68
- package/src/deploy/index.ts +17 -1
- package/src/deploy/inputs.ts +44 -0
- package/src/deploy/requirements.test.ts +64 -61
- package/src/deploy/requirements.ts +159 -41
- package/src/deploy/spec.test.ts +227 -0
- package/src/deploy/spec.ts +397 -0
- package/src/diagnostics/__fixtures__/diagnosticFixtures.ts +161 -158
- package/src/diagnostics/diagnostics.test.ts +881 -878
- package/src/diagnostics/diagnostics.ts +939 -936
- package/src/diagnostics/index.ts +14 -11
- package/src/edge/Edge.ts +26 -23
- package/src/edge/EdgeDefinition.ts +48 -45
- package/src/edge/EdgeType.ts +22 -19
- package/src/edge/index.ts +11 -8
- package/src/edge/serialization.ts +86 -83
- package/src/expression/index.ts +7 -4
- package/src/expression/parser.ts +365 -362
- package/src/expression/types.ts +33 -30
- package/src/function/FunctionDeclaration.ts +57 -54
- package/src/function/index.ts +6 -3
- package/src/function/serialization.ts +43 -40
- package/src/globals.d.ts +12 -9
- package/src/id/index.ts +11 -8
- package/src/index.ts +25 -22
- package/src/memory/Memory.ts +18 -15
- package/src/memory/MemoryDefinition.ts +19 -16
- package/src/memory/MemoryFileDefinition.ts +40 -37
- package/src/memory/MemoryRegistry.ts +38 -35
- package/src/memory/VectorDatabaseDefinition.ts +24 -21
- package/src/memory/index.ts +11 -8
- package/src/memory/serialization.ts +50 -47
- package/src/migration/index.ts +7 -4
- package/src/migration/migrate.test.ts +47 -44
- package/src/migration/migrate.ts +61 -58
- package/src/migration/migrations.ts +27 -24
- package/src/migration/version.ts +12 -9
- package/src/model/LLMModelDefinition.ts +15 -12
- package/src/model/Model.ts +42 -39
- package/src/model/ModelDefinition.ts +18 -15
- package/src/model/ModelRegistry.ts +36 -33
- package/src/model/index.ts +10 -7
- package/src/model/serialization.ts +33 -30
- package/src/node/AgentNode.ts +85 -82
- package/src/node/DataNode.ts +44 -41
- package/src/node/FunctionNode.ts +79 -76
- package/src/node/InputNode.ts +188 -185
- package/src/node/LogicNode.ts +36 -33
- package/src/node/MqttNode.ts +130 -127
- package/src/node/Node.ts +64 -61
- package/src/node/NodeDefinition.ts +40 -37
- package/src/node/NodeRegistry.ts +88 -85
- package/src/node/OutputNode.ts +90 -87
- package/src/node/ToolNode.ts +35 -32
- package/src/node/TriggerNode.ts +275 -272
- package/src/node/constants.ts +19 -16
- package/src/node/index.ts +29 -26
- package/src/node/methods.ts +281 -278
- package/src/node/serialization.test.ts +51 -0
- package/src/node/serialization.ts +565 -544
- package/src/parameter/OutputParameter.ts +71 -68
- package/src/parameter/Parameter.ts +246 -243
- package/src/parameter/index.ts +36 -33
- package/src/variable/Variable.ts +13 -10
- package/src/variable/index.ts +19 -16
- package/src/variable/operations.ts +109 -106
- package/src/workflow/Workflow.ts +44 -41
- package/src/workflow/index.ts +6 -3
- package/src/workflow/serialization.test.ts +243 -240
- package/src/workflow/serialization.ts +245 -242
|
@@ -1,243 +1,246 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
* `
|
|
117
|
-
*
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
| (ParameterBase &
|
|
136
|
-
| (ParameterBase &
|
|
137
|
-
| (ParameterBase &
|
|
138
|
-
| (ParameterBase &
|
|
139
|
-
| (ParameterBase &
|
|
140
|
-
| (ParameterBase &
|
|
141
|
-
| (ParameterBase &
|
|
142
|
-
| (ParameterBase &
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
*
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 ForestHub.
|
|
3
|
+
|
|
4
|
+
import type { Expression, Reference } from "../api";
|
|
5
|
+
import type { ChannelType } from "../channel";
|
|
6
|
+
import type { MemoryType } from "../memory";
|
|
7
|
+
import type { ModelType, ModelCapability } from "../model";
|
|
8
|
+
import { refToLookupKey } from "../variable";
|
|
9
|
+
import type { Schemas } from "../api";
|
|
10
|
+
|
|
11
|
+
export type DataType = Schemas["DataType"];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A field that is either a static value of T, or a function that derives T
|
|
15
|
+
* from the owning node's current arguments. Scope is strictly args-only —
|
|
16
|
+
* no access to variables, IO labels, or other canvas state. For wider
|
|
17
|
+
* context, use a purpose-named accessor (e.g. resolveExpressionType).
|
|
18
|
+
*/
|
|
19
|
+
export type FromArgs<T> = T | ((args: Record<string, unknown>) => T);
|
|
20
|
+
|
|
21
|
+
/** Unwrap a FromArgs value against the current node arguments. */
|
|
22
|
+
export function unwrapFromArgs<T>(value: FromArgs<T>, args: Record<string, unknown>): T {
|
|
23
|
+
return typeof value === "function" ? (value as (args: Record<string, unknown>) => T)(args) : value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Parameter definitions
|
|
28
|
+
// ============================================================================
|
|
29
|
+
|
|
30
|
+
export interface ParameterBase {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
description: string;
|
|
34
|
+
optional?: boolean;
|
|
35
|
+
/** Parameter is only active (visible, validated, serialized) when all rules are met. */
|
|
36
|
+
activationRules?: ActivationRule[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface BasicParam {
|
|
40
|
+
type: "int" | "float" | "time";
|
|
41
|
+
default?: number | string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface StringParam {
|
|
45
|
+
type: "string";
|
|
46
|
+
multiline?: boolean;
|
|
47
|
+
default?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface BoolParam {
|
|
51
|
+
type: "bool";
|
|
52
|
+
default: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface WeekdaysParam {
|
|
56
|
+
type: "weekdays";
|
|
57
|
+
default: string[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface SelectionParam {
|
|
61
|
+
type: "selection";
|
|
62
|
+
options: Array<{ value: string; label: string }>;
|
|
63
|
+
default?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ExpressionParam {
|
|
67
|
+
type: "expression";
|
|
68
|
+
/** Type can be dynamic (static value or args-only lambda). */
|
|
69
|
+
expressionType: FromArgs<DataType>;
|
|
70
|
+
/**
|
|
71
|
+
* Escape hatch for the variableSelect case: when set, points to the id of a sibling
|
|
72
|
+
* variableSelect parameter. If that parameter holds a live Reference, the expressionType
|
|
73
|
+
* is taken from the referenced variable. Falls back to `expressionType` otherwise.
|
|
74
|
+
*/
|
|
75
|
+
fromReference?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Required: An expression always has a value object never an unset state.
|
|
78
|
+
*/
|
|
79
|
+
default: Expression;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Reference-select parameters: pick an external entity by id. No `default`.
|
|
83
|
+
|
|
84
|
+
export interface VariableSelectParam {
|
|
85
|
+
type: "variableSelect";
|
|
86
|
+
default?: never;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Model reference parameter — selects a model id from the static catalog (props)
|
|
90
|
+
// unioned with declared custom models, filtered by model type and capability.
|
|
91
|
+
export interface ModelSelectParam {
|
|
92
|
+
type: "modelSelect";
|
|
93
|
+
/** Model types this slot accepts (e.g. ["LLMModel"]). Static list or args-derived lambda. */
|
|
94
|
+
modelType: FromArgs<ModelType[]>;
|
|
95
|
+
/** Optional capability filter (e.g. ["chat"]) applied to catalog and declared models alike. */
|
|
96
|
+
capabilities?: FromArgs<ModelCapability[]>;
|
|
97
|
+
default?: never;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface ChannelSelectParam {
|
|
101
|
+
type: "channelSelect";
|
|
102
|
+
/** Channel types this slot accepts. Static list or args-derived lambda. */
|
|
103
|
+
channelType: FromArgs<ChannelType[]>;
|
|
104
|
+
default?: never;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface MemorySelectParam {
|
|
108
|
+
type: "memorySelect";
|
|
109
|
+
/** Memory types this slot accepts (e.g. ["VectorDatabase"]). Static list or args-derived lambda. */
|
|
110
|
+
memoryType: FromArgs<MemoryType[]>;
|
|
111
|
+
default?: never;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* List parameter that binds an agent node to project-declared memory files,
|
|
116
|
+
* each with an access mode (`r` = read-only, `rw` = read + write). The editor
|
|
117
|
+
* holds the array directly; the API schema (`MemoryRef[]`) round-trips 1:1.
|
|
118
|
+
*
|
|
119
|
+
* `default` is required: a list param is always a
|
|
120
|
+
* concrete array, never unset — declare `default: []` for "starts empty".
|
|
121
|
+
*/
|
|
122
|
+
export interface MemoryRefsParam {
|
|
123
|
+
type: "memory-refs";
|
|
124
|
+
default: Schemas["MemoryRef"][];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Union of all reference-select parameter variants, used for type guards. */
|
|
128
|
+
export type ReferenceSelectParam = VariableSelectParam | ChannelSelectParam | MemorySelectParam | ModelSelectParam;
|
|
129
|
+
|
|
130
|
+
export function isReferenceSelectParam(param: Parameter): param is ParameterBase & ReferenceSelectParam {
|
|
131
|
+
return param.type === "variableSelect" || param.type === "channelSelect" || param.type === "memorySelect" || param.type === "modelSelect";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type Parameter =
|
|
135
|
+
| (ParameterBase & BasicParam)
|
|
136
|
+
| (ParameterBase & VariableSelectParam)
|
|
137
|
+
| (ParameterBase & StringParam)
|
|
138
|
+
| (ParameterBase & BoolParam)
|
|
139
|
+
| (ParameterBase & WeekdaysParam)
|
|
140
|
+
| (ParameterBase & SelectionParam)
|
|
141
|
+
| (ParameterBase & MemorySelectParam)
|
|
142
|
+
| (ParameterBase & ModelSelectParam)
|
|
143
|
+
| (ParameterBase & ExpressionParam)
|
|
144
|
+
| (ParameterBase & ChannelSelectParam)
|
|
145
|
+
| (ParameterBase & MemoryRefsParam);
|
|
146
|
+
|
|
147
|
+
// ============================================================================
|
|
148
|
+
// Parameter activation rules
|
|
149
|
+
// ============================================================================
|
|
150
|
+
|
|
151
|
+
/** Typed union of rules that control whether a parameter is active (visible, validated, serialized). */
|
|
152
|
+
export type ActivationRule =
|
|
153
|
+
| { type: "parameterIn"; parameterId: string; values: unknown[] }
|
|
154
|
+
| { type: "isControlFlow" }
|
|
155
|
+
| { type: "isToolInput" };
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Evaluate whether a parameter is active (visible, validated, serialized) given current context.
|
|
159
|
+
* All rules must be satisfied (AND logic). Undefined or empty array = always active.
|
|
160
|
+
*/
|
|
161
|
+
export function isParameterActive(param: Parameter, parameterValues: Record<string, unknown>, isToolInput: boolean): boolean {
|
|
162
|
+
if (!param.activationRules?.length) return true;
|
|
163
|
+
return param.activationRules.every((cond) => {
|
|
164
|
+
switch (cond.type) {
|
|
165
|
+
case "isControlFlow":
|
|
166
|
+
return !isToolInput;
|
|
167
|
+
case "isToolInput":
|
|
168
|
+
return isToolInput;
|
|
169
|
+
case "parameterIn":
|
|
170
|
+
return cond.values.includes(parameterValues[cond.parameterId]);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Whether a scalar argument value counts as "unset" for api purposes:
|
|
177
|
+
* `undefined`, `null`, or `""`. Deliberately NOT `false`/`0` (valid values) nor
|
|
178
|
+
* `[]` — an empty list is a real value, since list params are always
|
|
179
|
+
* materialized to a concrete array. Shared by required-param diagnostics and
|
|
180
|
+
* {@link pruneArguments} so "unset" has exactly one definition.
|
|
181
|
+
*/
|
|
182
|
+
export function isEmpty(value: unknown): boolean {
|
|
183
|
+
return value === undefined || value === null || value === "";
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Prune arguments that must not appear in the api, at the domain→api boundary.
|
|
188
|
+
* Mutates `args` in place. Two reasons an arg is dropped:
|
|
189
|
+
* 1. inactive — its parameter's activation rules aren't met for this context.
|
|
190
|
+
* 2. the parameter {@link isEmpty}.
|
|
191
|
+
*/
|
|
192
|
+
export function pruneArguments(args: Record<string, unknown>, parameters: readonly Parameter[], isToolInput = false): void {
|
|
193
|
+
for (const param of parameters) {
|
|
194
|
+
const inactive = !!param.activationRules?.length && !isParameterActive(param, args, isToolInput);
|
|
195
|
+
if (inactive || isEmpty(args[param.id])) {
|
|
196
|
+
delete args[param.id];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ============================================================================
|
|
202
|
+
// Parameter resolvers
|
|
203
|
+
// ============================================================================
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Resolve an ExpressionParam's expected dataType. Handles the `fromReference` escape hatch
|
|
207
|
+
* (type taken from a live variableSelect sibling parameter) and falls back to the
|
|
208
|
+
* declared FromArgs<DataType>.
|
|
209
|
+
*/
|
|
210
|
+
export function resolveExpressionType(
|
|
211
|
+
param: ExpressionParam,
|
|
212
|
+
args: Record<string, unknown>,
|
|
213
|
+
variables: Record<string, { dataType: DataType }>,
|
|
214
|
+
): DataType {
|
|
215
|
+
if (param.fromReference) {
|
|
216
|
+
const ref = args[param.fromReference] as Reference | undefined;
|
|
217
|
+
if (ref?.varId) {
|
|
218
|
+
const v = variables[refToLookupKey(ref)];
|
|
219
|
+
if (v) return v.dataType;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return unwrapFromArgs(param.expressionType, args);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Resolve a capability filter (ModelSelectParam) for the current node arguments. */
|
|
226
|
+
export function resolveCapabilities(
|
|
227
|
+
param: { capabilities?: FromArgs<ModelCapability[]> },
|
|
228
|
+
args: Record<string, unknown>,
|
|
229
|
+
): ModelCapability[] | undefined {
|
|
230
|
+
return param.capabilities === undefined ? undefined : unwrapFromArgs(param.capabilities, args);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Resolve the allowed channel types for a ChannelSelectParam. */
|
|
234
|
+
export function resolveChannelTypes(param: ChannelSelectParam, args: Record<string, unknown>): ChannelType[] {
|
|
235
|
+
return unwrapFromArgs(param.channelType, args);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Resolve the allowed memory types for a MemorySelectParam. */
|
|
239
|
+
export function resolveMemoryTypes(param: MemorySelectParam, args: Record<string, unknown>): MemoryType[] {
|
|
240
|
+
return unwrapFromArgs(param.memoryType, args);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Resolve the allowed model types for a ModelSelectParam. */
|
|
244
|
+
export function resolveModelTypes(param: ModelSelectParam, args: Record<string, unknown>): ModelType[] {
|
|
245
|
+
return unwrapFromArgs(param.modelType, args);
|
|
246
|
+
}
|
package/src/parameter/index.ts
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 ForestHub.
|
|
3
|
+
|
|
4
|
+
export type {
|
|
5
|
+
DataType,
|
|
6
|
+
FromArgs,
|
|
7
|
+
ParameterBase,
|
|
8
|
+
BasicParam,
|
|
9
|
+
StringParam,
|
|
10
|
+
BoolParam,
|
|
11
|
+
WeekdaysParam,
|
|
12
|
+
SelectionParam,
|
|
13
|
+
ExpressionParam,
|
|
14
|
+
VariableSelectParam,
|
|
15
|
+
ModelSelectParam,
|
|
16
|
+
ChannelSelectParam,
|
|
17
|
+
MemorySelectParam,
|
|
18
|
+
MemoryRefsParam,
|
|
19
|
+
ReferenceSelectParam,
|
|
20
|
+
Parameter,
|
|
21
|
+
ActivationRule,
|
|
22
|
+
} from "./Parameter";
|
|
23
|
+
export {
|
|
24
|
+
unwrapFromArgs,
|
|
25
|
+
isReferenceSelectParam,
|
|
26
|
+
isParameterActive,
|
|
27
|
+
isEmpty,
|
|
28
|
+
pruneArguments,
|
|
29
|
+
resolveExpressionType,
|
|
30
|
+
resolveCapabilities,
|
|
31
|
+
resolveChannelTypes,
|
|
32
|
+
resolveMemoryTypes,
|
|
33
|
+
resolveModelTypes,
|
|
34
|
+
} from "./Parameter";
|
|
35
|
+
export type { OutputBinding, OutputDeclaration, StaticOutput, OutputList, OutputParameter } from "./OutputParameter";
|
|
36
|
+
export { resolveStaticOutputDataType } from "./OutputParameter";
|
package/src/variable/Variable.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export type
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 ForestHub.
|
|
3
|
+
|
|
4
|
+
import type { Schemas } from "../api";
|
|
5
|
+
import type { DataType } from "../api";
|
|
6
|
+
|
|
7
|
+
export type ApiVariable = Schemas["Variable"]; // Differentiate from domain variable type
|
|
8
|
+
|
|
9
|
+
export type NodeOutputVariable = { kind: "node"; nodeId: string; outputId: string; name: string; dataType: DataType };
|
|
10
|
+
export type DeclaredVariable = { kind: "declared"; uid: string; name: string; dataType: DataType; initialValue?: unknown };
|
|
11
|
+
export type FunctionArgVariable = { kind: "fnarg"; uid: string; name: string; dataType: DataType };
|
|
12
|
+
|
|
13
|
+
export type Variable = NodeOutputVariable | DeclaredVariable | FunctionArgVariable;
|
package/src/variable/index.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 ForestHub.
|
|
3
|
+
|
|
4
|
+
// Public surface of the variable module. The discriminated-union types live in
|
|
5
|
+
// ./Variable; the key/lookup/uid helpers and availability computation live in
|
|
6
|
+
// ./operations. This file is a barrel only. Mirrors channel/memory/model.
|
|
7
|
+
|
|
8
|
+
export type { ApiVariable, NodeOutputVariable, DeclaredVariable, FunctionArgVariable, Variable } from "./Variable";
|
|
9
|
+
export {
|
|
10
|
+
varKey,
|
|
11
|
+
declaredVarKey,
|
|
12
|
+
fnargKey,
|
|
13
|
+
nodeOutputVarKey,
|
|
14
|
+
refToLookupKey,
|
|
15
|
+
ensureUid,
|
|
16
|
+
ensureUids,
|
|
17
|
+
paramKey,
|
|
18
|
+
computeAvailableVariables,
|
|
19
|
+
} from "./operations";
|