@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.
Files changed (298) 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 +74 -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/index.js +2 -0
  15. package/dist/api/index.js.map +1 -1
  16. package/dist/api/workflow.d.ts +25 -9
  17. package/dist/api/workflow.d.ts.map +1 -1
  18. package/dist/channel/Channel.d.ts +1 -1
  19. package/dist/channel/Channel.d.ts.map +1 -1
  20. package/dist/channel/Channel.js +3 -1
  21. package/dist/channel/Channel.js.map +1 -1
  22. package/dist/channel/ChannelDefinition.d.ts.map +1 -1
  23. package/dist/channel/ChannelDefinition.js +24 -0
  24. package/dist/channel/ChannelDefinition.js.map +1 -1
  25. package/dist/channel/index.d.ts.map +1 -1
  26. package/dist/channel/index.js +2 -0
  27. package/dist/channel/index.js.map +1 -1
  28. package/dist/channel/serialization.d.ts.map +1 -1
  29. package/dist/channel/serialization.js +8 -0
  30. package/dist/channel/serialization.js.map +1 -1
  31. package/dist/deploy/index.d.ts +5 -1
  32. package/dist/deploy/index.d.ts.map +1 -1
  33. package/dist/deploy/index.js +4 -1
  34. package/dist/deploy/index.js.map +1 -1
  35. package/dist/deploy/inputs.d.ts +26 -0
  36. package/dist/deploy/inputs.d.ts.map +1 -0
  37. package/dist/deploy/inputs.js +4 -0
  38. package/dist/deploy/inputs.js.map +1 -0
  39. package/dist/deploy/requirements.d.ts +24 -0
  40. package/dist/deploy/requirements.d.ts.map +1 -1
  41. package/dist/deploy/requirements.js +63 -0
  42. package/dist/deploy/requirements.js.map +1 -1
  43. package/dist/deploy/spec.d.ts +27 -0
  44. package/dist/deploy/spec.d.ts.map +1 -0
  45. package/dist/deploy/spec.js +352 -0
  46. package/dist/deploy/spec.js.map +1 -0
  47. package/dist/diagnostics/__fixtures__/diagnosticFixtures.d.ts.map +1 -1
  48. package/dist/diagnostics/__fixtures__/diagnosticFixtures.js +2 -0
  49. package/dist/diagnostics/__fixtures__/diagnosticFixtures.js.map +1 -1
  50. package/dist/diagnostics/diagnostics.d.ts.map +1 -1
  51. package/dist/diagnostics/diagnostics.js +2 -0
  52. package/dist/diagnostics/diagnostics.js.map +1 -1
  53. package/dist/diagnostics/index.d.ts.map +1 -1
  54. package/dist/diagnostics/index.js +2 -0
  55. package/dist/diagnostics/index.js.map +1 -1
  56. package/dist/edge/Edge.d.ts.map +1 -1
  57. package/dist/edge/Edge.js +2 -0
  58. package/dist/edge/Edge.js.map +1 -1
  59. package/dist/edge/EdgeDefinition.d.ts.map +1 -1
  60. package/dist/edge/EdgeDefinition.js +2 -0
  61. package/dist/edge/EdgeDefinition.js.map +1 -1
  62. package/dist/edge/EdgeType.d.ts.map +1 -1
  63. package/dist/edge/EdgeType.js +2 -0
  64. package/dist/edge/EdgeType.js.map +1 -1
  65. package/dist/edge/index.d.ts.map +1 -1
  66. package/dist/edge/index.js +2 -2
  67. package/dist/edge/index.js.map +1 -1
  68. package/dist/edge/serialization.d.ts.map +1 -1
  69. package/dist/edge/serialization.js +2 -0
  70. package/dist/edge/serialization.js.map +1 -1
  71. package/dist/expression/index.d.ts.map +1 -1
  72. package/dist/expression/index.js +2 -0
  73. package/dist/expression/index.js.map +1 -1
  74. package/dist/expression/parser.d.ts.map +1 -1
  75. package/dist/expression/parser.js +2 -0
  76. package/dist/expression/parser.js.map +1 -1
  77. package/dist/expression/types.d.ts.map +1 -1
  78. package/dist/expression/types.js +2 -0
  79. package/dist/expression/types.js.map +1 -1
  80. package/dist/function/FunctionDeclaration.d.ts.map +1 -1
  81. package/dist/function/FunctionDeclaration.js +2 -0
  82. package/dist/function/FunctionDeclaration.js.map +1 -1
  83. package/dist/function/index.d.ts.map +1 -1
  84. package/dist/function/index.js +2 -0
  85. package/dist/function/index.js.map +1 -1
  86. package/dist/function/serialization.d.ts.map +1 -1
  87. package/dist/function/serialization.js +2 -0
  88. package/dist/function/serialization.js.map +1 -1
  89. package/dist/id/index.d.ts.map +1 -1
  90. package/dist/id/index.js +2 -0
  91. package/dist/id/index.js.map +1 -1
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +2 -0
  94. package/dist/index.js.map +1 -1
  95. package/dist/memory/Memory.d.ts.map +1 -1
  96. package/dist/memory/Memory.js +2 -0
  97. package/dist/memory/Memory.js.map +1 -1
  98. package/dist/memory/MemoryDefinition.d.ts.map +1 -1
  99. package/dist/memory/MemoryDefinition.js +2 -0
  100. package/dist/memory/MemoryDefinition.js.map +1 -1
  101. package/dist/memory/MemoryFileDefinition.d.ts.map +1 -1
  102. package/dist/memory/MemoryFileDefinition.js +2 -0
  103. package/dist/memory/MemoryFileDefinition.js.map +1 -1
  104. package/dist/memory/MemoryRegistry.d.ts.map +1 -1
  105. package/dist/memory/MemoryRegistry.js +2 -0
  106. package/dist/memory/MemoryRegistry.js.map +1 -1
  107. package/dist/memory/VectorDatabaseDefinition.d.ts.map +1 -1
  108. package/dist/memory/VectorDatabaseDefinition.js +2 -0
  109. package/dist/memory/VectorDatabaseDefinition.js.map +1 -1
  110. package/dist/memory/index.d.ts.map +1 -1
  111. package/dist/memory/index.js +2 -0
  112. package/dist/memory/index.js.map +1 -1
  113. package/dist/memory/serialization.d.ts.map +1 -1
  114. package/dist/memory/serialization.js +2 -0
  115. package/dist/memory/serialization.js.map +1 -1
  116. package/dist/migration/index.d.ts.map +1 -1
  117. package/dist/migration/index.js +2 -0
  118. package/dist/migration/index.js.map +1 -1
  119. package/dist/migration/migrate.d.ts.map +1 -1
  120. package/dist/migration/migrate.js +2 -0
  121. package/dist/migration/migrate.js.map +1 -1
  122. package/dist/migration/migrations.d.ts.map +1 -1
  123. package/dist/migration/migrations.js +2 -0
  124. package/dist/migration/migrations.js.map +1 -1
  125. package/dist/migration/version.d.ts.map +1 -1
  126. package/dist/migration/version.js +2 -0
  127. package/dist/migration/version.js.map +1 -1
  128. package/dist/model/LLMModelDefinition.d.ts.map +1 -1
  129. package/dist/model/LLMModelDefinition.js +2 -0
  130. package/dist/model/LLMModelDefinition.js.map +1 -1
  131. package/dist/model/Model.d.ts.map +1 -1
  132. package/dist/model/Model.js +2 -13
  133. package/dist/model/Model.js.map +1 -1
  134. package/dist/model/ModelDefinition.d.ts.map +1 -1
  135. package/dist/model/ModelDefinition.js +2 -0
  136. package/dist/model/ModelDefinition.js.map +1 -1
  137. package/dist/model/ModelRegistry.d.ts.map +1 -1
  138. package/dist/model/ModelRegistry.js +2 -0
  139. package/dist/model/ModelRegistry.js.map +1 -1
  140. package/dist/model/index.d.ts.map +1 -1
  141. package/dist/model/index.js +2 -0
  142. package/dist/model/index.js.map +1 -1
  143. package/dist/model/serialization.d.ts.map +1 -1
  144. package/dist/model/serialization.js +2 -0
  145. package/dist/model/serialization.js.map +1 -1
  146. package/dist/node/AgentNode.d.ts.map +1 -1
  147. package/dist/node/AgentNode.js +2 -0
  148. package/dist/node/AgentNode.js.map +1 -1
  149. package/dist/node/DataNode.d.ts.map +1 -1
  150. package/dist/node/DataNode.js +2 -0
  151. package/dist/node/DataNode.js.map +1 -1
  152. package/dist/node/FunctionNode.d.ts.map +1 -1
  153. package/dist/node/FunctionNode.js +2 -0
  154. package/dist/node/FunctionNode.js.map +1 -1
  155. package/dist/node/InputNode.d.ts.map +1 -1
  156. package/dist/node/InputNode.js +2 -0
  157. package/dist/node/InputNode.js.map +1 -1
  158. package/dist/node/LogicNode.d.ts.map +1 -1
  159. package/dist/node/LogicNode.js +2 -0
  160. package/dist/node/LogicNode.js.map +1 -1
  161. package/dist/node/MqttNode.d.ts.map +1 -1
  162. package/dist/node/MqttNode.js +2 -0
  163. package/dist/node/MqttNode.js.map +1 -1
  164. package/dist/node/Node.d.ts.map +1 -1
  165. package/dist/node/Node.js +2 -7
  166. package/dist/node/Node.js.map +1 -1
  167. package/dist/node/NodeDefinition.d.ts.map +1 -1
  168. package/dist/node/NodeDefinition.js +2 -0
  169. package/dist/node/NodeDefinition.js.map +1 -1
  170. package/dist/node/NodeRegistry.d.ts.map +1 -1
  171. package/dist/node/NodeRegistry.js +2 -0
  172. package/dist/node/NodeRegistry.js.map +1 -1
  173. package/dist/node/OutputNode.d.ts.map +1 -1
  174. package/dist/node/OutputNode.js +4 -2
  175. package/dist/node/OutputNode.js.map +1 -1
  176. package/dist/node/ToolNode.d.ts.map +1 -1
  177. package/dist/node/ToolNode.js +2 -0
  178. package/dist/node/ToolNode.js.map +1 -1
  179. package/dist/node/TriggerNode.d.ts.map +1 -1
  180. package/dist/node/TriggerNode.js +2 -0
  181. package/dist/node/TriggerNode.js.map +1 -1
  182. package/dist/node/constants.d.ts.map +1 -1
  183. package/dist/node/constants.js +2 -0
  184. package/dist/node/constants.js.map +1 -1
  185. package/dist/node/index.d.ts.map +1 -1
  186. package/dist/node/index.js +2 -0
  187. package/dist/node/index.js.map +1 -1
  188. package/dist/node/methods.d.ts.map +1 -1
  189. package/dist/node/methods.js +2 -0
  190. package/dist/node/methods.js.map +1 -1
  191. package/dist/node/serialization.d.ts.map +1 -1
  192. package/dist/node/serialization.js +33 -13
  193. package/dist/node/serialization.js.map +1 -1
  194. package/dist/parameter/OutputParameter.d.ts.map +1 -1
  195. package/dist/parameter/OutputParameter.js +2 -0
  196. package/dist/parameter/OutputParameter.js.map +1 -1
  197. package/dist/parameter/Parameter.d.ts.map +1 -1
  198. package/dist/parameter/Parameter.js +2 -0
  199. package/dist/parameter/Parameter.js.map +1 -1
  200. package/dist/parameter/index.d.ts.map +1 -1
  201. package/dist/parameter/index.js +2 -0
  202. package/dist/parameter/index.js.map +1 -1
  203. package/dist/variable/Variable.d.ts.map +1 -1
  204. package/dist/variable/Variable.js +2 -0
  205. package/dist/variable/Variable.js.map +1 -1
  206. package/dist/variable/index.d.ts.map +1 -1
  207. package/dist/variable/index.js +2 -3
  208. package/dist/variable/index.js.map +1 -1
  209. package/dist/variable/operations.d.ts.map +1 -1
  210. package/dist/variable/operations.js +2 -0
  211. package/dist/variable/operations.js.map +1 -1
  212. package/dist/workflow/Workflow.d.ts.map +1 -1
  213. package/dist/workflow/Workflow.js +2 -0
  214. package/dist/workflow/Workflow.js.map +1 -1
  215. package/dist/workflow/index.d.ts.map +1 -1
  216. package/dist/workflow/index.js +2 -0
  217. package/dist/workflow/index.js.map +1 -1
  218. package/dist/workflow/serialization.d.ts.map +1 -1
  219. package/dist/workflow/serialization.js +2 -4
  220. package/dist/workflow/serialization.js.map +1 -1
  221. package/package.json +2 -2
  222. package/src/api/deployment.ts +74 -0
  223. package/src/api/engine.ts +744 -0
  224. package/src/api/index.ts +29 -11
  225. package/src/api/workflow.ts +25 -9
  226. package/src/channel/Channel.ts +14 -11
  227. package/src/channel/ChannelDefinition.ts +101 -76
  228. package/src/channel/index.ts +9 -6
  229. package/src/channel/serialization.ts +77 -68
  230. package/src/deploy/index.ts +17 -1
  231. package/src/deploy/inputs.ts +44 -0
  232. package/src/deploy/requirements.test.ts +64 -61
  233. package/src/deploy/requirements.ts +159 -41
  234. package/src/deploy/spec.test.ts +227 -0
  235. package/src/deploy/spec.ts +397 -0
  236. package/src/diagnostics/__fixtures__/diagnosticFixtures.ts +161 -158
  237. package/src/diagnostics/diagnostics.test.ts +881 -878
  238. package/src/diagnostics/diagnostics.ts +939 -936
  239. package/src/diagnostics/index.ts +14 -11
  240. package/src/edge/Edge.ts +26 -23
  241. package/src/edge/EdgeDefinition.ts +48 -45
  242. package/src/edge/EdgeType.ts +22 -19
  243. package/src/edge/index.ts +11 -8
  244. package/src/edge/serialization.ts +86 -83
  245. package/src/expression/index.ts +7 -4
  246. package/src/expression/parser.ts +365 -362
  247. package/src/expression/types.ts +33 -30
  248. package/src/function/FunctionDeclaration.ts +57 -54
  249. package/src/function/index.ts +6 -3
  250. package/src/function/serialization.ts +43 -40
  251. package/src/globals.d.ts +12 -9
  252. package/src/id/index.ts +11 -8
  253. package/src/index.ts +25 -22
  254. package/src/memory/Memory.ts +18 -15
  255. package/src/memory/MemoryDefinition.ts +19 -16
  256. package/src/memory/MemoryFileDefinition.ts +40 -37
  257. package/src/memory/MemoryRegistry.ts +38 -35
  258. package/src/memory/VectorDatabaseDefinition.ts +24 -21
  259. package/src/memory/index.ts +11 -8
  260. package/src/memory/serialization.ts +50 -47
  261. package/src/migration/index.ts +7 -4
  262. package/src/migration/migrate.test.ts +47 -44
  263. package/src/migration/migrate.ts +61 -58
  264. package/src/migration/migrations.ts +27 -24
  265. package/src/migration/version.ts +12 -9
  266. package/src/model/LLMModelDefinition.ts +15 -12
  267. package/src/model/Model.ts +42 -39
  268. package/src/model/ModelDefinition.ts +18 -15
  269. package/src/model/ModelRegistry.ts +36 -33
  270. package/src/model/index.ts +10 -7
  271. package/src/model/serialization.ts +33 -30
  272. package/src/node/AgentNode.ts +85 -82
  273. package/src/node/DataNode.ts +44 -41
  274. package/src/node/FunctionNode.ts +79 -76
  275. package/src/node/InputNode.ts +188 -185
  276. package/src/node/LogicNode.ts +36 -33
  277. package/src/node/MqttNode.ts +130 -127
  278. package/src/node/Node.ts +64 -61
  279. package/src/node/NodeDefinition.ts +40 -37
  280. package/src/node/NodeRegistry.ts +88 -85
  281. package/src/node/OutputNode.ts +90 -87
  282. package/src/node/ToolNode.ts +35 -32
  283. package/src/node/TriggerNode.ts +275 -272
  284. package/src/node/constants.ts +19 -16
  285. package/src/node/index.ts +29 -26
  286. package/src/node/methods.ts +281 -278
  287. package/src/node/serialization.test.ts +51 -0
  288. package/src/node/serialization.ts +565 -544
  289. package/src/parameter/OutputParameter.ts +71 -68
  290. package/src/parameter/Parameter.ts +246 -243
  291. package/src/parameter/index.ts +36 -33
  292. package/src/variable/Variable.ts +13 -10
  293. package/src/variable/index.ts +19 -16
  294. package/src/variable/operations.ts +109 -106
  295. package/src/workflow/Workflow.ts +44 -41
  296. package/src/workflow/index.ts +6 -3
  297. package/src/workflow/serialization.test.ts +243 -240
  298. package/src/workflow/serialization.ts +245 -242
@@ -1,30 +1,33 @@
1
- import type { NodeOutput } from "../node";
2
- import type { DataType, Expression } from "../api";
3
- import type { Variable } from "../variable";
4
- import { refToLookupKey } from "../variable";
5
-
6
- // ResolvedExpr represents an expression with its variable references resolved to runtime variables
7
- export interface ResolvedExpr {
8
- expression: string; // The expression string with variable references, e.g. "${} + ${}"
9
- variables: (NodeOutput | null)[]; // List of variables used in the expression (null if stale/invalid)
10
- expectedType: DataType; // The expected data type of the expression result
11
- }
12
-
13
- // Resolve an expression by converting variable references to runtime variables
14
- export function resolveExpression(apiExpr: Expression, availableVars: Record<string, Variable>): ResolvedExpr {
15
- return {
16
- expression: apiExpr.expression,
17
- expectedType: apiExpr.dataType,
18
- variables: apiExpr.references.map((ref) => {
19
- if (!ref.varId) return null;
20
- const key = refToLookupKey(ref);
21
- const v = availableVars[key];
22
- return v ? { name: v.name, dataType: v.dataType } : null;
23
- }),
24
- };
25
- }
26
-
27
- // Check if a value is an expression (has references array)
28
- export function isExpression(value: unknown): value is Expression {
29
- return typeof value === "object" && value !== null && "expression" in value && "references" in value;
30
- }
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ import type { NodeOutput } from "../node";
5
+ import type { DataType, Expression } from "../api";
6
+ import type { Variable } from "../variable";
7
+ import { refToLookupKey } from "../variable";
8
+
9
+ // ResolvedExpr represents an expression with its variable references resolved to runtime variables
10
+ export interface ResolvedExpr {
11
+ expression: string; // The expression string with variable references, e.g. "${} + ${}"
12
+ variables: (NodeOutput | null)[]; // List of variables used in the expression (null if stale/invalid)
13
+ expectedType: DataType; // The expected data type of the expression result
14
+ }
15
+
16
+ // Resolve an expression by converting variable references to runtime variables
17
+ export function resolveExpression(apiExpr: Expression, availableVars: Record<string, Variable>): ResolvedExpr {
18
+ return {
19
+ expression: apiExpr.expression,
20
+ expectedType: apiExpr.dataType,
21
+ variables: apiExpr.references.map((ref) => {
22
+ if (!ref.varId) return null;
23
+ const key = refToLookupKey(ref);
24
+ const v = availableVars[key];
25
+ return v ? { name: v.name, dataType: v.dataType } : null;
26
+ }),
27
+ };
28
+ }
29
+
30
+ // Check if a value is an expression (has references array)
31
+ export function isExpression(value: unknown): value is Expression {
32
+ return typeof value === "object" && value !== null && "expression" in value && "references" in value;
33
+ }
@@ -1,54 +1,57 @@
1
- import type { Expression, Schemas } from "../api";
2
- import type { ApiVariable } from "../variable";
3
- import type { DataType } from "../parameter";
4
-
5
- /**
6
- * The flat call-site signature of a function: identity + version + ports, with no
7
- * expressions (the contract's `FunctionInfo`, used both inside `Function` on the wire
8
- * and here in the domain). It is the snapshot a {@link FunctionCallNode} caches — to
9
- * detect drift against the live declaration and render its ports without a registry
10
- * lookup and the shape {@link buildFunctionNodeDef} consumes.
11
- */
12
- export type FunctionInfo = Schemas["FunctionInfo"];
13
-
14
- /**
15
- * A function output: its declaration (`uid`/`name`/`dataType`) bundled with the
16
- * `expression` that produces it (evaluated in callee scope at the function's end).
17
- * Acts as a supertype of {@link ApiVariable}.
18
- */
19
- export interface OutputAssignment {
20
- uid: string;
21
- name: string;
22
- dataType: DataType;
23
- expression: Expression;
24
- }
25
-
26
- /**
27
- * The domain function declaration: a signature with its outputs bundled
28
- * (declaration + assignment per output).
29
- * Separate from the function body (which is a canvas of nodes, edges, variables).
30
- */
31
- export interface FunctionDeclaration {
32
- id: string;
33
- version: number;
34
- name: string;
35
- arguments: ApiVariable[];
36
- outputs: OutputAssignment[];
37
- }
38
-
39
- /**
40
- * Project a declaration to the flat call-site signature, dropping the expressions
41
- * (the caller has no business storing the callee's internals). Used only when
42
- * crossing from declaration to a call-site snapshot — dropping or migrating a
43
- * `FunctionCall` node and by serialization. Never used to represent a function
44
- * within the domain.
45
- */
46
- export function toFunctionInfo(fn: FunctionDeclaration): FunctionInfo {
47
- return {
48
- id: fn.id,
49
- version: fn.version,
50
- name: fn.name,
51
- arguments: fn.arguments,
52
- returns: fn.outputs.map(({ uid, name, dataType }) => ({ uid, name, dataType })),
53
- };
54
- }
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ import type { Expression, Schemas } from "../api";
5
+ import type { ApiVariable } from "../variable";
6
+ import type { DataType } from "../parameter";
7
+
8
+ /**
9
+ * The flat call-site signature of a function: identity + version + ports, with no
10
+ * expressions (the contract's `FunctionInfo`, used both inside `Function` on the wire
11
+ * and here in the domain). It is the snapshot a {@link FunctionCallNode} caches — to
12
+ * detect drift against the live declaration and render its ports without a registry
13
+ * lookup — and the shape {@link buildFunctionNodeDef} consumes.
14
+ */
15
+ export type FunctionInfo = Schemas["FunctionInfo"];
16
+
17
+ /**
18
+ * A function output: its declaration (`uid`/`name`/`dataType`) bundled with the
19
+ * `expression` that produces it (evaluated in callee scope at the function's end).
20
+ * Acts as a supertype of {@link ApiVariable}.
21
+ */
22
+ export interface OutputAssignment {
23
+ uid: string;
24
+ name: string;
25
+ dataType: DataType;
26
+ expression: Expression;
27
+ }
28
+
29
+ /**
30
+ * The domain function declaration: a signature with its outputs bundled
31
+ * (declaration + assignment per output).
32
+ * Separate from the function body (which is a canvas of nodes, edges, variables).
33
+ */
34
+ export interface FunctionDeclaration {
35
+ id: string;
36
+ version: number;
37
+ name: string;
38
+ arguments: ApiVariable[];
39
+ outputs: OutputAssignment[];
40
+ }
41
+
42
+ /**
43
+ * Project a declaration to the flat call-site signature, dropping the expressions
44
+ * (the caller has no business storing the callee's internals). Used only when
45
+ * crossing from declaration to a call-site snapshot — dropping or migrating a
46
+ * `FunctionCall` node and by serialization. Never used to represent a function
47
+ * within the domain.
48
+ */
49
+ export function toFunctionInfo(fn: FunctionDeclaration): FunctionInfo {
50
+ return {
51
+ id: fn.id,
52
+ version: fn.version,
53
+ name: fn.name,
54
+ arguments: fn.arguments,
55
+ returns: fn.outputs.map(({ uid, name, dataType }) => ({ uid, name, dataType })),
56
+ };
57
+ }
@@ -1,3 +1,6 @@
1
- export type { OutputAssignment, FunctionDeclaration, FunctionInfo } from "./FunctionDeclaration";
2
- export { toFunctionInfo } from "./FunctionDeclaration";
3
- export { serialize, deserialize } from "./serialization";
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ export type { OutputAssignment, FunctionDeclaration, FunctionInfo } from "./FunctionDeclaration";
5
+ export { toFunctionInfo } from "./FunctionDeclaration";
6
+ export { serialize, deserialize } from "./serialization";
@@ -1,40 +1,43 @@
1
- import type { Expression } from "../api";
2
- import type { FunctionDeclaration, FunctionInfo } from "./FunctionDeclaration";
3
- import { toFunctionInfo } from "./FunctionDeclaration";
4
-
5
- /**
6
- * The two wire pieces a {@link FunctionDeclaration} splits into. The contract keeps
7
- * the signature (`functionInfo`) and the return-value expressions (`outputAssignments`)
8
- * apart; the domain bundles them on `outputs`. The function *body*
9
- * (nodes/edges/declaredVariables) is added separately by the workflow serializer
10
- * this only handles the declaration wire mapping.
11
- */
12
- export interface SerializedFunction {
13
- functionInfo: FunctionInfo;
14
- outputAssignments: Record<string, Expression>;
15
- }
16
-
17
- /** Domain declaration → wire pieces: flatten the signature and lift each output's
18
- * expression into the `outputAssignments` map keyed by output uid. */
19
- export function serialize(fn: FunctionDeclaration): SerializedFunction {
20
- const outputAssignments: Record<string, Expression> = {};
21
- for (const o of fn.outputs) outputAssignments[o.uid] = o.expression;
22
- return { functionInfo: toFunctionInfo(fn), outputAssignments };
23
- }
24
-
25
- /** Wire pieces → domain declaration: bundle each `return` with its assignment. A
26
- * return with no stored assignment gets an empty expression of the right dataType. */
27
- export function deserialize(functionInfo: FunctionInfo, outputAssignments: Record<string, Expression>): FunctionDeclaration {
28
- return {
29
- id: functionInfo.id,
30
- version: functionInfo.version,
31
- name: functionInfo.name,
32
- arguments: functionInfo.arguments,
33
- outputs: functionInfo.returns.map((r) => ({
34
- uid: r.uid,
35
- name: r.name,
36
- dataType: r.dataType,
37
- expression: outputAssignments[r.uid] ?? { expression: "", references: [], dataType: r.dataType },
38
- })),
39
- };
40
- }
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ import type { Expression } from "../api";
5
+ import type { FunctionDeclaration, FunctionInfo } from "./FunctionDeclaration";
6
+ import { toFunctionInfo } from "./FunctionDeclaration";
7
+
8
+ /**
9
+ * The two wire pieces a {@link FunctionDeclaration} splits into. The contract keeps
10
+ * the signature (`functionInfo`) and the return-value expressions (`outputAssignments`)
11
+ * apart; the domain bundles them on `outputs`. The function *body*
12
+ * (nodes/edges/declaredVariables) is added separately by the workflow serializer —
13
+ * this only handles the declaration ⇄ wire mapping.
14
+ */
15
+ export interface SerializedFunction {
16
+ functionInfo: FunctionInfo;
17
+ outputAssignments: Record<string, Expression>;
18
+ }
19
+
20
+ /** Domain declaration → wire pieces: flatten the signature and lift each output's
21
+ * expression into the `outputAssignments` map keyed by output uid. */
22
+ export function serialize(fn: FunctionDeclaration): SerializedFunction {
23
+ const outputAssignments: Record<string, Expression> = {};
24
+ for (const o of fn.outputs) outputAssignments[o.uid] = o.expression;
25
+ return { functionInfo: toFunctionInfo(fn), outputAssignments };
26
+ }
27
+
28
+ /** Wire pieces → domain declaration: bundle each `return` with its assignment. A
29
+ * return with no stored assignment gets an empty expression of the right dataType. */
30
+ export function deserialize(functionInfo: FunctionInfo, outputAssignments: Record<string, Expression>): FunctionDeclaration {
31
+ return {
32
+ id: functionInfo.id,
33
+ version: functionInfo.version,
34
+ name: functionInfo.name,
35
+ arguments: functionInfo.arguments,
36
+ outputs: functionInfo.returns.map((r) => ({
37
+ uid: r.uid,
38
+ name: r.name,
39
+ dataType: r.dataType,
40
+ expression: outputAssignments[r.uid] ?? { expression: "", references: [], dataType: r.dataType },
41
+ })),
42
+ };
43
+ }
package/src/globals.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- /**
2
- * This package drops the `DOM` lib (see tsconfig.json) to stay headless, so the
3
- * Web Crypto `crypto` global is untyped. It exists at runtime everywhere we run
4
- * — browsers, Node >= 19, Deno, Bun — so we declare only the one member we use
5
- * rather than pulling in `DOM` or `@types/node` and their global scope.
6
- */
7
- declare const crypto: {
8
- randomUUID(): `${string}-${string}-${string}-${string}-${string}`;
9
- };
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ /**
5
+ * This package drops the `DOM` lib (see tsconfig.json) to stay headless, so the
6
+ * Web Crypto `crypto` global is untyped. It exists at runtime everywhere we run
7
+ * — browsers, Node >= 19, Deno, Bun — so we declare only the one member we use
8
+ * rather than pulling in `DOM` or `@types/node` and their global scope.
9
+ */
10
+ declare const crypto: {
11
+ randomUUID(): `${string}-${string}-${string}-${string}-${string}`;
12
+ };
package/src/id/index.ts CHANGED
@@ -1,8 +1,11 @@
1
- /**
2
- * Centralized UID creation for every entity in a workflow — nodes, edges,
3
- * channels, memory, models, declared variables, function arguments, and
4
- * function canvases. IDs are opaque.
5
- */
6
- export function generateId(): string {
7
- return crypto.randomUUID();
8
- }
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ /**
5
+ * Centralized UID creation for every entity in a workflow — nodes, edges,
6
+ * channels, memory, models, declared variables, function arguments, and
7
+ * function canvases. IDs are opaque.
8
+ */
9
+ export function generateId(): string {
10
+ return crypto.randomUUID();
11
+ }
package/src/index.ts CHANGED
@@ -1,22 +1,25 @@
1
- import { deserialize } from "./workflow/serialization";
2
- import { validateWorkflowState, type ValidationResult } from "./diagnostics/diagnostics";
3
- import type { ApiWorkflow } from "./workflow/Workflow";
4
-
5
- // Api-layer types consumers use directly (no domain twin). Sourced from `api`
6
- // so they're available at the package root rather than via a domain subpath.
7
- // (`FunctionInfo` is the exception — it's the flat twin of the domain
8
- // `FunctionDeclaration`, so it lives on the `function` subpath, not here.)
9
- export type { DataType, Reference, Expression } from "./api";
10
-
11
- // Format versioning: load persisted documents through `migrate` before
12
- // deserializing.
13
- export { migrate, CURRENT_SCHEMA_VERSION } from "./migration";
14
-
15
- /**
16
- * Validate a workflow against the headless validator.
17
- * Pure: no I/O, no Zustand, no React, no DOM. Runnable in Node, a CLI, or
18
- * a Claude Code skill.
19
- */
20
- export function validateWorkflow(workflow: ApiWorkflow): ValidationResult {
21
- return validateWorkflowState(deserialize(workflow));
22
- }
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ import { deserialize } from "./workflow/serialization";
5
+ import { validateWorkflowState, type ValidationResult } from "./diagnostics/diagnostics";
6
+ import type { ApiWorkflow } from "./workflow/Workflow";
7
+
8
+ // Api-layer types consumers use directly (no domain twin). Sourced from `api`
9
+ // so they're available at the package root rather than via a domain subpath.
10
+ // (`FunctionInfo` is the exception — it's the flat twin of the domain
11
+ // `FunctionDeclaration`, so it lives on the `function` subpath, not here.)
12
+ export type { DataType, Reference, Expression } from "./api";
13
+
14
+ // Format versioning: load persisted documents through `migrate` before
15
+ // deserializing.
16
+ export { migrate, CURRENT_SCHEMA_VERSION } from "./migration";
17
+
18
+ /**
19
+ * Validate a workflow against the headless validator.
20
+ * Pure: no I/O, no Zustand, no React, no DOM. Runnable in Node, a CLI, or
21
+ * a Claude Code skill.
22
+ */
23
+ export function validateWorkflow(workflow: ApiWorkflow): ValidationResult {
24
+ return validateWorkflowState(deserialize(workflow));
25
+ }
@@ -1,15 +1,18 @@
1
- import type { Schemas } from "../api";
2
-
3
- export type MemoryType = "MemoryFile" | "VectorDatabase";
4
-
5
- export const ALL_MEMORY_TYPES: MemoryType[] = ["MemoryFile", "VectorDatabase"];
6
-
7
- export interface Memory {
8
- id: string;
9
- label: string;
10
- type: MemoryType;
11
- arguments: Record<string, unknown>;
12
- }
13
-
14
- /** Reference from an agent node to a declared MemoryFile, with access mode. Round-trips 1:1 with the API. */
15
- export type MemoryRef = Schemas["MemoryRef"];
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ import type { Schemas } from "../api";
5
+
6
+ export type MemoryType = "MemoryFile" | "VectorDatabase";
7
+
8
+ export const ALL_MEMORY_TYPES: MemoryType[] = ["MemoryFile", "VectorDatabase"];
9
+
10
+ export interface Memory {
11
+ id: string;
12
+ label: string;
13
+ type: MemoryType;
14
+ arguments: Record<string, unknown>;
15
+ }
16
+
17
+ /** Reference from an agent node to a declared MemoryFile, with access mode. Round-trips 1:1 with the API. */
18
+ export type MemoryRef = Schemas["MemoryRef"];
@@ -1,16 +1,19 @@
1
- import type { Parameter } from "../parameter";
2
- import type { MemoryType } from "./Memory";
3
-
4
- /**
5
- * Static, per-type metadata for a memory variant. Mirrors NodeDefinition:
6
- * one definition object per MemoryType, registered in MemoryRegistry — unlike
7
- * channels, which use a single union definition gated by activation rules.
8
- * `label` is a top-level instance field (edited like a channel label), so it is
9
- * never a parameter here.
10
- */
11
- export interface MemoryDefinition {
12
- type: MemoryType;
13
- label: string;
14
- description: string;
15
- parameters: Parameter[];
16
- }
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ import type { Parameter } from "../parameter";
5
+ import type { MemoryType } from "./Memory";
6
+
7
+ /**
8
+ * Static, per-type metadata for a memory variant. Mirrors NodeDefinition:
9
+ * one definition object per MemoryType, registered in MemoryRegistry — unlike
10
+ * channels, which use a single union definition gated by activation rules.
11
+ * `label` is a top-level instance field (edited like a channel label), so it is
12
+ * never a parameter here.
13
+ */
14
+ export interface MemoryDefinition {
15
+ type: MemoryType;
16
+ label: string;
17
+ description: string;
18
+ parameters: Parameter[];
19
+ }
@@ -1,37 +1,40 @@
1
- import type { MemoryDefinition } from "./MemoryDefinition";
2
-
3
- /**
4
- * Agent-scoped durable text storage. The instance `label` (edited like a channel
5
- * label) is the identifier the LLM sees in tool calls, so it is not a parameter.
6
- * The config panel renders these parameters via ParameterEditor, same as channels.
7
- */
8
- export const MemoryFileDefinition: MemoryDefinition = {
9
- type: "MemoryFile",
10
- label: "Memory File",
11
- description: "Durable text storage an agent can read and write",
12
- parameters: [
13
- {
14
- id: "description",
15
- label: "Description",
16
- description: "What this memory file is for (shown to the LLM as tool description)",
17
- type: "string",
18
- multiline: true,
19
- optional: true,
20
- },
21
- {
22
- id: "content",
23
- label: "Initial Content",
24
- description: "Seed content written on fresh deploy; existing rows keep their content on redeploy",
25
- type: "string",
26
- multiline: true,
27
- optional: true,
28
- },
29
- {
30
- id: "maxSizeBytes",
31
- label: "Max Size (bytes)",
32
- description: "Byte cap on writes; leave empty for unlimited",
33
- type: "int",
34
- optional: true,
35
- },
36
- ],
37
- };
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ import type { MemoryDefinition } from "./MemoryDefinition";
5
+
6
+ /**
7
+ * Agent-scoped durable text storage. The instance `label` (edited like a channel
8
+ * label) is the identifier the LLM sees in tool calls, so it is not a parameter.
9
+ * The config panel renders these parameters via ParameterEditor, same as channels.
10
+ */
11
+ export const MemoryFileDefinition: MemoryDefinition = {
12
+ type: "MemoryFile",
13
+ label: "Memory File",
14
+ description: "Durable text storage an agent can read and write",
15
+ parameters: [
16
+ {
17
+ id: "description",
18
+ label: "Description",
19
+ description: "What this memory file is for (shown to the LLM as tool description)",
20
+ type: "string",
21
+ multiline: true,
22
+ optional: true,
23
+ },
24
+ {
25
+ id: "content",
26
+ label: "Initial Content",
27
+ description: "Seed content written on fresh deploy; existing rows keep their content on redeploy",
28
+ type: "string",
29
+ multiline: true,
30
+ optional: true,
31
+ },
32
+ {
33
+ id: "maxSizeBytes",
34
+ label: "Max Size (bytes)",
35
+ description: "Byte cap on writes; leave empty for unlimited",
36
+ type: "int",
37
+ optional: true,
38
+ },
39
+ ],
40
+ };
@@ -1,35 +1,38 @@
1
- import type { MemoryType } from "./Memory";
2
- import type { MemoryDefinition } from "./MemoryDefinition";
3
- import { MemoryFileDefinition } from "./MemoryFileDefinition";
4
- import { VectorDatabaseDefinition } from "./VectorDatabaseDefinition";
5
-
6
- /**
7
- * Central registry for memory variant definitions (one per MemoryType).
8
- * Mirrors NodeRegistry.
9
- */
10
- class MemoryDefinitionRegistry {
11
- private memories: Map<MemoryType, MemoryDefinition> = new Map();
12
- private initialized = false;
13
-
14
- initialize() {
15
- if (this.initialized) return;
16
- this.register(MemoryFileDefinition);
17
- this.register(VectorDatabaseDefinition);
18
- this.initialized = true;
19
- }
20
-
21
- private register(definition: MemoryDefinition) {
22
- this.memories.set(definition.type, definition);
23
- }
24
-
25
- getAll(): MemoryDefinition[] {
26
- return Array.from(this.memories.values());
27
- }
28
-
29
- getByType(type: MemoryType): MemoryDefinition | undefined {
30
- return this.memories.get(type);
31
- }
32
- }
33
-
34
- export const MemoryRegistry = new MemoryDefinitionRegistry();
35
- MemoryRegistry.initialize();
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 ForestHub.
3
+
4
+ import type { MemoryType } from "./Memory";
5
+ import type { MemoryDefinition } from "./MemoryDefinition";
6
+ import { MemoryFileDefinition } from "./MemoryFileDefinition";
7
+ import { VectorDatabaseDefinition } from "./VectorDatabaseDefinition";
8
+
9
+ /**
10
+ * Central registry for memory variant definitions (one per MemoryType).
11
+ * Mirrors NodeRegistry.
12
+ */
13
+ class MemoryDefinitionRegistry {
14
+ private memories: Map<MemoryType, MemoryDefinition> = new Map();
15
+ private initialized = false;
16
+
17
+ initialize() {
18
+ if (this.initialized) return;
19
+ this.register(MemoryFileDefinition);
20
+ this.register(VectorDatabaseDefinition);
21
+ this.initialized = true;
22
+ }
23
+
24
+ private register(definition: MemoryDefinition) {
25
+ this.memories.set(definition.type, definition);
26
+ }
27
+
28
+ getAll(): MemoryDefinition[] {
29
+ return Array.from(this.memories.values());
30
+ }
31
+
32
+ getByType(type: MemoryType): MemoryDefinition | undefined {
33
+ return this.memories.get(type);
34
+ }
35
+ }
36
+
37
+ export const MemoryRegistry = new MemoryDefinitionRegistry();
38
+ MemoryRegistry.initialize();