@decaf-ts/as-graph 0.2.1 → 0.5.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 (297) hide show
  1. package/README.md +274 -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/DagsterGraphQLClient.cjs +738 -0
  11. package/lib/cjs/dagster/DagsterGraphQLClient.cjs.map +1 -0
  12. package/lib/cjs/dagster/DagsterResultMapper.cjs +56 -0
  13. package/lib/cjs/dagster/DagsterResultMapper.cjs.map +1 -0
  14. package/lib/cjs/dagster/DagsterTypes.cjs +4 -0
  15. package/lib/cjs/dagster/DagsterTypes.cjs.map +1 -0
  16. package/lib/cjs/dagster/capabilities.cjs +102 -0
  17. package/lib/cjs/dagster/capabilities.cjs.map +1 -0
  18. package/lib/cjs/dagster/constants.cjs +92 -0
  19. package/lib/cjs/dagster/constants.cjs.map +1 -0
  20. package/lib/cjs/dagster/index.cjs +33 -0
  21. package/lib/cjs/dagster/index.cjs.map +1 -0
  22. package/lib/cjs/engine/constants.cjs +6 -1
  23. package/lib/cjs/engine/constants.cjs.map +1 -1
  24. package/lib/cjs/engine/execution/GraphCodeMode.cjs +137 -0
  25. package/lib/cjs/engine/execution/GraphCodeMode.cjs.map +1 -0
  26. package/lib/cjs/engine/execution/GraphExecutionBackend.cjs +89 -0
  27. package/lib/cjs/engine/execution/GraphExecutionBackend.cjs.map +1 -0
  28. package/lib/cjs/engine/execution/GraphExecutionBackendRegistry.cjs +107 -0
  29. package/lib/cjs/engine/execution/GraphExecutionBackendRegistry.cjs.map +1 -0
  30. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs +250 -733
  31. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs.map +1 -1
  32. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs +804 -0
  33. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs.map +1 -0
  34. package/lib/cjs/engine/execution/index.cjs +4 -0
  35. package/lib/cjs/engine/execution/index.cjs.map +1 -1
  36. package/lib/cjs/engine/index.cjs +4 -0
  37. package/lib/cjs/engine/index.cjs.map +1 -1
  38. package/lib/cjs/engine/runs/GraphRunService.cjs +61 -0
  39. package/lib/cjs/engine/runs/GraphRunService.cjs.map +1 -1
  40. package/lib/cjs/engine/services/GraphWorkflowService.cjs +33 -14
  41. package/lib/cjs/engine/services/GraphWorkflowService.cjs.map +1 -1
  42. package/lib/cjs/mastra/MastraCapabilities.cjs +171 -0
  43. package/lib/cjs/mastra/MastraCapabilities.cjs.map +1 -0
  44. package/lib/cjs/mastra/MastraConditionBridge.cjs +39 -0
  45. package/lib/cjs/mastra/MastraConditionBridge.cjs.map +1 -0
  46. package/lib/cjs/mastra/MastraEventBridge.cjs +486 -0
  47. package/lib/cjs/mastra/MastraEventBridge.cjs.map +1 -0
  48. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs +351 -0
  49. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs.map +1 -0
  50. package/lib/cjs/mastra/MastraResumeGuard.cjs +127 -0
  51. package/lib/cjs/mastra/MastraResumeGuard.cjs.map +1 -0
  52. package/lib/cjs/mastra/MastraSchemaConverter.cjs +124 -0
  53. package/lib/cjs/mastra/MastraSchemaConverter.cjs.map +1 -0
  54. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs +461 -0
  55. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs.map +1 -0
  56. package/lib/cjs/mastra/MastraWorkflowManager.cjs +401 -0
  57. package/lib/cjs/mastra/MastraWorkflowManager.cjs.map +1 -0
  58. package/lib/cjs/mastra/index.cjs +35 -0
  59. package/lib/cjs/mastra/index.cjs.map +1 -0
  60. package/lib/cjs/mastra/types.cjs +34 -0
  61. package/lib/cjs/mastra/types.cjs.map +1 -0
  62. package/lib/cjs/nest/graph/GraphBackendHost.cjs +146 -0
  63. package/lib/cjs/nest/graph/GraphBackendHost.cjs.map +1 -0
  64. package/lib/cjs/nest/graph/GraphEngineCapabilityManifest.cjs +136 -0
  65. package/lib/cjs/nest/graph/GraphEngineCapabilityManifest.cjs.map +1 -0
  66. package/lib/cjs/nest/graph/GraphEngineCapabilityService.cjs +140 -0
  67. package/lib/cjs/nest/graph/GraphEngineCapabilityService.cjs.map +1 -0
  68. package/lib/cjs/nest/graph/GraphEngineController.cjs +227 -0
  69. package/lib/cjs/nest/graph/GraphEngineController.cjs.map +1 -0
  70. package/lib/cjs/nest/graph/GraphExecutionModule.cjs +31 -2
  71. package/lib/cjs/nest/graph/GraphExecutionModule.cjs.map +1 -1
  72. package/lib/cjs/nest/graph/index.cjs +4 -0
  73. package/lib/cjs/nest/graph/index.cjs.map +1 -1
  74. package/lib/cjs/nest/graph/main.cjs +139 -0
  75. package/lib/cjs/nest/graph/main.cjs.map +1 -0
  76. package/lib/cjs/nest/graph/servingErrors.cjs +3 -0
  77. package/lib/cjs/nest/graph/servingErrors.cjs.map +1 -1
  78. package/lib/cjs/node/utility/code/node.cjs +11 -3
  79. package/lib/cjs/node/utility/code/node.cjs.map +1 -1
  80. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs +2 -3
  81. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs.map +1 -1
  82. package/lib/cjs/shared/graph/constants.cjs +8 -0
  83. package/lib/cjs/shared/graph/constants.cjs.map +1 -1
  84. package/lib/cjs/shared/graph/index.cjs +2 -1
  85. package/lib/cjs/shared/graph/index.cjs.map +1 -1
  86. package/lib/cjs/shared/graph/layout/GraphWorkflowLayout.cjs +146 -0
  87. package/lib/cjs/shared/graph/layout/GraphWorkflowLayout.cjs.map +1 -0
  88. package/lib/cjs/shared/graph/layout/index.cjs +23 -0
  89. package/lib/cjs/shared/graph/layout/index.cjs.map +1 -0
  90. package/lib/cjs/shared/graph/layout/layout-options.cjs +93 -0
  91. package/lib/cjs/shared/graph/layout/layout-options.cjs.map +1 -0
  92. package/lib/cjs/shared/ui/index.cjs +8 -10
  93. package/lib/cjs/shared/ui/index.cjs.map +1 -1
  94. package/lib/esm/dagster/DagsterGraphEventBridge.js +339 -0
  95. package/lib/esm/dagster/DagsterGraphEventBridge.js.map +1 -0
  96. package/lib/esm/dagster/DagsterGraphExecutionBackend.js +781 -0
  97. package/lib/esm/dagster/DagsterGraphExecutionBackend.js.map +1 -0
  98. package/lib/esm/dagster/DagsterGraphQLClient.js +733 -0
  99. package/lib/esm/dagster/DagsterGraphQLClient.js.map +1 -0
  100. package/lib/esm/dagster/DagsterResultMapper.js +51 -0
  101. package/lib/esm/dagster/DagsterResultMapper.js.map +1 -0
  102. package/lib/esm/dagster/DagsterTypes.js +2 -0
  103. package/lib/esm/dagster/DagsterTypes.js.map +1 -0
  104. package/lib/esm/dagster/capabilities.js +97 -0
  105. package/lib/esm/dagster/capabilities.js.map +1 -0
  106. package/lib/esm/dagster/constants.js +88 -0
  107. package/lib/esm/dagster/constants.js.map +1 -0
  108. package/lib/esm/dagster/index.js +16 -0
  109. package/lib/esm/dagster/index.js.map +1 -0
  110. package/lib/esm/engine/constants.js +5 -0
  111. package/lib/esm/engine/constants.js.map +1 -1
  112. package/lib/esm/engine/execution/GraphCodeMode.js +132 -0
  113. package/lib/esm/engine/execution/GraphCodeMode.js.map +1 -0
  114. package/lib/esm/engine/execution/GraphExecutionBackend.js +83 -0
  115. package/lib/esm/engine/execution/GraphExecutionBackend.js.map +1 -0
  116. package/lib/esm/engine/execution/GraphExecutionBackendRegistry.js +102 -0
  117. package/lib/esm/engine/execution/GraphExecutionBackendRegistry.js.map +1 -0
  118. package/lib/esm/engine/execution/GraphExecutionEngine.js +232 -716
  119. package/lib/esm/engine/execution/GraphExecutionEngine.js.map +1 -1
  120. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js +799 -0
  121. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js.map +1 -0
  122. package/lib/esm/engine/execution/index.js +4 -0
  123. package/lib/esm/engine/execution/index.js.map +1 -1
  124. package/lib/esm/engine/index.js +4 -0
  125. package/lib/esm/engine/index.js.map +1 -1
  126. package/lib/esm/engine/runs/GraphRunService.js +62 -1
  127. package/lib/esm/engine/runs/GraphRunService.js.map +1 -1
  128. package/lib/esm/engine/services/GraphWorkflowService.js +33 -14
  129. package/lib/esm/engine/services/GraphWorkflowService.js.map +1 -1
  130. package/lib/esm/mastra/MastraCapabilities.js +164 -0
  131. package/lib/esm/mastra/MastraCapabilities.js.map +1 -0
  132. package/lib/esm/mastra/MastraConditionBridge.js +34 -0
  133. package/lib/esm/mastra/MastraConditionBridge.js.map +1 -0
  134. package/lib/esm/mastra/MastraEventBridge.js +481 -0
  135. package/lib/esm/mastra/MastraEventBridge.js.map +1 -0
  136. package/lib/esm/mastra/MastraGraphExecutionBackend.js +346 -0
  137. package/lib/esm/mastra/MastraGraphExecutionBackend.js.map +1 -0
  138. package/lib/esm/mastra/MastraResumeGuard.js +123 -0
  139. package/lib/esm/mastra/MastraResumeGuard.js.map +1 -0
  140. package/lib/esm/mastra/MastraSchemaConverter.js +119 -0
  141. package/lib/esm/mastra/MastraSchemaConverter.js.map +1 -0
  142. package/lib/esm/mastra/MastraWorkflowCompiler.js +456 -0
  143. package/lib/esm/mastra/MastraWorkflowCompiler.js.map +1 -0
  144. package/lib/esm/mastra/MastraWorkflowManager.js +396 -0
  145. package/lib/esm/mastra/MastraWorkflowManager.js.map +1 -0
  146. package/lib/esm/mastra/index.js +18 -0
  147. package/lib/esm/mastra/index.js.map +1 -0
  148. package/lib/esm/mastra/types.js +30 -0
  149. package/lib/esm/mastra/types.js.map +1 -0
  150. package/lib/esm/nest/graph/GraphBackendHost.js +138 -0
  151. package/lib/esm/nest/graph/GraphBackendHost.js.map +1 -0
  152. package/lib/esm/nest/graph/GraphEngineCapabilityManifest.js +129 -0
  153. package/lib/esm/nest/graph/GraphEngineCapabilityManifest.js.map +1 -0
  154. package/lib/esm/nest/graph/GraphEngineCapabilityService.js +131 -0
  155. package/lib/esm/nest/graph/GraphEngineCapabilityService.js.map +1 -0
  156. package/lib/esm/nest/graph/GraphEngineController.js +218 -0
  157. package/lib/esm/nest/graph/GraphEngineController.js.map +1 -0
  158. package/lib/esm/nest/graph/GraphExecutionModule.js +31 -2
  159. package/lib/esm/nest/graph/GraphExecutionModule.js.map +1 -1
  160. package/lib/esm/nest/graph/index.js +4 -0
  161. package/lib/esm/nest/graph/index.js.map +1 -1
  162. package/lib/esm/nest/graph/main.js +103 -0
  163. package/lib/esm/nest/graph/main.js.map +1 -0
  164. package/lib/esm/nest/graph/servingErrors.js +3 -0
  165. package/lib/esm/nest/graph/servingErrors.js.map +1 -1
  166. package/lib/esm/node/utility/code/node.js +11 -3
  167. package/lib/esm/node/utility/code/node.js.map +1 -1
  168. package/lib/esm/shared/graph/GraphExecutionStateMapper.js.map +1 -1
  169. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js +2 -3
  170. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js.map +1 -1
  171. package/lib/esm/shared/graph/constants.js +8 -0
  172. package/lib/esm/shared/graph/constants.js.map +1 -1
  173. package/lib/esm/shared/graph/index.js +2 -1
  174. package/lib/esm/shared/graph/index.js.map +1 -1
  175. package/lib/esm/shared/graph/layout/GraphWorkflowLayout.js +107 -0
  176. package/lib/esm/shared/graph/layout/GraphWorkflowLayout.js.map +1 -0
  177. package/lib/esm/shared/graph/layout/index.js +6 -0
  178. package/lib/esm/shared/graph/layout/index.js.map +1 -0
  179. package/lib/esm/shared/graph/layout/layout-options.js +96 -0
  180. package/lib/esm/shared/graph/layout/layout-options.js.map +1 -0
  181. package/lib/esm/shared/ui/index.js +8 -10
  182. package/lib/esm/shared/ui/index.js.map +1 -1
  183. package/lib/types/dagster/DagsterGraphEventBridge.d.cts +142 -0
  184. package/lib/types/dagster/DagsterGraphEventBridge.d.mts +142 -0
  185. package/lib/types/dagster/DagsterGraphExecutionBackend.d.cts +323 -0
  186. package/lib/types/dagster/DagsterGraphExecutionBackend.d.mts +323 -0
  187. package/lib/types/dagster/DagsterGraphQLClient.d.cts +231 -0
  188. package/lib/types/dagster/DagsterGraphQLClient.d.mts +231 -0
  189. package/lib/types/dagster/DagsterResultMapper.d.cts +50 -0
  190. package/lib/types/dagster/DagsterResultMapper.d.mts +50 -0
  191. package/lib/types/dagster/DagsterTypes.d.cts +355 -0
  192. package/lib/types/dagster/DagsterTypes.d.mts +355 -0
  193. package/lib/types/dagster/capabilities.d.cts +34 -0
  194. package/lib/types/dagster/capabilities.d.mts +34 -0
  195. package/lib/types/dagster/constants.d.cts +87 -0
  196. package/lib/types/dagster/constants.d.mts +87 -0
  197. package/lib/types/dagster/index.d.cts +15 -0
  198. package/lib/types/dagster/index.d.mts +15 -0
  199. package/lib/types/engine/constants.d.cts +5 -0
  200. package/lib/types/engine/constants.d.mts +5 -0
  201. package/lib/types/engine/execution/GraphCodeMode.d.cts +52 -0
  202. package/lib/types/engine/execution/GraphCodeMode.d.mts +52 -0
  203. package/lib/types/engine/execution/GraphExecutionBackend.d.cts +306 -0
  204. package/lib/types/engine/execution/GraphExecutionBackend.d.mts +306 -0
  205. package/lib/types/engine/execution/GraphExecutionBackendRegistry.d.cts +59 -0
  206. package/lib/types/engine/execution/GraphExecutionBackendRegistry.d.mts +59 -0
  207. package/lib/types/engine/execution/GraphExecutionEngine.d.cts +116 -135
  208. package/lib/types/engine/execution/GraphExecutionEngine.d.mts +116 -135
  209. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.cts +232 -0
  210. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.mts +232 -0
  211. package/lib/types/engine/execution/index.d.cts +4 -0
  212. package/lib/types/engine/execution/index.d.mts +4 -0
  213. package/lib/types/engine/index.d.cts +4 -0
  214. package/lib/types/engine/index.d.mts +4 -0
  215. package/lib/types/engine/runs/GraphRunService.d.cts +19 -0
  216. package/lib/types/engine/runs/GraphRunService.d.mts +19 -0
  217. package/lib/types/engine/services/GraphWorkflowService.d.cts +22 -0
  218. package/lib/types/engine/services/GraphWorkflowService.d.mts +22 -0
  219. package/lib/types/mastra/MastraCapabilities.d.cts +86 -0
  220. package/lib/types/mastra/MastraCapabilities.d.mts +86 -0
  221. package/lib/types/mastra/MastraConditionBridge.d.cts +38 -0
  222. package/lib/types/mastra/MastraConditionBridge.d.mts +38 -0
  223. package/lib/types/mastra/MastraEventBridge.d.cts +189 -0
  224. package/lib/types/mastra/MastraEventBridge.d.mts +189 -0
  225. package/lib/types/mastra/MastraGraphExecutionBackend.d.cts +119 -0
  226. package/lib/types/mastra/MastraGraphExecutionBackend.d.mts +119 -0
  227. package/lib/types/mastra/MastraResumeGuard.d.cts +58 -0
  228. package/lib/types/mastra/MastraResumeGuard.d.mts +58 -0
  229. package/lib/types/mastra/MastraSchemaConverter.d.cts +39 -0
  230. package/lib/types/mastra/MastraSchemaConverter.d.mts +39 -0
  231. package/lib/types/mastra/MastraWorkflowCompiler.d.cts +218 -0
  232. package/lib/types/mastra/MastraWorkflowCompiler.d.mts +218 -0
  233. package/lib/types/mastra/MastraWorkflowManager.d.cts +220 -0
  234. package/lib/types/mastra/MastraWorkflowManager.d.mts +220 -0
  235. package/lib/types/mastra/index.d.cts +17 -0
  236. package/lib/types/mastra/index.d.mts +17 -0
  237. package/lib/types/mastra/types.d.cts +222 -0
  238. package/lib/types/mastra/types.d.mts +222 -0
  239. package/lib/types/nest/graph/GraphBackendHost.d.cts +100 -0
  240. package/lib/types/nest/graph/GraphBackendHost.d.mts +100 -0
  241. package/lib/types/nest/graph/GraphEngineCapabilityManifest.d.cts +87 -0
  242. package/lib/types/nest/graph/GraphEngineCapabilityManifest.d.mts +87 -0
  243. package/lib/types/nest/graph/GraphEngineCapabilityService.d.cts +98 -0
  244. package/lib/types/nest/graph/GraphEngineCapabilityService.d.mts +98 -0
  245. package/lib/types/nest/graph/GraphEngineController.d.cts +74 -0
  246. package/lib/types/nest/graph/GraphEngineController.d.mts +74 -0
  247. package/lib/types/nest/graph/GraphExecutionModule.d.cts +20 -0
  248. package/lib/types/nest/graph/GraphExecutionModule.d.mts +20 -0
  249. package/lib/types/nest/graph/index.d.cts +4 -0
  250. package/lib/types/nest/graph/index.d.mts +4 -0
  251. package/lib/types/nest/graph/main.d.cts +1 -0
  252. package/lib/types/nest/graph/main.d.mts +1 -0
  253. package/lib/types/nest/graph/servingErrors.d.cts +3 -1
  254. package/lib/types/nest/graph/servingErrors.d.mts +3 -1
  255. package/lib/types/node/utility/code/node.d.cts +1 -1
  256. package/lib/types/node/utility/code/node.d.mts +1 -1
  257. package/lib/types/shared/graph/GraphExecutionStateMapper.d.cts +5 -5
  258. package/lib/types/shared/graph/GraphExecutionStateMapper.d.mts +5 -5
  259. package/lib/types/shared/graph/constants.d.cts +8 -0
  260. package/lib/types/shared/graph/constants.d.mts +8 -0
  261. package/lib/types/shared/graph/index.d.cts +2 -1
  262. package/lib/types/shared/graph/index.d.mts +2 -1
  263. package/lib/types/shared/graph/layout/GraphWorkflowLayout.d.cts +49 -0
  264. package/lib/types/shared/graph/layout/GraphWorkflowLayout.d.mts +49 -0
  265. package/lib/types/shared/graph/layout/index.d.cts +5 -0
  266. package/lib/types/shared/graph/layout/index.d.mts +5 -0
  267. package/lib/types/shared/graph/layout/layout-options.d.cts +46 -0
  268. package/lib/types/shared/graph/layout/layout-options.d.mts +46 -0
  269. package/lib/types/shared/graph/types.d.cts +4 -3
  270. package/lib/types/shared/graph/types.d.mts +4 -3
  271. package/lib/types/shared/ui/index.d.cts +8 -10
  272. package/lib/types/shared/ui/index.d.mts +8 -10
  273. package/package.json +55 -6
  274. package/lib/cjs/shared/ui/GraphNodeView.cjs +0 -114
  275. package/lib/cjs/shared/ui/GraphNodeView.cjs.map +0 -1
  276. package/lib/cjs/shared/ui/GraphRunView.cjs +0 -96
  277. package/lib/cjs/shared/ui/GraphRunView.cjs.map +0 -1
  278. package/lib/cjs/shared/ui/GraphWorkflowView.cjs +0 -78
  279. package/lib/cjs/shared/ui/GraphWorkflowView.cjs.map +0 -1
  280. package/lib/cjs/shared/ui/types.cjs +0 -4
  281. package/lib/cjs/shared/ui/types.cjs.map +0 -1
  282. package/lib/esm/shared/ui/GraphNodeView.js +0 -107
  283. package/lib/esm/shared/ui/GraphNodeView.js.map +0 -1
  284. package/lib/esm/shared/ui/GraphRunView.js +0 -90
  285. package/lib/esm/shared/ui/GraphRunView.js.map +0 -1
  286. package/lib/esm/shared/ui/GraphWorkflowView.js +0 -72
  287. package/lib/esm/shared/ui/GraphWorkflowView.js.map +0 -1
  288. package/lib/esm/shared/ui/types.js +0 -2
  289. package/lib/esm/shared/ui/types.js.map +0 -1
  290. package/lib/types/shared/ui/GraphNodeView.d.cts +0 -48
  291. package/lib/types/shared/ui/GraphNodeView.d.mts +0 -48
  292. package/lib/types/shared/ui/GraphRunView.d.cts +0 -88
  293. package/lib/types/shared/ui/GraphRunView.d.mts +0 -88
  294. package/lib/types/shared/ui/GraphWorkflowView.d.cts +0 -18
  295. package/lib/types/shared/ui/GraphWorkflowView.d.mts +0 -18
  296. package/lib/types/shared/ui/types.d.cts +0 -200
  297. package/lib/types/shared/ui/types.d.mts +0 -200
@@ -0,0 +1,396 @@
1
+ import { GraphExecutionError } from "./../engine/errors/GraphExecutionError.js";
2
+ import { graphRunDocumentFingerprint } from "./../engine/runs/GraphRunFingerprint.js";
3
+ import { canAccessGraphResource } from "./../engine/runs/ownership.js";
4
+ import { graphWorkflowOwnerOf } from "./../engine/services/GraphWorkflowService.js";
5
+ import { MastraWorkflowCompiler } from "./MastraWorkflowCompiler.js";
6
+ import { GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE, GRAPH_MASTRA_PERSIST_NOT_SUPPORTED, GRAPH_MASTRA_SERIALIZE_NOT_SUPPORTED, GRAPH_MASTRA_WORKFLOW_FORBIDDEN, GRAPH_MASTRA_WORKFLOW_NOT_FOUND, } from "./types.js";
7
+ /**
8
+ * Structural check for a Decaf execution {@link Context} inside a
9
+ * {@link MaybeContextualArg} argument list. Mirrors `@decaf-ts/core`'s own
10
+ * realm-safe duck-typing (multiple linked core builds defeat `instanceof`).
11
+ *
12
+ * @param value - A candidate argument.
13
+ * @returns `true` when the value is a Decaf execution context.
14
+ */
15
+ function isMastraManagerContextLike(value) {
16
+ if (!value || typeof value !== "object")
17
+ return false;
18
+ const candidate = value;
19
+ return (typeof candidate.get === "function" &&
20
+ typeof candidate.accumulate === "function" &&
21
+ typeof candidate.override === "function" &&
22
+ typeof candidate.toOverrides === "function" &&
23
+ candidate.cache !== undefined);
24
+ }
25
+ /**
26
+ * Resolves the caller owner from the forwarded contextual arguments, matching the
27
+ * backend's C23 resolution. The trailing context, when present, carries the
28
+ * authenticated principal resolved with {@link graphWorkflowOwnerOf}.
29
+ *
30
+ * @param args - The forwarded contextual arguments.
31
+ * @returns The caller owner, or `undefined` for owner-less callers.
32
+ */
33
+ function mastraManagerCallerOwnerOf(args) {
34
+ for (let index = args.length - 1; index >= 0; index -= 1) {
35
+ const candidate = args[index];
36
+ if (isMastraManagerContextLike(candidate)) {
37
+ return graphWorkflowOwnerOf(candidate);
38
+ }
39
+ }
40
+ return undefined;
41
+ }
42
+ /**
43
+ * Management surface over real `@mastra/core` workflows (SAA-346). Holds only the
44
+ * wired runtime reference and the canonical-document compiler; it never constructs a
45
+ * Mastra primitive itself and never synthesizes a method the pinned library does not
46
+ * expose. Every method validates the runtime surface it needs first and fails
47
+ * closed with {@link GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE} otherwise.
48
+ */
49
+ export class MastraWorkflowManager {
50
+ /**
51
+ * @param options - The wired runtime and optional shared compiler.
52
+ */
53
+ constructor(options = {}) {
54
+ this.options = options;
55
+ /** Canonical document revision (fingerprint) by managed workflow id. */
56
+ this.revisions = new Map();
57
+ /**
58
+ * Wrapper-managed provenance: the owner recorded when the wrapper created or
59
+ * updated a workflow. An id absent from this map is not wrapper-managed, so a
60
+ * host `origin: "code"` registration is protected from overwrite/delete (C3).
61
+ */
62
+ this.owners = new Map();
63
+ /** Standalone compiler used when the host does not inject one. */
64
+ this.fallbackCompiler = new MastraWorkflowCompiler();
65
+ }
66
+ /** The wired real `@mastra/core` runtime, when any. */
67
+ get runtime() {
68
+ return this.options.runtime;
69
+ }
70
+ /**
71
+ * Registers a workflow translated from a canonical document on the real Mastra
72
+ * instance (real `addWorkflow`). This is the honest "create" operation: the
73
+ * pinned library registers live, it does not persist a translated code-step
74
+ * definition (see {@link persist}).
75
+ *
76
+ * @param document - The canonical document to translate and register.
77
+ * @returns The managed workflow descriptor.
78
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE}
79
+ * when the runtime exposes no `addWorkflow`.
80
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_UNSUPPORTED_KIND} when the
81
+ * document cannot be translated.
82
+ */
83
+ async create(document, ...args) {
84
+ const runtime = this.requireRuntime("addWorkflow");
85
+ const owner = mastraManagerCallerOwnerOf(args);
86
+ this.assertWritableProvenance(runtime, document.id);
87
+ const compiled = this.compilerOf().compile(document);
88
+ this.revisions.set(document.id, compiled.fingerprint);
89
+ this.owners.set(document.id, owner);
90
+ runtime.addWorkflow?.(compiled.workflow, document.id);
91
+ return this.describe(document.id);
92
+ }
93
+ /**
94
+ * Edits a managed workflow by recompiling the updated canonical document and
95
+ * replacing the live registration (real `removeWorkflow` then `addWorkflow`). The
96
+ * pinned library documents `removeWorkflow` as the update/delete path so a
97
+ * subsequent save can re-register the same id cleanly.
98
+ *
99
+ * @param document - The updated canonical document.
100
+ * @returns The managed workflow descriptor with its new revision.
101
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE}
102
+ * when the runtime exposes no `addWorkflow`/`removeWorkflow`.
103
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_WORKFLOW_NOT_FOUND} when
104
+ * no workflow is registered under the document id.
105
+ */
106
+ async update(document, ...args) {
107
+ const runtime = this.requireRuntime("addWorkflow", "removeWorkflow");
108
+ const owner = mastraManagerCallerOwnerOf(args);
109
+ this.assertWritableProvenance(runtime, document.id);
110
+ this.assertOwnerAccess(document.id, owner);
111
+ const compiled = this.compilerOf().compile(document);
112
+ const removed = runtime.removeWorkflow?.(document.id) === true;
113
+ if (!removed) {
114
+ throw new GraphExecutionError(`Mastra runtime has no managed workflow '${document.id}' to update`, GRAPH_MASTRA_WORKFLOW_NOT_FOUND, { workflowId: document.id });
115
+ }
116
+ this.revisions.set(document.id, compiled.fingerprint);
117
+ this.owners.set(document.id, owner);
118
+ runtime.addWorkflow?.(compiled.workflow, document.id);
119
+ return this.describe(document.id);
120
+ }
121
+ /**
122
+ * Deletes a managed workflow from the live Mastra registry (real
123
+ * `removeWorkflow`).
124
+ *
125
+ * @param workflowId - The managed workflow id to remove.
126
+ * @returns `true` when a workflow was removed.
127
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE}
128
+ * when the runtime exposes no `removeWorkflow`.
129
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_WORKFLOW_NOT_FOUND} when no
130
+ * workflow is registered under the id.
131
+ */
132
+ async delete(workflowId, ...args) {
133
+ const runtime = this.requireRuntime("removeWorkflow");
134
+ const owner = mastraManagerCallerOwnerOf(args);
135
+ this.assertWritableProvenance(runtime, workflowId);
136
+ this.assertOwnerAccess(workflowId, owner);
137
+ const removed = runtime.removeWorkflow?.(workflowId) === true;
138
+ if (!removed) {
139
+ throw new GraphExecutionError(`Mastra runtime has no managed workflow '${workflowId}' to delete`, GRAPH_MASTRA_WORKFLOW_NOT_FOUND, { workflowId });
140
+ }
141
+ this.revisions.delete(workflowId);
142
+ this.owners.delete(workflowId);
143
+ return true;
144
+ }
145
+ /**
146
+ * Lists the managed workflows registered on the real Mastra instance (real
147
+ * `listWorkflows`).
148
+ *
149
+ * @returns The managed workflow descriptors, in registry order.
150
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE}
151
+ * when the runtime exposes no `listWorkflows`.
152
+ */
153
+ async list() {
154
+ const runtime = this.requireRuntime("listWorkflows");
155
+ const registered = runtime.listWorkflows?.() ?? {};
156
+ return Object.entries(registered).map(([id, workflow]) => this.describeWorkflow(id, workflow));
157
+ }
158
+ /**
159
+ * Reads one managed workflow registered on the real Mastra instance (real
160
+ * `getWorkflow`).
161
+ *
162
+ * @param workflowId - The managed workflow id to read.
163
+ * @returns The managed workflow descriptor.
164
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE}
165
+ * when the runtime exposes no `getWorkflow`.
166
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_WORKFLOW_NOT_FOUND} when no
167
+ * workflow is registered under the id.
168
+ */
169
+ async get(workflowId) {
170
+ const runtime = this.requireRuntime("getWorkflow");
171
+ const workflow = this.registeredWorkflow(runtime, workflowId);
172
+ return this.describeWorkflow(workflowId, workflow);
173
+ }
174
+ /**
175
+ * Serializes a managed workflow through the real Mastra
176
+ * `Workflow.serializedStepGraph` surface.
177
+ *
178
+ * @param workflowId - The managed workflow id to serialize.
179
+ * @returns The JSON-safe serialized workflow.
180
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE}
181
+ * when the runtime exposes no `getWorkflow`.
182
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_WORKFLOW_NOT_FOUND} when no
183
+ * workflow is registered under the id.
184
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_SERIALIZE_NOT_SUPPORTED}
185
+ * when the registered workflow exposes no serializable step graph.
186
+ */
187
+ async serialize(workflowId) {
188
+ const runtime = this.requireRuntime("getWorkflow");
189
+ const workflow = this.registeredWorkflow(runtime, workflowId);
190
+ const steps = workflow
191
+ .serializedStepGraph;
192
+ if (!Array.isArray(steps)) {
193
+ throw new GraphExecutionError(`Mastra workflow '${workflowId}' exposes no serialized step graph`, GRAPH_MASTRA_SERIALIZE_NOT_SUPPORTED, { workflowId });
194
+ }
195
+ const revision = this.revisions.get(workflowId);
196
+ return {
197
+ id: workflowId,
198
+ ...(revision !== undefined ? { revision } : {}),
199
+ steps,
200
+ };
201
+ }
202
+ /**
203
+ * The canonical document revision (fingerprint) the wrapper tracks for a
204
+ * document. Mastra has no native workflow version, so this is the honest
205
+ * `EXTENSION-POINT` revision identity: it is computed from the canonical
206
+ * document alone and requires no runtime.
207
+ *
208
+ * @param document - The canonical document to fingerprint.
209
+ * @returns The stable revision fingerprint.
210
+ */
211
+ revision(document) {
212
+ return graphRunDocumentFingerprint(document);
213
+ }
214
+ /**
215
+ * Persists a translated workflow to Mastra storage. The pinned real
216
+ * `Mastra.addDynamicWorkflow` persists only agent/tool-referenced steps, while
217
+ * the canonical translation emits host code steps, so this operation is
218
+ * `NOT-SUPPORTED` and fails closed rather than faking a persisted definition.
219
+ *
220
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_PERSIST_NOT_SUPPORTED}
221
+ * always.
222
+ */
223
+ async persist() {
224
+ throw new GraphExecutionError("Mastra addDynamicWorkflow persists only agent/tool-referenced steps; the canonical translation emits host code steps", GRAPH_MASTRA_PERSIST_NOT_SUPPORTED);
225
+ }
226
+ /** The compiler the surface translates canonical documents with. */
227
+ compilerOf() {
228
+ return this.options.compiler ?? this.fallbackCompiler;
229
+ }
230
+ /**
231
+ * Resolves the wired runtime after asserting it exposes every required real
232
+ * Mastra method.
233
+ *
234
+ * @param methods - The real method names the operation needs.
235
+ * @returns The wired runtime.
236
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE}
237
+ * when the runtime is unwired or omits a required method.
238
+ */
239
+ requireRuntime(...methods) {
240
+ const runtime = this.options.runtime;
241
+ if (!runtime || typeof runtime !== "object") {
242
+ throw new GraphExecutionError("Mastra runtime is not wired; workflow management is unavailable", GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE);
243
+ }
244
+ const candidate = runtime;
245
+ for (const method of methods) {
246
+ if (typeof candidate[method] !== "function") {
247
+ throw new GraphExecutionError(`Mastra runtime exposes no '${method}' method; workflow management is unavailable`, GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE, { method });
248
+ }
249
+ }
250
+ return runtime;
251
+ }
252
+ /**
253
+ * Fails closed when a management mutation targets a workflow the wrapper did not
254
+ * create (C3 complete mediation). A wrapper-managed id is writable; any
255
+ * pre-existing registration — including a host `origin: "code"` workflow — is
256
+ * protected from overwrite/delete, and an existing workflow whose provenance
257
+ * cannot be determined is refused rather than mutated.
258
+ *
259
+ * @param runtime - The validated runtime.
260
+ * @param workflowId - The managed workflow id.
261
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_WORKFLOW_FORBIDDEN} when the
262
+ * workflow is not wrapper-managed.
263
+ */
264
+ assertWritableProvenance(runtime, workflowId) {
265
+ if (this.revisions.has(workflowId))
266
+ return;
267
+ const origin = this.originOf(runtime, workflowId);
268
+ if (origin !== undefined) {
269
+ throw new GraphExecutionError(`Mastra workflow '${workflowId}' is a host registration (origin '${origin}'); the wrapper only manages workflows it created`, GRAPH_MASTRA_WORKFLOW_FORBIDDEN, { workflowId, origin });
270
+ }
271
+ if (this.registered(runtime, workflowId)) {
272
+ throw new GraphExecutionError(`Mastra workflow '${workflowId}' exists but is not wrapper-managed; refusing to modify a foreign registration`, GRAPH_MASTRA_WORKFLOW_FORBIDDEN, { workflowId });
273
+ }
274
+ }
275
+ /**
276
+ * Enforces the C23 ownership predicate on a wrapper-managed workflow before a
277
+ * management mutation, mirroring the backend's `canAccessGraphResource`
278
+ * enforcement. Owner-less workflows stay writable by every caller.
279
+ *
280
+ * @param workflowId - The managed workflow id.
281
+ * @param callerOwner - The caller owner resolved from the context.
282
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_WORKFLOW_FORBIDDEN} when the
283
+ * caller may not write the workflow.
284
+ */
285
+ assertOwnerAccess(workflowId, callerOwner) {
286
+ const owner = this.owners.get(workflowId);
287
+ if (!canAccessGraphResource({ owner }, callerOwner)) {
288
+ throw new GraphExecutionError(`Mastra workflow '${workflowId}' is not writable by the caller`, GRAPH_MASTRA_WORKFLOW_FORBIDDEN, { workflowId });
289
+ }
290
+ }
291
+ /**
292
+ * Reads how the runtime reports a workflow's registration origin.
293
+ *
294
+ * @param runtime - The validated runtime.
295
+ * @param workflowId - The workflow id.
296
+ * @returns The origin, or `undefined` when the runtime reports none.
297
+ */
298
+ originOf(runtime, workflowId) {
299
+ if (typeof runtime.getWorkflowOrigin !== "function")
300
+ return undefined;
301
+ try {
302
+ return runtime.getWorkflowOrigin(workflowId);
303
+ }
304
+ catch {
305
+ return undefined;
306
+ }
307
+ }
308
+ /**
309
+ * Whether the runtime already has a workflow registered under the id.
310
+ *
311
+ * @param runtime - The validated runtime.
312
+ * @param workflowId - The workflow id.
313
+ * @returns `true` when a workflow is registered under the id.
314
+ */
315
+ registered(runtime, workflowId) {
316
+ if (typeof runtime.getWorkflow !== "function")
317
+ return false;
318
+ try {
319
+ const workflow = runtime.getWorkflow(workflowId);
320
+ return workflow !== undefined && workflow !== null;
321
+ }
322
+ catch {
323
+ return false;
324
+ }
325
+ }
326
+ /**
327
+ * Reads a registered workflow, mapping the real not-found failure onto the
328
+ * canonical error code.
329
+ *
330
+ * @param runtime - The validated runtime.
331
+ * @param workflowId - The managed workflow id to read.
332
+ * @returns The registered workflow object.
333
+ * @throws {GraphExecutionError} {@link GRAPH_MASTRA_WORKFLOW_NOT_FOUND} when no
334
+ * workflow is registered under the id.
335
+ */
336
+ registeredWorkflow(runtime, workflowId) {
337
+ let workflow;
338
+ try {
339
+ workflow = runtime.getWorkflow?.(workflowId);
340
+ }
341
+ catch {
342
+ workflow = undefined;
343
+ }
344
+ if (workflow === undefined || workflow === null) {
345
+ throw new GraphExecutionError(`Mastra runtime has no managed workflow '${workflowId}'`, GRAPH_MASTRA_WORKFLOW_NOT_FOUND, { workflowId });
346
+ }
347
+ return workflow;
348
+ }
349
+ /**
350
+ * Builds a managed workflow descriptor, reading the real registration origin
351
+ * and the wrapper-tracked revision when available.
352
+ *
353
+ * @param workflowId - The managed workflow id.
354
+ * @param workflow - The registered workflow object.
355
+ * @returns The managed workflow descriptor.
356
+ */
357
+ describeWorkflow(workflowId, workflow) {
358
+ const name = workflow?.name;
359
+ let origin;
360
+ const runtime = this.options.runtime;
361
+ try {
362
+ origin = runtime?.getWorkflowOrigin?.(workflowId);
363
+ }
364
+ catch {
365
+ origin = undefined;
366
+ }
367
+ const revision = this.revisions.get(workflowId);
368
+ return {
369
+ id: workflowId,
370
+ ...(typeof name === "string" ? { name } : {}),
371
+ ...(origin ? { origin } : {}),
372
+ ...(revision !== undefined ? { revision } : {}),
373
+ };
374
+ }
375
+ /**
376
+ * Builds a descriptor for a workflow the wrapper has just registered or
377
+ * updated.
378
+ *
379
+ * @param workflowId - The managed workflow id.
380
+ * @returns The managed workflow descriptor.
381
+ */
382
+ describe(workflowId) {
383
+ const runtime = this.options.runtime;
384
+ let workflow;
385
+ if (typeof runtime?.getWorkflow === "function") {
386
+ try {
387
+ workflow = runtime.getWorkflow(workflowId);
388
+ }
389
+ catch {
390
+ workflow = undefined;
391
+ }
392
+ }
393
+ return this.describeWorkflow(workflowId, workflow);
394
+ }
395
+ }
396
+ //# sourceMappingURL=MastraWorkflowManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MastraWorkflowManager.js","sourceRoot":"","sources":["../../../src/mastra/MastraWorkflowManager.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,mBAAmB,EAAE,kDAA6C;AAC3E,OAAO,EAAE,2BAA2B,EAAE,gDAA2C;AACjF,OAAO,EAAE,sBAAsB,EAAE,sCAAiC;AAClE,OAAO,EAAE,oBAAoB,EAAE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CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAChD,OAAO;YACL,EAAE,EAAE,UAAU;YACd,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7C,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7B,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACK,QAAQ,CAAC,UAAkB;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAEhB,CAAC;QACd,IAAI,QAAiB,CAAC;QACtB,IAAI,OAAO,OAAO,EAAE,WAAW,KAAK,UAAU,EAAE,CAAC;YAC/C,IAAI,CAAC;gBACH,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACP,QAAQ,GAAG,SAAS,CAAC;YACvB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module as-graph/mastra
3
+ * @summary Mastra graph execution backend barrel (SAA-196).
4
+ * @description Public surface of the `@decaf-ts/as-graph/mastra` entrypoint:
5
+ * the Mastra execution backend, the workflow compiler, the event bridge, the
6
+ * condition bridge, the schema converter, the resume guard, the capability
7
+ * table, and the shared types/ports.
8
+ */
9
+ export * from "./types.js";
10
+ export * from "./MastraCapabilities.js";
11
+ export * from "./MastraSchemaConverter.js";
12
+ export * from "./MastraConditionBridge.js";
13
+ export * from "./MastraEventBridge.js";
14
+ export * from "./MastraWorkflowCompiler.js";
15
+ export * from "./MastraWorkflowManager.js";
16
+ export * from "./MastraResumeGuard.js";
17
+ export * from "./MastraGraphExecutionBackend.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mastra/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,2BAAwB;AACxB,wCAAqC;AACrC,2CAAwC;AACxC,2CAAwC;AACxC,uCAAoC;AACpC,4CAAyC;AACzC,2CAAwC;AACxC,uCAAoC;AACpC,iDAA8C"}
@@ -0,0 +1,30 @@
1
+ /** The flavour id the Mastra backend registers under in the backend registry. */
2
+ export const MASTRA_BACKEND_FLAVOUR = "mastra";
3
+ /** A document node kind the Mastra translator cannot represent. */
4
+ export const GRAPH_MASTRA_UNSUPPORTED_KIND = "GRAPH_MASTRA_UNSUPPORTED_KIND";
5
+ /** A suspendable step declared a missing or degraded resume schema. */
6
+ export const GRAPH_MASTRA_RESUME_SCHEMA_UNSAFE = "GRAPH_MASTRA_RESUME_SCHEMA_UNSAFE";
7
+ /** A resume request failed validation (size, JSON safety, schema, or step). */
8
+ export const GRAPH_MASTRA_RESUME_INVALID = "GRAPH_MASTRA_RESUME_INVALID";
9
+ /** The resume step or iteration index is not allowlisted by the document. */
10
+ export const GRAPH_MASTRA_RESUME_STEP_UNKNOWN = "GRAPH_MASTRA_RESUME_STEP_UNKNOWN";
11
+ /** The Mastra snapshot is not a suspended run of the current document. */
12
+ export const GRAPH_MASTRA_RESUME_STATE_INVALID = "GRAPH_MASTRA_RESUME_STATE_INVALID";
13
+ /** The document translation emitted non-JSON-safe Mastra config. */
14
+ export const GRAPH_MASTRA_TRANSLATION_JSON_UNSAFE = "GRAPH_MASTRA_TRANSLATION_JSON_UNSAFE";
15
+ /** No Mastra agent is available for an agent-backed node. */
16
+ export const GRAPH_MASTRA_AGENT_UNAVAILABLE = "GRAPH_MASTRA_AGENT_UNAVAILABLE";
17
+ /** The wired Mastra runtime exposes no workflow-management surface. */
18
+ export const GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE = "GRAPH_MASTRA_MANAGEMENT_UNAVAILABLE";
19
+ /** A managed workflow id has no workflow registered on the runtime. */
20
+ export const GRAPH_MASTRA_WORKFLOW_NOT_FOUND = "GRAPH_MASTRA_WORKFLOW_NOT_FOUND";
21
+ /** Persisting a translated workflow to Mastra storage is not supported. */
22
+ export const GRAPH_MASTRA_PERSIST_NOT_SUPPORTED = "GRAPH_MASTRA_PERSIST_NOT_SUPPORTED";
23
+ /** A registered workflow exposes no serializable step graph. */
24
+ export const GRAPH_MASTRA_SERIALIZE_NOT_SUPPORTED = "GRAPH_MASTRA_SERIALIZE_NOT_SUPPORTED";
25
+ /**
26
+ * A management mutation targeted a workflow the caller may not write, or a host
27
+ * registration the wrapper did not create (C3 complete-mediation guard).
28
+ */
29
+ export const GRAPH_MASTRA_WORKFLOW_FORBIDDEN = "GRAPH_MASTRA_WORKFLOW_FORBIDDEN";
30
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/mastra/types.ts"],"names":[],"mappings":"AAuBA,iFAAiF;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC;AAE/C,mEAAmE;AACnE,MAAM,CAAC,MAAM,6BAA6B,GAAG,+BAA+B,CAAC;AAC7E,uEAAuE;AACvE,MAAM,CAAC,MAAM,iCAAiC,GAC5C,mCAAmC,CAAC;AACtC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,2BAA2B,GAAG,6BAA6B,CAAC;AACzE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gCAAgC,GAC3C,kCAAkC,CAAC;AACrC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,iCAAiC,GAC5C,mCAAmC,CAAC;AACtC,oEAAoE;AACpE,MAAM,CAAC,MAAM,oCAAoC,GAC/C,sCAAsC,CAAC;AACzC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,8BAA8B,GACzC,gCAAgC,CAAC;AACnC,uEAAuE;AACvE,MAAM,CAAC,MAAM,mCAAmC,GAC9C,qCAAqC,CAAC;AACxC,uEAAuE;AACvE,MAAM,CAAC,MAAM,+BAA+B,GAC1C,iCAAiC,CAAC;AACpC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kCAAkC,GAC7C,oCAAoC,CAAC;AACvC,gEAAgE;AAChE,MAAM,CAAC,MAAM,oCAAoC,GAC/C,sCAAsC,CAAC;AACzC;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAC1C,iCAAiC,CAAC"}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * @module as-graph/nest/graph/GraphBackendHost
3
+ * @summary Boot-time engine-variant selection for the graph backend host (SAA-706).
4
+ * @description Resolves which of the three pluggable graph engines — the built-in
5
+ * local reference interpreter, the `@mastra/core` translated backend, or the
6
+ * read-only Dagster backend — a host boots, constructs and registers that
7
+ * backend, and assembles the {@link GraphExecutionModule} options that make the
8
+ * Nest host serve the matching C20 capability manifest (`graph/engines`) and the
9
+ * per-engine workflow catalogue (`graph/engines/{engineId}/workflows`).
10
+ *
11
+ * The host never stubs an engine: each variant constructs the real backend. A
12
+ * translated/remote backend whose host wiring is absent (no Mastra runtime, no
13
+ * Dagster client) still boots and serves the manifest; its catalogue then reports
14
+ * the engine's honest `NOT_SUPPORTED` verdict through the engine facade, exactly
15
+ * as `GraphEngineController` maps it to `501`. The variant is chosen at boot by
16
+ * the `GRAPH_BACKEND_ENGINE` environment variable, so switching engines is a
17
+ * configuration change, never a code change.
18
+ */
19
+ import { GraphExecutionError } from "./../../engine/errors/GraphExecutionError.js";
20
+ import { GraphExecutionBackendRegistry } from "./../../engine/execution/GraphExecutionBackendRegistry.js";
21
+ import { GRAPH_LOCAL_EXECUTION_BACKEND } from "./../../engine/constants.js";
22
+ import { MastraGraphExecutionBackend } from "./../../mastra/MastraGraphExecutionBackend.js";
23
+ import { MASTRA_BACKEND_FLAVOUR, } from "./../../mastra/types.js";
24
+ import { DagsterGraphExecutionBackend } from "./../../dagster/DagsterGraphExecutionBackend.js";
25
+ import { DAGSTER_BACKEND_FLAVOUR } from "./../../dagster/constants.js";
26
+ /** Every bootable engine variant, in manifest order. */
27
+ export const GRAPH_ENGINE_VARIANTS = [
28
+ "local",
29
+ "mastra",
30
+ "dagster",
31
+ ];
32
+ /** Environment variable selecting the engine variant the host boots. */
33
+ export const GRAPH_BACKEND_ENGINE_ENV = "GRAPH_BACKEND_ENGINE";
34
+ /** The engine variant a host boots when none is configured. */
35
+ export const DEFAULT_GRAPH_ENGINE_VARIANT = "local";
36
+ /**
37
+ * Parses a configured engine variant, failing closed on an unknown value so a
38
+ * typo never silently boots the wrong engine.
39
+ *
40
+ * @param value - The raw configured value (`undefined`/empty selects the fallback).
41
+ * @param fallback - The variant to use when no value is configured.
42
+ * @returns The resolved engine variant.
43
+ * @throws {GraphExecutionError} when the value names no known variant.
44
+ */
45
+ export function parseGraphEngineVariant(value, fallback = DEFAULT_GRAPH_ENGINE_VARIANT) {
46
+ if (value === undefined || value.trim() === "")
47
+ return fallback;
48
+ const normalized = value.trim().toLowerCase();
49
+ if (GRAPH_ENGINE_VARIANTS.includes(normalized)) {
50
+ return normalized;
51
+ }
52
+ throw new GraphExecutionError(`Unknown graph engine variant '${value}'; expected one of ${GRAPH_ENGINE_VARIANTS.join(", ")}`, "GRAPH_BACKEND_ENGINE_UNKNOWN", { variant: value });
53
+ }
54
+ /**
55
+ * Reads the engine variant from an environment bag (defaults to `process.env`),
56
+ * applying {@link parseGraphEngineVariant}.
57
+ *
58
+ * @param env - The environment to read from.
59
+ * @returns The resolved engine variant.
60
+ */
61
+ export function graphEngineVariantFromEnv(env = process.env) {
62
+ return parseGraphEngineVariant(env[GRAPH_BACKEND_ENGINE_ENV]);
63
+ }
64
+ /**
65
+ * Constructs and registers the backend for the selected variant. The local
66
+ * variant constructs nothing: the engine's built-in default backend is the
67
+ * reference interpreter, so the host leaves `backend` unset and the engine
68
+ * registers it during boot.
69
+ *
70
+ * @param options - The host options.
71
+ * @returns The constructed backend, or `undefined` for the local variant.
72
+ */
73
+ async function buildGraphBackend(options) {
74
+ switch (options.variant) {
75
+ case "mastra": {
76
+ const backend = new MastraGraphExecutionBackend();
77
+ await backend.initialize(options.mastra ?? {});
78
+ return backend;
79
+ }
80
+ case "dagster": {
81
+ const backend = new DagsterGraphExecutionBackend();
82
+ const wiring = options.dagster ?? {};
83
+ const config = {
84
+ ...(wiring.client ? { client: wiring.client } : {}),
85
+ ...(wiring.executionEnabled !== undefined
86
+ ? { executionEnabled: wiring.executionEnabled }
87
+ : {}),
88
+ ...(wiring.tags ? { tags: wiring.tags } : {}),
89
+ };
90
+ await backend.initialize(config);
91
+ return backend;
92
+ }
93
+ case "local":
94
+ default:
95
+ return undefined;
96
+ }
97
+ }
98
+ /**
99
+ * Builds the bootable graph backend host for one engine variant: constructs and
100
+ * registers the selected backend, selects it as the registry current so the
101
+ * engine facade's default engine follows the variant, and assembles the
102
+ * {@link GraphExecutionModule} options that advertise that engine's capability
103
+ * manifest and per-engine workflow catalogue.
104
+ *
105
+ * @param options - The host options (variant, per-variant wiring, base options).
106
+ * @returns The resolved host, including the module options to boot.
107
+ */
108
+ export async function createGraphBackendHost(options) {
109
+ const { variant } = options;
110
+ const backend = await buildGraphBackend(options);
111
+ // Select the variant as the registry current so the engine facade's default
112
+ // backend (used by `GET /graph/workflows` and the run lifecycle) follows it.
113
+ GraphExecutionBackendRegistry.setCurrent(variant);
114
+ const base = options.base ?? {};
115
+ const moduleOptions = {
116
+ ...base,
117
+ ...(backend ? { backend } : {}),
118
+ engines: {
119
+ ...(base.engines ?? {}),
120
+ defaultEngineId: variant,
121
+ },
122
+ };
123
+ return {
124
+ variant,
125
+ engineId: variant,
126
+ ...(backend ? { backend } : {}),
127
+ moduleOptions,
128
+ };
129
+ }
130
+ /** The allowlisted engine id for a variant (the backend flavour). */
131
+ export function graphEngineIdOf(variant) {
132
+ return variant === "local"
133
+ ? GRAPH_LOCAL_EXECUTION_BACKEND
134
+ : variant === "mastra"
135
+ ? MASTRA_BACKEND_FLAVOUR
136
+ : DAGSTER_BACKEND_FLAVOUR;
137
+ }
138
+ //# sourceMappingURL=GraphBackendHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphBackendHost.js","sourceRoot":"","sources":["../../../../src/nest/graph/GraphBackendHost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,mBAAmB,EAAE,qDAAgD;AAC9E,OAAO,EAAE,6BAA6B,EAAE,kEAA6D;AAErG,OAAO,EAAE,6BAA6B,EAAE,oCAA+B;AACvE,OAAO,EAAE,2BAA2B,EAAE,sDAAiD;AACvF,OAAO,EACL,sBAAsB,GAEvB,gCAA2B;AAC5B,OAAO,EAAE,4BAA4B,EAAE,wDAAmD;AAK1F,OAAO,EAAE,uBAAuB,EAAE,qCAAgC;AAUlE,wDAAwD;AACxD,MAAM,CAAC,MAAM,qBAAqB,GAAkC;IAClE,OAAO;IACP,QAAQ;IACR,SAAS;CACV,CAAC;AAEF,wEAAwE;AACxE,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D,+DAA+D;AAC/D,MAAM,CAAC,MAAM,4BAA4B,GAAuB,OAAO,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAyB,EACzB,WAA+B,4BAA4B;IAE3D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,QAAQ,CAAC;IAChE,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAK,qBAA2C,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACtE,OAAO,UAAgC,CAAC;IAC1C,CAAC;IACD,MAAM,IAAI,mBAAmB,CAC3B,iCAAiC,KAAK,sBAAsB,qBAAqB,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