@decaf-ts/as-graph 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (374) hide show
  1. package/README.md +160 -2
  2. package/dist/as-graph.cjs +1 -1
  3. package/dist/as-graph.cjs.map +1 -1
  4. package/dist/as-graph.js +1 -1
  5. package/dist/as-graph.js.map +1 -1
  6. package/lib/cjs/dagster/DagsterGraphEventBridge.cjs +344 -0
  7. package/lib/cjs/dagster/DagsterGraphEventBridge.cjs.map +1 -0
  8. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs +789 -0
  9. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs.map +1 -0
  10. package/lib/cjs/dagster/DagsterResultMapper.cjs +56 -0
  11. package/lib/cjs/dagster/DagsterResultMapper.cjs.map +1 -0
  12. package/lib/cjs/dagster/DagsterTypes.cjs +4 -0
  13. package/lib/cjs/dagster/DagsterTypes.cjs.map +1 -0
  14. package/lib/cjs/dagster/capabilities.cjs +102 -0
  15. package/lib/cjs/dagster/capabilities.cjs.map +1 -0
  16. package/lib/cjs/dagster/constants.cjs +92 -0
  17. package/lib/cjs/dagster/constants.cjs.map +1 -0
  18. package/lib/cjs/dagster/index.cjs +32 -0
  19. package/lib/cjs/dagster/index.cjs.map +1 -0
  20. package/lib/cjs/engine/constants.cjs +6 -1
  21. package/lib/cjs/engine/constants.cjs.map +1 -1
  22. package/lib/cjs/engine/execution/GraphCodeMode.cjs +137 -0
  23. package/lib/cjs/engine/execution/GraphCodeMode.cjs.map +1 -0
  24. package/lib/cjs/engine/execution/GraphExecutionBackend.cjs +89 -0
  25. package/lib/cjs/engine/execution/GraphExecutionBackend.cjs.map +1 -0
  26. package/lib/cjs/engine/execution/GraphExecutionBackendRegistry.cjs +107 -0
  27. package/lib/cjs/engine/execution/GraphExecutionBackendRegistry.cjs.map +1 -0
  28. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs +250 -733
  29. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs.map +1 -1
  30. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs +804 -0
  31. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs.map +1 -0
  32. package/lib/cjs/engine/execution/index.cjs +4 -0
  33. package/lib/cjs/engine/execution/index.cjs.map +1 -1
  34. package/lib/cjs/engine/index.cjs +5 -0
  35. package/lib/cjs/engine/index.cjs.map +1 -1
  36. package/lib/cjs/engine/loops/ConditionEvaluator.cjs +116 -0
  37. package/lib/cjs/engine/loops/ConditionEvaluator.cjs.map +1 -0
  38. package/lib/cjs/engine/loops/GraphConditionEvaluator.cjs +25 -2
  39. package/lib/cjs/engine/loops/GraphConditionEvaluator.cjs.map +1 -1
  40. package/lib/cjs/engine/loops/index.cjs +1 -0
  41. package/lib/cjs/engine/loops/index.cjs.map +1 -1
  42. package/lib/cjs/engine/runs/GraphRunService.cjs +121 -3
  43. package/lib/cjs/engine/runs/GraphRunService.cjs.map +1 -1
  44. package/lib/cjs/engine/runs/InMemoryGraphRunStore.cjs +33 -0
  45. package/lib/cjs/engine/runs/InMemoryGraphRunStore.cjs.map +1 -1
  46. package/lib/cjs/engine/runs/ownership.cjs +100 -11
  47. package/lib/cjs/engine/runs/ownership.cjs.map +1 -1
  48. package/lib/cjs/engine/services/GraphRunModelService.cjs +16 -0
  49. package/lib/cjs/engine/services/GraphRunModelService.cjs.map +1 -1
  50. package/lib/cjs/engine/services/GraphWorkflowService.cjs +153 -16
  51. package/lib/cjs/engine/services/GraphWorkflowService.cjs.map +1 -1
  52. package/lib/cjs/mastra/MastraCapabilities.cjs +171 -0
  53. package/lib/cjs/mastra/MastraCapabilities.cjs.map +1 -0
  54. package/lib/cjs/mastra/MastraConditionBridge.cjs +39 -0
  55. package/lib/cjs/mastra/MastraConditionBridge.cjs.map +1 -0
  56. package/lib/cjs/mastra/MastraEventBridge.cjs +486 -0
  57. package/lib/cjs/mastra/MastraEventBridge.cjs.map +1 -0
  58. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs +351 -0
  59. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs.map +1 -0
  60. package/lib/cjs/mastra/MastraResumeGuard.cjs +127 -0
  61. package/lib/cjs/mastra/MastraResumeGuard.cjs.map +1 -0
  62. package/lib/cjs/mastra/MastraSchemaConverter.cjs +124 -0
  63. package/lib/cjs/mastra/MastraSchemaConverter.cjs.map +1 -0
  64. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs +461 -0
  65. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs.map +1 -0
  66. package/lib/cjs/mastra/MastraWorkflowManager.cjs +401 -0
  67. package/lib/cjs/mastra/MastraWorkflowManager.cjs.map +1 -0
  68. package/lib/cjs/mastra/index.cjs +35 -0
  69. package/lib/cjs/mastra/index.cjs.map +1 -0
  70. package/lib/cjs/mastra/types.cjs +34 -0
  71. package/lib/cjs/mastra/types.cjs.map +1 -0
  72. package/lib/cjs/nest/graph/GraphEngineCapabilityManifest.cjs +136 -0
  73. package/lib/cjs/nest/graph/GraphEngineCapabilityManifest.cjs.map +1 -0
  74. package/lib/cjs/nest/graph/GraphEngineCapabilityService.cjs +140 -0
  75. package/lib/cjs/nest/graph/GraphEngineCapabilityService.cjs.map +1 -0
  76. package/lib/cjs/nest/graph/GraphEngineController.cjs +227 -0
  77. package/lib/cjs/nest/graph/GraphEngineController.cjs.map +1 -0
  78. package/lib/cjs/nest/graph/GraphExecutionModule.cjs +30 -2
  79. package/lib/cjs/nest/graph/GraphExecutionModule.cjs.map +1 -1
  80. package/lib/cjs/nest/graph/GraphRunController.cjs +208 -28
  81. package/lib/cjs/nest/graph/GraphRunController.cjs.map +1 -1
  82. package/lib/cjs/nest/graph/GraphWorkflowController.cjs +97 -14
  83. package/lib/cjs/nest/graph/GraphWorkflowController.cjs.map +1 -1
  84. package/lib/cjs/nest/graph/index.cjs +3 -0
  85. package/lib/cjs/nest/graph/index.cjs.map +1 -1
  86. package/lib/cjs/nest/graph/main.cjs +54 -0
  87. package/lib/cjs/nest/graph/main.cjs.map +1 -0
  88. package/lib/cjs/nest/graph/servingDates.cjs +53 -0
  89. package/lib/cjs/nest/graph/servingDates.cjs.map +1 -0
  90. package/lib/cjs/nest/graph/servingErrors.cjs +68 -0
  91. package/lib/cjs/nest/graph/servingErrors.cjs.map +1 -0
  92. package/lib/cjs/node/flow/if/node.cjs +27 -9
  93. package/lib/cjs/node/flow/if/node.cjs.map +1 -1
  94. package/lib/cjs/node/flow/loop/until/node.cjs +5 -2
  95. package/lib/cjs/node/flow/loop/until/node.cjs.map +1 -1
  96. package/lib/cjs/node/flow/loop/while/node.cjs +8 -2
  97. package/lib/cjs/node/flow/loop/while/node.cjs.map +1 -1
  98. package/lib/cjs/node/flow/switch/node.cjs +2 -37
  99. package/lib/cjs/node/flow/switch/node.cjs.map +1 -1
  100. package/lib/cjs/node/utility/code/node.cjs +11 -3
  101. package/lib/cjs/node/utility/code/node.cjs.map +1 -1
  102. package/lib/cjs/ram/GraphRunStore.cjs +14 -0
  103. package/lib/cjs/ram/GraphRunStore.cjs.map +1 -1
  104. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs +2 -3
  105. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs.map +1 -1
  106. package/lib/cjs/shared/graph/constants.cjs +8 -0
  107. package/lib/cjs/shared/graph/constants.cjs.map +1 -1
  108. package/lib/cjs/shared/graph/index.cjs +2 -1
  109. package/lib/cjs/shared/graph/index.cjs.map +1 -1
  110. package/lib/cjs/shared/graph/layout/GraphWorkflowLayout.cjs +146 -0
  111. package/lib/cjs/shared/graph/layout/GraphWorkflowLayout.cjs.map +1 -0
  112. package/lib/cjs/shared/graph/layout/index.cjs +23 -0
  113. package/lib/cjs/shared/graph/layout/index.cjs.map +1 -0
  114. package/lib/cjs/shared/graph/layout/layout-options.cjs +93 -0
  115. package/lib/cjs/shared/graph/layout/layout-options.cjs.map +1 -0
  116. package/lib/cjs/shared/ui/index.cjs +8 -10
  117. package/lib/cjs/shared/ui/index.cjs.map +1 -1
  118. package/lib/esm/dagster/DagsterGraphEventBridge.js +339 -0
  119. package/lib/esm/dagster/DagsterGraphEventBridge.js.map +1 -0
  120. package/lib/esm/dagster/DagsterGraphExecutionBackend.js +781 -0
  121. package/lib/esm/dagster/DagsterGraphExecutionBackend.js.map +1 -0
  122. package/lib/esm/dagster/DagsterResultMapper.js +51 -0
  123. package/lib/esm/dagster/DagsterResultMapper.js.map +1 -0
  124. package/lib/esm/dagster/DagsterTypes.js +2 -0
  125. package/lib/esm/dagster/DagsterTypes.js.map +1 -0
  126. package/lib/esm/dagster/capabilities.js +97 -0
  127. package/lib/esm/dagster/capabilities.js.map +1 -0
  128. package/lib/esm/dagster/constants.js +88 -0
  129. package/lib/esm/dagster/constants.js.map +1 -0
  130. package/lib/esm/dagster/index.js +15 -0
  131. package/lib/esm/dagster/index.js.map +1 -0
  132. package/lib/esm/engine/constants.js +5 -0
  133. package/lib/esm/engine/constants.js.map +1 -1
  134. package/lib/esm/engine/execution/GraphCodeMode.js +132 -0
  135. package/lib/esm/engine/execution/GraphCodeMode.js.map +1 -0
  136. package/lib/esm/engine/execution/GraphExecutionBackend.js +83 -0
  137. package/lib/esm/engine/execution/GraphExecutionBackend.js.map +1 -0
  138. package/lib/esm/engine/execution/GraphExecutionBackendRegistry.js +102 -0
  139. package/lib/esm/engine/execution/GraphExecutionBackendRegistry.js.map +1 -0
  140. package/lib/esm/engine/execution/GraphExecutionEngine.js +232 -716
  141. package/lib/esm/engine/execution/GraphExecutionEngine.js.map +1 -1
  142. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js +799 -0
  143. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js.map +1 -0
  144. package/lib/esm/engine/execution/index.js +4 -0
  145. package/lib/esm/engine/execution/index.js.map +1 -1
  146. package/lib/esm/engine/index.js +5 -0
  147. package/lib/esm/engine/index.js.map +1 -1
  148. package/lib/esm/engine/loops/ConditionEvaluator.js +108 -0
  149. package/lib/esm/engine/loops/ConditionEvaluator.js.map +1 -0
  150. package/lib/esm/engine/loops/GraphConditionEvaluator.js +25 -2
  151. package/lib/esm/engine/loops/GraphConditionEvaluator.js.map +1 -1
  152. package/lib/esm/engine/loops/index.js +1 -0
  153. package/lib/esm/engine/loops/index.js.map +1 -1
  154. package/lib/esm/engine/runs/GraphRunService.js +123 -5
  155. package/lib/esm/engine/runs/GraphRunService.js.map +1 -1
  156. package/lib/esm/engine/runs/InMemoryGraphRunStore.js +33 -0
  157. package/lib/esm/engine/runs/InMemoryGraphRunStore.js.map +1 -1
  158. package/lib/esm/engine/runs/ownership.js +97 -11
  159. package/lib/esm/engine/runs/ownership.js.map +1 -1
  160. package/lib/esm/engine/services/GraphRunModelService.js +16 -0
  161. package/lib/esm/engine/services/GraphRunModelService.js.map +1 -1
  162. package/lib/esm/engine/services/GraphWorkflowService.js +155 -18
  163. package/lib/esm/engine/services/GraphWorkflowService.js.map +1 -1
  164. package/lib/esm/mastra/MastraCapabilities.js +164 -0
  165. package/lib/esm/mastra/MastraCapabilities.js.map +1 -0
  166. package/lib/esm/mastra/MastraConditionBridge.js +34 -0
  167. package/lib/esm/mastra/MastraConditionBridge.js.map +1 -0
  168. package/lib/esm/mastra/MastraEventBridge.js +481 -0
  169. package/lib/esm/mastra/MastraEventBridge.js.map +1 -0
  170. package/lib/esm/mastra/MastraGraphExecutionBackend.js +346 -0
  171. package/lib/esm/mastra/MastraGraphExecutionBackend.js.map +1 -0
  172. package/lib/esm/mastra/MastraResumeGuard.js +123 -0
  173. package/lib/esm/mastra/MastraResumeGuard.js.map +1 -0
  174. package/lib/esm/mastra/MastraSchemaConverter.js +119 -0
  175. package/lib/esm/mastra/MastraSchemaConverter.js.map +1 -0
  176. package/lib/esm/mastra/MastraWorkflowCompiler.js +456 -0
  177. package/lib/esm/mastra/MastraWorkflowCompiler.js.map +1 -0
  178. package/lib/esm/mastra/MastraWorkflowManager.js +396 -0
  179. package/lib/esm/mastra/MastraWorkflowManager.js.map +1 -0
  180. package/lib/esm/mastra/index.js +18 -0
  181. package/lib/esm/mastra/index.js.map +1 -0
  182. package/lib/esm/mastra/types.js +30 -0
  183. package/lib/esm/mastra/types.js.map +1 -0
  184. package/lib/esm/nest/graph/GraphEngineCapabilityManifest.js +129 -0
  185. package/lib/esm/nest/graph/GraphEngineCapabilityManifest.js.map +1 -0
  186. package/lib/esm/nest/graph/GraphEngineCapabilityService.js +131 -0
  187. package/lib/esm/nest/graph/GraphEngineCapabilityService.js.map +1 -0
  188. package/lib/esm/nest/graph/GraphEngineController.js +218 -0
  189. package/lib/esm/nest/graph/GraphEngineController.js.map +1 -0
  190. package/lib/esm/nest/graph/GraphExecutionModule.js +30 -2
  191. package/lib/esm/nest/graph/GraphExecutionModule.js.map +1 -1
  192. package/lib/esm/nest/graph/GraphRunController.js +209 -29
  193. package/lib/esm/nest/graph/GraphRunController.js.map +1 -1
  194. package/lib/esm/nest/graph/GraphWorkflowController.js +98 -15
  195. package/lib/esm/nest/graph/GraphWorkflowController.js.map +1 -1
  196. package/lib/esm/nest/graph/index.js +3 -0
  197. package/lib/esm/nest/graph/index.js.map +1 -1
  198. package/lib/esm/nest/graph/main.js +51 -0
  199. package/lib/esm/nest/graph/main.js.map +1 -0
  200. package/lib/esm/nest/graph/servingDates.js +49 -0
  201. package/lib/esm/nest/graph/servingDates.js.map +1 -0
  202. package/lib/esm/nest/graph/servingErrors.js +63 -0
  203. package/lib/esm/nest/graph/servingErrors.js.map +1 -0
  204. package/lib/esm/node/flow/if/node.js +27 -9
  205. package/lib/esm/node/flow/if/node.js.map +1 -1
  206. package/lib/esm/node/flow/loop/until/node.js +5 -2
  207. package/lib/esm/node/flow/loop/until/node.js.map +1 -1
  208. package/lib/esm/node/flow/loop/while/node.js +8 -2
  209. package/lib/esm/node/flow/loop/while/node.js.map +1 -1
  210. package/lib/esm/node/flow/switch/node.js +2 -37
  211. package/lib/esm/node/flow/switch/node.js.map +1 -1
  212. package/lib/esm/node/utility/code/node.js +11 -3
  213. package/lib/esm/node/utility/code/node.js.map +1 -1
  214. package/lib/esm/ram/GraphRunStore.js +14 -0
  215. package/lib/esm/ram/GraphRunStore.js.map +1 -1
  216. package/lib/esm/shared/graph/GraphExecutionStateMapper.js.map +1 -1
  217. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js +2 -3
  218. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js.map +1 -1
  219. package/lib/esm/shared/graph/constants.js +8 -0
  220. package/lib/esm/shared/graph/constants.js.map +1 -1
  221. package/lib/esm/shared/graph/document/GraphFlowBuilder.js.map +1 -1
  222. package/lib/esm/shared/graph/index.js +2 -1
  223. package/lib/esm/shared/graph/index.js.map +1 -1
  224. package/lib/esm/shared/graph/layout/GraphWorkflowLayout.js +107 -0
  225. package/lib/esm/shared/graph/layout/GraphWorkflowLayout.js.map +1 -0
  226. package/lib/esm/shared/graph/layout/index.js +6 -0
  227. package/lib/esm/shared/graph/layout/index.js.map +1 -0
  228. package/lib/esm/shared/graph/layout/layout-options.js +96 -0
  229. package/lib/esm/shared/graph/layout/layout-options.js.map +1 -0
  230. package/lib/esm/shared/ui/index.js +8 -10
  231. package/lib/esm/shared/ui/index.js.map +1 -1
  232. package/lib/types/dagster/DagsterGraphEventBridge.d.cts +142 -0
  233. package/lib/types/dagster/DagsterGraphEventBridge.d.mts +142 -0
  234. package/lib/types/dagster/DagsterGraphExecutionBackend.d.cts +323 -0
  235. package/lib/types/dagster/DagsterGraphExecutionBackend.d.mts +323 -0
  236. package/lib/types/dagster/DagsterResultMapper.d.cts +50 -0
  237. package/lib/types/dagster/DagsterResultMapper.d.mts +50 -0
  238. package/lib/types/dagster/DagsterTypes.d.cts +355 -0
  239. package/lib/types/dagster/DagsterTypes.d.mts +355 -0
  240. package/lib/types/dagster/capabilities.d.cts +34 -0
  241. package/lib/types/dagster/capabilities.d.mts +34 -0
  242. package/lib/types/dagster/constants.d.cts +87 -0
  243. package/lib/types/dagster/constants.d.mts +87 -0
  244. package/lib/types/dagster/index.d.cts +14 -0
  245. package/lib/types/dagster/index.d.mts +14 -0
  246. package/lib/types/engine/constants.d.cts +5 -0
  247. package/lib/types/engine/constants.d.mts +5 -0
  248. package/lib/types/engine/execution/GraphCodeMode.d.cts +52 -0
  249. package/lib/types/engine/execution/GraphCodeMode.d.mts +52 -0
  250. package/lib/types/engine/execution/GraphExecutionBackend.d.cts +306 -0
  251. package/lib/types/engine/execution/GraphExecutionBackend.d.mts +306 -0
  252. package/lib/types/engine/execution/GraphExecutionBackendRegistry.d.cts +59 -0
  253. package/lib/types/engine/execution/GraphExecutionBackendRegistry.d.mts +59 -0
  254. package/lib/types/engine/execution/GraphExecutionEngine.d.cts +116 -135
  255. package/lib/types/engine/execution/GraphExecutionEngine.d.mts +116 -135
  256. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.cts +232 -0
  257. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.mts +232 -0
  258. package/lib/types/engine/execution/index.d.cts +4 -0
  259. package/lib/types/engine/execution/index.d.mts +4 -0
  260. package/lib/types/engine/index.d.cts +5 -0
  261. package/lib/types/engine/index.d.mts +5 -0
  262. package/lib/types/engine/loops/ConditionEvaluator.d.cts +87 -0
  263. package/lib/types/engine/loops/ConditionEvaluator.d.mts +87 -0
  264. package/lib/types/engine/loops/GraphConditionEvaluator.d.cts +27 -7
  265. package/lib/types/engine/loops/GraphConditionEvaluator.d.mts +27 -7
  266. package/lib/types/engine/loops/index.d.cts +1 -0
  267. package/lib/types/engine/loops/index.d.mts +1 -0
  268. package/lib/types/engine/runs/GraphRunService.d.cts +60 -1
  269. package/lib/types/engine/runs/GraphRunService.d.mts +60 -1
  270. package/lib/types/engine/runs/InMemoryGraphRunStore.d.cts +29 -0
  271. package/lib/types/engine/runs/InMemoryGraphRunStore.d.mts +29 -0
  272. package/lib/types/engine/runs/ownership.d.cts +89 -4
  273. package/lib/types/engine/runs/ownership.d.mts +89 -4
  274. package/lib/types/engine/runs/types.d.cts +12 -1
  275. package/lib/types/engine/runs/types.d.mts +12 -1
  276. package/lib/types/engine/services/GraphRunModelService.d.cts +13 -0
  277. package/lib/types/engine/services/GraphRunModelService.d.mts +13 -0
  278. package/lib/types/engine/services/GraphWorkflowService.d.cts +74 -2
  279. package/lib/types/engine/services/GraphWorkflowService.d.mts +74 -2
  280. package/lib/types/engine/types.d.cts +11 -4
  281. package/lib/types/engine/types.d.mts +11 -4
  282. package/lib/types/mastra/MastraCapabilities.d.cts +91 -0
  283. package/lib/types/mastra/MastraCapabilities.d.mts +91 -0
  284. package/lib/types/mastra/MastraConditionBridge.d.cts +38 -0
  285. package/lib/types/mastra/MastraConditionBridge.d.mts +38 -0
  286. package/lib/types/mastra/MastraEventBridge.d.cts +189 -0
  287. package/lib/types/mastra/MastraEventBridge.d.mts +189 -0
  288. package/lib/types/mastra/MastraGraphExecutionBackend.d.cts +119 -0
  289. package/lib/types/mastra/MastraGraphExecutionBackend.d.mts +119 -0
  290. package/lib/types/mastra/MastraResumeGuard.d.cts +58 -0
  291. package/lib/types/mastra/MastraResumeGuard.d.mts +58 -0
  292. package/lib/types/mastra/MastraSchemaConverter.d.cts +39 -0
  293. package/lib/types/mastra/MastraSchemaConverter.d.mts +39 -0
  294. package/lib/types/mastra/MastraWorkflowCompiler.d.cts +218 -0
  295. package/lib/types/mastra/MastraWorkflowCompiler.d.mts +218 -0
  296. package/lib/types/mastra/MastraWorkflowManager.d.cts +220 -0
  297. package/lib/types/mastra/MastraWorkflowManager.d.mts +220 -0
  298. package/lib/types/mastra/index.d.cts +17 -0
  299. package/lib/types/mastra/index.d.mts +17 -0
  300. package/lib/types/mastra/types.d.cts +222 -0
  301. package/lib/types/mastra/types.d.mts +222 -0
  302. package/lib/types/nest/graph/GraphEngineCapabilityManifest.d.cts +87 -0
  303. package/lib/types/nest/graph/GraphEngineCapabilityManifest.d.mts +87 -0
  304. package/lib/types/nest/graph/GraphEngineCapabilityService.d.cts +98 -0
  305. package/lib/types/nest/graph/GraphEngineCapabilityService.d.mts +98 -0
  306. package/lib/types/nest/graph/GraphEngineController.d.cts +74 -0
  307. package/lib/types/nest/graph/GraphEngineController.d.mts +74 -0
  308. package/lib/types/nest/graph/GraphExecutionModule.d.cts +14 -1
  309. package/lib/types/nest/graph/GraphExecutionModule.d.mts +14 -1
  310. package/lib/types/nest/graph/GraphRunController.d.cts +69 -14
  311. package/lib/types/nest/graph/GraphRunController.d.mts +69 -14
  312. package/lib/types/nest/graph/GraphWorkflowController.d.cts +50 -17
  313. package/lib/types/nest/graph/GraphWorkflowController.d.mts +50 -17
  314. package/lib/types/nest/graph/index.d.cts +3 -0
  315. package/lib/types/nest/graph/index.d.mts +3 -0
  316. package/lib/types/nest/graph/main.d.cts +1 -0
  317. package/lib/types/nest/graph/main.d.mts +1 -0
  318. package/lib/types/nest/graph/servingDates.d.cts +35 -0
  319. package/lib/types/nest/graph/servingDates.d.mts +35 -0
  320. package/lib/types/nest/graph/servingErrors.d.cts +44 -0
  321. package/lib/types/nest/graph/servingErrors.d.mts +44 -0
  322. package/lib/types/node/flow/if/node.d.cts +20 -8
  323. package/lib/types/node/flow/if/node.d.mts +20 -8
  324. package/lib/types/node/flow/loop/until/node.d.cts +4 -1
  325. package/lib/types/node/flow/loop/until/node.d.mts +4 -1
  326. package/lib/types/node/flow/loop/while/node.d.cts +4 -1
  327. package/lib/types/node/flow/loop/while/node.d.mts +4 -1
  328. package/lib/types/node/utility/code/node.d.cts +1 -1
  329. package/lib/types/node/utility/code/node.d.mts +1 -1
  330. package/lib/types/ram/GraphRunStore.d.cts +12 -0
  331. package/lib/types/ram/GraphRunStore.d.mts +12 -0
  332. package/lib/types/shared/graph/GraphExecutionStateMapper.d.cts +5 -5
  333. package/lib/types/shared/graph/GraphExecutionStateMapper.d.mts +5 -5
  334. package/lib/types/shared/graph/constants.d.cts +8 -0
  335. package/lib/types/shared/graph/constants.d.mts +8 -0
  336. package/lib/types/shared/graph/document/GraphFlowBuilder.d.cts +5 -5
  337. package/lib/types/shared/graph/document/GraphFlowBuilder.d.mts +5 -5
  338. package/lib/types/shared/graph/index.d.cts +2 -1
  339. package/lib/types/shared/graph/index.d.mts +2 -1
  340. package/lib/types/shared/graph/layout/GraphWorkflowLayout.d.cts +49 -0
  341. package/lib/types/shared/graph/layout/GraphWorkflowLayout.d.mts +49 -0
  342. package/lib/types/shared/graph/layout/index.d.cts +5 -0
  343. package/lib/types/shared/graph/layout/index.d.mts +5 -0
  344. package/lib/types/shared/graph/layout/layout-options.d.cts +46 -0
  345. package/lib/types/shared/graph/layout/layout-options.d.mts +46 -0
  346. package/lib/types/shared/graph/types.d.cts +12 -4
  347. package/lib/types/shared/graph/types.d.mts +12 -4
  348. package/lib/types/shared/ui/index.d.cts +8 -10
  349. package/lib/types/shared/ui/index.d.mts +8 -10
  350. package/package.json +49 -6
  351. package/lib/cjs/shared/ui/GraphNodeView.cjs +0 -114
  352. package/lib/cjs/shared/ui/GraphNodeView.cjs.map +0 -1
  353. package/lib/cjs/shared/ui/GraphRunView.cjs +0 -96
  354. package/lib/cjs/shared/ui/GraphRunView.cjs.map +0 -1
  355. package/lib/cjs/shared/ui/GraphWorkflowView.cjs +0 -78
  356. package/lib/cjs/shared/ui/GraphWorkflowView.cjs.map +0 -1
  357. package/lib/cjs/shared/ui/types.cjs +0 -4
  358. package/lib/cjs/shared/ui/types.cjs.map +0 -1
  359. package/lib/esm/shared/ui/GraphNodeView.js +0 -107
  360. package/lib/esm/shared/ui/GraphNodeView.js.map +0 -1
  361. package/lib/esm/shared/ui/GraphRunView.js +0 -90
  362. package/lib/esm/shared/ui/GraphRunView.js.map +0 -1
  363. package/lib/esm/shared/ui/GraphWorkflowView.js +0 -72
  364. package/lib/esm/shared/ui/GraphWorkflowView.js.map +0 -1
  365. package/lib/esm/shared/ui/types.js +0 -2
  366. package/lib/esm/shared/ui/types.js.map +0 -1
  367. package/lib/types/shared/ui/GraphNodeView.d.cts +0 -48
  368. package/lib/types/shared/ui/GraphNodeView.d.mts +0 -48
  369. package/lib/types/shared/ui/GraphRunView.d.cts +0 -88
  370. package/lib/types/shared/ui/GraphRunView.d.mts +0 -88
  371. package/lib/types/shared/ui/GraphWorkflowView.d.cts +0 -18
  372. package/lib/types/shared/ui/GraphWorkflowView.d.mts +0 -18
  373. package/lib/types/shared/ui/types.d.cts +0 -200
  374. package/lib/types/shared/ui/types.d.mts +0 -200
@@ -0,0 +1,804 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalGraphExecutionBackend = void 0;
4
+ const index_js_1 = require("./../../shared/graph/index.cjs");
5
+ const constants_js_1 = require("./../constants.cjs");
6
+ const index_js_2 = require("./../errors/index.cjs");
7
+ const GraphParameterValidator_js_1 = require("./../validation/GraphParameterValidator.cjs");
8
+ const GraphValueRepository_js_1 = require("./../store/GraphValueRepository.cjs");
9
+ const GraphPinningService_js_1 = require("./../pinning/GraphPinningService.cjs");
10
+ const GraphPinningPolicy_js_1 = require("./../pinning/GraphPinningPolicy.cjs");
11
+ const GraphPinningDependencyResolver_js_1 = require("./../pinning/GraphPinningDependencyResolver.cjs");
12
+ const GraphExecutionContext_js_1 = require("./GraphExecutionContext.cjs");
13
+ const GraphExecutionResult_js_1 = require("./GraphExecutionResult.cjs");
14
+ const GraphExecutionBackendRegistry_js_1 = require("./GraphExecutionBackendRegistry.cjs");
15
+ /**
16
+ * Compiles a `{{ ... }}` text template into a JavaScript template literal so
17
+ * the pluggable code sandbox evaluator can resolve its placeholders against
18
+ * the same `$input`/`$vars`/`$item` bindings used by expression bindings.
19
+ *
20
+ * @param template - The persisted template body.
21
+ * @returns A backtick-quoted template literal expression.
22
+ */
23
+ function graphTemplateToExpression(template) {
24
+ const escaped = template.replace(/\\/g, "\\\\").replace(/`/g, "\\`");
25
+ const interpolated = escaped.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g, (_match, expression) => `\${${expression}}`);
26
+ return `\`${interpolated}\``;
27
+ }
28
+ /**
29
+ * Built-in reference graph execution backend. Registers itself under
30
+ * {@link GRAPH_LOCAL_EXECUTION_BACKEND} on construction.
31
+ */
32
+ class LocalGraphExecutionBackend {
33
+ constructor() {
34
+ /** This backend executes locally, in-process. */
35
+ this.local = true;
36
+ /**
37
+ * This backend executes code-mode surfaces host-side through the
38
+ * facade-owned `CodeSandboxEvaluator` (SAA-193 C1).
39
+ */
40
+ this.codeMode = "hostSide";
41
+ GraphExecutionBackendRegistry_js_1.GraphExecutionBackendRegistry.register(constants_js_1.GRAPH_LOCAL_EXECUTION_BACKEND, this);
42
+ }
43
+ /**
44
+ * Resolves the backend's runtime collaborators. Called by the facade during
45
+ * `GraphExecutionEngine.initialize`.
46
+ *
47
+ * @param config - The facade-provided collaborators.
48
+ */
49
+ async initialize(config) {
50
+ this.valueAdapter = config.valueAdapter;
51
+ this.codeSandboxEvaluator = config.codeSandboxEvaluator;
52
+ this.workflowStore = config.workflowStore;
53
+ this.engine = config.engine;
54
+ }
55
+ /**
56
+ * Effective capability metadata: code-mode is host-side and workflow
57
+ * listing/lookup is supported exactly when a catalogue port is wired in.
58
+ */
59
+ get capabilities() {
60
+ const status = this.workflowStore ? "supported" : "not_supported";
61
+ return {
62
+ codeMode: this.codeMode,
63
+ workflows: { list: status, get: status },
64
+ };
65
+ }
66
+ /**
67
+ * Lists the workflows visible to the requesting principal through the wired
68
+ * `GraphWorkflowStore` port.
69
+ *
70
+ * @param args - Optional decaf contextual arguments forwarded to the store.
71
+ * @returns Workflow summaries, newest first when the store orders them.
72
+ * @throws {GraphExecutionError} when no workflow store is wired in.
73
+ */
74
+ async listWorkflows(...args) {
75
+ const store = this.workflowStore;
76
+ if (!store) {
77
+ throw new index_js_2.GraphExecutionError("LocalGraphExecutionBackend has no workflowStore configured; workflow listing is not supported", "GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");
78
+ }
79
+ const records = await store.listWorkflows(...args);
80
+ return records.map((record) => ({
81
+ id: record.workflowId,
82
+ ...(record.name !== undefined ? { name: record.name } : {}),
83
+ ...(record.updatedAt !== undefined && record.updatedAt !== null
84
+ ? { updatedAt: record.updatedAt }
85
+ : {}),
86
+ }));
87
+ }
88
+ /**
89
+ * Reads a single canonical workflow document through the wired
90
+ * `GraphWorkflowStore` port.
91
+ *
92
+ * @param workflowId - The workflow id to read.
93
+ * @param args - Optional decaf contextual arguments forwarded to the store.
94
+ * @returns The canonical workflow document.
95
+ * @throws {GraphExecutionError} when no workflow store is wired in.
96
+ */
97
+ async getWorkflow(workflowId, ...args) {
98
+ const store = this.workflowStore;
99
+ if (!store) {
100
+ throw new index_js_2.GraphExecutionError("LocalGraphExecutionBackend has no workflowStore configured; workflow lookup is not supported", "GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");
101
+ }
102
+ return await store.getDocument(workflowId, ...args);
103
+ }
104
+ /**
105
+ * Executes a validated/resolved workflow's plan against the facade-owned
106
+ * frame carried by the request's event sink.
107
+ *
108
+ * @param request - The execution request.
109
+ * @returns The complete execution result.
110
+ * @throws {GraphExecutionError} when the request's sink is not the
111
+ * facade-created frame-aware sink.
112
+ */
113
+ async execute(request) {
114
+ const { document, plan, inputs, options: opts, events } = request;
115
+ const sink = events;
116
+ const frame = sink.frame;
117
+ if (!frame) {
118
+ throw new index_js_2.GraphExecutionError("LocalGraphExecutionBackend requires the frame-bound event sink created by GraphExecutionEngine", "GRAPH_EXECUTION_FRAME_MISSING");
119
+ }
120
+ const valueStore = frame.valueStore;
121
+ const runId = frame.runId;
122
+ const path = opts.path ?? [];
123
+ const emitFn = async (partial) => {
124
+ await sink.emit(partial);
125
+ };
126
+ try {
127
+ for (const layer of plan.layers) {
128
+ this.assertNotAborted(opts);
129
+ await this.executeLayer(frame, plan, layer.nodes, opts, emitFn);
130
+ }
131
+ this.assertNotAborted(opts);
132
+ const firstFailure = [...frame.nodeResults.values()].find((result) => result.status === index_js_1.GraphExecutionStatus.FAILED);
133
+ if (firstFailure?.error) {
134
+ throw new index_js_2.GraphExecutionError(firstFailure.error.message, firstFailure.error.code ?? "GRAPH_EXECUTION_ERROR", firstFailure.error.details);
135
+ }
136
+ frame.finish();
137
+ await sink.emit({
138
+ type: index_js_1.GraphExecutionEventType.WORKFLOW_COMPLETED,
139
+ runId,
140
+ parentRunId: opts.parentRunId,
141
+ workflowId: plan.workflowId,
142
+ path,
143
+ status: index_js_1.GraphExecutionStatus.SUCCEEDED,
144
+ payload: { outputs: valueStore.getWorkflowValues() },
145
+ });
146
+ return (0, GraphExecutionResult_js_1.buildGraphExecutionResult)(frame, document, inputs, index_js_1.GraphExecutionStatus.SUCCEEDED, opts.metadata);
147
+ }
148
+ catch (error) {
149
+ // A cooperative `GraphBreakSignal` is loop-control flow, not a workflow
150
+ // failure: propagate it unchanged so the enclosing loop executor can stop
151
+ // iterating instead of seeing a failed child run.
152
+ if (error instanceof index_js_2.GraphBreakSignal) {
153
+ frame.finish();
154
+ throw error;
155
+ }
156
+ frame.finish();
157
+ const errorPayload = this.toErrorPayload(error);
158
+ if (error instanceof index_js_2.GraphRunCancelledError ||
159
+ opts.abortSignal?.aborted === true) {
160
+ await sink.emit({
161
+ type: index_js_1.GraphExecutionEventType.WORKFLOW_CANCELLED,
162
+ runId,
163
+ parentRunId: opts.parentRunId,
164
+ workflowId: plan.workflowId,
165
+ path,
166
+ status: index_js_1.GraphExecutionStatus.CANCELLED,
167
+ error: errorPayload,
168
+ });
169
+ return (0, GraphExecutionResult_js_1.buildGraphExecutionResult)(frame, document, inputs, index_js_1.GraphExecutionStatus.CANCELLED, opts.metadata);
170
+ }
171
+ await sink.emit({
172
+ type: index_js_1.GraphExecutionEventType.WORKFLOW_FAILED,
173
+ runId,
174
+ parentRunId: opts.parentRunId,
175
+ workflowId: plan.workflowId,
176
+ path,
177
+ status: index_js_1.GraphExecutionStatus.FAILED,
178
+ error: errorPayload,
179
+ });
180
+ return (0, GraphExecutionResult_js_1.buildGraphExecutionResult)(frame, document, inputs, index_js_1.GraphExecutionStatus.FAILED, opts.metadata);
181
+ }
182
+ }
183
+ /**
184
+ * Executes a layer of nodes with the configured concurrency.
185
+ */
186
+ async executeLayer(frame, plan, nodes, opts, emitFn) {
187
+ const concurrency = Math.max(1, opts.concurrency ?? constants_js_1.GRAPH_DEFAULT_CONCURRENCY);
188
+ const queue = [...nodes];
189
+ while (queue.length > 0) {
190
+ const batch = queue.splice(0, concurrency);
191
+ await Promise.all(batch.map((node) => this.executeNode(frame, plan, node, opts, emitFn)));
192
+ }
193
+ }
194
+ /**
195
+ * Executes a single node, honouring disabled-node semantics (§4.9).
196
+ */
197
+ async executeNode(frame, plan, planNode, opts, emitFn) {
198
+ this.assertNotAborted(opts);
199
+ if (!this.isNodeActivated(frame, plan, planNode)) {
200
+ await this.skipInactiveNode(frame, plan, planNode, opts, emitFn);
201
+ return;
202
+ }
203
+ if (planNode.instance.disabled === true) {
204
+ await this.executeDisabledNode(frame, plan, planNode, opts, emitFn);
205
+ return;
206
+ }
207
+ const startedAt = new Date();
208
+ const nodePath = [...(opts.path ?? []), planNode.id];
209
+ await emitFn({
210
+ type: index_js_1.GraphExecutionEventType.NODE_STARTED,
211
+ runId: frame.runId,
212
+ workflowId: plan.workflowId,
213
+ nodeId: planNode.id,
214
+ path: nodePath,
215
+ status: index_js_1.GraphExecutionStatus.RUNNING,
216
+ });
217
+ this.emitNodeStateChanged(frame, plan, planNode, nodePath, index_js_1.GraphVisualState.RUNNING, index_js_1.GraphExecutionStatus.RUNNING, emitFn);
218
+ const inputs = await this.resolveNodeInputs(frame, plan, planNode, opts);
219
+ // Cache-hit: check for a pinned value before executing the node
220
+ if (opts.usePinnedValues) {
221
+ const cached = await this.tryPinnedValue(frame, plan, planNode, inputs);
222
+ if (cached) {
223
+ frame.valueStore.setNodeOutputs(planNode.id, cached.outputs);
224
+ this.routeOutgoingEdges(frame, plan, planNode, cached.outputs, emitFn);
225
+ const finishedAt = new Date();
226
+ const result = {
227
+ nodeId: planNode.id,
228
+ status: index_js_1.GraphExecutionStatus.CACHED,
229
+ inputs,
230
+ outputs: cached.outputs,
231
+ startedAt,
232
+ finishedAt,
233
+ fromCache: true,
234
+ pinned: true,
235
+ events: [],
236
+ };
237
+ frame.recordNodeResult(result);
238
+ await emitFn({
239
+ type: index_js_1.GraphExecutionEventType.NODE_CACHE_HIT,
240
+ runId: frame.runId,
241
+ workflowId: plan.workflowId,
242
+ nodeId: planNode.id,
243
+ path: nodePath,
244
+ status: index_js_1.GraphExecutionStatus.CACHED,
245
+ payload: { outputs: cached.outputs },
246
+ });
247
+ await emitFn({
248
+ type: index_js_1.GraphExecutionEventType.NODE_COMPLETED,
249
+ runId: frame.runId,
250
+ workflowId: plan.workflowId,
251
+ nodeId: planNode.id,
252
+ path: nodePath,
253
+ status: index_js_1.GraphExecutionStatus.SUCCEEDED,
254
+ payload: { outputs: cached.outputs, fromCache: true },
255
+ });
256
+ this.emitNodeStateChanged(frame, plan, planNode, nodePath, index_js_1.GraphVisualState.SUCCEEDED, index_js_1.GraphExecutionStatus.SUCCEEDED, emitFn);
257
+ return;
258
+ }
259
+ }
260
+ try {
261
+ const context = new GraphExecutionContext_js_1.GraphExecutionContext(frame.runId, opts.parentRunId, plan.workflowId, plan.resolved.document, planNode.instance, planNode.manifest, nodePath, emitFn, opts.metadata, this.engine, opts.abortSignal, this.executionLimits(opts));
262
+ const parameters = await this.resolveNodeParameters(planNode, inputs, opts);
263
+ const request = {
264
+ nodeId: planNode.id,
265
+ kind: planNode.kind,
266
+ inputs,
267
+ parameters,
268
+ credentials: this.collectCredentials(planNode),
269
+ metadata: planNode.instance.metadata,
270
+ };
271
+ const rawOutputs = await this.invokeExecutor(planNode, request, context);
272
+ const outputs = this.validateNodeOutputs(planNode, rawOutputs ?? {});
273
+ frame.valueStore.setNodeOutputs(planNode.id, outputs);
274
+ this.routeOutgoingEdges(frame, plan, planNode, outputs, emitFn);
275
+ const finishedAt = new Date();
276
+ const result = {
277
+ nodeId: planNode.id,
278
+ status: index_js_1.GraphExecutionStatus.SUCCEEDED,
279
+ inputs,
280
+ outputs,
281
+ startedAt,
282
+ finishedAt,
283
+ events: [],
284
+ };
285
+ frame.recordNodeResult(result);
286
+ await emitFn({
287
+ type: index_js_1.GraphExecutionEventType.NODE_COMPLETED,
288
+ runId: frame.runId,
289
+ workflowId: plan.workflowId,
290
+ nodeId: planNode.id,
291
+ path: nodePath,
292
+ status: index_js_1.GraphExecutionStatus.SUCCEEDED,
293
+ payload: { outputs },
294
+ });
295
+ this.emitNodeStateChanged(frame, plan, planNode, nodePath, index_js_1.GraphVisualState.SUCCEEDED, index_js_1.GraphExecutionStatus.SUCCEEDED, emitFn);
296
+ }
297
+ catch (error) {
298
+ // Loop-control flow is not a node failure: rethrow the break token so
299
+ // the enclosing loop executor observes it rather than a FAILED node.
300
+ if (error instanceof index_js_2.GraphBreakSignal)
301
+ throw error;
302
+ const finishedAt = new Date();
303
+ const errorPayload = this.toErrorPayload(error);
304
+ const result = {
305
+ nodeId: planNode.id,
306
+ status: index_js_1.GraphExecutionStatus.FAILED,
307
+ inputs,
308
+ error: errorPayload,
309
+ startedAt,
310
+ finishedAt,
311
+ events: [],
312
+ };
313
+ frame.recordNodeResult(result);
314
+ await emitFn({
315
+ type: index_js_1.GraphExecutionEventType.NODE_FAILED,
316
+ runId: frame.runId,
317
+ workflowId: plan.workflowId,
318
+ nodeId: planNode.id,
319
+ path: nodePath,
320
+ status: index_js_1.GraphExecutionStatus.FAILED,
321
+ error: errorPayload,
322
+ });
323
+ this.emitNodeStateChanged(frame, plan, planNode, nodePath, index_js_1.GraphVisualState.FAILED, index_js_1.GraphExecutionStatus.FAILED, emitFn);
324
+ if (opts.failFast ?? true)
325
+ throw error;
326
+ }
327
+ }
328
+ /**
329
+ * Resolves whether a plan node is activated for execution under the
330
+ * DECAF-50 §4.9 branch semantics. A node with no incoming data edges is
331
+ * a root/source node and always runs. A node fed by one or more data
332
+ * edges runs only when at least one of those edges was activated by a
333
+ * routed upstream output port — a branch the upstream switch (or any
334
+ * partial-output node) did not select leaves its downstream edges
335
+ * unactivated, so the branch is never executed. Workflow-boundary edges
336
+ * are active from the start because workflow inputs are seeded before
337
+ * execution begins.
338
+ */
339
+ isNodeActivated(frame, plan, planNode) {
340
+ const incoming = (plan.incomingByNode.get(planNode.id) ?? []).filter((edge) => edge.type === "data");
341
+ if (incoming.length === 0)
342
+ return true;
343
+ return incoming.some((edge) => edge.sourceNodeId === constants_js_1.GRAPH_WORKFLOW_BOUNDARY ||
344
+ frame.isDataEdgeActive(edge.id));
345
+ }
346
+ /**
347
+ * Skips a node whose incoming data edges were all left unactivated by an
348
+ * upstream branch selection. The node is not executed and its outputs are
349
+ * never routed or collected into workflow outputs (DECAF-50 §4.9).
350
+ */
351
+ async skipInactiveNode(frame, plan, planNode, opts, emitFn) {
352
+ const startedAt = new Date();
353
+ const nodePath = [...(opts.path ?? []), planNode.id];
354
+ await emitFn({
355
+ type: index_js_1.GraphExecutionEventType.NODE_SKIPPED,
356
+ runId: frame.runId,
357
+ workflowId: plan.workflowId,
358
+ nodeId: planNode.id,
359
+ path: nodePath,
360
+ status: index_js_1.GraphExecutionStatus.SKIPPED,
361
+ payload: { reason: "branchNotSelected" },
362
+ });
363
+ const result = {
364
+ nodeId: planNode.id,
365
+ status: index_js_1.GraphExecutionStatus.SKIPPED,
366
+ inputs: {},
367
+ startedAt,
368
+ finishedAt: new Date(),
369
+ events: [],
370
+ };
371
+ frame.recordNodeResult(result);
372
+ this.emitNodeStateChanged(frame, plan, planNode, nodePath, index_js_1.GraphVisualState.SKIPPED, index_js_1.GraphExecutionStatus.SKIPPED, emitFn);
373
+ }
374
+ /**
375
+ * Applies the explicit disabled-node semantics (§4.9):
376
+ * `skip`, `passThroughFirstInput`, or `emitDefaults`, resolved from the
377
+ * instance metadata, document settings, and the default.
378
+ */
379
+ async executeDisabledNode(frame, plan, planNode, opts, emitFn) {
380
+ const startedAt = new Date();
381
+ const nodePath = [...(opts.path ?? []), planNode.id];
382
+ const behavior = GraphParameterValidator_js_1.GraphParameterValidator.disabledBehaviorOf(planNode.instance, plan.resolved.document.settings);
383
+ await emitFn({
384
+ type: index_js_1.GraphExecutionEventType.NODE_SKIPPED,
385
+ runId: frame.runId,
386
+ workflowId: plan.workflowId,
387
+ nodeId: planNode.id,
388
+ path: nodePath,
389
+ status: index_js_1.GraphExecutionStatus.SKIPPED,
390
+ payload: { disabled: true, behavior },
391
+ });
392
+ if (behavior === "skip") {
393
+ const result = {
394
+ nodeId: planNode.id,
395
+ status: index_js_1.GraphExecutionStatus.SKIPPED,
396
+ inputs: {},
397
+ startedAt,
398
+ finishedAt: new Date(),
399
+ events: [],
400
+ };
401
+ frame.recordNodeResult(result);
402
+ this.emitNodeStateChanged(frame, plan, planNode, nodePath, index_js_1.GraphVisualState.SKIPPED, index_js_1.GraphExecutionStatus.SKIPPED, emitFn);
403
+ return;
404
+ }
405
+ const inputs = await this.resolveNodeInputs(frame, plan, planNode, opts);
406
+ let outputs;
407
+ if (behavior === "passThroughFirstInput") {
408
+ const firstIncoming = (plan.incomingByNode.get(planNode.id) ?? []).find((edge) => edge.type === "data");
409
+ const firstOutput = planNode.manifest.outputs[0]?.id ?? "value";
410
+ const value = firstIncoming
411
+ ? frame.valueStore.getPort(firstIncoming.sourceNodeId, firstIncoming.sourcePort)
412
+ : Object.values(inputs)[0];
413
+ outputs = { [firstOutput]: value };
414
+ }
415
+ else {
416
+ // emitDefaults — every declared output port is emitted with its
417
+ // declared default (absent a declared default, undefined).
418
+ outputs = {};
419
+ for (const port of planNode.manifest.outputs) {
420
+ outputs[port.id] = port.metadata?.["defaultValue"];
421
+ }
422
+ }
423
+ frame.valueStore.setNodeOutputs(planNode.id, outputs);
424
+ this.routeOutgoingEdges(frame, plan, planNode, outputs, emitFn);
425
+ const result = {
426
+ nodeId: planNode.id,
427
+ status: index_js_1.GraphExecutionStatus.SUCCEEDED,
428
+ inputs,
429
+ outputs,
430
+ startedAt,
431
+ finishedAt: new Date(),
432
+ events: [],
433
+ };
434
+ frame.recordNodeResult(result);
435
+ this.emitNodeStateChanged(frame, plan, planNode, nodePath, index_js_1.GraphVisualState.SUCCEEDED, index_js_1.GraphExecutionStatus.SUCCEEDED, emitFn);
436
+ }
437
+ /**
438
+ * Invokes the node's catalogue-resolved executor (§4.9 request contract,
439
+ * post-cutover: every executor receives the full request with
440
+ * configuration and input data separated).
441
+ */
442
+ async invokeExecutor(planNode, request, context) {
443
+ return await planNode.executor.execute(request, context);
444
+ }
445
+ /**
446
+ * Validates executor outputs against the effective output manifest
447
+ * (§4.9): unknown outputs are rejected by default; missing required
448
+ * outputs fail the node. Lenient transition manifests (legacy
449
+ * executor-only registrations) are exempt until cutover.
450
+ */
451
+ validateNodeOutputs(planNode, outputs) {
452
+ const manifest = planNode.manifest;
453
+ if (manifest.policies?.allowUnknownOutputs === true) {
454
+ return outputs;
455
+ }
456
+ const declaredOutputs = new Set(manifest.outputs.map((port) => port.id));
457
+ const unknownOutputs = Object.keys(outputs).filter((key) => !declaredOutputs.has(key));
458
+ if (unknownOutputs.length > 0) {
459
+ throw new index_js_2.GraphExecutionError(`Node '${planNode.id}' of kind '${planNode.kind}' produced unknown output(s): ${unknownOutputs.join(", ")}`, "GRAPH_OUTPUT_VALIDATION_FAILED", { nodeId: planNode.id, unknownOutputs });
460
+ }
461
+ const missingRequired = manifest.outputs
462
+ .filter((port) => port.required === true && !(port.id in outputs))
463
+ .map((port) => port.id);
464
+ if (missingRequired.length > 0) {
465
+ throw new index_js_2.GraphExecutionError(`Node '${planNode.id}' of kind '${planNode.kind}' did not produce required output(s): ${missingRequired.join(", ")}`, "GRAPH_OUTPUT_VALIDATION_FAILED", { nodeId: planNode.id, missingRequired });
466
+ }
467
+ return outputs;
468
+ }
469
+ /**
470
+ * Collects the resolved credential references for a node: credential-type
471
+ * parameter values plus the `credentials` record in instance metadata.
472
+ * Documents carry references only — secret material never enters requests.
473
+ */
474
+ collectCredentials(planNode) {
475
+ const credentials = {};
476
+ for (const parameter of planNode.manifest.parameters) {
477
+ if (parameter.type !== "credential")
478
+ continue;
479
+ const value = (planNode.instance.parameters ?? {})[parameter.id];
480
+ if (typeof value === "string" && value.length > 0) {
481
+ credentials[parameter.id] = {
482
+ credentialId: value,
483
+ credentialType: parameter.credentialType ?? "",
484
+ };
485
+ }
486
+ else if ((0, GraphParameterValidator_js_1.isGraphCredentialReferenceLike)(value)) {
487
+ credentials[parameter.id] = {
488
+ credentialId: value.credentialId,
489
+ credentialType: value.credentialType,
490
+ };
491
+ }
492
+ }
493
+ const extra = (planNode.instance.metadata ?? {})["credentials"];
494
+ if (extra && typeof extra === "object" && !Array.isArray(extra)) {
495
+ for (const [key, raw] of Object.entries(extra)) {
496
+ const value = raw;
497
+ if (typeof value === "string" && value.length > 0) {
498
+ credentials[key] = { credentialId: value, credentialType: "" };
499
+ }
500
+ else if ((0, GraphParameterValidator_js_1.isGraphCredentialReferenceLike)(value)) {
501
+ credentials[key] = {
502
+ credentialId: value.credentialId,
503
+ credentialType: value.credentialType,
504
+ };
505
+ }
506
+ }
507
+ }
508
+ return credentials;
509
+ }
510
+ /**
511
+ * Resolves a node's input values from routed data edges, literal bindings,
512
+ * allowed expression bindings, and manifest port defaults (§4.9).
513
+ *
514
+ * When multiple edges target the same port, their values are spread into the
515
+ * top-level inputs keyed by each edge's `sourcePort`. This allows multiple
516
+ * workflow input badges to connect to a single port (e.g. the Code node's
517
+ * `data` port) and have all values accessible directly as
518
+ * `$input.{sourcePort}` (e.g. `$input.count`, `$input.text`).
519
+ */
520
+ async resolveNodeInputs(frame, plan, planNode, opts) {
521
+ const inputs = {};
522
+ const incoming = (plan.incomingByNode.get(planNode.id) ?? []).filter((edge) => edge.type === "data");
523
+ const edgesByTarget = new Map();
524
+ for (const edge of incoming) {
525
+ const list = edgesByTarget.get(edge.targetPort) ?? [];
526
+ list.push(edge);
527
+ edgesByTarget.set(edge.targetPort, list);
528
+ }
529
+ for (const [targetPort, edges] of edgesByTarget) {
530
+ if (edges.length === 1) {
531
+ inputs[targetPort] = frame.valueStore.getPort(edges[0].sourceNodeId, edges[0].sourcePort);
532
+ }
533
+ else {
534
+ let definedValue;
535
+ let hasDefined = false;
536
+ for (const edge of edges) {
537
+ const value = frame.valueStore.getPort(edge.sourceNodeId, edge.sourcePort);
538
+ inputs[edge.sourcePort] = value;
539
+ if (value !== undefined) {
540
+ definedValue = value;
541
+ hasDefined = true;
542
+ }
543
+ }
544
+ // Branch merges route several mutually-exclusive outputs onto the same
545
+ // target port (e.g. an if/switch branch). The port-keyed map above
546
+ // preserves distinct source ports, but the target port must also receive
547
+ // the single defined branch value so the node reads its own port.
548
+ if (hasDefined && inputs[targetPort] === undefined) {
549
+ inputs[targetPort] = definedValue;
550
+ }
551
+ }
552
+ }
553
+ // Literal bindings, expression bindings, and manifest defaults.
554
+ const bindings = planNode.instance.inputBindings ?? {};
555
+ for (const port of planNode.manifest.inputs) {
556
+ const binding = bindings[port.id];
557
+ if (binding?.mode === "literal") {
558
+ inputs[port.id] = binding.value;
559
+ }
560
+ else if (binding?.mode === "expression") {
561
+ inputs[port.id] = await this.evaluateExpressionBinding(planNode, binding.expression, inputs, opts);
562
+ }
563
+ else if (inputs[port.id] === undefined) {
564
+ const defaultValue = port.metadata?.["defaultValue"];
565
+ if (defaultValue !== undefined) {
566
+ inputs[port.id] = defaultValue;
567
+ }
568
+ }
569
+ }
570
+ return inputs;
571
+ }
572
+ /**
573
+ * Resolves a node's persisted parameters at execution time, evaluating any
574
+ * `GraphValueTemplate` user property through the code-evaluator VM and
575
+ * leaving straight literal values unchanged.
576
+ */
577
+ async resolveNodeParameters(planNode, inputs, opts) {
578
+ const parameters = planNode.instance.parameters ?? {};
579
+ const resolved = {};
580
+ for (const [key, value] of Object.entries(parameters)) {
581
+ resolved[key] = (0, index_js_1.isGraphValueTemplate)(value)
582
+ ? await this.evaluateValueTemplate(value, planNode, inputs, opts)
583
+ : value;
584
+ }
585
+ return resolved;
586
+ }
587
+ /**
588
+ * Evaluates a persisted `GraphValueTemplate` with the pluggable
589
+ * {@link CodeSandboxEvaluator} (DECAF-32 §22.4) — no new evaluator.
590
+ * `expression` mode evaluates the body directly; `template` mode compiles its
591
+ * `{{ ... }}` placeholders into a JavaScript template literal evaluated in
592
+ * the same sandbox, so both modes share the code-evaluator VM.
593
+ */
594
+ async evaluateValueTemplate(template, planNode, inputs, opts) {
595
+ const evaluator = this.codeSandboxEvaluator;
596
+ if (!evaluator) {
597
+ throw new index_js_2.GraphExecutionError(`Value template on node '${planNode.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`, "GRAPH_CODE_SANDBOX_NOT_CONFIGURED", { nodeId: planNode.id });
598
+ }
599
+ const language = template.language ?? (0, index_js_1.graphValueTemplateDefaultLanguage)(template.mode);
600
+ const code = template.mode === "template"
601
+ ? graphTemplateToExpression(template.expression)
602
+ : template.expression;
603
+ const md = opts.metadata;
604
+ const result = await evaluator.evaluate({
605
+ code,
606
+ language: language === "typescript" ? "typescript" : "javascript",
607
+ input: inputs,
608
+ vars: md?.vars ?? undefined,
609
+ item: md?.item,
610
+ index: md?.index,
611
+ abortSignal: opts.abortSignal,
612
+ });
613
+ return result;
614
+ }
615
+ /**
616
+ * Evaluates an expression binding with the EXISTING allowed-expression
617
+ * machinery only (the pluggable {@link CodeSandboxEvaluator}, DECAF-32
618
+ * §22.4) — no new evaluator. The expression sees the already-routed input
619
+ * values as `$input` and the run metadata as context.
620
+ */
621
+ async evaluateExpressionBinding(planNode, expression, inputs, opts) {
622
+ const evaluator = this.codeSandboxEvaluator;
623
+ if (!evaluator) {
624
+ throw new index_js_2.GraphExecutionError(`Expression binding on node '${planNode.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`, "GRAPH_CODE_SANDBOX_NOT_CONFIGURED", { nodeId: planNode.id, expression });
625
+ }
626
+ const md = opts.metadata;
627
+ return await evaluator.evaluate({
628
+ code: expression,
629
+ language: "javascript",
630
+ input: inputs,
631
+ vars: md?.vars ?? undefined,
632
+ item: md?.item,
633
+ index: md?.index,
634
+ abortSignal: opts.abortSignal,
635
+ });
636
+ }
637
+ /**
638
+ * Attempts to read a pinned value for the node. Returns the cached outputs
639
+ * when a valid pinned value exists, or `undefined` to proceed with normal
640
+ * execution.
641
+ */
642
+ async tryPinnedValue(frame, plan, planNode, inputs) {
643
+ const policy = new GraphPinningPolicy_js_1.GraphPinningPolicy();
644
+ if (!policy.shouldUsePinnedValue(planNode))
645
+ return undefined;
646
+ const service = this.createPinningService(frame);
647
+ const depFingerprints = this.computeDependencyFingerprints(frame, plan, planNode.id);
648
+ return service.readPinnedValue(plan.workflowId, planNode, inputs, depFingerprints);
649
+ }
650
+ /**
651
+ * Recursively computes fingerprints for all upstream dependencies of a node
652
+ * using the results already accumulated in the frame.
653
+ */
654
+ computeDependencyFingerprints(frame, plan, nodeId) {
655
+ const service = this.createPinningService(frame);
656
+ const depResolver = new GraphPinningDependencyResolver_js_1.GraphPinningDependencyResolver();
657
+ const deps = depResolver.getDependencies(plan, nodeId);
658
+ const fingerprints = {};
659
+ for (const dep of deps) {
660
+ const node = plan.nodes.find((n) => n.id === dep);
661
+ if (node) {
662
+ const depResult = frame.nodeResults.get(dep);
663
+ const inputs = depResult?.inputs ?? {};
664
+ const nestedDeps = this.computeDependencyFingerprints(frame, plan, dep);
665
+ fingerprints[dep] = service.computeFingerprint(plan.workflowId, node, inputs, nestedDeps);
666
+ }
667
+ }
668
+ return fingerprints;
669
+ }
670
+ /**
671
+ * Routes a node's outputs to downstream inputs and workflow outputs along
672
+ * data edges (connection edges are structural and never route values).
673
+ *
674
+ * An edge is traversed only when the source node actually emitted the
675
+ * edge's `sourcePort` (DECAF-50 §4.9 branch semantics). A node that
676
+ * emitted a subset of its declared outputs — e.g. a switch that selected
677
+ * one case — therefore activates only the downstream branch edges of the
678
+ * emitted ports; unselected branch edges are left unactivated, so their
679
+ * downstream nodes are skipped and never contribute to workflow outputs.
680
+ * Emitting an output port explicitly with `undefined` still counts as
681
+ * activated (the port was produced by the executor).
682
+ */
683
+ routeOutgoingEdges(frame, plan, planNode, outputs, emitFn) {
684
+ const outgoing = (plan.outgoingByNode.get(planNode.id) ?? []).filter((edge) => edge.type === "data");
685
+ for (const edge of outgoing) {
686
+ if (!Object.prototype.hasOwnProperty.call(outputs, edge.sourcePort)) {
687
+ // The source node did not emit this output port: the edge's branch
688
+ // was not selected, so no value is routed.
689
+ continue;
690
+ }
691
+ const value = outputs[edge.sourcePort];
692
+ frame.activateDataEdge(edge.id);
693
+ if (edge.targetNodeId === constants_js_1.GRAPH_WORKFLOW_BOUNDARY) {
694
+ frame.valueStore.setWorkflowOutput(edge.targetPort, value);
695
+ }
696
+ this.emitEdgeStateChanged(frame, plan, planNode, edge, index_js_1.GraphVisualState.SUCCEEDED, index_js_1.GraphExecutionStatus.SUCCEEDED, emitFn);
697
+ emitFn({
698
+ type: index_js_1.GraphExecutionEventType.EDGE_VALUE_ROUTED,
699
+ runId: frame.runId,
700
+ workflowId: plan.workflowId,
701
+ edgeId: edge.id,
702
+ nodeId: planNode.id,
703
+ path: [],
704
+ payload: { edge, value },
705
+ }).catch(() => {
706
+ // observer failures must not crash
707
+ });
708
+ }
709
+ }
710
+ /**
711
+ * Emits a `NODE_STATE_CHANGED` event (DECAF-48 §4.4) carrying the given
712
+ * visual state for the node. Rides the existing Observable pipeline; no
713
+ * second out-of-band channel.
714
+ */
715
+ emitNodeStateChanged(frame, plan, planNode, nodePath, state, status, emitFn) {
716
+ emitFn({
717
+ type: index_js_1.GraphExecutionEventType.NODE_STATE_CHANGED,
718
+ runId: frame.runId,
719
+ workflowId: plan.workflowId,
720
+ nodeId: planNode.id,
721
+ path: nodePath,
722
+ status,
723
+ payload: {
724
+ nodeId: planNode.id,
725
+ state,
726
+ runId: frame.runId,
727
+ workflowId: plan.workflowId,
728
+ status,
729
+ },
730
+ }).catch(() => {
731
+ // observer failures must not crash execution
732
+ });
733
+ }
734
+ /**
735
+ * Emits an `EDGE_STATE_CHANGED` event (DECAF-48 §4.4) carrying the given
736
+ * visual state for a routed edge.
737
+ */
738
+ emitEdgeStateChanged(frame, plan, planNode, edge, state, status, emitFn) {
739
+ emitFn({
740
+ type: index_js_1.GraphExecutionEventType.EDGE_STATE_CHANGED,
741
+ runId: frame.runId,
742
+ workflowId: plan.workflowId,
743
+ edgeId: edge.id,
744
+ nodeId: planNode.id,
745
+ path: [],
746
+ status,
747
+ payload: {
748
+ edgeId: edge.id,
749
+ state,
750
+ runId: frame.runId,
751
+ workflowId: plan.workflowId,
752
+ nodeId: planNode.id,
753
+ status,
754
+ },
755
+ }).catch(() => {
756
+ // observer failures must not crash execution
757
+ });
758
+ }
759
+ /**
760
+ * Creates a {@link GraphPinningService} backed by the run's value store
761
+ * adapter.
762
+ */
763
+ createPinningService(frame) {
764
+ const adapter = frame.valueStore.getAdapter() ?? this.valueAdapter;
765
+ const store = (0, GraphValueRepository_js_1.createGraphValueRepository)(adapter);
766
+ return new GraphPinningService_js_1.GraphPinningService(store, new GraphPinningPolicy_js_1.GraphPinningPolicy(), new GraphPinningDependencyResolver_js_1.GraphPinningDependencyResolver());
767
+ }
768
+ /**
769
+ * Resolves the effective loop-iteration ceilings for a run. A node-level
770
+ * `maxIterations` can never exceed these; loop executors read them from the
771
+ * node context.
772
+ */
773
+ executionLimits(opts) {
774
+ return {
775
+ maxLoopIterations: opts.maxLoopIterations ?? constants_js_1.GRAPH_MAX_LOOP_ITERATIONS,
776
+ maxForeachIterations: opts.maxForeachIterations ?? constants_js_1.GRAPH_MAX_FOREACH_ITERATIONS,
777
+ };
778
+ }
779
+ assertNotAborted(opts) {
780
+ if (opts.abortSignal?.aborted === true) {
781
+ throw new index_js_2.GraphRunCancelledError(opts.runId ?? "unknown");
782
+ }
783
+ }
784
+ /**
785
+ * Converts an error into a serialized payload.
786
+ */
787
+ toErrorPayload(error) {
788
+ if (error instanceof Error) {
789
+ return {
790
+ name: error.name,
791
+ message: error.message,
792
+ stack: error.stack,
793
+ code: error.graphCode ??
794
+ (typeof error.code === "number"
795
+ ? String(error.code)
796
+ : error.code),
797
+ };
798
+ }
799
+ return { name: "UnknownError", message: String(error) };
800
+ }
801
+ }
802
+ exports.LocalGraphExecutionBackend = LocalGraphExecutionBackend;
803
+ //# sourceMappingURL=LocalGraphExecutionBackend.js.map
804
+ //# sourceMappingURL=LocalGraphExecutionBackend.cjs.map