@foresthubai/workflow-core 0.3.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 (339) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +14 -0
  3. package/README.md +63 -0
  4. package/dist/api/index.d.ts +7 -0
  5. package/dist/api/index.d.ts.map +1 -0
  6. package/dist/api/index.js +2 -0
  7. package/dist/api/index.js.map +1 -0
  8. package/dist/api/workflow.d.ts +607 -0
  9. package/dist/api/workflow.d.ts.map +1 -0
  10. package/dist/api/workflow.js +6 -0
  11. package/dist/api/workflow.js.map +1 -0
  12. package/dist/channel/Channel.d.ts +10 -0
  13. package/dist/channel/Channel.d.ts.map +1 -0
  14. package/dist/channel/Channel.js +2 -0
  15. package/dist/channel/Channel.js.map +1 -0
  16. package/dist/channel/ChannelDefinition.d.ts +27 -0
  17. package/dist/channel/ChannelDefinition.d.ts.map +1 -0
  18. package/dist/channel/ChannelDefinition.js +50 -0
  19. package/dist/channel/ChannelDefinition.js.map +1 -0
  20. package/dist/channel/index.d.ts +7 -0
  21. package/dist/channel/index.d.ts.map +1 -0
  22. package/dist/channel/index.js +4 -0
  23. package/dist/channel/index.js.map +1 -0
  24. package/dist/channel/serialization.d.ts +17 -0
  25. package/dist/channel/serialization.d.ts.map +1 -0
  26. package/dist/channel/serialization.js +63 -0
  27. package/dist/channel/serialization.js.map +1 -0
  28. package/dist/deploy/index.d.ts +2 -0
  29. package/dist/deploy/index.d.ts.map +1 -0
  30. package/dist/deploy/index.js +2 -0
  31. package/dist/deploy/index.js.map +1 -0
  32. package/dist/deploy/requirements.d.ts +17 -0
  33. package/dist/deploy/requirements.d.ts.map +1 -0
  34. package/dist/deploy/requirements.js +41 -0
  35. package/dist/deploy/requirements.js.map +1 -0
  36. package/dist/diagnostics/__fixtures__/diagnosticFixtures.d.ts +28 -0
  37. package/dist/diagnostics/__fixtures__/diagnosticFixtures.d.ts.map +1 -0
  38. package/dist/diagnostics/__fixtures__/diagnosticFixtures.js +125 -0
  39. package/dist/diagnostics/__fixtures__/diagnosticFixtures.js.map +1 -0
  40. package/dist/diagnostics/diagnostics.d.ts +128 -0
  41. package/dist/diagnostics/diagnostics.d.ts.map +1 -0
  42. package/dist/diagnostics/diagnostics.js +783 -0
  43. package/dist/diagnostics/diagnostics.js.map +1 -0
  44. package/dist/diagnostics/index.d.ts +3 -0
  45. package/dist/diagnostics/index.d.ts.map +1 -0
  46. package/dist/diagnostics/index.js +2 -0
  47. package/dist/diagnostics/index.js.map +1 -0
  48. package/dist/edge/Edge.d.ts +22 -0
  49. package/dist/edge/Edge.d.ts.map +1 -0
  50. package/dist/edge/Edge.js +2 -0
  51. package/dist/edge/Edge.js.map +1 -0
  52. package/dist/edge/EdgeDefinition.d.ts +10 -0
  53. package/dist/edge/EdgeDefinition.d.ts.map +1 -0
  54. package/dist/edge/EdgeDefinition.js +36 -0
  55. package/dist/edge/EdgeDefinition.js.map +1 -0
  56. package/dist/edge/EdgeType.d.ts +6 -0
  57. package/dist/edge/EdgeType.d.ts.map +1 -0
  58. package/dist/edge/EdgeType.js +7 -0
  59. package/dist/edge/EdgeType.js.map +1 -0
  60. package/dist/edge/index.d.ts +6 -0
  61. package/dist/edge/index.d.ts.map +1 -0
  62. package/dist/edge/index.js +6 -0
  63. package/dist/edge/index.js.map +1 -0
  64. package/dist/edge/serialization.d.ts +18 -0
  65. package/dist/edge/serialization.d.ts.map +1 -0
  66. package/dist/edge/serialization.js +76 -0
  67. package/dist/edge/serialization.js.map +1 -0
  68. package/dist/expression/index.d.ts +5 -0
  69. package/dist/expression/index.d.ts.map +1 -0
  70. package/dist/expression/index.js +3 -0
  71. package/dist/expression/index.js.map +1 -0
  72. package/dist/expression/parser.d.ts +14 -0
  73. package/dist/expression/parser.d.ts.map +1 -0
  74. package/dist/expression/parser.js +309 -0
  75. package/dist/expression/parser.js.map +1 -0
  76. package/dist/expression/types.d.ts +11 -0
  77. package/dist/expression/types.d.ts.map +1 -0
  78. package/dist/expression/types.js +20 -0
  79. package/dist/expression/types.js.map +1 -0
  80. package/dist/function/FunctionDeclaration.d.ts +43 -0
  81. package/dist/function/FunctionDeclaration.d.ts.map +1 -0
  82. package/dist/function/FunctionDeclaration.js +17 -0
  83. package/dist/function/FunctionDeclaration.js.map +1 -0
  84. package/dist/function/index.d.ts +4 -0
  85. package/dist/function/index.d.ts.map +1 -0
  86. package/dist/function/index.js +3 -0
  87. package/dist/function/index.js.map +1 -0
  88. package/dist/function/serialization.d.ts +20 -0
  89. package/dist/function/serialization.d.ts.map +1 -0
  90. package/dist/function/serialization.js +26 -0
  91. package/dist/function/serialization.js.map +1 -0
  92. package/dist/id/index.d.ts +7 -0
  93. package/dist/id/index.d.ts.map +1 -0
  94. package/dist/id/index.js +9 -0
  95. package/dist/id/index.js.map +1 -0
  96. package/dist/index.d.ts +11 -0
  97. package/dist/index.d.ts.map +1 -0
  98. package/dist/index.js +14 -0
  99. package/dist/index.js.map +1 -0
  100. package/dist/memory/Memory.d.ts +12 -0
  101. package/dist/memory/Memory.d.ts.map +1 -0
  102. package/dist/memory/Memory.js +2 -0
  103. package/dist/memory/Memory.js.map +1 -0
  104. package/dist/memory/MemoryDefinition.d.ts +16 -0
  105. package/dist/memory/MemoryDefinition.d.ts.map +1 -0
  106. package/dist/memory/MemoryDefinition.js +2 -0
  107. package/dist/memory/MemoryDefinition.js.map +1 -0
  108. package/dist/memory/MemoryFileDefinition.d.ts +8 -0
  109. package/dist/memory/MemoryFileDefinition.d.ts.map +1 -0
  110. package/dist/memory/MemoryFileDefinition.js +36 -0
  111. package/dist/memory/MemoryFileDefinition.js.map +1 -0
  112. package/dist/memory/MemoryRegistry.d.ts +17 -0
  113. package/dist/memory/MemoryRegistry.d.ts.map +1 -0
  114. package/dist/memory/MemoryRegistry.js +29 -0
  115. package/dist/memory/MemoryRegistry.js.map +1 -0
  116. package/dist/memory/VectorDatabaseDefinition.d.ts +7 -0
  117. package/dist/memory/VectorDatabaseDefinition.d.ts.map +1 -0
  118. package/dist/memory/VectorDatabaseDefinition.js +20 -0
  119. package/dist/memory/VectorDatabaseDefinition.js.map +1 -0
  120. package/dist/memory/index.d.ts +9 -0
  121. package/dist/memory/index.d.ts.map +1 -0
  122. package/dist/memory/index.js +6 -0
  123. package/dist/memory/index.js.map +1 -0
  124. package/dist/memory/serialization.d.ts +11 -0
  125. package/dist/memory/serialization.d.ts.map +1 -0
  126. package/dist/memory/serialization.js +44 -0
  127. package/dist/memory/serialization.js.map +1 -0
  128. package/dist/migration/index.d.ts +5 -0
  129. package/dist/migration/index.d.ts.map +1 -0
  130. package/dist/migration/index.js +4 -0
  131. package/dist/migration/index.js.map +1 -0
  132. package/dist/migration/migrate.d.ts +11 -0
  133. package/dist/migration/migrate.d.ts.map +1 -0
  134. package/dist/migration/migrate.js +52 -0
  135. package/dist/migration/migrate.js.map +1 -0
  136. package/dist/migration/migrations.d.ts +22 -0
  137. package/dist/migration/migrations.d.ts.map +1 -0
  138. package/dist/migration/migrations.js +10 -0
  139. package/dist/migration/migrations.js.map +1 -0
  140. package/dist/migration/version.d.ts +9 -0
  141. package/dist/migration/version.d.ts.map +1 -0
  142. package/dist/migration/version.js +9 -0
  143. package/dist/migration/version.js.map +1 -0
  144. package/dist/model/LLMModelDefinition.d.ts +7 -0
  145. package/dist/model/LLMModelDefinition.d.ts.map +1 -0
  146. package/dist/model/LLMModelDefinition.js +11 -0
  147. package/dist/model/LLMModelDefinition.js.map +1 -0
  148. package/dist/model/Model.d.ts +21 -0
  149. package/dist/model/Model.d.ts.map +1 -0
  150. package/dist/model/Model.js +15 -0
  151. package/dist/model/Model.js.map +1 -0
  152. package/dist/model/ModelDefinition.d.ts +15 -0
  153. package/dist/model/ModelDefinition.d.ts.map +1 -0
  154. package/dist/model/ModelDefinition.js +2 -0
  155. package/dist/model/ModelDefinition.js.map +1 -0
  156. package/dist/model/ModelRegistry.d.ts +17 -0
  157. package/dist/model/ModelRegistry.d.ts.map +1 -0
  158. package/dist/model/ModelRegistry.js +27 -0
  159. package/dist/model/ModelRegistry.js.map +1 -0
  160. package/dist/model/index.d.ts +8 -0
  161. package/dist/model/index.d.ts.map +1 -0
  162. package/dist/model/index.js +5 -0
  163. package/dist/model/index.js.map +1 -0
  164. package/dist/model/serialization.d.ts +8 -0
  165. package/dist/model/serialization.d.ts.map +1 -0
  166. package/dist/model/serialization.js +25 -0
  167. package/dist/model/serialization.js.map +1 -0
  168. package/dist/node/AgentNode.d.ts +21 -0
  169. package/dist/node/AgentNode.d.ts.map +1 -0
  170. package/dist/node/AgentNode.js +60 -0
  171. package/dist/node/AgentNode.js.map +1 -0
  172. package/dist/node/DataNode.d.ts +14 -0
  173. package/dist/node/DataNode.d.ts.map +1 -0
  174. package/dist/node/DataNode.js +26 -0
  175. package/dist/node/DataNode.js.map +1 -0
  176. package/dist/node/FunctionNode.d.ts +24 -0
  177. package/dist/node/FunctionNode.d.ts.map +1 -0
  178. package/dist/node/FunctionNode.js +44 -0
  179. package/dist/node/FunctionNode.js.map +1 -0
  180. package/dist/node/InputNode.d.ts +46 -0
  181. package/dist/node/InputNode.d.ts.map +1 -0
  182. package/dist/node/InputNode.js +133 -0
  183. package/dist/node/InputNode.js.map +1 -0
  184. package/dist/node/LogicNode.d.ts +13 -0
  185. package/dist/node/LogicNode.d.ts.map +1 -0
  186. package/dist/node/LogicNode.js +19 -0
  187. package/dist/node/LogicNode.js.map +1 -0
  188. package/dist/node/MqttNode.d.ts +27 -0
  189. package/dist/node/MqttNode.d.ts.map +1 -0
  190. package/dist/node/MqttNode.js +96 -0
  191. package/dist/node/MqttNode.js.map +1 -0
  192. package/dist/node/Node.d.ts +49 -0
  193. package/dist/node/Node.d.ts.map +1 -0
  194. package/dist/node/Node.js +9 -0
  195. package/dist/node/Node.js.map +1 -0
  196. package/dist/node/NodeDefinition.d.ts +30 -0
  197. package/dist/node/NodeDefinition.d.ts.map +1 -0
  198. package/dist/node/NodeDefinition.js +2 -0
  199. package/dist/node/NodeDefinition.js.map +1 -0
  200. package/dist/node/NodeRegistry.d.ts +19 -0
  201. package/dist/node/NodeRegistry.d.ts.map +1 -0
  202. package/dist/node/NodeRegistry.js +65 -0
  203. package/dist/node/NodeRegistry.js.map +1 -0
  204. package/dist/node/OutputNode.d.ts +23 -0
  205. package/dist/node/OutputNode.d.ts.map +1 -0
  206. package/dist/node/OutputNode.js +62 -0
  207. package/dist/node/OutputNode.js.map +1 -0
  208. package/dist/node/ToolNode.d.ts +12 -0
  209. package/dist/node/ToolNode.d.ts.map +1 -0
  210. package/dist/node/ToolNode.js +18 -0
  211. package/dist/node/ToolNode.js.map +1 -0
  212. package/dist/node/TriggerNode.d.ts +67 -0
  213. package/dist/node/TriggerNode.d.ts.map +1 -0
  214. package/dist/node/TriggerNode.js +172 -0
  215. package/dist/node/TriggerNode.js.map +1 -0
  216. package/dist/node/constants.d.ts +16 -0
  217. package/dist/node/constants.d.ts.map +1 -0
  218. package/dist/node/constants.js +18 -0
  219. package/dist/node/constants.js.map +1 -0
  220. package/dist/node/index.d.ts +12 -0
  221. package/dist/node/index.d.ts.map +1 -0
  222. package/dist/node/index.js +9 -0
  223. package/dist/node/index.js.map +1 -0
  224. package/dist/node/methods.d.ts +73 -0
  225. package/dist/node/methods.d.ts.map +1 -0
  226. package/dist/node/methods.js +261 -0
  227. package/dist/node/methods.js.map +1 -0
  228. package/dist/node/serialization.d.ts +25 -0
  229. package/dist/node/serialization.d.ts.map +1 -0
  230. package/dist/node/serialization.js +525 -0
  231. package/dist/node/serialization.js.map +1 -0
  232. package/dist/parameter/OutputParameter.d.ts +69 -0
  233. package/dist/parameter/OutputParameter.d.ts.map +1 -0
  234. package/dist/parameter/OutputParameter.js +6 -0
  235. package/dist/parameter/OutputParameter.js.map +1 -0
  236. package/dist/parameter/Parameter.d.ts +152 -0
  237. package/dist/parameter/Parameter.d.ts.map +1 -0
  238. package/dist/parameter/Parameter.js +86 -0
  239. package/dist/parameter/Parameter.js.map +1 -0
  240. package/dist/parameter/index.d.ts +5 -0
  241. package/dist/parameter/index.d.ts.map +1 -0
  242. package/dist/parameter/index.js +3 -0
  243. package/dist/parameter/index.js.map +1 -0
  244. package/dist/variable/Variable.d.ts +25 -0
  245. package/dist/variable/Variable.d.ts.map +1 -0
  246. package/dist/variable/Variable.js +2 -0
  247. package/dist/variable/Variable.js.map +1 -0
  248. package/dist/variable/index.d.ts +3 -0
  249. package/dist/variable/index.d.ts.map +1 -0
  250. package/dist/variable/index.js +5 -0
  251. package/dist/variable/index.js.map +1 -0
  252. package/dist/variable/operations.d.ts +37 -0
  253. package/dist/variable/operations.d.ts.map +1 -0
  254. package/dist/variable/operations.js +88 -0
  255. package/dist/variable/operations.js.map +1 -0
  256. package/dist/workflow/Workflow.d.ts +38 -0
  257. package/dist/workflow/Workflow.d.ts.map +1 -0
  258. package/dist/workflow/Workflow.js +8 -0
  259. package/dist/workflow/Workflow.js.map +1 -0
  260. package/dist/workflow/index.d.ts +4 -0
  261. package/dist/workflow/index.d.ts.map +1 -0
  262. package/dist/workflow/index.js +3 -0
  263. package/dist/workflow/index.js.map +1 -0
  264. package/dist/workflow/serialization.d.ts +43 -0
  265. package/dist/workflow/serialization.d.ts.map +1 -0
  266. package/dist/workflow/serialization.js +215 -0
  267. package/dist/workflow/serialization.js.map +1 -0
  268. package/package.json +105 -0
  269. package/src/api/index.ts +11 -0
  270. package/src/api/workflow.ts +607 -0
  271. package/src/channel/Channel.ts +11 -0
  272. package/src/channel/ChannelDefinition.ts +76 -0
  273. package/src/channel/index.ts +6 -0
  274. package/src/channel/serialization.ts +68 -0
  275. package/src/deploy/index.ts +1 -0
  276. package/src/deploy/requirements.test.ts +61 -0
  277. package/src/deploy/requirements.ts +41 -0
  278. package/src/diagnostics/__fixtures__/diagnosticFixtures.ts +158 -0
  279. package/src/diagnostics/diagnostics.test.ts +878 -0
  280. package/src/diagnostics/diagnostics.ts +936 -0
  281. package/src/diagnostics/index.ts +11 -0
  282. package/src/edge/Edge.ts +23 -0
  283. package/src/edge/EdgeDefinition.ts +45 -0
  284. package/src/edge/EdgeType.ts +19 -0
  285. package/src/edge/index.ts +8 -0
  286. package/src/edge/serialization.ts +83 -0
  287. package/src/expression/index.ts +4 -0
  288. package/src/expression/parser.ts +362 -0
  289. package/src/expression/types.ts +30 -0
  290. package/src/function/FunctionDeclaration.ts +54 -0
  291. package/src/function/index.ts +3 -0
  292. package/src/function/serialization.ts +40 -0
  293. package/src/globals.d.ts +9 -0
  294. package/src/id/index.ts +8 -0
  295. package/src/index.ts +22 -0
  296. package/src/memory/Memory.ts +15 -0
  297. package/src/memory/MemoryDefinition.ts +16 -0
  298. package/src/memory/MemoryFileDefinition.ts +37 -0
  299. package/src/memory/MemoryRegistry.ts +35 -0
  300. package/src/memory/VectorDatabaseDefinition.ts +21 -0
  301. package/src/memory/index.ts +8 -0
  302. package/src/memory/serialization.ts +47 -0
  303. package/src/migration/index.ts +4 -0
  304. package/src/migration/migrate.test.ts +44 -0
  305. package/src/migration/migrate.ts +58 -0
  306. package/src/migration/migrations.ts +24 -0
  307. package/src/migration/version.ts +9 -0
  308. package/src/model/LLMModelDefinition.ts +12 -0
  309. package/src/model/Model.ts +39 -0
  310. package/src/model/ModelDefinition.ts +15 -0
  311. package/src/model/ModelRegistry.ts +33 -0
  312. package/src/model/index.ts +7 -0
  313. package/src/model/serialization.ts +30 -0
  314. package/src/node/AgentNode.ts +82 -0
  315. package/src/node/DataNode.ts +41 -0
  316. package/src/node/FunctionNode.ts +76 -0
  317. package/src/node/InputNode.ts +185 -0
  318. package/src/node/LogicNode.ts +33 -0
  319. package/src/node/MqttNode.ts +127 -0
  320. package/src/node/Node.ts +61 -0
  321. package/src/node/NodeDefinition.ts +37 -0
  322. package/src/node/NodeRegistry.ts +85 -0
  323. package/src/node/OutputNode.ts +87 -0
  324. package/src/node/ToolNode.ts +32 -0
  325. package/src/node/TriggerNode.ts +272 -0
  326. package/src/node/constants.ts +16 -0
  327. package/src/node/index.ts +26 -0
  328. package/src/node/methods.ts +278 -0
  329. package/src/node/serialization.ts +544 -0
  330. package/src/parameter/OutputParameter.ts +68 -0
  331. package/src/parameter/Parameter.ts +243 -0
  332. package/src/parameter/index.ts +33 -0
  333. package/src/variable/Variable.ts +10 -0
  334. package/src/variable/index.ts +16 -0
  335. package/src/variable/operations.ts +106 -0
  336. package/src/workflow/Workflow.ts +41 -0
  337. package/src/workflow/index.ts +3 -0
  338. package/src/workflow/serialization.test.ts +240 -0
  339. package/src/workflow/serialization.ts +242 -0
@@ -0,0 +1,309 @@
1
+ import jsep from "jsep";
2
+ /**
3
+ * Parse and validate an expression against C-style type rules.
4
+ * Replaces ${} placeholders with temporary identifiers, parses with jsep,
5
+ * infers types from the AST, and validates against the expected type.
6
+ */
7
+ export function parseExpression(expr) {
8
+ // Handle early returns
9
+ if (!expr.expression.trim()) {
10
+ return { isValid: false, inferredType: null, errors: ["Expression is empty"] };
11
+ }
12
+ if (expr.variables.some((v) => v === null)) {
13
+ return { isValid: false, inferredType: null, errors: ["Expression contains stale variable references"] };
14
+ }
15
+ const errors = [];
16
+ // 1. Build type context from variables
17
+ const typeContext = new Map();
18
+ // Replace ${} placeholders with temp identifiers for jsep
19
+ let parsableExpr = expr.expression;
20
+ // Count placeholders in expression
21
+ const placeholderCount = (expr.expression.match(/\$\{\}/g) || []).length;
22
+ if (placeholderCount !== expr.variables.length) {
23
+ errors.push(`Placeholder count (${placeholderCount}) doesn't match reference count (${expr.variables.length})`);
24
+ return { isValid: false, inferredType: null, errors };
25
+ }
26
+ expr.variables.forEach((variable, i) => {
27
+ const placeholder = `__var${i}__`;
28
+ parsableExpr = parsableExpr.replace("${}", placeholder);
29
+ if (variable) {
30
+ typeContext.set(placeholder, variable.dataType);
31
+ }
32
+ else {
33
+ // Stale reference - variable was deleted
34
+ errors.push(`Referenced variable at position ${i + 1} not found`);
35
+ }
36
+ });
37
+ // If we have stale/null variables, don't proceed with parsing
38
+ if (errors.length > 0) {
39
+ return { isValid: false, inferredType: null, errors };
40
+ }
41
+ // 2. For string-type expressions, auto-wrap bare text as string literals
42
+ // so users don't need to type quotes. E.g. `hello __var0__` → `"hello " + __var0__`
43
+ if (expr.expectedType === "string") {
44
+ parsableExpr = wrapStringTemplate(parsableExpr);
45
+ }
46
+ // 3. Parse with jsep
47
+ let ast;
48
+ try {
49
+ ast = jsep(parsableExpr);
50
+ }
51
+ catch (e) {
52
+ const message = e instanceof Error ? e.message : String(e);
53
+ return { isValid: false, inferredType: null, errors: [`Parse error: ${message}`] };
54
+ }
55
+ // 4. Infer type by walking AST
56
+ const inferredType = inferType(ast, typeContext, errors);
57
+ // 5. Check against expected type
58
+ if (inferredType && expr.expectedType !== inferredType) {
59
+ // Allow implicit conversions (int → float, etc.)
60
+ if (!isCompatible(inferredType, expr.expectedType)) {
61
+ errors.push(`Type mismatch: expression evaluates to '${inferredType}', expected '${expr.expectedType}'`);
62
+ }
63
+ }
64
+ return {
65
+ isValid: errors.length === 0 && inferredType !== null,
66
+ inferredType,
67
+ errors,
68
+ };
69
+ }
70
+ /**
71
+ * Recursively infer the type of an AST node
72
+ */
73
+ function inferType(node, ctx, errors) {
74
+ switch (node.type) {
75
+ case "Literal":
76
+ return inferLiteralType(node);
77
+ case "Identifier": {
78
+ const name = node.name;
79
+ const type = ctx.get(name);
80
+ if (!type) {
81
+ // Check if it's a placeholder variable that's missing
82
+ if (name.startsWith("__var") && name.endsWith("__")) {
83
+ errors.push(`Missing type for variable reference`);
84
+ }
85
+ else {
86
+ errors.push(`Unknown identifier: '${name}'`);
87
+ }
88
+ }
89
+ return type ?? null;
90
+ }
91
+ case "BinaryExpression":
92
+ return inferBinaryType(node, ctx, errors);
93
+ case "UnaryExpression":
94
+ return inferUnaryType(node, ctx, errors);
95
+ case "ConditionalExpression": {
96
+ // Ternary: condition ? consequent : alternate
97
+ const cond = node;
98
+ const condType = inferType(cond.test, ctx, errors);
99
+ if (condType !== "bool") {
100
+ errors.push("Ternary condition must be boolean");
101
+ }
102
+ const consType = inferType(cond.consequent, ctx, errors);
103
+ const altType = inferType(cond.alternate, ctx, errors);
104
+ if (consType && altType && consType !== altType) {
105
+ // Allow numeric promotion
106
+ if (isNumeric(consType) && isNumeric(altType)) {
107
+ return "float";
108
+ }
109
+ errors.push(`Ternary branches must have same type (got '${consType}' and '${altType}')`);
110
+ }
111
+ return consType;
112
+ }
113
+ case "MemberExpression": {
114
+ // For now, we don't support member expressions in C code generation
115
+ errors.push("Member expressions (e.g., obj.property) are not supported");
116
+ return null;
117
+ }
118
+ case "CallExpression": {
119
+ return inferCallType(node, ctx, errors);
120
+ }
121
+ default:
122
+ errors.push(`Unsupported expression type: ${node.type}`);
123
+ return null;
124
+ }
125
+ }
126
+ /**
127
+ * Infer the type of a literal value
128
+ */
129
+ function inferLiteralType(node) {
130
+ const value = node.value;
131
+ if (typeof value === "boolean")
132
+ return "bool";
133
+ if (typeof value === "number") {
134
+ // Check if it's an integer or float
135
+ return Number.isInteger(value) ? "int" : "float";
136
+ }
137
+ if (typeof value === "string")
138
+ return "string";
139
+ // null/undefined - default to int
140
+ return "int";
141
+ }
142
+ /**
143
+ * Infer the result type of a binary operation
144
+ */
145
+ function inferBinaryType(node, ctx, errors) {
146
+ const leftType = inferType(node.left, ctx, errors);
147
+ const rightType = inferType(node.right, ctx, errors);
148
+ const op = node.operator;
149
+ // If either operand failed to type, propagate null
150
+ if (!leftType || !rightType)
151
+ return null;
152
+ // String concatenation: string + any → string
153
+ if (op === "+" && (leftType === "string" || rightType === "string")) {
154
+ return "string";
155
+ }
156
+ // Arithmetic operators: int/float → int/float (promote to float if either is float)
157
+ if (["+", "-", "*", "/"].includes(op)) {
158
+ if (!isNumeric(leftType) || !isNumeric(rightType)) {
159
+ errors.push(`Operator '${op}' requires numeric operands (got '${leftType}' and '${rightType}')`);
160
+ return null;
161
+ }
162
+ return leftType === "float" || rightType === "float" ? "float" : "int";
163
+ }
164
+ // Modulo: int only
165
+ if (op === "%") {
166
+ if (leftType !== "int" || rightType !== "int") {
167
+ errors.push(`Operator '%' requires integer operands (got '${leftType}' and '${rightType}')`);
168
+ return null;
169
+ }
170
+ return "int";
171
+ }
172
+ // Comparison operators: numeric → bool
173
+ if (["<", ">", "<=", ">="].includes(op)) {
174
+ if (!isNumeric(leftType) || !isNumeric(rightType)) {
175
+ errors.push(`Operator '${op}' requires numeric operands (got '${leftType}' and '${rightType}')`);
176
+ }
177
+ return "bool";
178
+ }
179
+ // Equality operators: any → bool (but types should match)
180
+ if (["==", "!="].includes(op)) {
181
+ if (leftType !== rightType && !(isNumeric(leftType) && isNumeric(rightType))) {
182
+ errors.push(`Comparing incompatible types: '${leftType}' and '${rightType}'`);
183
+ }
184
+ return "bool";
185
+ }
186
+ // Logical operators: bool → bool
187
+ if (["&&", "||"].includes(op)) {
188
+ if (leftType !== "bool" || rightType !== "bool") {
189
+ errors.push(`Operator '${op}' requires boolean operands (got '${leftType}' and '${rightType}')`);
190
+ }
191
+ return "bool";
192
+ }
193
+ // Bitwise operators: int → int
194
+ if (["&", "|", "^", "<<", ">>"].includes(op)) {
195
+ if (leftType !== "int" || rightType !== "int") {
196
+ errors.push(`Bitwise operator '${op}' requires integer operands (got '${leftType}' and '${rightType}')`);
197
+ return null;
198
+ }
199
+ return "int";
200
+ }
201
+ errors.push(`Unknown operator: '${op}'`);
202
+ return null;
203
+ }
204
+ /**
205
+ * Infer the result type of a unary operation
206
+ */
207
+ function inferUnaryType(node, ctx, errors) {
208
+ const argType = inferType(node.argument, ctx, errors);
209
+ if (!argType)
210
+ return null;
211
+ // Logical NOT: bool → bool
212
+ if (node.operator === "!") {
213
+ if (argType !== "bool") {
214
+ errors.push(`Logical NOT '!' requires boolean operand (got '${argType}')`);
215
+ }
216
+ return "bool";
217
+ }
218
+ // Unary plus/minus: numeric → same type
219
+ if (node.operator === "-" || node.operator === "+") {
220
+ if (!isNumeric(argType)) {
221
+ errors.push(`Unary '${node.operator}' requires numeric operand (got '${argType}')`);
222
+ }
223
+ return argType;
224
+ }
225
+ // Bitwise NOT: int → int
226
+ if (node.operator === "~") {
227
+ if (argType !== "int") {
228
+ errors.push(`Bitwise NOT '~' requires integer operand (got '${argType}')`);
229
+ }
230
+ return "int";
231
+ }
232
+ errors.push(`Unknown unary operator: '${node.operator}'`);
233
+ return argType;
234
+ }
235
+ /** Cast functions: expression syntax uses int(), float(), bool(), str()
236
+ * which the code generator translates to C casts / conversion calls.
237
+ */
238
+ const CAST_FUNCTIONS = {
239
+ int: "int",
240
+ float: "float",
241
+ bool: "bool",
242
+ str: "string",
243
+ };
244
+ /**
245
+ * Infer the result type of a cast function call, e.g. int(expr), str(expr).
246
+ * Any type can be cast to any other type — it's the user's explicit intent.
247
+ */
248
+ function inferCallType(node, ctx, errors) {
249
+ const callee = node.callee;
250
+ if (callee.type !== "Identifier") {
251
+ errors.push("Only cast functions are supported (int, float, bool, str)");
252
+ return null;
253
+ }
254
+ const name = callee.name;
255
+ const targetType = CAST_FUNCTIONS[name];
256
+ if (!targetType) {
257
+ errors.push(`Unknown function '${name}'. Available cast functions: int(), float(), bool(), str()`);
258
+ return null;
259
+ }
260
+ if (node.arguments.length !== 1) {
261
+ errors.push(`${name}() expects exactly 1 argument, got ${node.arguments.length}`);
262
+ return null;
263
+ }
264
+ // Validate the argument expression (ensure it type-checks). Length checked as 1 above.
265
+ inferType(node.arguments[0], ctx, errors);
266
+ return targetType;
267
+ }
268
+ /**
269
+ * Check if a type is numeric (int or float)
270
+ */
271
+ function isNumeric(type) {
272
+ return type === "int" || type === "float";
273
+ }
274
+ /**
275
+ * Check if a type can be implicitly converted to another.
276
+ * - int ↔ float: both directions (truncation for float→int, common in embedded)
277
+ * - any → string: allowed (format strings)
278
+ * - bool is strict: requires explicit cast to/from bool
279
+ */
280
+ function isCompatible(from, to) {
281
+ if (from === to)
282
+ return true;
283
+ if (isNumeric(from) && isNumeric(to))
284
+ return true;
285
+ if (to === "string")
286
+ return true;
287
+ return false;
288
+ }
289
+ /**
290
+ * Wrap bare text in a string-type expression into quoted string literals for jsep.
291
+ * Splits by variable placeholders (__varN__), quotes text segments, joins with +.
292
+ * E.g. `hello __var0__` → `"hello " + __var0__`
293
+ */
294
+ function wrapStringTemplate(expr) {
295
+ // Split by __varN__ placeholders but keep them as delimiters
296
+ const parts = expr.split(/(__var\d+__)/);
297
+ const segments = [];
298
+ for (const part of parts) {
299
+ if (/^__var\d+__$/.test(part)) {
300
+ segments.push(part);
301
+ }
302
+ else if (part !== "") {
303
+ const escaped = part.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
304
+ segments.push(`"${escaped}"`);
305
+ }
306
+ }
307
+ return segments.join(" + ");
308
+ }
309
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/expression/parser.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAaxB;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAkB;IAChD,uBAAuB;IACvB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,qBAAqB,CAAC,EAAE,CAAC;IACjF,CAAC;IACD,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QAC3C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,+CAA+C,CAAC,EAAE,CAAC;IAC3G,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,uCAAuC;IACvC,MAAM,WAAW,GAAgB,IAAI,GAAG,EAAE,CAAC;IAE3C,0DAA0D;IAC1D,IAAI,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC;IAEnC,mCAAmC;IACnC,MAAM,gBAAgB,GAAG,CAAC,IAAI,CA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,GAAa,EAAE,CAAC;IAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YACvB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACjE,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { NodeOutput } from "../node";
2
+ import type { DataType, Expression } from "../api";
3
+ import type { Variable } from "../variable";
4
+ export interface ResolvedExpr {
5
+ expression: string;
6
+ variables: (NodeOutput | null)[];
7
+ expectedType: DataType;
8
+ }
9
+ export declare function resolveExpression(apiExpr: Expression, availableVars: Record<string, Variable>): ResolvedExpr;
10
+ export declare function isExpression(value: unknown): value is Expression;
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/expression/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC;IACjC,YAAY,EAAE,QAAQ,CAAC;CACxB;AAGD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,YAAY,CAW5G;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE"}
@@ -0,0 +1,20 @@
1
+ import { refToLookupKey } from "../variable";
2
+ // Resolve an expression by converting variable references to runtime variables
3
+ export function resolveExpression(apiExpr, availableVars) {
4
+ return {
5
+ expression: apiExpr.expression,
6
+ expectedType: apiExpr.dataType,
7
+ variables: apiExpr.references.map((ref) => {
8
+ if (!ref.varId)
9
+ return null;
10
+ const key = refToLookupKey(ref);
11
+ const v = availableVars[key];
12
+ return v ? { name: v.name, dataType: v.dataType } : null;
13
+ }),
14
+ };
15
+ }
16
+ // Check if a value is an expression (has references array)
17
+ export function isExpression(value) {
18
+ return typeof value === "object" && value !== null && "expression" in value && "references" in value;
19
+ }
20
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/expression/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAS7C,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,OAAmB,EAAE,aAAuC;IAC5F,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,YAAY,EAAE,OAAO,CAAC,QAAQ;QAC9B,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACxC,IAAI,CAAC,GAAG,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAC;YAC5B,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;YAChC,MAAM,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;YAC7B,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3D,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,YAAY,IAAI,KAAK,IAAI,YAAY,IAAI,KAAK,CAAC;AACvG,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { Expression, Schemas } from "../api";
2
+ import type { ApiVariable } from "../variable";
3
+ import type { DataType } from "../parameter";
4
+ /**
5
+ * The flat call-site signature of a function: identity + version + ports, with no
6
+ * expressions (the contract's `FunctionInfo`, used both inside `Function` on the wire
7
+ * and here in the domain). It is the snapshot a {@link FunctionCallNode} caches — to
8
+ * detect drift against the live declaration and render its ports without a registry
9
+ * lookup — and the shape {@link buildFunctionNodeDef} consumes.
10
+ */
11
+ export type FunctionInfo = Schemas["FunctionInfo"];
12
+ /**
13
+ * A function output: its declaration (`uid`/`name`/`dataType`) bundled with the
14
+ * `expression` that produces it (evaluated in callee scope at the function's end).
15
+ * Acts as a supertype of {@link ApiVariable}.
16
+ */
17
+ export interface OutputAssignment {
18
+ uid: string;
19
+ name: string;
20
+ dataType: DataType;
21
+ expression: Expression;
22
+ }
23
+ /**
24
+ * The domain function declaration: a signature with its outputs bundled
25
+ * (declaration + assignment per output).
26
+ * Separate from the function body (which is a canvas of nodes, edges, variables).
27
+ */
28
+ export interface FunctionDeclaration {
29
+ id: string;
30
+ version: number;
31
+ name: string;
32
+ arguments: ApiVariable[];
33
+ outputs: OutputAssignment[];
34
+ }
35
+ /**
36
+ * Project a declaration to the flat call-site signature, dropping the expressions
37
+ * (the caller has no business storing the callee's internals). Used only when
38
+ * crossing from declaration to a call-site snapshot — dropping or migrating a
39
+ * `FunctionCall` node — and by serialization. Never used to represent a function
40
+ * within the domain.
41
+ */
42
+ export declare function toFunctionInfo(fn: FunctionDeclaration): FunctionInfo;
43
+ //# sourceMappingURL=FunctionDeclaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionDeclaration.d.ts","sourceRoot":"","sources":["../../src/function/FunctionDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,mBAAmB,GAAG,YAAY,CAQpE"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Project a declaration to the flat call-site signature, dropping the expressions
3
+ * (the caller has no business storing the callee's internals). Used only when
4
+ * crossing from declaration to a call-site snapshot — dropping or migrating a
5
+ * `FunctionCall` node — and by serialization. Never used to represent a function
6
+ * within the domain.
7
+ */
8
+ export function toFunctionInfo(fn) {
9
+ return {
10
+ id: fn.id,
11
+ version: fn.version,
12
+ name: fn.name,
13
+ arguments: fn.arguments,
14
+ returns: fn.outputs.map(({ uid, name, dataType }) => ({ uid, name, dataType })),
15
+ };
16
+ }
17
+ //# sourceMappingURL=FunctionDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionDeclaration.js","sourceRoot":"","sources":["../../src/function/FunctionDeclaration.ts"],"names":[],"mappings":"AAsCA;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,EAAuB;IACpD,OAAO;QACL,EAAE,EAAE,EAAE,CAAC,EAAE;QACT,OAAO,EAAE,EAAE,CAAC,OAAO;QACnB,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,SAAS,EAAE,EAAE,CAAC,SAAS;QACvB,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;KAChF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export type { OutputAssignment, FunctionDeclaration, FunctionInfo } from "./FunctionDeclaration";
2
+ export { toFunctionInfo } from "./FunctionDeclaration";
3
+ export { serialize, deserialize } from "./serialization";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/function/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { toFunctionInfo } from "./FunctionDeclaration";
2
+ export { serialize, deserialize } from "./serialization";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/function/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Expression } from "../api";
2
+ import type { FunctionDeclaration, FunctionInfo } from "./FunctionDeclaration";
3
+ /**
4
+ * The two wire pieces a {@link FunctionDeclaration} splits into. The contract keeps
5
+ * the signature (`functionInfo`) and the return-value expressions (`outputAssignments`)
6
+ * apart; the domain bundles them on `outputs`. The function *body*
7
+ * (nodes/edges/declaredVariables) is added separately by the workflow serializer —
8
+ * this only handles the declaration ⇄ wire mapping.
9
+ */
10
+ export interface SerializedFunction {
11
+ functionInfo: FunctionInfo;
12
+ outputAssignments: Record<string, Expression>;
13
+ }
14
+ /** Domain declaration → wire pieces: flatten the signature and lift each output's
15
+ * expression into the `outputAssignments` map keyed by output uid. */
16
+ export declare function serialize(fn: FunctionDeclaration): SerializedFunction;
17
+ /** Wire pieces → domain declaration: bundle each `return` with its assignment. A
18
+ * return with no stored assignment gets an empty expression of the right dataType. */
19
+ export declare function deserialize(functionInfo: FunctionInfo, outputAssignments: Record<string, Expression>): FunctionDeclaration;
20
+ //# sourceMappingURL=serialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/function/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG/E;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAC/C;AAED;uEACuE;AACvE,wBAAgB,SAAS,CAAC,EAAE,EAAE,mBAAmB,GAAG,kBAAkB,CAIrE;AAED;uFACuF;AACvF,wBAAgB,WAAW,CAAC,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,mBAAmB,CAa1H"}
@@ -0,0 +1,26 @@
1
+ import { toFunctionInfo } from "./FunctionDeclaration";
2
+ /** Domain declaration → wire pieces: flatten the signature and lift each output's
3
+ * expression into the `outputAssignments` map keyed by output uid. */
4
+ export function serialize(fn) {
5
+ const outputAssignments = {};
6
+ for (const o of fn.outputs)
7
+ outputAssignments[o.uid] = o.expression;
8
+ return { functionInfo: toFunctionInfo(fn), outputAssignments };
9
+ }
10
+ /** Wire pieces → domain declaration: bundle each `return` with its assignment. A
11
+ * return with no stored assignment gets an empty expression of the right dataType. */
12
+ export function deserialize(functionInfo, outputAssignments) {
13
+ return {
14
+ id: functionInfo.id,
15
+ version: functionInfo.version,
16
+ name: functionInfo.name,
17
+ arguments: functionInfo.arguments,
18
+ outputs: functionInfo.returns.map((r) => ({
19
+ uid: r.uid,
20
+ name: r.name,
21
+ dataType: r.dataType,
22
+ expression: outputAssignments[r.uid] ?? { expression: "", references: [], dataType: r.dataType },
23
+ })),
24
+ };
25
+ }
26
+ //# sourceMappingURL=serialization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/function/serialization.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAcvD;uEACuE;AACvE,MAAM,UAAU,SAAS,CAAC,EAAuB;IAC/C,MAAM,iBAAiB,GAA+B,EAAE,CAAC;IACzD,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO;QAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC;IACpE,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC;AACjE,CAAC;AAED;uFACuF;AACvF,MAAM,UAAU,WAAW,CAAC,YAA0B,EAAE,iBAA6C;IACnG,OAAO;QACL,EAAE,EAAE,YAAY,CAAC,EAAE;QACnB,OAAO,EAAE,YAAY,CAAC,OAAO;QAC7B,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,SAAS,EAAE,YAAY,CAAC,SAAS;QACjC,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACxC,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE;SACjG,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
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 declare function generateId(): string;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/id/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
@@ -0,0 +1,9 @@
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() {
7
+ return crypto.randomUUID();
8
+ }
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/id/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type ValidationResult } from "./diagnostics/diagnostics";
2
+ import type { ApiWorkflow } from "./workflow/Workflow";
3
+ export type { DataType, Reference, Expression } from "./api";
4
+ export { migrate, CURRENT_SCHEMA_VERSION } from "./migration";
5
+ /**
6
+ * Validate a workflow against the headless validator.
7
+ * Pure: no I/O, no Zustand, no React, no DOM. Runnable in Node, a CLI, or
8
+ * a Claude Code skill.
9
+ */
10
+ export declare function validateWorkflow(workflow: ApiWorkflow): ValidationResult;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMvD,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,WAAW,GAAG,gBAAgB,CAExE"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ import { deserialize } from "./workflow/serialization";
2
+ import { validateWorkflowState } from "./diagnostics/diagnostics";
3
+ // Format versioning: load persisted documents through `migrate` before
4
+ // deserializing.
5
+ export { migrate, CURRENT_SCHEMA_VERSION } from "./migration";
6
+ /**
7
+ * Validate a workflow against the headless validator.
8
+ * Pure: no I/O, no Zustand, no React, no DOM. Runnable in Node, a CLI, or
9
+ * a Claude Code skill.
10
+ */
11
+ export function validateWorkflow(workflow) {
12
+ return validateWorkflowState(deserialize(workflow));
13
+ }
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAyB,MAAM,2BAA2B,CAAC;AASzF,uEAAuE;AACvE,iBAAiB;AACjB,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAqB;IACpD,OAAO,qBAAqB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Schemas } from "../api";
2
+ export type MemoryType = "MemoryFile" | "VectorDatabase";
3
+ export declare const ALL_MEMORY_TYPES: MemoryType[];
4
+ export interface Memory {
5
+ id: string;
6
+ label: string;
7
+ type: MemoryType;
8
+ arguments: Record<string, unknown>;
9
+ }
10
+ /** Reference from an agent node to a declared MemoryFile, with access mode. Round-trips 1:1 with the API. */
11
+ export type MemoryRef = Schemas["MemoryRef"];
12
+ //# sourceMappingURL=Memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Memory.d.ts","sourceRoot":"","sources":["../../src/memory/Memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,gBAAgB,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,UAAU,EAAqC,CAAC;AAE/E,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,6GAA6G;AAC7G,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const ALL_MEMORY_TYPES = ["MemoryFile", "VectorDatabase"];
2
+ //# sourceMappingURL=Memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Memory.js","sourceRoot":"","sources":["../../src/memory/Memory.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,gBAAgB,GAAiB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Parameter } from "../parameter";
2
+ import type { MemoryType } from "./Memory";
3
+ /**
4
+ * Static, per-type metadata for a memory variant. Mirrors NodeDefinition:
5
+ * one definition object per MemoryType, registered in MemoryRegistry — unlike
6
+ * channels, which use a single union definition gated by activation rules.
7
+ * `label` is a top-level instance field (edited like a channel label), so it is
8
+ * never a parameter here.
9
+ */
10
+ export interface MemoryDefinition {
11
+ type: MemoryType;
12
+ label: string;
13
+ description: string;
14
+ parameters: Parameter[];
15
+ }
16
+ //# sourceMappingURL=MemoryDefinition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryDefinition.d.ts","sourceRoot":"","sources":["../../src/memory/MemoryDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MemoryDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryDefinition.js","sourceRoot":"","sources":["../../src/memory/MemoryDefinition.ts"],"names":[],"mappings":""}