@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,119 @@
1
+ /**
2
+ * @module as-graph/mastra/MastraGraphExecutionBackend
3
+ * @summary `@mastra/core`-translated graph execution backend (SAA-196).
4
+ * @description The Mastra analogue of the backend seam: translates the canonical
5
+ * document into a Mastra workflow, runs it through the injected Mastra runtime,
6
+ * bridges the run's `fullStream` onto the facade event sink, and enforces the
7
+ * SAA-193 resume guard conditions for suspended runs. The backend registers
8
+ * itself under the `mastra` flavour on construction and never probes remote
9
+ * engines.
10
+ */
11
+ import type { Context, MaybeContextualArg } from "@decaf-ts/core";
12
+ import type { GraphWorkflowDocument } from "../shared/graph/document/GraphWorkflowDocument.d.mts";
13
+ import type { GraphBackendExecutionRequest, GraphBackendWorkflowSummary, GraphExecutionBackend } from "../engine/execution/GraphExecutionBackend.d.mts";
14
+ import type { GraphExecutionResult, GraphRunId } from "../engine/types.d.mts";
15
+ import { MastraWorkflowManager } from "./MastraWorkflowManager.d.mts";
16
+ import { type MastraBackendCapabilities } from "./MastraCapabilities.d.mts";
17
+ import { type MastraBackendConfig, type MastraResumeAudit, type MastraResumeRequest } from "./types.d.mts";
18
+ /**
19
+ * `@mastra/core`-translated execution backend (SAA-196). Translates the
20
+ * canonical document into a Mastra workflow, runs it through the injected Mastra
21
+ * runtime, bridges Mastra's `fullStream` onto the facade event sink, and enforces
22
+ * the SAA-193 resume guard conditions. Code-mode surfaces are not executed:
23
+ * `codeMode` is `unsupported`, so the facade fails closed before delegating.
24
+ */
25
+ export declare class MastraGraphExecutionBackend implements GraphExecutionBackend<MastraBackendConfig> {
26
+ /** Translated backend: never executes in-process. */
27
+ readonly local = false;
28
+ /** Code-mode surfaces are rejected by the facade gate (C3). */
29
+ readonly codeMode: "unsupported";
30
+ private compiler;
31
+ private readonly documents;
32
+ private readonly runWorkflows;
33
+ private runtime?;
34
+ private managementManager?;
35
+ private suspendStateReader?;
36
+ private maxResumeBytes;
37
+ private initialized;
38
+ private _config?;
39
+ constructor();
40
+ initialize(config: MastraBackendConfig): Promise<void>;
41
+ get capabilities(): MastraBackendCapabilities;
42
+ /**
43
+ * The workflow-management surface over the wired real `@mastra/core` runtime
44
+ * (SAA-346). The manager translates canonical documents through the same
45
+ * compiler the backend executes with, so a created/updated workflow is the one
46
+ * `execute` runs. Every operation fails closed when the wired runtime exposes
47
+ * no real Mastra method.
48
+ */
49
+ get management(): MastraWorkflowManager;
50
+ /**
51
+ * Lists the translated workflows visible to the requesting caller (C23). The
52
+ * catalogue is ownership-filtered with the same
53
+ * {@link canAccessGraphResource} predicate the service layer uses: a document
54
+ * executed by a named owner is visible only to that owner, an owner-less
55
+ * document stays visible to every caller, and an anonymous caller sees only
56
+ * owner-less documents. The caller owner is resolved from the forwarded
57
+ * contextual arguments; a missing context denies foreign-owner rows.
58
+ *
59
+ * @param args - Optional decaf contextual arguments carrying the caller principal.
60
+ * @returns Workflow summaries visible to the caller.
61
+ */
62
+ listWorkflows(...args: MaybeContextualArg<Context>): Promise<GraphBackendWorkflowSummary[]>;
63
+ /**
64
+ * Reads a single translated workflow document, enforcing the C23 ownership
65
+ * predicate. An unknown id and a foreign-owner id both fail closed: an unknown
66
+ * id keeps the backend's existing translated-catalogue error, and a foreign-owner
67
+ * id is denied with a constant `NotFoundError` that maps to `404` and never
68
+ * carries `GraphExecutionError.details`, so a foreign caller cannot read
69
+ * another owner's canonical document.
70
+ *
71
+ * @param workflowId - The canonical workflow id to read.
72
+ * @param args - Optional decaf contextual arguments carrying the caller principal.
73
+ * @returns The canonical workflow document.
74
+ * @throws {GraphExecutionError} when no translated workflow exists for the id.
75
+ * @throws {NotFoundError} when the workflow is owned by another user.
76
+ */
77
+ getWorkflow(workflowId: string, ...args: MaybeContextualArg<Context>): Promise<GraphWorkflowDocument>;
78
+ execute(request: GraphBackendExecutionRequest, ...args: MaybeContextualArg<Context>): Promise<GraphExecutionResult>;
79
+ /**
80
+ * Resumes a suspended Mastra run after enforcing the SAA-193 resume guard
81
+ * (C13/C15/C16/C17/C18). The Mastra run snapshot is authoritative for the
82
+ * suspended state; the current document fingerprint must match the snapshot
83
+ * (C17). Returns the C18 audit record, never the raw `resumeData`.
84
+ */
85
+ resume(runId: GraphRunId, request: MastraResumeRequest, ..._args: MaybeContextualArg<Context>): Promise<MastraResumeAudit>;
86
+ /**
87
+ * Resolves the owner recorded for a run (C23). The facade-resolved principal
88
+ * bound onto `options.auth` is authoritative; when absent (a direct backend call)
89
+ * the owner is resolved from the forwarded contextual arguments. Returns
90
+ * `undefined` for owner-less runs, matching the service-layer owner-less
91
+ * visibility rule.
92
+ *
93
+ * @param request - The execution request carrying the facade-resolved options.
94
+ * @param args - The forwarded contextual arguments.
95
+ * @returns The run's owner, or `undefined` when owner-less.
96
+ */
97
+ private callerOwnerOf;
98
+ /**
99
+ * Releases the per-run catalogue state (C23). Removes the run's workflow
100
+ * association and drops the translated document once no other live run still
101
+ * references it, so the process-lifetime catalogue cannot grow unbounded and
102
+ * widen the BOLA surface over time.
103
+ *
104
+ * @param runId - The completed run whose resources are released.
105
+ */
106
+ release(runId: GraphRunId): Promise<void>;
107
+ dispose(): Promise<void>;
108
+ /**
109
+ * The configuration most recently resolved by {@link initialize}. Exposed so
110
+ * `GraphExecutionEngine.initialize` can merge its facade-owned collaborators
111
+ * over the host's keys (`mastra`, `stepHandlers`, `suspendStateReader`, ...)
112
+ * instead of dropping them when it re-initializes the backend at boot.
113
+ */
114
+ get config(): MastraBackendConfig | undefined;
115
+ /** Whether {@link initialize} has resolved. */
116
+ get ready(): boolean;
117
+ private loadRun;
118
+ private errorPayload;
119
+ }
@@ -0,0 +1,58 @@
1
+ import { type MastraResumeAudit, type MastraResumeRequest } from "./types.d.cts";
2
+ /**
3
+ * Mastra-authoritative snapshot a suspended run resumes from. Mastra owns the
4
+ * execution state for a suspended workflow (gap-1): this snapshot is the single
5
+ * source of truth for resume, never `GraphRunStore`.
6
+ */
7
+ export interface MastraResumeSnapshot {
8
+ /** Canonical run id. */
9
+ runId: string;
10
+ /** Canonical workflow id. */
11
+ workflowId: string;
12
+ /** Fingerprint of the document the run was launched from. */
13
+ documentFingerprint: string;
14
+ /** Mastra run status; resume is only legal from `suspended`. */
15
+ status: string;
16
+ /** Mastra step id the run suspended on. */
17
+ step: string;
18
+ /** Per-iteration index when the suspension happened inside a `foreach`. */
19
+ forEachIndex?: number;
20
+ /** Total iteration count when the suspension happened inside a `foreach`. */
21
+ forEachCount?: number;
22
+ /** Mastra serialized execution state (opaque, engine-authoritative). */
23
+ state: unknown;
24
+ }
25
+ export interface MastraResumeGuardOptions {
26
+ /** Maximum serialised size, in bytes, of accepted `resumeData`. */
27
+ maxResumeBytes: number;
28
+ /** Node ids the current document declares as resumable. */
29
+ allowlistedSteps: readonly string[];
30
+ /** Fingerprint of the current document. */
31
+ documentFingerprint: string;
32
+ /**
33
+ * Declared resume schema of the suspended node. When present, `resumeData`
34
+ * must validate against it (C15).
35
+ */
36
+ resumeSchema?: {
37
+ safeParse(value: unknown): {
38
+ success: boolean;
39
+ };
40
+ };
41
+ }
42
+ /**
43
+ * Validates an untrusted resume request against the Mastra-authoritative
44
+ * snapshot and the current document, enforcing C13/C15/C16/C17 before any state
45
+ * is handed back to Mastra. On success it returns the C18 audit record; the raw
46
+ * `resumeData` is never logged or echoed.
47
+ *
48
+ * @param request - The untrusted resume request to validate.
49
+ * @param snapshot - The Mastra-authoritative suspended-run snapshot.
50
+ * @param options - Document-derived validation options (byte cap, allowlist,
51
+ * fingerprint, and the suspended step's resume schema).
52
+ * @returns The C18 audit record for the accepted resume.
53
+ * @throws {GraphExecutionError} `GRAPH_MASTRA_RESUME_INVALID` for non-JSON-safe or
54
+ * oversized `resumeData`; `GRAPH_MASTRA_RESUME_STEP_UNKNOWN` when the suspended
55
+ * step or iteration is not allowlisted; `GRAPH_MASTRA_RESUME_STATE_INVALID`
56
+ * when the snapshot is not suspended or its fingerprint does not match.
57
+ */
58
+ export declare function assertMastraResumeAllowed(request: MastraResumeRequest, snapshot: MastraResumeSnapshot, options: MastraResumeGuardOptions): MastraResumeAudit;
@@ -0,0 +1,58 @@
1
+ import { type MastraResumeAudit, type MastraResumeRequest } from "./types.d.mts";
2
+ /**
3
+ * Mastra-authoritative snapshot a suspended run resumes from. Mastra owns the
4
+ * execution state for a suspended workflow (gap-1): this snapshot is the single
5
+ * source of truth for resume, never `GraphRunStore`.
6
+ */
7
+ export interface MastraResumeSnapshot {
8
+ /** Canonical run id. */
9
+ runId: string;
10
+ /** Canonical workflow id. */
11
+ workflowId: string;
12
+ /** Fingerprint of the document the run was launched from. */
13
+ documentFingerprint: string;
14
+ /** Mastra run status; resume is only legal from `suspended`. */
15
+ status: string;
16
+ /** Mastra step id the run suspended on. */
17
+ step: string;
18
+ /** Per-iteration index when the suspension happened inside a `foreach`. */
19
+ forEachIndex?: number;
20
+ /** Total iteration count when the suspension happened inside a `foreach`. */
21
+ forEachCount?: number;
22
+ /** Mastra serialized execution state (opaque, engine-authoritative). */
23
+ state: unknown;
24
+ }
25
+ export interface MastraResumeGuardOptions {
26
+ /** Maximum serialised size, in bytes, of accepted `resumeData`. */
27
+ maxResumeBytes: number;
28
+ /** Node ids the current document declares as resumable. */
29
+ allowlistedSteps: readonly string[];
30
+ /** Fingerprint of the current document. */
31
+ documentFingerprint: string;
32
+ /**
33
+ * Declared resume schema of the suspended node. When present, `resumeData`
34
+ * must validate against it (C15).
35
+ */
36
+ resumeSchema?: {
37
+ safeParse(value: unknown): {
38
+ success: boolean;
39
+ };
40
+ };
41
+ }
42
+ /**
43
+ * Validates an untrusted resume request against the Mastra-authoritative
44
+ * snapshot and the current document, enforcing C13/C15/C16/C17 before any state
45
+ * is handed back to Mastra. On success it returns the C18 audit record; the raw
46
+ * `resumeData` is never logged or echoed.
47
+ *
48
+ * @param request - The untrusted resume request to validate.
49
+ * @param snapshot - The Mastra-authoritative suspended-run snapshot.
50
+ * @param options - Document-derived validation options (byte cap, allowlist,
51
+ * fingerprint, and the suspended step's resume schema).
52
+ * @returns The C18 audit record for the accepted resume.
53
+ * @throws {GraphExecutionError} `GRAPH_MASTRA_RESUME_INVALID` for non-JSON-safe or
54
+ * oversized `resumeData`; `GRAPH_MASTRA_RESUME_STEP_UNKNOWN` when the suspended
55
+ * step or iteration is not allowlisted; `GRAPH_MASTRA_RESUME_STATE_INVALID`
56
+ * when the snapshot is not suspended or its fingerprint does not match.
57
+ */
58
+ export declare function assertMastraResumeAllowed(request: MastraResumeRequest, snapshot: MastraResumeSnapshot, options: MastraResumeGuardOptions): MastraResumeAudit;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @module as-graph/mastra/MastraSchemaConverter
3
+ * @summary Converts canonical {@link GraphValueSchema} declarations into Zod
4
+ * schemas for the Mastra backend (SAA-196).
5
+ * @description Mastra workflows are built on Zod schemas. The converter maps
6
+ * every canonical schema shape to its closest Zod equivalent, tracking whether
7
+ * the conversion degraded (or collapsed to `any`), so suspendable steps can be
8
+ * required to declare a strict, non-degraded resume schema before translation.
9
+ */
10
+ import { z } from "zod";
11
+ import type { GraphValueSchema } from "../shared/graph/catalog/GraphValueSchema.d.cts";
12
+ /** Result of converting one canonical schema into a Zod schema. */
13
+ export interface MastraZodConversion {
14
+ /** The converted Zod schema (an `any` schema when degraded). */
15
+ schema: z.ZodTypeAny;
16
+ /** Whether any part of the canonical schema could not be represented. */
17
+ degraded: boolean;
18
+ /** Whether the whole conversion collapsed to a permissive `any` schema. */
19
+ any: boolean;
20
+ }
21
+ /**
22
+ * Converts a canonical schema (or the absence of one) into a Zod schema.
23
+ * A missing schema converts to a degraded `any` schema.
24
+ *
25
+ * @param schema - The canonical schema to convert, if declared.
26
+ * @returns The conversion result with its degradation flags.
27
+ */
28
+ export declare function toMastraZodSchema(schema: GraphValueSchema | undefined): MastraZodConversion;
29
+ /**
30
+ * Requires that a suspendable Mastra step declares a strict resume schema: the
31
+ * conversion must be neither degraded nor collapsed to `any`, otherwise resume
32
+ * payloads could not be validated (C15).
33
+ *
34
+ * @param schema - The declared resume schema of the suspended step.
35
+ * @returns The validated Zod resume schema.
36
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_RESUME_SCHEMA_UNSAFE} when
37
+ * the schema is missing, degraded, or collapsed to `any`.
38
+ */
39
+ export declare function assertMastraResumeSchemaSafe(schema: GraphValueSchema | undefined): z.ZodTypeAny;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @module as-graph/mastra/MastraSchemaConverter
3
+ * @summary Converts canonical {@link GraphValueSchema} declarations into Zod
4
+ * schemas for the Mastra backend (SAA-196).
5
+ * @description Mastra workflows are built on Zod schemas. The converter maps
6
+ * every canonical schema shape to its closest Zod equivalent, tracking whether
7
+ * the conversion degraded (or collapsed to `any`), so suspendable steps can be
8
+ * required to declare a strict, non-degraded resume schema before translation.
9
+ */
10
+ import { z } from "zod";
11
+ import type { GraphValueSchema } from "../shared/graph/catalog/GraphValueSchema.d.mts";
12
+ /** Result of converting one canonical schema into a Zod schema. */
13
+ export interface MastraZodConversion {
14
+ /** The converted Zod schema (an `any` schema when degraded). */
15
+ schema: z.ZodTypeAny;
16
+ /** Whether any part of the canonical schema could not be represented. */
17
+ degraded: boolean;
18
+ /** Whether the whole conversion collapsed to a permissive `any` schema. */
19
+ any: boolean;
20
+ }
21
+ /**
22
+ * Converts a canonical schema (or the absence of one) into a Zod schema.
23
+ * A missing schema converts to a degraded `any` schema.
24
+ *
25
+ * @param schema - The canonical schema to convert, if declared.
26
+ * @returns The conversion result with its degradation flags.
27
+ */
28
+ export declare function toMastraZodSchema(schema: GraphValueSchema | undefined): MastraZodConversion;
29
+ /**
30
+ * Requires that a suspendable Mastra step declares a strict resume schema: the
31
+ * conversion must be neither degraded nor collapsed to `any`, otherwise resume
32
+ * payloads could not be validated (C15).
33
+ *
34
+ * @param schema - The declared resume schema of the suspended step.
35
+ * @returns The validated Zod resume schema.
36
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_RESUME_SCHEMA_UNSAFE} when
37
+ * the schema is missing, degraded, or collapsed to `any`.
38
+ */
39
+ export declare function assertMastraResumeSchemaSafe(schema: GraphValueSchema | undefined): z.ZodTypeAny;
@@ -0,0 +1,218 @@
1
+ /**
2
+ * @module as-graph/mastra/MastraWorkflowCompiler
3
+ * @summary Compiles canonical workflow documents into Mastra workflows
4
+ * (SAA-196).
5
+ * @description The compiler translates the canonical document's topological
6
+ * order into Mastra builder calls: leaf nodes become steps via host-provided
7
+ * handlers, `if`/`switch` nodes become branches over shared condition
8
+ * predicates, loops nest a recursive sub-compilation, and human-approval nodes
9
+ * become suspending steps with validated resume schemas. Compiled workflows are
10
+ * cached by document id and fingerprint; translation fails closed on unsupported
11
+ * kinds and cyclic documents.
12
+ */
13
+ import { z } from "zod";
14
+ import type { GraphWorkflowDocument } from "../shared/graph/document/GraphWorkflowDocument.d.cts";
15
+ import { type MastraBackendConfig, type MastraNodeStepHandler } from "./types.d.cts";
16
+ /** Document kind translated into a Mastra `if` branch. */
17
+ export declare const GRAPH_MASTRA_IF_KIND = "core.flow.if";
18
+ /** Document kind translated into a Mastra `switch` branch set. */
19
+ export declare const GRAPH_MASTRA_SWITCH_KIND = "core.flow.switch";
20
+ /** Document kind translated into a Mastra `foreach` loop. */
21
+ export declare const GRAPH_MASTRA_FOREACH_KIND = "graph-foreach-loop-node";
22
+ /** Document kind translated into a Mastra `do-while` loop. */
23
+ export declare const GRAPH_MASTRA_WHILE_KIND = "graph-while-loop-node";
24
+ /** Document kind translated into a Mastra `do-until` loop. */
25
+ export declare const GRAPH_MASTRA_UNTIL_KIND = "graph-until-loop-node";
26
+ /** Document kind translated into a Mastra suspending approval step. */
27
+ export declare const GRAPH_MASTRA_HUMAN_APPROVAL_KIND = "core.flow.humanApproval";
28
+ /**
29
+ * A compiled Mastra workflow plus everything resume and capability reporting
30
+ * need: the translated steps by node id, the validated resume schemas by
31
+ * suspendable node id, and the node ids whose output schemas degraded.
32
+ */
33
+ export interface MastraCompiledWorkflow {
34
+ /** The canonical workflow id the workflow was compiled from. */
35
+ workflowId: string;
36
+ /** The document fingerprint the workflow was compiled from. */
37
+ fingerprint: string;
38
+ /** The cache key (`workflowId::fingerprint`) the compilation is stored under. */
39
+ cacheKey: string;
40
+ /** The committed Mastra workflow object. */
41
+ workflow: unknown;
42
+ /** The translated Mastra steps, keyed by document node id. */
43
+ steps: Map<string, unknown>;
44
+ /** Validated resume schemas, keyed by suspendable node id. */
45
+ resumeSchemas: Map<string, z.ZodTypeAny>;
46
+ /** Node ids whose declared output schema degraded during conversion. */
47
+ degradedSchemas: string[];
48
+ }
49
+ /** Options a {@link MastraWorkflowCompiler} is created with. */
50
+ export interface MastraWorkflowCompilerOptions {
51
+ /** Node-kind step handlers used to translate leaf nodes. */
52
+ stepHandlers?: MastraNodeStepHandler[];
53
+ /** Optional backend configuration (reserved for handler plumbing). */
54
+ config?: MastraBackendConfig;
55
+ }
56
+ /**
57
+ * Translates canonical documents into cached Mastra workflows. Leaf node
58
+ * translation is delegated entirely to host-provided step handlers, so the
59
+ * compiler has no node executors of its own and fails closed when a kind has no
60
+ * handler.
61
+ */
62
+ export declare class MastraWorkflowCompiler {
63
+ /** Compiled workflows keyed by `workflowId::fingerprint`. */
64
+ private readonly cache;
65
+ /** Node-kind step handlers used for leaf translation. */
66
+ private readonly handlers;
67
+ /**
68
+ * Creates the compiler with an optional set of step handlers.
69
+ *
70
+ * @param options - Step handlers and optional backend configuration.
71
+ */
72
+ constructor(options?: MastraWorkflowCompilerOptions);
73
+ /** Clears the compiled-workflow cache. */
74
+ clear(): void;
75
+ /**
76
+ * Whether a workflow is cached under the given cache key.
77
+ *
78
+ * @param cacheKey - The cache key to probe.
79
+ * @returns `true` when a compilation is cached.
80
+ */
81
+ has(cacheKey: string): boolean;
82
+ /**
83
+ * Returns the cached compilation for a document, if any.
84
+ *
85
+ * @param document - The document whose compilation to look up.
86
+ * @returns The cached compilation, or `undefined` on a cache miss.
87
+ */
88
+ get(document: GraphWorkflowDocument): MastraCompiledWorkflow | undefined;
89
+ /**
90
+ * Computes the compilation cache key of a document.
91
+ *
92
+ * @param document - The document to key.
93
+ * @returns The `workflowId::fingerprint` cache key.
94
+ */
95
+ cacheKeyOf(document: GraphWorkflowDocument): string;
96
+ /**
97
+ * Compiles a document into a Mastra workflow, returning the cached
98
+ * compilation on a cache hit. Steps are applied in the document's topological
99
+ * order and the resulting builder is committed.
100
+ *
101
+ * @param document - The canonical document to compile.
102
+ * @returns The compiled workflow, steps, and resume-schema bookkeeping.
103
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_UNSUPPORTED_KIND} when the
104
+ * document is cyclic or a node kind has no step handler.
105
+ */
106
+ compile(document: GraphWorkflowDocument): MastraCompiledWorkflow;
107
+ /**
108
+ * Applies one node to the builder, dispatching on its kind: branch, switch,
109
+ * loop, human approval, or leaf step.
110
+ *
111
+ * @param cursor - The builder position to extend.
112
+ * @param node - The document node to translate.
113
+ * @param document - The document being compiled.
114
+ * @param steps - Accumulated steps by node id.
115
+ * @param resumeSchemas - Accumulated resume schemas by node id.
116
+ * @param degradedSchemas - Accumulated degraded-schema node ids.
117
+ * @returns The extended builder position.
118
+ */
119
+ private applyNode;
120
+ /**
121
+ * Translates an `if` node into a Mastra branch over its `then` and optional
122
+ * `else` targets, guarded by the node's condition.
123
+ *
124
+ * @param cursor - The builder position to extend.
125
+ * @param node - The `if` node to translate.
126
+ * @param document - The document being compiled.
127
+ * @param steps - Accumulated steps by node id.
128
+ * @param resumeSchemas - Accumulated resume schemas by node id.
129
+ * @param degradedSchemas - Accumulated degraded-schema node ids.
130
+ * @returns The extended builder position.
131
+ * @throws {GraphExecutionError} When the condition is missing or code-mode.
132
+ */
133
+ private applyIf;
134
+ /**
135
+ * Translates a `switch` node into a Mastra branch set over its declared
136
+ * cases and optional default port; fails when no branch is translatable.
137
+ *
138
+ * @param cursor - The builder position to extend.
139
+ * @param node - The `switch` node to translate.
140
+ * @param document - The document being compiled.
141
+ * @param steps - Accumulated steps by node id.
142
+ * @param resumeSchemas - Accumulated resume schemas by node id.
143
+ * @param degradedSchemas - Accumulated degraded-schema node ids.
144
+ * @returns The extended builder position.
145
+ * @throws {GraphExecutionError} When a case condition is untranslatable or
146
+ * no branch could be translated.
147
+ */
148
+ private applySwitch;
149
+ /**
150
+ * Translates a loop node by recursively compiling its body document and
151
+ * applying it as a `foreach`, `do-while`, or `do-until` loop.
152
+ *
153
+ * @param cursor - The builder position to extend.
154
+ * @param node - The loop node to translate.
155
+ * @param document - The document being compiled.
156
+ * @param steps - Accumulated steps by node id.
157
+ * @param resumeSchemas - Accumulated resume schemas by node id.
158
+ * @param degradedSchemas - Accumulated degraded-schema node ids.
159
+ * @returns The extended builder position.
160
+ * @throws {GraphExecutionError} When the loop has no body or the condition
161
+ * is untranslatable.
162
+ */
163
+ private applyLoop;
164
+ /**
165
+ * Translates a human-approval node into a suspending Mastra step with a
166
+ * validated resume schema (C15); a non-approved resume is reported as a
167
+ * rejected outcome.
168
+ *
169
+ * @param cursor - The builder position to extend.
170
+ * @param node - The human-approval node to translate.
171
+ * @param steps - Accumulated steps by node id.
172
+ * @param resumeSchemas - Accumulated resume schemas by node id.
173
+ * @param degradedSchemas - Accumulated degraded-schema node ids.
174
+ * @returns The extended builder position.
175
+ * @throws {GraphExecutionError} When the declared resume schema is unsafe.
176
+ */
177
+ private applyHumanApproval;
178
+ /**
179
+ * Translates a leaf node through its registered step handler and records
180
+ * degraded output schemas.
181
+ *
182
+ * @param node - The leaf node to translate.
183
+ * @param steps - Accumulated steps by node id.
184
+ * @param degradedSchemas - Accumulated degraded-schema node ids.
185
+ * @returns The created Mastra step.
186
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_UNSUPPORTED_KIND} when no
187
+ * handler is registered for the node kind.
188
+ */
189
+ private buildLeafStep;
190
+ /**
191
+ * Resolves the Mastra step a control node's output port routes to, by
192
+ * following the first data edge leaving that port.
193
+ *
194
+ * @param nodeId - The control node id the port belongs to.
195
+ * @param port - The output port whose routing edge to follow.
196
+ * @param document - The document being compiled.
197
+ * @param steps - Accumulated steps by node id.
198
+ * @param resumeSchemas - Accumulated resume schemas by node id.
199
+ * @param degradedSchemas - Accumulated degraded-schema node ids.
200
+ * @returns The target step, or `undefined` when the port routes nowhere.
201
+ */
202
+ private targetStep;
203
+ /**
204
+ * Reads the canonical condition attached to a node's parameters.
205
+ *
206
+ * @param node - The node whose condition to read.
207
+ * @returns The condition, or `undefined` when none is declared.
208
+ */
209
+ private conditionOf;
210
+ /**
211
+ * Resolves a switch node's case metadata, preferring node metadata and
212
+ * falling back to parameter-declared cases.
213
+ *
214
+ * @param node - The `switch` node to read.
215
+ * @returns The resolved switch metadata.
216
+ */
217
+ private switchMetadataOf;
218
+ }