@decaf-ts/as-graph 0.6.0 → 0.8.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 (1262) hide show
  1. package/README.md +857 -27
  2. package/assets/i18n/en.json +3899 -15
  3. package/dist/as-graph.cjs +1 -1
  4. package/dist/as-graph.cjs.map +1 -1
  5. package/dist/as-graph.js +1 -1
  6. package/dist/as-graph.js.map +1 -1
  7. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs +13 -0
  8. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs.map +1 -1
  9. package/lib/cjs/dagster/capabilities.cjs +5 -0
  10. package/lib/cjs/dagster/capabilities.cjs.map +1 -1
  11. package/lib/cjs/engine/auth/GraphAuthValidator.cjs +19 -0
  12. package/lib/cjs/engine/auth/GraphAuthValidator.cjs.map +1 -1
  13. package/lib/cjs/engine/constants.cjs +61 -1
  14. package/lib/cjs/engine/constants.cjs.map +1 -1
  15. package/lib/cjs/engine/credentials/GraphNodeCredentials.cjs +158 -0
  16. package/lib/cjs/engine/credentials/GraphNodeCredentials.cjs.map +1 -0
  17. package/lib/cjs/engine/execution/GraphCodeMode.cjs +42 -0
  18. package/lib/cjs/engine/execution/GraphCodeMode.cjs.map +1 -1
  19. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs +263 -71
  20. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs.map +1 -1
  21. package/lib/cjs/engine/execution/GraphNodeEngineRequirements.cjs +33 -0
  22. package/lib/cjs/engine/execution/GraphNodeEngineRequirements.cjs.map +1 -0
  23. package/lib/cjs/engine/execution/GraphWebhookResponseRegistry.cjs +108 -0
  24. package/lib/cjs/engine/execution/GraphWebhookResponseRegistry.cjs.map +1 -0
  25. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs +53 -1
  26. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs.map +1 -1
  27. package/lib/cjs/engine/execution/index.cjs +1 -0
  28. package/lib/cjs/engine/execution/index.cjs.map +1 -1
  29. package/lib/cjs/engine/index.cjs +4 -0
  30. package/lib/cjs/engine/index.cjs.map +1 -1
  31. package/lib/cjs/engine/store/GraphDataTableModel.cjs +76 -0
  32. package/lib/cjs/engine/store/GraphDataTableModel.cjs.map +1 -0
  33. package/lib/cjs/engine/store/GraphDataTableRepository.cjs +324 -0
  34. package/lib/cjs/engine/store/GraphDataTableRepository.cjs.map +1 -0
  35. package/lib/cjs/engine/store/index.cjs +2 -0
  36. package/lib/cjs/engine/store/index.cjs.map +1 -1
  37. package/lib/cjs/engine/validation/GraphConnectionPolicyValidator.cjs +28 -0
  38. package/lib/cjs/engine/validation/GraphConnectionPolicyValidator.cjs.map +1 -1
  39. package/lib/cjs/engine/validation/GraphCredentialReferenceValidator.cjs +4 -2
  40. package/lib/cjs/engine/validation/GraphCredentialReferenceValidator.cjs.map +1 -1
  41. package/lib/cjs/engine/validation/GraphNodeInstanceValidator.cjs +29 -1
  42. package/lib/cjs/engine/validation/GraphNodeInstanceValidator.cjs.map +1 -1
  43. package/lib/cjs/engine/validation/GraphParameterValidator.cjs +6 -0
  44. package/lib/cjs/engine/validation/GraphParameterValidator.cjs.map +1 -1
  45. package/lib/cjs/engine/validation/GraphWorkflowDocumentValidator.cjs +6 -2
  46. package/lib/cjs/engine/validation/GraphWorkflowDocumentValidator.cjs.map +1 -1
  47. package/lib/cjs/mastra/MastraAgeVectorDriver.cjs +298 -0
  48. package/lib/cjs/mastra/MastraAgeVectorDriver.cjs.map +1 -0
  49. package/lib/cjs/mastra/MastraAgentBuilder.cjs +249 -0
  50. package/lib/cjs/mastra/MastraAgentBuilder.cjs.map +1 -0
  51. package/lib/cjs/mastra/MastraAgentModelAdapter.cjs +65 -0
  52. package/lib/cjs/mastra/MastraAgentModelAdapter.cjs.map +1 -0
  53. package/lib/cjs/mastra/MastraAgentProcessors.cjs +397 -0
  54. package/lib/cjs/mastra/MastraAgentProcessors.cjs.map +1 -0
  55. package/lib/cjs/mastra/MastraAgentStepHandler.cjs +332 -0
  56. package/lib/cjs/mastra/MastraAgentStepHandler.cjs.map +1 -0
  57. package/lib/cjs/mastra/MastraCapabilities.cjs +115 -0
  58. package/lib/cjs/mastra/MastraCapabilities.cjs.map +1 -1
  59. package/lib/cjs/mastra/MastraChannelResponse.cjs +162 -0
  60. package/lib/cjs/mastra/MastraChannelResponse.cjs.map +1 -0
  61. package/lib/cjs/mastra/MastraChannelTrigger.cjs +124 -0
  62. package/lib/cjs/mastra/MastraChannelTrigger.cjs.map +1 -0
  63. package/lib/cjs/mastra/MastraDefaultStepHandlers.cjs +240 -22
  64. package/lib/cjs/mastra/MastraDefaultStepHandlers.cjs.map +1 -1
  65. package/lib/cjs/mastra/MastraEnvironment.cjs +297 -0
  66. package/lib/cjs/mastra/MastraEnvironment.cjs.map +1 -0
  67. package/lib/cjs/mastra/MastraEvalModels.cjs +546 -0
  68. package/lib/cjs/mastra/MastraEvalModels.cjs.map +1 -0
  69. package/lib/cjs/mastra/MastraEventBridge.cjs +21 -1
  70. package/lib/cjs/mastra/MastraEventBridge.cjs.map +1 -1
  71. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs +414 -19
  72. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs.map +1 -1
  73. package/lib/cjs/mastra/MastraGraphExecutionModule.cjs +148 -0
  74. package/lib/cjs/mastra/MastraGraphExecutionModule.cjs.map +1 -0
  75. package/lib/cjs/mastra/MastraHitlStepHandler.cjs +67 -0
  76. package/lib/cjs/mastra/MastraHitlStepHandler.cjs.map +1 -0
  77. package/lib/cjs/mastra/MastraMcpTrigger.cjs +254 -0
  78. package/lib/cjs/mastra/MastraMcpTrigger.cjs.map +1 -0
  79. package/lib/cjs/mastra/MastraMemory.cjs +467 -0
  80. package/lib/cjs/mastra/MastraMemory.cjs.map +1 -0
  81. package/lib/cjs/mastra/MastraMetricsAdapter.cjs +279 -0
  82. package/lib/cjs/mastra/MastraMetricsAdapter.cjs.map +1 -0
  83. package/lib/cjs/mastra/MastraMetricsGateway.cjs +404 -0
  84. package/lib/cjs/mastra/MastraMetricsGateway.cjs.map +1 -0
  85. package/lib/cjs/mastra/MastraMetricsModels.cjs +498 -0
  86. package/lib/cjs/mastra/MastraMetricsModels.cjs.map +1 -0
  87. package/lib/cjs/mastra/MastraMetricsStatement.cjs +220 -0
  88. package/lib/cjs/mastra/MastraMetricsStatement.cjs.map +1 -0
  89. package/lib/cjs/mastra/MastraModelSchemaConverter.cjs +84 -0
  90. package/lib/cjs/mastra/MastraModelSchemaConverter.cjs.map +1 -0
  91. package/lib/cjs/mastra/MastraObservability.cjs +335 -0
  92. package/lib/cjs/mastra/MastraObservability.cjs.map +1 -0
  93. package/lib/cjs/mastra/MastraPersistence.cjs +545 -0
  94. package/lib/cjs/mastra/MastraPersistence.cjs.map +1 -0
  95. package/lib/cjs/mastra/MastraRagStepHandlers.cjs +927 -0
  96. package/lib/cjs/mastra/MastraRagStepHandlers.cjs.map +1 -0
  97. package/lib/cjs/mastra/MastraRunMetricsEndpoint.cjs +153 -0
  98. package/lib/cjs/mastra/MastraRunMetricsEndpoint.cjs.map +1 -0
  99. package/lib/cjs/mastra/MastraRunRecovery.cjs +94 -0
  100. package/lib/cjs/mastra/MastraRunRecovery.cjs.map +1 -0
  101. package/lib/cjs/mastra/MastraScheduleTrigger.cjs +115 -0
  102. package/lib/cjs/mastra/MastraScheduleTrigger.cjs.map +1 -0
  103. package/lib/cjs/mastra/MastraStorageWiring.cjs +125 -0
  104. package/lib/cjs/mastra/MastraStorageWiring.cjs.map +1 -0
  105. package/lib/cjs/mastra/MastraStructuredOutput.cjs +152 -0
  106. package/lib/cjs/mastra/MastraStructuredOutput.cjs.map +1 -0
  107. package/lib/cjs/mastra/MastraToolBuilder.cjs +73 -0
  108. package/lib/cjs/mastra/MastraToolBuilder.cjs.map +1 -0
  109. package/lib/cjs/mastra/MastraToolConfig.cjs +42 -0
  110. package/lib/cjs/mastra/MastraToolConfig.cjs.map +1 -0
  111. package/lib/cjs/mastra/MastraToolDecorator.cjs +99 -0
  112. package/lib/cjs/mastra/MastraToolDecorator.cjs.map +1 -0
  113. package/lib/cjs/mastra/MastraVectorStore.cjs +618 -0
  114. package/lib/cjs/mastra/MastraVectorStore.cjs.map +1 -0
  115. package/lib/cjs/mastra/MastraVoiceStepHandler.cjs +90 -0
  116. package/lib/cjs/mastra/MastraVoiceStepHandler.cjs.map +1 -0
  117. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs +79 -15
  118. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs.map +1 -1
  119. package/lib/cjs/mastra/MastraWorkflowManager.cjs +100 -50
  120. package/lib/cjs/mastra/MastraWorkflowManager.cjs.map +1 -1
  121. package/lib/cjs/mastra/index.cjs +40 -1
  122. package/lib/cjs/mastra/index.cjs.map +1 -1
  123. package/lib/cjs/mastra/nodes/MastraNodeRegistry.cjs +232 -0
  124. package/lib/cjs/mastra/nodes/MastraNodeRegistry.cjs.map +1 -0
  125. package/lib/cjs/mastra/nodes/index.cjs +29 -0
  126. package/lib/cjs/mastra/nodes/index.cjs.map +1 -0
  127. package/lib/cjs/mastra/nodes/types.cjs +4 -0
  128. package/lib/cjs/mastra/nodes/types.cjs.map +1 -0
  129. package/lib/cjs/mastra/types.cjs +126 -1
  130. package/lib/cjs/mastra/types.cjs.map +1 -1
  131. package/lib/cjs/nest/graph/GraphBackendHost.cjs +12 -4
  132. package/lib/cjs/nest/graph/GraphBackendHost.cjs.map +1 -1
  133. package/lib/cjs/nest/graph/GraphEngineController.cjs +18 -0
  134. package/lib/cjs/nest/graph/GraphEngineController.cjs.map +1 -1
  135. package/lib/cjs/nest/graph/GraphExecutionModule.cjs +35 -1
  136. package/lib/cjs/nest/graph/GraphExecutionModule.cjs.map +1 -1
  137. package/lib/cjs/nest/graph/GraphNodeCatalogueController.cjs +14 -0
  138. package/lib/cjs/nest/graph/GraphNodeCatalogueController.cjs.map +1 -1
  139. package/lib/cjs/nest/graph/GraphRunController.cjs +64 -6
  140. package/lib/cjs/nest/graph/GraphRunController.cjs.map +1 -1
  141. package/lib/cjs/nest/graph/GraphWorkflowController.cjs +34 -5
  142. package/lib/cjs/nest/graph/GraphWorkflowController.cjs.map +1 -1
  143. package/lib/cjs/nest/graph/main.cjs +83 -1
  144. package/lib/cjs/nest/graph/main.cjs.map +1 -1
  145. package/lib/cjs/node/agents/agent/node.cjs +189 -31
  146. package/lib/cjs/node/agents/agent/node.cjs.map +1 -1
  147. package/lib/cjs/node/agents/hitl/node.cjs +115 -0
  148. package/lib/cjs/node/agents/hitl/node.cjs.map +1 -0
  149. package/lib/cjs/node/agents/hooks/delegation/node.cjs +122 -0
  150. package/lib/cjs/node/agents/hooks/delegation/node.cjs.map +1 -0
  151. package/lib/cjs/node/agents/hooks/hook/node.cjs +120 -0
  152. package/lib/cjs/node/agents/hooks/hook/node.cjs.map +1 -0
  153. package/lib/cjs/node/agents/hooks/tool-deny/node.cjs +104 -0
  154. package/lib/cjs/node/agents/hooks/tool-deny/node.cjs.map +1 -0
  155. package/lib/cjs/node/agents/memory/memory/node.cjs +231 -0
  156. package/lib/cjs/node/agents/memory/memory/node.cjs.map +1 -0
  157. package/lib/cjs/node/agents/memory/memory-selector/node.cjs +101 -0
  158. package/lib/cjs/node/agents/memory/memory-selector/node.cjs.map +1 -0
  159. package/lib/cjs/node/agents/processors/guardrail/node.cjs +126 -0
  160. package/lib/cjs/node/agents/processors/guardrail/node.cjs.map +1 -0
  161. package/lib/cjs/node/agents/processors/input-processor/node.cjs +118 -0
  162. package/lib/cjs/node/agents/processors/input-processor/node.cjs.map +1 -0
  163. package/lib/cjs/node/agents/processors/output-processor/node.cjs +108 -0
  164. package/lib/cjs/node/agents/processors/output-processor/node.cjs.map +1 -0
  165. package/lib/cjs/node/agents/processors/types.cjs +68 -0
  166. package/lib/cjs/node/agents/processors/types.cjs.map +1 -0
  167. package/lib/cjs/node/agents/rag/chains/basic/node.cjs +103 -0
  168. package/lib/cjs/node/agents/rag/chains/basic/node.cjs.map +1 -0
  169. package/lib/cjs/node/agents/rag/chains/qa/node.cjs +124 -0
  170. package/lib/cjs/node/agents/rag/chains/qa/node.cjs.map +1 -0
  171. package/lib/cjs/node/agents/rag/chains/summarization/node.cjs +116 -0
  172. package/lib/cjs/node/agents/rag/chains/summarization/node.cjs.map +1 -0
  173. package/lib/cjs/node/agents/rag/chunking/node.cjs +222 -0
  174. package/lib/cjs/node/agents/rag/chunking/node.cjs.map +1 -0
  175. package/lib/cjs/node/agents/rag/embedding/node.cjs +110 -0
  176. package/lib/cjs/node/agents/rag/embedding/node.cjs.map +1 -0
  177. package/lib/cjs/node/agents/rag/information-extractor/node.cjs +115 -0
  178. package/lib/cjs/node/agents/rag/information-extractor/node.cjs.map +1 -0
  179. package/lib/cjs/node/agents/rag/langchain-code/node.cjs +113 -0
  180. package/lib/cjs/node/agents/rag/langchain-code/node.cjs.map +1 -0
  181. package/lib/cjs/node/agents/rag/rerank/node.cjs +112 -0
  182. package/lib/cjs/node/agents/rag/rerank/node.cjs.map +1 -0
  183. package/lib/cjs/node/agents/rag/retriever/node.cjs +120 -0
  184. package/lib/cjs/node/agents/rag/retriever/node.cjs.map +1 -0
  185. package/lib/cjs/node/agents/rag/structured-output-parser/node.cjs +121 -0
  186. package/lib/cjs/node/agents/rag/structured-output-parser/node.cjs.map +1 -0
  187. package/lib/cjs/node/agents/rag/vector-store/node.cjs +187 -0
  188. package/lib/cjs/node/agents/rag/vector-store/node.cjs.map +1 -0
  189. package/lib/cjs/node/agents/responses/discord/node.cjs +101 -0
  190. package/lib/cjs/node/agents/responses/discord/node.cjs.map +1 -0
  191. package/lib/cjs/node/agents/responses/slack/node.cjs +101 -0
  192. package/lib/cjs/node/agents/responses/slack/node.cjs.map +1 -0
  193. package/lib/cjs/node/agents/responses/teams/node.cjs +101 -0
  194. package/lib/cjs/node/agents/responses/teams/node.cjs.map +1 -0
  195. package/lib/cjs/node/agents/responses/telegram/node.cjs +101 -0
  196. package/lib/cjs/node/agents/responses/telegram/node.cjs.map +1 -0
  197. package/lib/cjs/node/agents/sandbox/node.cjs +135 -0
  198. package/lib/cjs/node/agents/sandbox/node.cjs.map +1 -0
  199. package/lib/cjs/node/agents/scorers/scorer/node.cjs +107 -0
  200. package/lib/cjs/node/agents/scorers/scorer/node.cjs.map +1 -0
  201. package/lib/cjs/node/agents/scorers/scorer-selector/node.cjs +100 -0
  202. package/lib/cjs/node/agents/scorers/scorer-selector/node.cjs.map +1 -0
  203. package/lib/cjs/node/agents/skills/skill/node.cjs +105 -0
  204. package/lib/cjs/node/agents/skills/skill/node.cjs.map +1 -0
  205. package/lib/cjs/node/agents/skills/skill-selector/node.cjs +98 -0
  206. package/lib/cjs/node/agents/skills/skill-selector/node.cjs.map +1 -0
  207. package/lib/cjs/node/agents/tools/tool/node.cjs +100 -0
  208. package/lib/cjs/node/agents/tools/tool/node.cjs.map +1 -0
  209. package/lib/cjs/node/agents/tools/tool-selector/node.cjs +99 -0
  210. package/lib/cjs/node/agents/tools/tool-selector/node.cjs.map +1 -0
  211. package/lib/cjs/node/agents/triggers/discord/node.cjs +101 -0
  212. package/lib/cjs/node/agents/triggers/discord/node.cjs.map +1 -0
  213. package/lib/cjs/node/agents/triggers/mcp-server/node.cjs +147 -0
  214. package/lib/cjs/node/agents/triggers/mcp-server/node.cjs.map +1 -0
  215. package/lib/cjs/node/agents/triggers/slack/node.cjs +101 -0
  216. package/lib/cjs/node/agents/triggers/slack/node.cjs.map +1 -0
  217. package/lib/cjs/node/agents/triggers/teams/node.cjs +101 -0
  218. package/lib/cjs/node/agents/triggers/teams/node.cjs.map +1 -0
  219. package/lib/cjs/node/agents/triggers/telegram/node.cjs +101 -0
  220. package/lib/cjs/node/agents/triggers/telegram/node.cjs.map +1 -0
  221. package/lib/cjs/node/agents/voice/node.cjs +107 -0
  222. package/lib/cjs/node/agents/voice/node.cjs.map +1 -0
  223. package/lib/cjs/node/agents/zones.cjs +43 -0
  224. package/lib/cjs/node/agents/zones.cjs.map +1 -0
  225. package/lib/cjs/node/comms/discord/node.cjs +384 -0
  226. package/lib/cjs/node/comms/discord/node.cjs.map +1 -0
  227. package/lib/cjs/node/comms/email-send/node.cjs +340 -0
  228. package/lib/cjs/node/comms/email-send/node.cjs.map +1 -0
  229. package/lib/cjs/node/comms/gmail/node.cjs +287 -0
  230. package/lib/cjs/node/comms/gmail/node.cjs.map +1 -0
  231. package/lib/cjs/node/comms/outlook/node.cjs +395 -0
  232. package/lib/cjs/node/comms/outlook/node.cjs.map +1 -0
  233. package/lib/cjs/node/comms/slack/node.cjs +276 -0
  234. package/lib/cjs/node/comms/slack/node.cjs.map +1 -0
  235. package/lib/cjs/node/comms/teams/node.cjs +231 -0
  236. package/lib/cjs/node/comms/teams/node.cjs.map +1 -0
  237. package/lib/cjs/node/comms/telegram/node.cjs +260 -0
  238. package/lib/cjs/node/comms/telegram/node.cjs.map +1 -0
  239. package/lib/cjs/node/comms/whatsapp/node.cjs +341 -0
  240. package/lib/cjs/node/comms/whatsapp/node.cjs.map +1 -0
  241. package/lib/cjs/node/credentials.cjs +103 -0
  242. package/lib/cjs/node/credentials.cjs.map +1 -0
  243. package/lib/cjs/node/data/aggregate/node.cjs +196 -0
  244. package/lib/cjs/node/data/aggregate/node.cjs.map +1 -0
  245. package/lib/cjs/node/data/compare-datasets/node.cjs +331 -0
  246. package/lib/cjs/node/data/compare-datasets/node.cjs.map +1 -0
  247. package/lib/cjs/node/data/data-table/node.cjs +265 -0
  248. package/lib/cjs/node/data/data-table/node.cjs.map +1 -0
  249. package/lib/cjs/node/data/date-time/node.cjs +180 -0
  250. package/lib/cjs/node/data/date-time/node.cjs.map +1 -0
  251. package/lib/cjs/node/data/filter/node.cjs +134 -0
  252. package/lib/cjs/node/data/filter/node.cjs.map +1 -0
  253. package/lib/cjs/node/data/item-lists/node.cjs +416 -0
  254. package/lib/cjs/node/data/item-lists/node.cjs.map +1 -0
  255. package/lib/cjs/node/data/limit/node.cjs +104 -0
  256. package/lib/cjs/node/data/limit/node.cjs.map +1 -0
  257. package/lib/cjs/node/data/merge/node.cjs +251 -0
  258. package/lib/cjs/node/data/merge/node.cjs.map +1 -0
  259. package/lib/cjs/node/data/remove-duplicates/node.cjs +141 -0
  260. package/lib/cjs/node/data/remove-duplicates/node.cjs.map +1 -0
  261. package/lib/cjs/node/data/rename-keys/node.cjs +139 -0
  262. package/lib/cjs/node/data/rename-keys/node.cjs.map +1 -0
  263. package/lib/cjs/node/data/set/node.cjs +148 -0
  264. package/lib/cjs/node/data/set/node.cjs.map +1 -0
  265. package/lib/cjs/node/data/sort/node.cjs +125 -0
  266. package/lib/cjs/node/data/sort/node.cjs.map +1 -0
  267. package/lib/cjs/node/data/split-out/node.cjs +140 -0
  268. package/lib/cjs/node/data/split-out/node.cjs.map +1 -0
  269. package/lib/cjs/node/data/summarize/node.cjs +155 -0
  270. package/lib/cjs/node/data/summarize/node.cjs.map +1 -0
  271. package/lib/cjs/node/data/support.cjs +403 -0
  272. package/lib/cjs/node/data/support.cjs.map +1 -0
  273. package/lib/cjs/node/data/transform-utils.cjs +719 -0
  274. package/lib/cjs/node/data/transform-utils.cjs.map +1 -0
  275. package/lib/cjs/node/devops/crypto/node.cjs +364 -0
  276. package/lib/cjs/node/devops/crypto/node.cjs.map +1 -0
  277. package/lib/cjs/node/devops/execute-command/node.cjs +201 -0
  278. package/lib/cjs/node/devops/execute-command/node.cjs.map +1 -0
  279. package/lib/cjs/node/devops/ftp/node.cjs +241 -0
  280. package/lib/cjs/node/devops/ftp/node.cjs.map +1 -0
  281. package/lib/cjs/node/devops/github/node.cjs +282 -0
  282. package/lib/cjs/node/devops/github/node.cjs.map +1 -0
  283. package/lib/cjs/node/devops/gitlab/node.cjs +273 -0
  284. package/lib/cjs/node/devops/gitlab/node.cjs.map +1 -0
  285. package/lib/cjs/node/devops/jwt/node.cjs +204 -0
  286. package/lib/cjs/node/devops/jwt/node.cjs.map +1 -0
  287. package/lib/cjs/node/flow/execute-sub-workflow/node.cjs +223 -0
  288. package/lib/cjs/node/flow/execute-sub-workflow/node.cjs.map +1 -0
  289. package/lib/cjs/node/index.cjs +508 -66
  290. package/lib/cjs/node/index.cjs.map +1 -1
  291. package/lib/cjs/node/io/airtable/node.cjs +318 -0
  292. package/lib/cjs/node/io/airtable/node.cjs.map +1 -0
  293. package/lib/cjs/node/io/confluence/node.cjs +253 -0
  294. package/lib/cjs/node/io/confluence/node.cjs.map +1 -0
  295. package/lib/cjs/node/io/convert-to-file/node.cjs +349 -0
  296. package/lib/cjs/node/io/convert-to-file/node.cjs.map +1 -0
  297. package/lib/cjs/node/io/extract-from-file/node.cjs +269 -0
  298. package/lib/cjs/node/io/extract-from-file/node.cjs.map +1 -0
  299. package/lib/cjs/node/io/file-support.cjs +311 -0
  300. package/lib/cjs/node/io/file-support.cjs.map +1 -0
  301. package/lib/cjs/node/io/google-calendar/node.cjs +359 -0
  302. package/lib/cjs/node/io/google-calendar/node.cjs.map +1 -0
  303. package/lib/cjs/node/io/google-docs/node.cjs +272 -0
  304. package/lib/cjs/node/io/google-docs/node.cjs.map +1 -0
  305. package/lib/cjs/node/io/google-sheets/node.cjs +267 -0
  306. package/lib/cjs/node/io/google-sheets/node.cjs.map +1 -0
  307. package/lib/cjs/node/io/graphql/node.cjs +169 -0
  308. package/lib/cjs/node/io/graphql/node.cjs.map +1 -0
  309. package/lib/cjs/node/io/html/node.cjs +275 -0
  310. package/lib/cjs/node/io/html/node.cjs.map +1 -0
  311. package/lib/cjs/node/io/html-extract/node.cjs +162 -0
  312. package/lib/cjs/node/io/html-extract/node.cjs.map +1 -0
  313. package/lib/cjs/node/io/html-support.cjs +246 -0
  314. package/lib/cjs/node/io/html-support.cjs.map +1 -0
  315. package/lib/cjs/node/io/http-request/node.cjs +415 -0
  316. package/lib/cjs/node/io/http-request/node.cjs.map +1 -0
  317. package/lib/cjs/node/io/jira/node.cjs +351 -0
  318. package/lib/cjs/node/io/jira/node.cjs.map +1 -0
  319. package/lib/cjs/node/io/markdown/node.cjs +229 -0
  320. package/lib/cjs/node/io/markdown/node.cjs.map +1 -0
  321. package/lib/cjs/node/io/microsoft-excel/node.cjs +261 -0
  322. package/lib/cjs/node/io/microsoft-excel/node.cjs.map +1 -0
  323. package/lib/cjs/node/io/microsoft-sharepoint/node.cjs +274 -0
  324. package/lib/cjs/node/io/microsoft-sharepoint/node.cjs.map +1 -0
  325. package/lib/cjs/node/io/read-binary-file/node.cjs +114 -0
  326. package/lib/cjs/node/io/read-binary-file/node.cjs.map +1 -0
  327. package/lib/cjs/node/io/read-binary-files/node.cjs +113 -0
  328. package/lib/cjs/node/io/read-binary-files/node.cjs.map +1 -0
  329. package/lib/cjs/node/io/read-pdf/node.cjs +206 -0
  330. package/lib/cjs/node/io/read-pdf/node.cjs.map +1 -0
  331. package/lib/cjs/node/io/read-write-file/node.cjs +314 -0
  332. package/lib/cjs/node/io/read-write-file/node.cjs.map +1 -0
  333. package/lib/cjs/node/io/respond-to-webhook/node.cjs +183 -0
  334. package/lib/cjs/node/io/respond-to-webhook/node.cjs.map +1 -0
  335. package/lib/cjs/node/io/spreadsheet-file/node.cjs +192 -0
  336. package/lib/cjs/node/io/spreadsheet-file/node.cjs.map +1 -0
  337. package/lib/cjs/node/io/write-binary-file/node.cjs +164 -0
  338. package/lib/cjs/node/io/write-binary-file/node.cjs.map +1 -0
  339. package/lib/cjs/node/io/xml/node.cjs +322 -0
  340. package/lib/cjs/node/io/xml/node.cjs.map +1 -0
  341. package/lib/cjs/node/manifests.cjs +322 -36
  342. package/lib/cjs/node/manifests.cjs.map +1 -1
  343. package/lib/cjs/node/storage/blob/azure/node.cjs +138 -0
  344. package/lib/cjs/node/storage/blob/azure/node.cjs.map +1 -0
  345. package/lib/cjs/node/storage/blob/base.cjs +321 -0
  346. package/lib/cjs/node/storage/blob/base.cjs.map +1 -0
  347. package/lib/cjs/node/storage/blob/gcs/node.cjs +126 -0
  348. package/lib/cjs/node/storage/blob/gcs/node.cjs.map +1 -0
  349. package/lib/cjs/node/storage/blob/s3/node.cjs +186 -0
  350. package/lib/cjs/node/storage/blob/s3/node.cjs.map +1 -0
  351. package/lib/cjs/node/storage/database/base.cjs +301 -0
  352. package/lib/cjs/node/storage/database/base.cjs.map +1 -0
  353. package/lib/cjs/node/storage/database/mssql/node.cjs +50 -0
  354. package/lib/cjs/node/storage/database/mssql/node.cjs.map +1 -0
  355. package/lib/cjs/node/storage/database/mysql/node.cjs +50 -0
  356. package/lib/cjs/node/storage/database/mysql/node.cjs.map +1 -0
  357. package/lib/cjs/node/storage/database/postgres/node.cjs +50 -0
  358. package/lib/cjs/node/storage/database/postgres/node.cjs.map +1 -0
  359. package/lib/cjs/node/storage/rabbitmq/node.cjs +252 -0
  360. package/lib/cjs/node/storage/rabbitmq/node.cjs.map +1 -0
  361. package/lib/cjs/node/storage/redis/node.cjs +340 -0
  362. package/lib/cjs/node/storage/redis/node.cjs.map +1 -0
  363. package/lib/cjs/node/storage/support.cjs +81 -0
  364. package/lib/cjs/node/storage/support.cjs.map +1 -0
  365. package/lib/cjs/node/triggers/error/node.cjs +108 -0
  366. package/lib/cjs/node/triggers/error/node.cjs.map +1 -0
  367. package/lib/cjs/node/triggers/execute-workflow/node.cjs +94 -0
  368. package/lib/cjs/node/triggers/execute-workflow/node.cjs.map +1 -0
  369. package/lib/cjs/node/triggers/postgres/node.cjs +244 -0
  370. package/lib/cjs/node/triggers/postgres/node.cjs.map +1 -0
  371. package/lib/cjs/node/triggers/rabbitmq/node.cjs +284 -0
  372. package/lib/cjs/node/triggers/rabbitmq/node.cjs.map +1 -0
  373. package/lib/cjs/node/triggers/redis/node.cjs +233 -0
  374. package/lib/cjs/node/triggers/redis/node.cjs.map +1 -0
  375. package/lib/cjs/node/triggers/sse/node.cjs +196 -0
  376. package/lib/cjs/node/triggers/sse/node.cjs.map +1 -0
  377. package/lib/cjs/node/triggers/support.cjs +107 -0
  378. package/lib/cjs/node/triggers/support.cjs.map +1 -0
  379. package/lib/cjs/node/triggers/workflow/node.cjs +193 -0
  380. package/lib/cjs/node/triggers/workflow/node.cjs.map +1 -0
  381. package/lib/cjs/ram/GraphRunEventModel.cjs +4 -0
  382. package/lib/cjs/ram/GraphRunEventModel.cjs.map +1 -1
  383. package/lib/cjs/shared/graph/GraphNodeModel.cjs +4 -0
  384. package/lib/cjs/shared/graph/GraphNodeModel.cjs.map +1 -1
  385. package/lib/cjs/shared/graph/GraphWorkflowModel.cjs +4 -0
  386. package/lib/cjs/shared/graph/GraphWorkflowModel.cjs.map +1 -1
  387. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs +40 -0
  388. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs.map +1 -1
  389. package/lib/cjs/shared/graph/catalog/GraphValueSchemaDerivation.cjs +20 -3
  390. package/lib/cjs/shared/graph/catalog/GraphValueSchemaDerivation.cjs.map +1 -1
  391. package/lib/cjs/shared/graph/category-styles.cjs +12 -0
  392. package/lib/cjs/shared/graph/category-styles.cjs.map +1 -1
  393. package/lib/cjs/typeorm/TypeormGraphAdapter.cjs +250 -0
  394. package/lib/cjs/typeorm/TypeormGraphAdapter.cjs.map +1 -0
  395. package/lib/cjs/typeorm/index.cjs +29 -0
  396. package/lib/cjs/typeorm/index.cjs.map +1 -0
  397. package/lib/cjs/workflows/boundary-value.workflow.cjs +38 -0
  398. package/lib/cjs/workflows/boundary-value.workflow.cjs.map +1 -0
  399. package/lib/cjs/workflows/builders.cjs +47 -0
  400. package/lib/cjs/workflows/builders.cjs.map +1 -0
  401. package/lib/cjs/workflows/chat-agent.workflow.cjs +40 -0
  402. package/lib/cjs/workflows/chat-agent.workflow.cjs.map +1 -0
  403. package/lib/cjs/workflows/error-boundary.workflow.cjs +54 -0
  404. package/lib/cjs/workflows/error-boundary.workflow.cjs.map +1 -0
  405. package/lib/cjs/workflows/event-map.workflow.cjs +37 -0
  406. package/lib/cjs/workflows/event-map.workflow.cjs.map +1 -0
  407. package/lib/cjs/workflows/foreach-break.workflow.cjs +58 -0
  408. package/lib/cjs/workflows/foreach-break.workflow.cjs.map +1 -0
  409. package/lib/cjs/workflows/human-approval.workflow.cjs +44 -0
  410. package/lib/cjs/workflows/human-approval.workflow.cjs.map +1 -0
  411. package/lib/cjs/workflows/if-switch.workflow.cjs +66 -0
  412. package/lib/cjs/workflows/if-switch.workflow.cjs.map +1 -0
  413. package/lib/cjs/workflows/index.cjs +135 -0
  414. package/lib/cjs/workflows/index.cjs.map +1 -0
  415. package/lib/cjs/workflows/loops-while-until.workflow.cjs +76 -0
  416. package/lib/cjs/workflows/loops-while-until.workflow.cjs.map +1 -0
  417. package/lib/cjs/workflows/manual-log.workflow.cjs +52 -0
  418. package/lib/cjs/workflows/manual-log.workflow.cjs.map +1 -0
  419. package/lib/cjs/workflows/schedule-code.workflow.cjs +42 -0
  420. package/lib/cjs/workflows/schedule-code.workflow.cjs.map +1 -0
  421. package/lib/cjs/workflows/types.cjs +4 -0
  422. package/lib/cjs/workflows/types.cjs.map +1 -0
  423. package/lib/cjs/workflows/value-templates.workflow.cjs +43 -0
  424. package/lib/cjs/workflows/value-templates.workflow.cjs.map +1 -0
  425. package/lib/cjs/workflows/webhook-form.workflow.cjs +48 -0
  426. package/lib/cjs/workflows/webhook-form.workflow.cjs.map +1 -0
  427. package/lib/esm/dagster/DagsterGraphExecutionBackend.js +13 -0
  428. package/lib/esm/dagster/DagsterGraphExecutionBackend.js.map +1 -1
  429. package/lib/esm/dagster/capabilities.js +5 -0
  430. package/lib/esm/dagster/capabilities.js.map +1 -1
  431. package/lib/esm/engine/auth/GraphAuthValidator.js +19 -0
  432. package/lib/esm/engine/auth/GraphAuthValidator.js.map +1 -1
  433. package/lib/esm/engine/constants.js +60 -0
  434. package/lib/esm/engine/constants.js.map +1 -1
  435. package/lib/esm/engine/credentials/GraphNodeCredentials.js +152 -0
  436. package/lib/esm/engine/credentials/GraphNodeCredentials.js.map +1 -0
  437. package/lib/esm/engine/execution/GraphCodeMode.js +40 -0
  438. package/lib/esm/engine/execution/GraphCodeMode.js.map +1 -1
  439. package/lib/esm/engine/execution/GraphExecutionBackend.js.map +1 -1
  440. package/lib/esm/engine/execution/GraphExecutionEngine.js +265 -73
  441. package/lib/esm/engine/execution/GraphExecutionEngine.js.map +1 -1
  442. package/lib/esm/engine/execution/GraphNodeEngineRequirements.js +28 -0
  443. package/lib/esm/engine/execution/GraphNodeEngineRequirements.js.map +1 -0
  444. package/lib/esm/engine/execution/GraphWebhookResponseRegistry.js +103 -0
  445. package/lib/esm/engine/execution/GraphWebhookResponseRegistry.js.map +1 -0
  446. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js +54 -2
  447. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js.map +1 -1
  448. package/lib/esm/engine/execution/index.js +1 -0
  449. package/lib/esm/engine/execution/index.js.map +1 -1
  450. package/lib/esm/engine/index.js +4 -0
  451. package/lib/esm/engine/index.js.map +1 -1
  452. package/lib/esm/engine/store/GraphDataTableModel.js +67 -0
  453. package/lib/esm/engine/store/GraphDataTableModel.js.map +1 -0
  454. package/lib/esm/engine/store/GraphDataTableRepository.js +314 -0
  455. package/lib/esm/engine/store/GraphDataTableRepository.js.map +1 -0
  456. package/lib/esm/engine/store/index.js +2 -0
  457. package/lib/esm/engine/store/index.js.map +1 -1
  458. package/lib/esm/engine/validation/GraphConnectionPolicyValidator.js +28 -0
  459. package/lib/esm/engine/validation/GraphConnectionPolicyValidator.js.map +1 -1
  460. package/lib/esm/engine/validation/GraphCredentialReferenceValidator.js +4 -2
  461. package/lib/esm/engine/validation/GraphCredentialReferenceValidator.js.map +1 -1
  462. package/lib/esm/engine/validation/GraphNodeInstanceValidator.js +29 -1
  463. package/lib/esm/engine/validation/GraphNodeInstanceValidator.js.map +1 -1
  464. package/lib/esm/engine/validation/GraphParameterValidator.js +6 -0
  465. package/lib/esm/engine/validation/GraphParameterValidator.js.map +1 -1
  466. package/lib/esm/engine/validation/GraphWorkflowDocumentValidator.js +6 -2
  467. package/lib/esm/engine/validation/GraphWorkflowDocumentValidator.js.map +1 -1
  468. package/lib/esm/mastra/MastraAgeVectorDriver.js +294 -0
  469. package/lib/esm/mastra/MastraAgeVectorDriver.js.map +1 -0
  470. package/lib/esm/mastra/MastraAgentBuilder.js +244 -0
  471. package/lib/esm/mastra/MastraAgentBuilder.js.map +1 -0
  472. package/lib/esm/mastra/MastraAgentModelAdapter.js +59 -0
  473. package/lib/esm/mastra/MastraAgentModelAdapter.js.map +1 -0
  474. package/lib/esm/mastra/MastraAgentProcessors.js +391 -0
  475. package/lib/esm/mastra/MastraAgentProcessors.js.map +1 -0
  476. package/lib/esm/mastra/MastraAgentStepHandler.js +327 -0
  477. package/lib/esm/mastra/MastraAgentStepHandler.js.map +1 -0
  478. package/lib/esm/mastra/MastraCapabilities.js +115 -0
  479. package/lib/esm/mastra/MastraCapabilities.js.map +1 -1
  480. package/lib/esm/mastra/MastraChannelResponse.js +154 -0
  481. package/lib/esm/mastra/MastraChannelResponse.js.map +1 -0
  482. package/lib/esm/mastra/MastraChannelTrigger.js +116 -0
  483. package/lib/esm/mastra/MastraChannelTrigger.js.map +1 -0
  484. package/lib/esm/mastra/MastraDefaultStepHandlers.js +240 -22
  485. package/lib/esm/mastra/MastraDefaultStepHandlers.js.map +1 -1
  486. package/lib/esm/mastra/MastraEnvironment.js +287 -0
  487. package/lib/esm/mastra/MastraEnvironment.js.map +1 -0
  488. package/lib/esm/mastra/MastraEvalModels.js +535 -0
  489. package/lib/esm/mastra/MastraEvalModels.js.map +1 -0
  490. package/lib/esm/mastra/MastraEventBridge.js +21 -1
  491. package/lib/esm/mastra/MastraEventBridge.js.map +1 -1
  492. package/lib/esm/mastra/MastraGraphExecutionBackend.js +414 -19
  493. package/lib/esm/mastra/MastraGraphExecutionBackend.js.map +1 -1
  494. package/lib/esm/mastra/MastraGraphExecutionModule.js +139 -0
  495. package/lib/esm/mastra/MastraGraphExecutionModule.js.map +1 -0
  496. package/lib/esm/mastra/MastraHitlStepHandler.js +62 -0
  497. package/lib/esm/mastra/MastraHitlStepHandler.js.map +1 -0
  498. package/lib/esm/mastra/MastraMcpTrigger.js +246 -0
  499. package/lib/esm/mastra/MastraMcpTrigger.js.map +1 -0
  500. package/lib/esm/mastra/MastraMemory.js +455 -0
  501. package/lib/esm/mastra/MastraMemory.js.map +1 -0
  502. package/lib/esm/mastra/MastraMetricsAdapter.js +273 -0
  503. package/lib/esm/mastra/MastraMetricsAdapter.js.map +1 -0
  504. package/lib/esm/mastra/MastraMetricsGateway.js +394 -0
  505. package/lib/esm/mastra/MastraMetricsGateway.js.map +1 -0
  506. package/lib/esm/mastra/MastraMetricsModels.js +486 -0
  507. package/lib/esm/mastra/MastraMetricsModels.js.map +1 -0
  508. package/lib/esm/mastra/MastraMetricsStatement.js +213 -0
  509. package/lib/esm/mastra/MastraMetricsStatement.js.map +1 -0
  510. package/lib/esm/mastra/MastraModelSchemaConverter.js +78 -0
  511. package/lib/esm/mastra/MastraModelSchemaConverter.js.map +1 -0
  512. package/lib/esm/mastra/MastraObservability.js +327 -0
  513. package/lib/esm/mastra/MastraObservability.js.map +1 -0
  514. package/lib/esm/mastra/MastraPersistence.js +530 -0
  515. package/lib/esm/mastra/MastraPersistence.js.map +1 -0
  516. package/lib/esm/mastra/MastraRagStepHandlers.js +920 -0
  517. package/lib/esm/mastra/MastraRagStepHandlers.js.map +1 -0
  518. package/lib/esm/mastra/MastraRunMetricsEndpoint.js +147 -0
  519. package/lib/esm/mastra/MastraRunMetricsEndpoint.js.map +1 -0
  520. package/lib/esm/mastra/MastraRunRecovery.js +89 -0
  521. package/lib/esm/mastra/MastraRunRecovery.js.map +1 -0
  522. package/lib/esm/mastra/MastraScheduleTrigger.js +110 -0
  523. package/lib/esm/mastra/MastraScheduleTrigger.js.map +1 -0
  524. package/lib/esm/mastra/MastraStorageWiring.js +119 -0
  525. package/lib/esm/mastra/MastraStorageWiring.js.map +1 -0
  526. package/lib/esm/mastra/MastraStructuredOutput.js +144 -0
  527. package/lib/esm/mastra/MastraStructuredOutput.js.map +1 -0
  528. package/lib/esm/mastra/MastraToolBuilder.js +68 -0
  529. package/lib/esm/mastra/MastraToolBuilder.js.map +1 -0
  530. package/lib/esm/mastra/MastraToolConfig.js +37 -0
  531. package/lib/esm/mastra/MastraToolConfig.js.map +1 -0
  532. package/lib/esm/mastra/MastraToolDecorator.js +92 -0
  533. package/lib/esm/mastra/MastraToolDecorator.js.map +1 -0
  534. package/lib/esm/mastra/MastraVectorStore.js +605 -0
  535. package/lib/esm/mastra/MastraVectorStore.js.map +1 -0
  536. package/lib/esm/mastra/MastraVoiceStepHandler.js +84 -0
  537. package/lib/esm/mastra/MastraVoiceStepHandler.js.map +1 -0
  538. package/lib/esm/mastra/MastraWorkflowCompiler.js +79 -15
  539. package/lib/esm/mastra/MastraWorkflowCompiler.js.map +1 -1
  540. package/lib/esm/mastra/MastraWorkflowManager.js +101 -51
  541. package/lib/esm/mastra/MastraWorkflowManager.js.map +1 -1
  542. package/lib/esm/mastra/index.js +40 -1
  543. package/lib/esm/mastra/index.js.map +1 -1
  544. package/lib/esm/mastra/nodes/MastraNodeRegistry.js +225 -0
  545. package/lib/esm/mastra/nodes/MastraNodeRegistry.js.map +1 -0
  546. package/lib/esm/mastra/nodes/index.js +12 -0
  547. package/lib/esm/mastra/nodes/index.js.map +1 -0
  548. package/lib/esm/mastra/nodes/types.js +2 -0
  549. package/lib/esm/mastra/nodes/types.js.map +1 -0
  550. package/lib/esm/mastra/types.js +125 -0
  551. package/lib/esm/mastra/types.js.map +1 -1
  552. package/lib/esm/nest/graph/GraphBackendHost.js +10 -2
  553. package/lib/esm/nest/graph/GraphBackendHost.js.map +1 -1
  554. package/lib/esm/nest/graph/GraphEngineController.js +19 -1
  555. package/lib/esm/nest/graph/GraphEngineController.js.map +1 -1
  556. package/lib/esm/nest/graph/GraphExecutionModule.js +35 -1
  557. package/lib/esm/nest/graph/GraphExecutionModule.js.map +1 -1
  558. package/lib/esm/nest/graph/GraphNodeCatalogueController.js +15 -1
  559. package/lib/esm/nest/graph/GraphNodeCatalogueController.js.map +1 -1
  560. package/lib/esm/nest/graph/GraphRunController.js +65 -7
  561. package/lib/esm/nest/graph/GraphRunController.js.map +1 -1
  562. package/lib/esm/nest/graph/GraphWorkflowController.js +35 -6
  563. package/lib/esm/nest/graph/GraphWorkflowController.js.map +1 -1
  564. package/lib/esm/nest/graph/main.js +83 -1
  565. package/lib/esm/nest/graph/main.js.map +1 -1
  566. package/lib/esm/node/agents/agent/node.js +189 -31
  567. package/lib/esm/node/agents/agent/node.js.map +1 -1
  568. package/lib/esm/node/agents/hitl/node.js +106 -0
  569. package/lib/esm/node/agents/hitl/node.js.map +1 -0
  570. package/lib/esm/node/agents/hooks/delegation/node.js +113 -0
  571. package/lib/esm/node/agents/hooks/delegation/node.js.map +1 -0
  572. package/lib/esm/node/agents/hooks/hook/node.js +111 -0
  573. package/lib/esm/node/agents/hooks/hook/node.js.map +1 -0
  574. package/lib/esm/node/agents/hooks/tool-deny/node.js +95 -0
  575. package/lib/esm/node/agents/hooks/tool-deny/node.js.map +1 -0
  576. package/lib/esm/node/agents/memory/memory/node.js +222 -0
  577. package/lib/esm/node/agents/memory/memory/node.js.map +1 -0
  578. package/lib/esm/node/agents/memory/memory-selector/node.js +92 -0
  579. package/lib/esm/node/agents/memory/memory-selector/node.js.map +1 -0
  580. package/lib/esm/node/agents/processors/guardrail/node.js +117 -0
  581. package/lib/esm/node/agents/processors/guardrail/node.js.map +1 -0
  582. package/lib/esm/node/agents/processors/input-processor/node.js +109 -0
  583. package/lib/esm/node/agents/processors/input-processor/node.js.map +1 -0
  584. package/lib/esm/node/agents/processors/output-processor/node.js +99 -0
  585. package/lib/esm/node/agents/processors/output-processor/node.js.map +1 -0
  586. package/lib/esm/node/agents/processors/types.js +64 -0
  587. package/lib/esm/node/agents/processors/types.js.map +1 -0
  588. package/lib/esm/node/agents/rag/chains/basic/node.js +94 -0
  589. package/lib/esm/node/agents/rag/chains/basic/node.js.map +1 -0
  590. package/lib/esm/node/agents/rag/chains/qa/node.js +115 -0
  591. package/lib/esm/node/agents/rag/chains/qa/node.js.map +1 -0
  592. package/lib/esm/node/agents/rag/chains/summarization/node.js +107 -0
  593. package/lib/esm/node/agents/rag/chains/summarization/node.js.map +1 -0
  594. package/lib/esm/node/agents/rag/chunking/node.js +211 -0
  595. package/lib/esm/node/agents/rag/chunking/node.js.map +1 -0
  596. package/lib/esm/node/agents/rag/embedding/node.js +101 -0
  597. package/lib/esm/node/agents/rag/embedding/node.js.map +1 -0
  598. package/lib/esm/node/agents/rag/information-extractor/node.js +106 -0
  599. package/lib/esm/node/agents/rag/information-extractor/node.js.map +1 -0
  600. package/lib/esm/node/agents/rag/langchain-code/node.js +104 -0
  601. package/lib/esm/node/agents/rag/langchain-code/node.js.map +1 -0
  602. package/lib/esm/node/agents/rag/rerank/node.js +103 -0
  603. package/lib/esm/node/agents/rag/rerank/node.js.map +1 -0
  604. package/lib/esm/node/agents/rag/retriever/node.js +111 -0
  605. package/lib/esm/node/agents/rag/retriever/node.js.map +1 -0
  606. package/lib/esm/node/agents/rag/structured-output-parser/node.js +112 -0
  607. package/lib/esm/node/agents/rag/structured-output-parser/node.js.map +1 -0
  608. package/lib/esm/node/agents/rag/vector-store/node.js +178 -0
  609. package/lib/esm/node/agents/rag/vector-store/node.js.map +1 -0
  610. package/lib/esm/node/agents/responses/discord/node.js +92 -0
  611. package/lib/esm/node/agents/responses/discord/node.js.map +1 -0
  612. package/lib/esm/node/agents/responses/slack/node.js +92 -0
  613. package/lib/esm/node/agents/responses/slack/node.js.map +1 -0
  614. package/lib/esm/node/agents/responses/teams/node.js +92 -0
  615. package/lib/esm/node/agents/responses/teams/node.js.map +1 -0
  616. package/lib/esm/node/agents/responses/telegram/node.js +92 -0
  617. package/lib/esm/node/agents/responses/telegram/node.js.map +1 -0
  618. package/lib/esm/node/agents/sandbox/node.js +125 -0
  619. package/lib/esm/node/agents/sandbox/node.js.map +1 -0
  620. package/lib/esm/node/agents/scorers/scorer/node.js +98 -0
  621. package/lib/esm/node/agents/scorers/scorer/node.js.map +1 -0
  622. package/lib/esm/node/agents/scorers/scorer-selector/node.js +91 -0
  623. package/lib/esm/node/agents/scorers/scorer-selector/node.js.map +1 -0
  624. package/lib/esm/node/agents/skills/skill/node.js +96 -0
  625. package/lib/esm/node/agents/skills/skill/node.js.map +1 -0
  626. package/lib/esm/node/agents/skills/skill-selector/node.js +89 -0
  627. package/lib/esm/node/agents/skills/skill-selector/node.js.map +1 -0
  628. package/lib/esm/node/agents/tools/tool/node.js +91 -0
  629. package/lib/esm/node/agents/tools/tool/node.js.map +1 -0
  630. package/lib/esm/node/agents/tools/tool-selector/node.js +90 -0
  631. package/lib/esm/node/agents/tools/tool-selector/node.js.map +1 -0
  632. package/lib/esm/node/agents/triggers/discord/node.js +92 -0
  633. package/lib/esm/node/agents/triggers/discord/node.js.map +1 -0
  634. package/lib/esm/node/agents/triggers/mcp-server/node.js +138 -0
  635. package/lib/esm/node/agents/triggers/mcp-server/node.js.map +1 -0
  636. package/lib/esm/node/agents/triggers/slack/node.js +92 -0
  637. package/lib/esm/node/agents/triggers/slack/node.js.map +1 -0
  638. package/lib/esm/node/agents/triggers/teams/node.js +92 -0
  639. package/lib/esm/node/agents/triggers/teams/node.js.map +1 -0
  640. package/lib/esm/node/agents/triggers/telegram/node.js +92 -0
  641. package/lib/esm/node/agents/triggers/telegram/node.js.map +1 -0
  642. package/lib/esm/node/agents/voice/node.js +98 -0
  643. package/lib/esm/node/agents/voice/node.js.map +1 -0
  644. package/lib/esm/node/agents/zones.js +39 -0
  645. package/lib/esm/node/agents/zones.js.map +1 -0
  646. package/lib/esm/node/comms/discord/node.js +375 -0
  647. package/lib/esm/node/comms/discord/node.js.map +1 -0
  648. package/lib/esm/node/comms/email-send/node.js +331 -0
  649. package/lib/esm/node/comms/email-send/node.js.map +1 -0
  650. package/lib/esm/node/comms/gmail/node.js +278 -0
  651. package/lib/esm/node/comms/gmail/node.js.map +1 -0
  652. package/lib/esm/node/comms/outlook/node.js +386 -0
  653. package/lib/esm/node/comms/outlook/node.js.map +1 -0
  654. package/lib/esm/node/comms/slack/node.js +267 -0
  655. package/lib/esm/node/comms/slack/node.js.map +1 -0
  656. package/lib/esm/node/comms/teams/node.js +222 -0
  657. package/lib/esm/node/comms/teams/node.js.map +1 -0
  658. package/lib/esm/node/comms/telegram/node.js +251 -0
  659. package/lib/esm/node/comms/telegram/node.js.map +1 -0
  660. package/lib/esm/node/comms/whatsapp/node.js +332 -0
  661. package/lib/esm/node/comms/whatsapp/node.js.map +1 -0
  662. package/lib/esm/node/credentials.js +96 -0
  663. package/lib/esm/node/credentials.js.map +1 -0
  664. package/lib/esm/node/data/aggregate/node.js +187 -0
  665. package/lib/esm/node/data/aggregate/node.js.map +1 -0
  666. package/lib/esm/node/data/compare-datasets/node.js +322 -0
  667. package/lib/esm/node/data/compare-datasets/node.js.map +1 -0
  668. package/lib/esm/node/data/data-table/node.js +256 -0
  669. package/lib/esm/node/data/data-table/node.js.map +1 -0
  670. package/lib/esm/node/data/date-time/node.js +171 -0
  671. package/lib/esm/node/data/date-time/node.js.map +1 -0
  672. package/lib/esm/node/data/filter/node.js +125 -0
  673. package/lib/esm/node/data/filter/node.js.map +1 -0
  674. package/lib/esm/node/data/item-lists/node.js +407 -0
  675. package/lib/esm/node/data/item-lists/node.js.map +1 -0
  676. package/lib/esm/node/data/limit/node.js +95 -0
  677. package/lib/esm/node/data/limit/node.js.map +1 -0
  678. package/lib/esm/node/data/merge/node.js +242 -0
  679. package/lib/esm/node/data/merge/node.js.map +1 -0
  680. package/lib/esm/node/data/remove-duplicates/node.js +132 -0
  681. package/lib/esm/node/data/remove-duplicates/node.js.map +1 -0
  682. package/lib/esm/node/data/rename-keys/node.js +130 -0
  683. package/lib/esm/node/data/rename-keys/node.js.map +1 -0
  684. package/lib/esm/node/data/set/node.js +139 -0
  685. package/lib/esm/node/data/set/node.js.map +1 -0
  686. package/lib/esm/node/data/sort/node.js +116 -0
  687. package/lib/esm/node/data/sort/node.js.map +1 -0
  688. package/lib/esm/node/data/split-out/node.js +131 -0
  689. package/lib/esm/node/data/split-out/node.js.map +1 -0
  690. package/lib/esm/node/data/summarize/node.js +146 -0
  691. package/lib/esm/node/data/summarize/node.js.map +1 -0
  692. package/lib/esm/node/data/support.js +386 -0
  693. package/lib/esm/node/data/support.js.map +1 -0
  694. package/lib/esm/node/data/transform-utils.js +702 -0
  695. package/lib/esm/node/data/transform-utils.js.map +1 -0
  696. package/lib/esm/node/devops/crypto/node.js +355 -0
  697. package/lib/esm/node/devops/crypto/node.js.map +1 -0
  698. package/lib/esm/node/devops/execute-command/node.js +192 -0
  699. package/lib/esm/node/devops/execute-command/node.js.map +1 -0
  700. package/lib/esm/node/devops/ftp/node.js +232 -0
  701. package/lib/esm/node/devops/ftp/node.js.map +1 -0
  702. package/lib/esm/node/devops/github/node.js +273 -0
  703. package/lib/esm/node/devops/github/node.js.map +1 -0
  704. package/lib/esm/node/devops/gitlab/node.js +264 -0
  705. package/lib/esm/node/devops/gitlab/node.js.map +1 -0
  706. package/lib/esm/node/devops/jwt/node.js +195 -0
  707. package/lib/esm/node/devops/jwt/node.js.map +1 -0
  708. package/lib/esm/node/flow/execute-sub-workflow/node.js +214 -0
  709. package/lib/esm/node/flow/execute-sub-workflow/node.js.map +1 -0
  710. package/lib/esm/node/index.js +444 -2
  711. package/lib/esm/node/index.js.map +1 -1
  712. package/lib/esm/node/io/airtable/node.js +309 -0
  713. package/lib/esm/node/io/airtable/node.js.map +1 -0
  714. package/lib/esm/node/io/confluence/node.js +244 -0
  715. package/lib/esm/node/io/confluence/node.js.map +1 -0
  716. package/lib/esm/node/io/convert-to-file/node.js +340 -0
  717. package/lib/esm/node/io/convert-to-file/node.js.map +1 -0
  718. package/lib/esm/node/io/extract-from-file/node.js +260 -0
  719. package/lib/esm/node/io/extract-from-file/node.js.map +1 -0
  720. package/lib/esm/node/io/file-support.js +299 -0
  721. package/lib/esm/node/io/file-support.js.map +1 -0
  722. package/lib/esm/node/io/google-calendar/node.js +350 -0
  723. package/lib/esm/node/io/google-calendar/node.js.map +1 -0
  724. package/lib/esm/node/io/google-docs/node.js +263 -0
  725. package/lib/esm/node/io/google-docs/node.js.map +1 -0
  726. package/lib/esm/node/io/google-sheets/node.js +258 -0
  727. package/lib/esm/node/io/google-sheets/node.js.map +1 -0
  728. package/lib/esm/node/io/graphql/node.js +160 -0
  729. package/lib/esm/node/io/graphql/node.js.map +1 -0
  730. package/lib/esm/node/io/html/node.js +266 -0
  731. package/lib/esm/node/io/html/node.js.map +1 -0
  732. package/lib/esm/node/io/html-extract/node.js +153 -0
  733. package/lib/esm/node/io/html-extract/node.js.map +1 -0
  734. package/lib/esm/node/io/html-support.js +206 -0
  735. package/lib/esm/node/io/html-support.js.map +1 -0
  736. package/lib/esm/node/io/http-request/node.js +406 -0
  737. package/lib/esm/node/io/http-request/node.js.map +1 -0
  738. package/lib/esm/node/io/jira/node.js +342 -0
  739. package/lib/esm/node/io/jira/node.js.map +1 -0
  740. package/lib/esm/node/io/markdown/node.js +217 -0
  741. package/lib/esm/node/io/markdown/node.js.map +1 -0
  742. package/lib/esm/node/io/microsoft-excel/node.js +252 -0
  743. package/lib/esm/node/io/microsoft-excel/node.js.map +1 -0
  744. package/lib/esm/node/io/microsoft-sharepoint/node.js +265 -0
  745. package/lib/esm/node/io/microsoft-sharepoint/node.js.map +1 -0
  746. package/lib/esm/node/io/read-binary-file/node.js +105 -0
  747. package/lib/esm/node/io/read-binary-file/node.js.map +1 -0
  748. package/lib/esm/node/io/read-binary-files/node.js +104 -0
  749. package/lib/esm/node/io/read-binary-files/node.js.map +1 -0
  750. package/lib/esm/node/io/read-pdf/node.js +164 -0
  751. package/lib/esm/node/io/read-pdf/node.js.map +1 -0
  752. package/lib/esm/node/io/read-write-file/node.js +305 -0
  753. package/lib/esm/node/io/read-write-file/node.js.map +1 -0
  754. package/lib/esm/node/io/respond-to-webhook/node.js +174 -0
  755. package/lib/esm/node/io/respond-to-webhook/node.js.map +1 -0
  756. package/lib/esm/node/io/spreadsheet-file/node.js +183 -0
  757. package/lib/esm/node/io/spreadsheet-file/node.js.map +1 -0
  758. package/lib/esm/node/io/write-binary-file/node.js +155 -0
  759. package/lib/esm/node/io/write-binary-file/node.js.map +1 -0
  760. package/lib/esm/node/io/xml/node.js +313 -0
  761. package/lib/esm/node/io/xml/node.js.map +1 -0
  762. package/lib/esm/node/manifests.js +286 -0
  763. package/lib/esm/node/manifests.js.map +1 -1
  764. package/lib/esm/node/storage/blob/azure/node.js +129 -0
  765. package/lib/esm/node/storage/blob/azure/node.js.map +1 -0
  766. package/lib/esm/node/storage/blob/base.js +311 -0
  767. package/lib/esm/node/storage/blob/base.js.map +1 -0
  768. package/lib/esm/node/storage/blob/gcs/node.js +117 -0
  769. package/lib/esm/node/storage/blob/gcs/node.js.map +1 -0
  770. package/lib/esm/node/storage/blob/s3/node.js +176 -0
  771. package/lib/esm/node/storage/blob/s3/node.js.map +1 -0
  772. package/lib/esm/node/storage/database/base.js +291 -0
  773. package/lib/esm/node/storage/database/base.js.map +1 -0
  774. package/lib/esm/node/storage/database/mssql/node.js +42 -0
  775. package/lib/esm/node/storage/database/mssql/node.js.map +1 -0
  776. package/lib/esm/node/storage/database/mysql/node.js +42 -0
  777. package/lib/esm/node/storage/database/mysql/node.js.map +1 -0
  778. package/lib/esm/node/storage/database/postgres/node.js +42 -0
  779. package/lib/esm/node/storage/database/postgres/node.js.map +1 -0
  780. package/lib/esm/node/storage/rabbitmq/node.js +243 -0
  781. package/lib/esm/node/storage/rabbitmq/node.js.map +1 -0
  782. package/lib/esm/node/storage/redis/node.js +331 -0
  783. package/lib/esm/node/storage/redis/node.js.map +1 -0
  784. package/lib/esm/node/storage/support.js +69 -0
  785. package/lib/esm/node/storage/support.js.map +1 -0
  786. package/lib/esm/node/triggers/error/node.js +99 -0
  787. package/lib/esm/node/triggers/error/node.js.map +1 -0
  788. package/lib/esm/node/triggers/execute-workflow/node.js +85 -0
  789. package/lib/esm/node/triggers/execute-workflow/node.js.map +1 -0
  790. package/lib/esm/node/triggers/postgres/node.js +235 -0
  791. package/lib/esm/node/triggers/postgres/node.js.map +1 -0
  792. package/lib/esm/node/triggers/rabbitmq/node.js +275 -0
  793. package/lib/esm/node/triggers/rabbitmq/node.js.map +1 -0
  794. package/lib/esm/node/triggers/redis/node.js +224 -0
  795. package/lib/esm/node/triggers/redis/node.js.map +1 -0
  796. package/lib/esm/node/triggers/sse/node.js +187 -0
  797. package/lib/esm/node/triggers/sse/node.js.map +1 -0
  798. package/lib/esm/node/triggers/support.js +99 -0
  799. package/lib/esm/node/triggers/support.js.map +1 -0
  800. package/lib/esm/node/triggers/workflow/node.js +184 -0
  801. package/lib/esm/node/triggers/workflow/node.js.map +1 -0
  802. package/lib/esm/ram/GraphRunEventModel.js +5 -1
  803. package/lib/esm/ram/GraphRunEventModel.js.map +1 -1
  804. package/lib/esm/shared/graph/GraphNodeModel.js +5 -1
  805. package/lib/esm/shared/graph/GraphNodeModel.js.map +1 -1
  806. package/lib/esm/shared/graph/GraphWorkflowModel.js +5 -1
  807. package/lib/esm/shared/graph/GraphWorkflowModel.js.map +1 -1
  808. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js +40 -0
  809. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js.map +1 -1
  810. package/lib/esm/shared/graph/catalog/GraphPortManifest.js.map +1 -1
  811. package/lib/esm/shared/graph/catalog/GraphValueSchemaDerivation.js +20 -3
  812. package/lib/esm/shared/graph/catalog/GraphValueSchemaDerivation.js.map +1 -1
  813. package/lib/esm/shared/graph/category-styles.js +12 -0
  814. package/lib/esm/shared/graph/category-styles.js.map +1 -1
  815. package/lib/esm/shared/graph/constants.js.map +1 -1
  816. package/lib/esm/typeorm/TypeormGraphAdapter.js +213 -0
  817. package/lib/esm/typeorm/TypeormGraphAdapter.js.map +1 -0
  818. package/lib/esm/typeorm/index.js +12 -0
  819. package/lib/esm/typeorm/index.js.map +1 -0
  820. package/lib/esm/workflows/boundary-value.workflow.js +34 -0
  821. package/lib/esm/workflows/boundary-value.workflow.js.map +1 -0
  822. package/lib/esm/workflows/builders.js +40 -0
  823. package/lib/esm/workflows/builders.js.map +1 -0
  824. package/lib/esm/workflows/chat-agent.workflow.js +36 -0
  825. package/lib/esm/workflows/chat-agent.workflow.js.map +1 -0
  826. package/lib/esm/workflows/error-boundary.workflow.js +50 -0
  827. package/lib/esm/workflows/error-boundary.workflow.js.map +1 -0
  828. package/lib/esm/workflows/event-map.workflow.js +33 -0
  829. package/lib/esm/workflows/event-map.workflow.js.map +1 -0
  830. package/lib/esm/workflows/foreach-break.workflow.js +54 -0
  831. package/lib/esm/workflows/foreach-break.workflow.js.map +1 -0
  832. package/lib/esm/workflows/human-approval.workflow.js +40 -0
  833. package/lib/esm/workflows/human-approval.workflow.js.map +1 -0
  834. package/lib/esm/workflows/if-switch.workflow.js +62 -0
  835. package/lib/esm/workflows/if-switch.workflow.js.map +1 -0
  836. package/lib/esm/workflows/index.js +116 -0
  837. package/lib/esm/workflows/index.js.map +1 -0
  838. package/lib/esm/workflows/loops-while-until.workflow.js +72 -0
  839. package/lib/esm/workflows/loops-while-until.workflow.js.map +1 -0
  840. package/lib/esm/workflows/manual-log.workflow.js +48 -0
  841. package/lib/esm/workflows/manual-log.workflow.js.map +1 -0
  842. package/lib/esm/workflows/schedule-code.workflow.js +38 -0
  843. package/lib/esm/workflows/schedule-code.workflow.js.map +1 -0
  844. package/lib/esm/workflows/types.js +2 -0
  845. package/lib/esm/workflows/types.js.map +1 -0
  846. package/lib/esm/workflows/value-templates.workflow.js +39 -0
  847. package/lib/esm/workflows/value-templates.workflow.js.map +1 -0
  848. package/lib/esm/workflows/webhook-form.workflow.js +44 -0
  849. package/lib/esm/workflows/webhook-form.workflow.js.map +1 -0
  850. package/lib/types/dagster/DagsterGraphExecutionBackend.d.cts +7 -0
  851. package/lib/types/dagster/DagsterGraphExecutionBackend.d.mts +7 -0
  852. package/lib/types/engine/auth/GraphAuthValidator.d.cts +13 -0
  853. package/lib/types/engine/auth/GraphAuthValidator.d.mts +13 -0
  854. package/lib/types/engine/constants.d.cts +60 -0
  855. package/lib/types/engine/constants.d.mts +60 -0
  856. package/lib/types/engine/credentials/GraphNodeCredentials.d.cts +145 -0
  857. package/lib/types/engine/credentials/GraphNodeCredentials.d.mts +145 -0
  858. package/lib/types/engine/execution/GraphCodeMode.d.cts +46 -0
  859. package/lib/types/engine/execution/GraphCodeMode.d.mts +46 -0
  860. package/lib/types/engine/execution/GraphExecutionBackend.d.cts +21 -0
  861. package/lib/types/engine/execution/GraphExecutionBackend.d.mts +21 -0
  862. package/lib/types/engine/execution/GraphExecutionEngine.d.cts +116 -4
  863. package/lib/types/engine/execution/GraphExecutionEngine.d.mts +116 -4
  864. package/lib/types/engine/execution/GraphNodeEngineRequirements.d.cts +24 -0
  865. package/lib/types/engine/execution/GraphNodeEngineRequirements.d.mts +24 -0
  866. package/lib/types/engine/execution/GraphWebhookResponseRegistry.d.cts +67 -0
  867. package/lib/types/engine/execution/GraphWebhookResponseRegistry.d.mts +67 -0
  868. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.cts +12 -3
  869. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.mts +12 -3
  870. package/lib/types/engine/execution/index.d.cts +1 -0
  871. package/lib/types/engine/execution/index.d.mts +1 -0
  872. package/lib/types/engine/index.d.cts +4 -0
  873. package/lib/types/engine/index.d.mts +4 -0
  874. package/lib/types/engine/store/GraphDataTableModel.d.cts +24 -0
  875. package/lib/types/engine/store/GraphDataTableModel.d.mts +24 -0
  876. package/lib/types/engine/store/GraphDataTableRepository.d.cts +136 -0
  877. package/lib/types/engine/store/GraphDataTableRepository.d.mts +136 -0
  878. package/lib/types/engine/store/index.d.cts +2 -0
  879. package/lib/types/engine/store/index.d.mts +2 -0
  880. package/lib/types/engine/types.d.cts +12 -0
  881. package/lib/types/engine/types.d.mts +12 -0
  882. package/lib/types/engine/validation/GraphConnectionPolicyValidator.d.cts +10 -0
  883. package/lib/types/engine/validation/GraphConnectionPolicyValidator.d.mts +10 -0
  884. package/lib/types/engine/validation/GraphNodeInstanceValidator.d.cts +11 -1
  885. package/lib/types/engine/validation/GraphNodeInstanceValidator.d.mts +11 -1
  886. package/lib/types/engine/validation/GraphParameterValidator.d.cts +1 -1
  887. package/lib/types/engine/validation/GraphParameterValidator.d.mts +1 -1
  888. package/lib/types/engine/validation/GraphWorkflowDocumentValidator.d.cts +7 -0
  889. package/lib/types/engine/validation/GraphWorkflowDocumentValidator.d.mts +7 -0
  890. package/lib/types/mastra/MastraAgeVectorDriver.d.cts +55 -0
  891. package/lib/types/mastra/MastraAgeVectorDriver.d.mts +55 -0
  892. package/lib/types/mastra/MastraAgentBuilder.d.cts +188 -0
  893. package/lib/types/mastra/MastraAgentBuilder.d.mts +188 -0
  894. package/lib/types/mastra/MastraAgentModelAdapter.d.cts +76 -0
  895. package/lib/types/mastra/MastraAgentModelAdapter.d.mts +76 -0
  896. package/lib/types/mastra/MastraAgentProcessors.d.cts +50 -0
  897. package/lib/types/mastra/MastraAgentProcessors.d.mts +50 -0
  898. package/lib/types/mastra/MastraAgentStepHandler.d.cts +128 -0
  899. package/lib/types/mastra/MastraAgentStepHandler.d.mts +128 -0
  900. package/lib/types/mastra/MastraCapabilities.d.cts +20 -0
  901. package/lib/types/mastra/MastraCapabilities.d.mts +20 -0
  902. package/lib/types/mastra/MastraChannelResponse.d.cts +64 -0
  903. package/lib/types/mastra/MastraChannelResponse.d.mts +64 -0
  904. package/lib/types/mastra/MastraChannelTrigger.d.cts +57 -0
  905. package/lib/types/mastra/MastraChannelTrigger.d.mts +57 -0
  906. package/lib/types/mastra/MastraDefaultStepHandlers.d.cts +53 -6
  907. package/lib/types/mastra/MastraDefaultStepHandlers.d.mts +53 -6
  908. package/lib/types/mastra/MastraEnvironment.d.cts +270 -0
  909. package/lib/types/mastra/MastraEnvironment.d.mts +270 -0
  910. package/lib/types/mastra/MastraEvalModels.d.cts +191 -0
  911. package/lib/types/mastra/MastraEvalModels.d.mts +191 -0
  912. package/lib/types/mastra/MastraEventBridge.d.cts +17 -0
  913. package/lib/types/mastra/MastraEventBridge.d.mts +17 -0
  914. package/lib/types/mastra/MastraGraphExecutionBackend.d.cts +108 -1
  915. package/lib/types/mastra/MastraGraphExecutionBackend.d.mts +108 -1
  916. package/lib/types/mastra/MastraGraphExecutionModule.d.cts +114 -0
  917. package/lib/types/mastra/MastraGraphExecutionModule.d.mts +114 -0
  918. package/lib/types/mastra/MastraHitlStepHandler.d.cts +18 -0
  919. package/lib/types/mastra/MastraHitlStepHandler.d.mts +18 -0
  920. package/lib/types/mastra/MastraMcpTrigger.d.cts +133 -0
  921. package/lib/types/mastra/MastraMcpTrigger.d.mts +133 -0
  922. package/lib/types/mastra/MastraMemory.d.cts +362 -0
  923. package/lib/types/mastra/MastraMemory.d.mts +362 -0
  924. package/lib/types/mastra/MastraMetricsAdapter.d.cts +216 -0
  925. package/lib/types/mastra/MastraMetricsAdapter.d.mts +216 -0
  926. package/lib/types/mastra/MastraMetricsGateway.d.cts +265 -0
  927. package/lib/types/mastra/MastraMetricsGateway.d.mts +265 -0
  928. package/lib/types/mastra/MastraMetricsModels.d.cts +175 -0
  929. package/lib/types/mastra/MastraMetricsModels.d.mts +175 -0
  930. package/lib/types/mastra/MastraMetricsStatement.d.cts +116 -0
  931. package/lib/types/mastra/MastraMetricsStatement.d.mts +116 -0
  932. package/lib/types/mastra/MastraModelSchemaConverter.d.cts +45 -0
  933. package/lib/types/mastra/MastraModelSchemaConverter.d.mts +45 -0
  934. package/lib/types/mastra/MastraObservability.d.cts +197 -0
  935. package/lib/types/mastra/MastraObservability.d.mts +197 -0
  936. package/lib/types/mastra/MastraPersistence.d.cts +241 -0
  937. package/lib/types/mastra/MastraPersistence.d.mts +241 -0
  938. package/lib/types/mastra/MastraRagStepHandlers.d.cts +137 -0
  939. package/lib/types/mastra/MastraRagStepHandlers.d.mts +137 -0
  940. package/lib/types/mastra/MastraRunMetricsEndpoint.d.cts +53 -0
  941. package/lib/types/mastra/MastraRunMetricsEndpoint.d.mts +53 -0
  942. package/lib/types/mastra/MastraRunRecovery.d.cts +26 -0
  943. package/lib/types/mastra/MastraRunRecovery.d.mts +26 -0
  944. package/lib/types/mastra/MastraScheduleTrigger.d.cts +20 -0
  945. package/lib/types/mastra/MastraScheduleTrigger.d.mts +20 -0
  946. package/lib/types/mastra/MastraStorageWiring.d.cts +71 -0
  947. package/lib/types/mastra/MastraStorageWiring.d.mts +71 -0
  948. package/lib/types/mastra/MastraStructuredOutput.d.cts +165 -0
  949. package/lib/types/mastra/MastraStructuredOutput.d.mts +165 -0
  950. package/lib/types/mastra/MastraToolBuilder.d.cts +70 -0
  951. package/lib/types/mastra/MastraToolBuilder.d.mts +70 -0
  952. package/lib/types/mastra/MastraToolConfig.d.cts +136 -0
  953. package/lib/types/mastra/MastraToolConfig.d.mts +136 -0
  954. package/lib/types/mastra/MastraToolDecorator.d.cts +47 -0
  955. package/lib/types/mastra/MastraToolDecorator.d.mts +47 -0
  956. package/lib/types/mastra/MastraVectorStore.d.cts +383 -0
  957. package/lib/types/mastra/MastraVectorStore.d.mts +383 -0
  958. package/lib/types/mastra/MastraVoiceStepHandler.d.cts +40 -0
  959. package/lib/types/mastra/MastraVoiceStepHandler.d.mts +40 -0
  960. package/lib/types/mastra/MastraWorkflowCompiler.d.cts +23 -8
  961. package/lib/types/mastra/MastraWorkflowCompiler.d.mts +23 -8
  962. package/lib/types/mastra/MastraWorkflowManager.d.cts +36 -28
  963. package/lib/types/mastra/MastraWorkflowManager.d.mts +36 -28
  964. package/lib/types/mastra/index.d.cts +40 -1
  965. package/lib/types/mastra/index.d.mts +40 -1
  966. package/lib/types/mastra/nodes/MastraNodeRegistry.d.cts +41 -0
  967. package/lib/types/mastra/nodes/MastraNodeRegistry.d.mts +41 -0
  968. package/lib/types/mastra/nodes/index.d.cts +11 -0
  969. package/lib/types/mastra/nodes/index.d.mts +11 -0
  970. package/lib/types/mastra/nodes/types.d.cts +57 -0
  971. package/lib/types/mastra/nodes/types.d.mts +57 -0
  972. package/lib/types/mastra/types.d.cts +365 -6
  973. package/lib/types/mastra/types.d.mts +365 -6
  974. package/lib/types/nest/graph/GraphEngineController.d.cts +19 -0
  975. package/lib/types/nest/graph/GraphEngineController.d.mts +19 -0
  976. package/lib/types/nest/graph/GraphExecutionModule.d.cts +17 -0
  977. package/lib/types/nest/graph/GraphExecutionModule.d.mts +17 -0
  978. package/lib/types/nest/graph/GraphNodeCatalogueController.d.cts +13 -0
  979. package/lib/types/nest/graph/GraphNodeCatalogueController.d.mts +13 -0
  980. package/lib/types/nest/graph/GraphRunController.d.cts +40 -4
  981. package/lib/types/nest/graph/GraphRunController.d.mts +40 -4
  982. package/lib/types/nest/graph/GraphWorkflowController.d.cts +26 -3
  983. package/lib/types/nest/graph/GraphWorkflowController.d.mts +26 -3
  984. package/lib/types/node/agents/agent/node.d.cts +72 -16
  985. package/lib/types/node/agents/agent/node.d.mts +72 -16
  986. package/lib/types/node/agents/hitl/node.d.cts +45 -0
  987. package/lib/types/node/agents/hitl/node.d.mts +45 -0
  988. package/lib/types/node/agents/hooks/delegation/node.d.cts +48 -0
  989. package/lib/types/node/agents/hooks/delegation/node.d.mts +48 -0
  990. package/lib/types/node/agents/hooks/hook/node.d.cts +45 -0
  991. package/lib/types/node/agents/hooks/hook/node.d.mts +45 -0
  992. package/lib/types/node/agents/hooks/tool-deny/node.d.cts +39 -0
  993. package/lib/types/node/agents/hooks/tool-deny/node.d.mts +39 -0
  994. package/lib/types/node/agents/memory/memory/node.d.cts +73 -0
  995. package/lib/types/node/agents/memory/memory/node.d.mts +73 -0
  996. package/lib/types/node/agents/memory/memory-selector/node.d.cts +34 -0
  997. package/lib/types/node/agents/memory/memory-selector/node.d.mts +34 -0
  998. package/lib/types/node/agents/processors/guardrail/node.d.cts +47 -0
  999. package/lib/types/node/agents/processors/guardrail/node.d.mts +47 -0
  1000. package/lib/types/node/agents/processors/input-processor/node.d.cts +40 -0
  1001. package/lib/types/node/agents/processors/input-processor/node.d.mts +40 -0
  1002. package/lib/types/node/agents/processors/output-processor/node.d.cts +34 -0
  1003. package/lib/types/node/agents/processors/output-processor/node.d.mts +34 -0
  1004. package/lib/types/node/agents/processors/types.d.cts +45 -0
  1005. package/lib/types/node/agents/processors/types.d.mts +45 -0
  1006. package/lib/types/node/agents/rag/chains/basic/node.d.cts +36 -0
  1007. package/lib/types/node/agents/rag/chains/basic/node.d.mts +36 -0
  1008. package/lib/types/node/agents/rag/chains/qa/node.d.cts +44 -0
  1009. package/lib/types/node/agents/rag/chains/qa/node.d.mts +44 -0
  1010. package/lib/types/node/agents/rag/chains/summarization/node.d.cts +39 -0
  1011. package/lib/types/node/agents/rag/chains/summarization/node.d.mts +39 -0
  1012. package/lib/types/node/agents/rag/chunking/node.d.cts +73 -0
  1013. package/lib/types/node/agents/rag/chunking/node.d.mts +73 -0
  1014. package/lib/types/node/agents/rag/embedding/node.d.cts +37 -0
  1015. package/lib/types/node/agents/rag/embedding/node.d.mts +37 -0
  1016. package/lib/types/node/agents/rag/information-extractor/node.d.cts +39 -0
  1017. package/lib/types/node/agents/rag/information-extractor/node.d.mts +39 -0
  1018. package/lib/types/node/agents/rag/langchain-code/node.d.cts +36 -0
  1019. package/lib/types/node/agents/rag/langchain-code/node.d.mts +36 -0
  1020. package/lib/types/node/agents/rag/rerank/node.d.cts +39 -0
  1021. package/lib/types/node/agents/rag/rerank/node.d.mts +39 -0
  1022. package/lib/types/node/agents/rag/retriever/node.d.cts +42 -0
  1023. package/lib/types/node/agents/rag/retriever/node.d.mts +42 -0
  1024. package/lib/types/node/agents/rag/structured-output-parser/node.d.cts +35 -0
  1025. package/lib/types/node/agents/rag/structured-output-parser/node.d.mts +35 -0
  1026. package/lib/types/node/agents/rag/vector-store/node.d.cts +59 -0
  1027. package/lib/types/node/agents/rag/vector-store/node.d.mts +59 -0
  1028. package/lib/types/node/agents/responses/discord/node.d.cts +34 -0
  1029. package/lib/types/node/agents/responses/discord/node.d.mts +34 -0
  1030. package/lib/types/node/agents/responses/slack/node.d.cts +34 -0
  1031. package/lib/types/node/agents/responses/slack/node.d.mts +34 -0
  1032. package/lib/types/node/agents/responses/teams/node.d.cts +34 -0
  1033. package/lib/types/node/agents/responses/teams/node.d.mts +34 -0
  1034. package/lib/types/node/agents/responses/telegram/node.d.cts +34 -0
  1035. package/lib/types/node/agents/responses/telegram/node.d.mts +34 -0
  1036. package/lib/types/node/agents/sandbox/node.d.cts +47 -0
  1037. package/lib/types/node/agents/sandbox/node.d.mts +47 -0
  1038. package/lib/types/node/agents/scorers/scorer/node.d.cts +33 -0
  1039. package/lib/types/node/agents/scorers/scorer/node.d.mts +33 -0
  1040. package/lib/types/node/agents/scorers/scorer-selector/node.d.cts +33 -0
  1041. package/lib/types/node/agents/scorers/scorer-selector/node.d.mts +33 -0
  1042. package/lib/types/node/agents/skills/skill/node.d.cts +32 -0
  1043. package/lib/types/node/agents/skills/skill/node.d.mts +32 -0
  1044. package/lib/types/node/agents/skills/skill-selector/node.d.cts +33 -0
  1045. package/lib/types/node/agents/skills/skill-selector/node.d.mts +33 -0
  1046. package/lib/types/node/agents/tools/tool/node.d.cts +33 -0
  1047. package/lib/types/node/agents/tools/tool/node.d.mts +33 -0
  1048. package/lib/types/node/agents/tools/tool-selector/node.d.cts +33 -0
  1049. package/lib/types/node/agents/tools/tool-selector/node.d.mts +33 -0
  1050. package/lib/types/node/agents/triggers/discord/node.d.cts +40 -0
  1051. package/lib/types/node/agents/triggers/discord/node.d.mts +40 -0
  1052. package/lib/types/node/agents/triggers/mcp-server/node.d.cts +51 -0
  1053. package/lib/types/node/agents/triggers/mcp-server/node.d.mts +51 -0
  1054. package/lib/types/node/agents/triggers/slack/node.d.cts +40 -0
  1055. package/lib/types/node/agents/triggers/slack/node.d.mts +40 -0
  1056. package/lib/types/node/agents/triggers/teams/node.d.cts +40 -0
  1057. package/lib/types/node/agents/triggers/teams/node.d.mts +40 -0
  1058. package/lib/types/node/agents/triggers/telegram/node.d.cts +40 -0
  1059. package/lib/types/node/agents/triggers/telegram/node.d.mts +40 -0
  1060. package/lib/types/node/agents/voice/node.d.cts +34 -0
  1061. package/lib/types/node/agents/voice/node.d.mts +34 -0
  1062. package/lib/types/node/agents/zones.d.cts +30 -0
  1063. package/lib/types/node/agents/zones.d.mts +30 -0
  1064. package/lib/types/node/comms/discord/node.d.cts +67 -0
  1065. package/lib/types/node/comms/discord/node.d.mts +67 -0
  1066. package/lib/types/node/comms/email-send/node.d.cts +85 -0
  1067. package/lib/types/node/comms/email-send/node.d.mts +85 -0
  1068. package/lib/types/node/comms/gmail/node.d.cts +67 -0
  1069. package/lib/types/node/comms/gmail/node.d.mts +67 -0
  1070. package/lib/types/node/comms/outlook/node.d.cts +77 -0
  1071. package/lib/types/node/comms/outlook/node.d.mts +77 -0
  1072. package/lib/types/node/comms/slack/node.d.cts +65 -0
  1073. package/lib/types/node/comms/slack/node.d.mts +65 -0
  1074. package/lib/types/node/comms/teams/node.d.cts +49 -0
  1075. package/lib/types/node/comms/teams/node.d.mts +49 -0
  1076. package/lib/types/node/comms/telegram/node.d.cts +61 -0
  1077. package/lib/types/node/comms/telegram/node.d.mts +61 -0
  1078. package/lib/types/node/comms/whatsapp/node.d.cts +71 -0
  1079. package/lib/types/node/comms/whatsapp/node.d.mts +71 -0
  1080. package/lib/types/node/credentials.d.cts +43 -0
  1081. package/lib/types/node/credentials.d.mts +43 -0
  1082. package/lib/types/node/data/aggregate/node.d.cts +58 -0
  1083. package/lib/types/node/data/aggregate/node.d.mts +58 -0
  1084. package/lib/types/node/data/compare-datasets/node.d.cts +72 -0
  1085. package/lib/types/node/data/compare-datasets/node.d.mts +72 -0
  1086. package/lib/types/node/data/data-table/node.d.cts +86 -0
  1087. package/lib/types/node/data/data-table/node.d.mts +86 -0
  1088. package/lib/types/node/data/date-time/node.d.cts +49 -0
  1089. package/lib/types/node/data/date-time/node.d.mts +49 -0
  1090. package/lib/types/node/data/filter/node.d.cts +31 -0
  1091. package/lib/types/node/data/filter/node.d.mts +31 -0
  1092. package/lib/types/node/data/item-lists/node.d.cts +92 -0
  1093. package/lib/types/node/data/item-lists/node.d.mts +92 -0
  1094. package/lib/types/node/data/limit/node.d.cts +28 -0
  1095. package/lib/types/node/data/limit/node.d.mts +28 -0
  1096. package/lib/types/node/data/merge/node.d.cts +63 -0
  1097. package/lib/types/node/data/merge/node.d.mts +63 -0
  1098. package/lib/types/node/data/remove-duplicates/node.d.cts +47 -0
  1099. package/lib/types/node/data/remove-duplicates/node.d.mts +47 -0
  1100. package/lib/types/node/data/rename-keys/node.d.cts +35 -0
  1101. package/lib/types/node/data/rename-keys/node.d.mts +35 -0
  1102. package/lib/types/node/data/set/node.d.cts +52 -0
  1103. package/lib/types/node/data/set/node.d.mts +52 -0
  1104. package/lib/types/node/data/sort/node.d.cts +40 -0
  1105. package/lib/types/node/data/sort/node.d.mts +40 -0
  1106. package/lib/types/node/data/split-out/node.d.cts +30 -0
  1107. package/lib/types/node/data/split-out/node.d.mts +30 -0
  1108. package/lib/types/node/data/summarize/node.d.cts +44 -0
  1109. package/lib/types/node/data/summarize/node.d.mts +44 -0
  1110. package/lib/types/node/data/support.d.cts +177 -0
  1111. package/lib/types/node/data/support.d.mts +177 -0
  1112. package/lib/types/node/data/transform-utils.d.cts +236 -0
  1113. package/lib/types/node/data/transform-utils.d.mts +236 -0
  1114. package/lib/types/node/devops/crypto/node.d.cts +65 -0
  1115. package/lib/types/node/devops/crypto/node.d.mts +65 -0
  1116. package/lib/types/node/devops/execute-command/node.d.cts +55 -0
  1117. package/lib/types/node/devops/execute-command/node.d.mts +55 -0
  1118. package/lib/types/node/devops/ftp/node.d.cts +55 -0
  1119. package/lib/types/node/devops/ftp/node.d.mts +55 -0
  1120. package/lib/types/node/devops/github/node.d.cts +61 -0
  1121. package/lib/types/node/devops/github/node.d.mts +61 -0
  1122. package/lib/types/node/devops/gitlab/node.d.cts +61 -0
  1123. package/lib/types/node/devops/gitlab/node.d.mts +61 -0
  1124. package/lib/types/node/devops/jwt/node.d.cts +53 -0
  1125. package/lib/types/node/devops/jwt/node.d.mts +53 -0
  1126. package/lib/types/node/flow/execute-sub-workflow/node.d.cts +63 -0
  1127. package/lib/types/node/flow/execute-sub-workflow/node.d.mts +63 -0
  1128. package/lib/types/node/index.d.cts +230 -2
  1129. package/lib/types/node/index.d.mts +230 -2
  1130. package/lib/types/node/io/airtable/node.d.cts +73 -0
  1131. package/lib/types/node/io/airtable/node.d.mts +73 -0
  1132. package/lib/types/node/io/confluence/node.d.cts +49 -0
  1133. package/lib/types/node/io/confluence/node.d.mts +49 -0
  1134. package/lib/types/node/io/convert-to-file/node.d.cts +75 -0
  1135. package/lib/types/node/io/convert-to-file/node.d.mts +75 -0
  1136. package/lib/types/node/io/extract-from-file/node.d.cts +38 -0
  1137. package/lib/types/node/io/extract-from-file/node.d.mts +38 -0
  1138. package/lib/types/node/io/file-support.d.cts +118 -0
  1139. package/lib/types/node/io/file-support.d.mts +118 -0
  1140. package/lib/types/node/io/google-calendar/node.d.cts +65 -0
  1141. package/lib/types/node/io/google-calendar/node.d.mts +65 -0
  1142. package/lib/types/node/io/google-docs/node.d.cts +51 -0
  1143. package/lib/types/node/io/google-docs/node.d.mts +51 -0
  1144. package/lib/types/node/io/google-sheets/node.d.cts +77 -0
  1145. package/lib/types/node/io/google-sheets/node.d.mts +77 -0
  1146. package/lib/types/node/io/graphql/node.d.cts +46 -0
  1147. package/lib/types/node/io/graphql/node.d.mts +46 -0
  1148. package/lib/types/node/io/html/node.d.cts +68 -0
  1149. package/lib/types/node/io/html/node.d.mts +68 -0
  1150. package/lib/types/node/io/html-extract/node.d.cts +42 -0
  1151. package/lib/types/node/io/html-extract/node.d.mts +42 -0
  1152. package/lib/types/node/io/html-support.d.cts +69 -0
  1153. package/lib/types/node/io/html-support.d.mts +69 -0
  1154. package/lib/types/node/io/http-request/node.d.cts +107 -0
  1155. package/lib/types/node/io/http-request/node.d.mts +107 -0
  1156. package/lib/types/node/io/jira/node.d.cts +57 -0
  1157. package/lib/types/node/io/jira/node.d.mts +57 -0
  1158. package/lib/types/node/io/markdown/node.d.cts +61 -0
  1159. package/lib/types/node/io/markdown/node.d.mts +61 -0
  1160. package/lib/types/node/io/microsoft-excel/node.d.cts +45 -0
  1161. package/lib/types/node/io/microsoft-excel/node.d.mts +45 -0
  1162. package/lib/types/node/io/microsoft-sharepoint/node.d.cts +47 -0
  1163. package/lib/types/node/io/microsoft-sharepoint/node.d.mts +47 -0
  1164. package/lib/types/node/io/read-binary-file/node.d.cts +45 -0
  1165. package/lib/types/node/io/read-binary-file/node.d.mts +45 -0
  1166. package/lib/types/node/io/read-binary-files/node.d.cts +41 -0
  1167. package/lib/types/node/io/read-binary-files/node.d.mts +41 -0
  1168. package/lib/types/node/io/read-pdf/node.d.cts +40 -0
  1169. package/lib/types/node/io/read-pdf/node.d.mts +40 -0
  1170. package/lib/types/node/io/read-write-file/node.d.cts +41 -0
  1171. package/lib/types/node/io/read-write-file/node.d.mts +41 -0
  1172. package/lib/types/node/io/respond-to-webhook/node.d.cts +45 -0
  1173. package/lib/types/node/io/respond-to-webhook/node.d.mts +45 -0
  1174. package/lib/types/node/io/spreadsheet-file/node.d.cts +51 -0
  1175. package/lib/types/node/io/spreadsheet-file/node.d.mts +51 -0
  1176. package/lib/types/node/io/write-binary-file/node.d.cts +55 -0
  1177. package/lib/types/node/io/write-binary-file/node.d.mts +55 -0
  1178. package/lib/types/node/io/xml/node.d.cts +67 -0
  1179. package/lib/types/node/io/xml/node.d.mts +67 -0
  1180. package/lib/types/node/storage/blob/azure/node.d.cts +27 -0
  1181. package/lib/types/node/storage/blob/azure/node.d.mts +27 -0
  1182. package/lib/types/node/storage/blob/base.d.cts +83 -0
  1183. package/lib/types/node/storage/blob/base.d.mts +83 -0
  1184. package/lib/types/node/storage/blob/gcs/node.d.cts +27 -0
  1185. package/lib/types/node/storage/blob/gcs/node.d.mts +27 -0
  1186. package/lib/types/node/storage/blob/s3/node.d.cts +39 -0
  1187. package/lib/types/node/storage/blob/s3/node.d.mts +39 -0
  1188. package/lib/types/node/storage/database/base.d.cts +97 -0
  1189. package/lib/types/node/storage/database/base.d.mts +97 -0
  1190. package/lib/types/node/storage/database/mssql/node.d.cts +8 -0
  1191. package/lib/types/node/storage/database/mssql/node.d.mts +8 -0
  1192. package/lib/types/node/storage/database/mysql/node.d.cts +8 -0
  1193. package/lib/types/node/storage/database/mysql/node.d.mts +8 -0
  1194. package/lib/types/node/storage/database/postgres/node.d.cts +8 -0
  1195. package/lib/types/node/storage/database/postgres/node.d.mts +8 -0
  1196. package/lib/types/node/storage/rabbitmq/node.d.cts +55 -0
  1197. package/lib/types/node/storage/rabbitmq/node.d.mts +55 -0
  1198. package/lib/types/node/storage/redis/node.d.cts +68 -0
  1199. package/lib/types/node/storage/redis/node.d.mts +68 -0
  1200. package/lib/types/node/storage/support.d.cts +36 -0
  1201. package/lib/types/node/storage/support.d.mts +36 -0
  1202. package/lib/types/node/triggers/error/node.d.cts +34 -0
  1203. package/lib/types/node/triggers/error/node.d.mts +34 -0
  1204. package/lib/types/node/triggers/execute-workflow/node.d.cts +25 -0
  1205. package/lib/types/node/triggers/execute-workflow/node.d.mts +25 -0
  1206. package/lib/types/node/triggers/postgres/node.d.cts +54 -0
  1207. package/lib/types/node/triggers/postgres/node.d.mts +54 -0
  1208. package/lib/types/node/triggers/rabbitmq/node.d.cts +59 -0
  1209. package/lib/types/node/triggers/rabbitmq/node.d.mts +59 -0
  1210. package/lib/types/node/triggers/redis/node.d.cts +53 -0
  1211. package/lib/types/node/triggers/redis/node.d.mts +53 -0
  1212. package/lib/types/node/triggers/sse/node.d.cts +43 -0
  1213. package/lib/types/node/triggers/sse/node.d.mts +43 -0
  1214. package/lib/types/node/triggers/support.d.cts +41 -0
  1215. package/lib/types/node/triggers/support.d.mts +41 -0
  1216. package/lib/types/node/triggers/workflow/node.d.cts +46 -0
  1217. package/lib/types/node/triggers/workflow/node.d.mts +46 -0
  1218. package/lib/types/ram/GraphRunEventModel.d.cts +6 -0
  1219. package/lib/types/ram/GraphRunEventModel.d.mts +6 -0
  1220. package/lib/types/shared/graph/GraphNodeModel.d.cts +6 -0
  1221. package/lib/types/shared/graph/GraphNodeModel.d.mts +6 -0
  1222. package/lib/types/shared/graph/GraphWorkflowModel.d.cts +6 -0
  1223. package/lib/types/shared/graph/GraphWorkflowModel.d.mts +6 -0
  1224. package/lib/types/shared/graph/catalog/GraphPortManifest.d.cts +7 -0
  1225. package/lib/types/shared/graph/catalog/GraphPortManifest.d.mts +7 -0
  1226. package/lib/types/shared/graph/constants.d.cts +39 -0
  1227. package/lib/types/shared/graph/constants.d.mts +39 -0
  1228. package/lib/types/typeorm/TypeormGraphAdapter.d.cts +32 -0
  1229. package/lib/types/typeorm/TypeormGraphAdapter.d.mts +32 -0
  1230. package/lib/types/typeorm/index.d.cts +11 -0
  1231. package/lib/types/typeorm/index.d.mts +11 -0
  1232. package/lib/types/workflows/boundary-value.workflow.d.cts +3 -0
  1233. package/lib/types/workflows/boundary-value.workflow.d.mts +3 -0
  1234. package/lib/types/workflows/builders.d.cts +31 -0
  1235. package/lib/types/workflows/builders.d.mts +31 -0
  1236. package/lib/types/workflows/chat-agent.workflow.d.cts +3 -0
  1237. package/lib/types/workflows/chat-agent.workflow.d.mts +3 -0
  1238. package/lib/types/workflows/error-boundary.workflow.d.cts +3 -0
  1239. package/lib/types/workflows/error-boundary.workflow.d.mts +3 -0
  1240. package/lib/types/workflows/event-map.workflow.d.cts +3 -0
  1241. package/lib/types/workflows/event-map.workflow.d.mts +3 -0
  1242. package/lib/types/workflows/foreach-break.workflow.d.cts +3 -0
  1243. package/lib/types/workflows/foreach-break.workflow.d.mts +3 -0
  1244. package/lib/types/workflows/human-approval.workflow.d.cts +3 -0
  1245. package/lib/types/workflows/human-approval.workflow.d.mts +3 -0
  1246. package/lib/types/workflows/if-switch.workflow.d.cts +3 -0
  1247. package/lib/types/workflows/if-switch.workflow.d.mts +3 -0
  1248. package/lib/types/workflows/index.d.cts +37 -0
  1249. package/lib/types/workflows/index.d.mts +37 -0
  1250. package/lib/types/workflows/loops-while-until.workflow.d.cts +3 -0
  1251. package/lib/types/workflows/loops-while-until.workflow.d.mts +3 -0
  1252. package/lib/types/workflows/manual-log.workflow.d.cts +3 -0
  1253. package/lib/types/workflows/manual-log.workflow.d.mts +3 -0
  1254. package/lib/types/workflows/schedule-code.workflow.d.cts +3 -0
  1255. package/lib/types/workflows/schedule-code.workflow.d.mts +3 -0
  1256. package/lib/types/workflows/types.d.cts +32 -0
  1257. package/lib/types/workflows/types.d.mts +32 -0
  1258. package/lib/types/workflows/value-templates.workflow.d.cts +16 -0
  1259. package/lib/types/workflows/value-templates.workflow.d.mts +16 -0
  1260. package/lib/types/workflows/webhook-form.workflow.d.cts +3 -0
  1261. package/lib/types/workflows/webhook-form.workflow.d.mts +3 -0
  1262. package/package.json +283 -21
package/dist/as-graph.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e,t;e=this,t=function(e,t,o,n,r,a,i,s,d,l,c,u,p){"use strict";function h(e){var t=Object.create(null);return e&&Object.keys(e).forEach(o=>{if("default"!==o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}),t.default=e,Object.freeze(t)}var f,g,m=h(l),y=h(c),w=h(u);r.ValidationKeys.REQUIRED,r.ValidationKeys.MIN,r.ValidationKeys.MIN_LENGTH,r.ValidationKeys.MAX,r.ValidationKeys.MAX_LENGTH,r.ValidationKeys.PATTERN,r.ValidationKeys.URL,r.ValidationKeys.STEP,r.ValidationKeys.DATE,r.ValidationKeys.EMAIL,r.ValidationKeys.PASSWORD,r.ValidationKeys.EQUALS,r.ValidationKeys.DIFF,r.ValidationKeys.LESS_THAN,r.ValidationKeys.LESS_THAN_OR_EQUAL,r.ValidationKeys.GREATER_THAN,r.ValidationKeys.GREATER_THAN_OR_EQUAL,(e=>{e.GRAPH="graph",e.NODE="graph.node",e.EDGE="graph.edge",e.PORT="graph.port",e.STATE="graph.state"})(f||(f={})),(e=>{e.INPUT="input",e.OUTPUT="output",e.CONNECTION="connection"})(g||(g={}));const _={};function b(e,t={}){let o=e.width??96,n=e.height??96;for(const r of e.sizeRules??[]){if("parameterCount"!==r.type)continue;const e=t[r.parameter]??0;e>0&&("width"===r.dimension?o+=e*r.perItem:n+=e*r.perItem)}return{width:o,height:n}}function v(e,t){_[e]=t}function N(e,t,o){const n=t?_[t]:void 0;return n?.color?n.color:e||"#64748b"}function E(e,t,o){const n=t?_[t]:void 0;return n?.icon?n.icon:e||"ti-pointer"}const I=["skip","passThroughFirstInput","emitDefaults"];function A(e){return I.includes(e)}var O,k,x,S;(e=>{e.PENDING="pending",e.PLANNING="planning",e.RUNNING="running",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped",e.CANCELLED="cancelled",e.CACHED="cached"})(O||(O={})),(e=>{e.IDLE="idle",e.RUNNING="running",e.BLOCKED="blocked",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped"})(k||(k={})),(e=>{e.NODE_ID="nodeId",e.WORKFLOW_ID="workflowId",e.RUN_ID="runId",e.USER="user",e.ROLES="roles",e.NAMESPACES="namespaces",e.ORGANIZATION="organization",e.IP="ip"})(x||(x={})),(e=>{e.WORKFLOW_STARTED="workflow.started",e.WORKFLOW_PLANNED="workflow.planned",e.WORKFLOW_COMPLETED="workflow.completed",e.WORKFLOW_FAILED="workflow.failed",e.WORKFLOW_CANCELLED="workflow.cancelled",e.WORKFLOW_SUSPENDED="workflow.suspended",e.WORKFLOW_RESUMED="workflow.resumed",e.NODE_QUEUED="node.queued",e.NODE_STARTED="node.started",e.NODE_OUTPUT="node.output",e.NODE_COMPLETED="node.completed",e.NODE_FAILED="node.failed",e.NODE_SKIPPED="node.skipped",e.NODE_CACHE_HIT="node.cacheHit",e.NODE_PINNED="node.pinned",e.NODE_UNPINNED="node.unpinned",e.NODE_STATE_CHANGED="node.stateChanged",e.EDGE_VALUE_ROUTED="edge.valueRouted",e.EDGE_STATE_CHANGED="edge.stateChanged",e.GRAPH_RUN_LOG="graph.run.log",e.LOOP_STARTED="loop.started",e.LOOP_ITERATION_STARTED="loop.iteration.started",e.LOOP_ITERATION_COMPLETED="loop.iteration.completed",e.LOOP_CONDITION_EVALUATED="loop.condition.evaluated",e.LOOP_COMPLETED="loop.completed",e.LOOP_LIMIT_REACHED="loop.limitReached",e.VALIDATION_STARTED="validation.started",e.VALIDATION_FAILED="validation.failed",e.VALIDATION_COMPLETED="validation.completed",e.STORE_READ="store.read",e.STORE_WRITE="store.write",e.STORE_DELETE="store.delete"})(S||(S={}));const D={maxRequestBytes:4e6,maxConcurrentRuns:32,maxEventsPerRun:1e4,maxEventPayloadBytes:256e3,executionTimeoutMs:6e5,eventReplayWindowMs:3e5},R=[S.WORKFLOW_COMPLETED,S.WORKFLOW_FAILED,S.WORKFLOW_CANCELLED];function P(e){return R.includes(e)}function C(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function T(e){const t=n.Metadata.constr(e);if("function"==typeof t)return t;const o=e.constructor;return"function"==typeof o?o:e}function $(e){if(null!=e)return"string"==typeof e?e:e+""}function G(e,t,o){return $(e?.props?.label??e?.props?.name)??$(t?.name)??o??""}function L(e,t,o){const a=V(e,t);if(a?.model&&"function"==typeof a.model&&r.Model.isModel(a.model))return a.model;const i=n.Metadata.type(e,t);if("function"==typeof i&&r.Model.isModel(i))return i;const s=n.Metadata.getPropDesignTypes?.(e,t)?.designTypes||[];for(const e of s)if("function"==typeof e&&r.Model.isModel(e))return e;const d=o?.[r.ValidationKeys.TYPE]?.customTypes||[];for(const e of d)if("function"==typeof e&&r.Model.isModel(e))return e}function M(e,t){const o=[t,e.path??e.property].filter(Boolean).join(".");return{...e,path:o,children:e.children?.map(e=>M(e,o))}}function F(e){const t=T(e);return n.Metadata.get(t,f.NODE)}function V(e,t){const o=T(e);return n.Metadata.get(o,n.Metadata.key(f.PORT,t+""))}function j(e,t,o,r=new Set){const a=V(e,t);if(!a?.schema)return;const i=L(e,t,n.Metadata.validationFor(e,t));if(!i)return;if(r.has(i))return[];const s=new Set(r);return s.add(e),s.add(i),W(i,s).filter(e=>e.direction===o)}function U(e,t,o=new Set){const a=V(e,t);if(!a)return;const i=n.Metadata.validationFor(e,t),s=L(e,t,i);if(a.schema&&s)return;const d=r.Model.uiElementOf(e,t)||void 0,l=r.Model.uiDecorationOf(e,t,"uiprop"),c=n.Metadata.type(e,t),u=$(a.type??i?.[r.ValidationKeys.TYPE]?.customTypes?.[0]?.name??d?.props?.type??l?.type??c?.name),p=(a.expand||s&&!o.has(s))&&s?(()=>{const n=new Set(o);return n.add(e),n.add(s),W(s,n).map(e=>M(e,t))})():void 0;return{property:t,path:t,direction:a.direction,name:t,label:G(d,l,t),type:u?.toLowerCase(),required:!!i?.[r.ValidationKeys.REQUIRED],hidden:!!r.Model.uiIsHidden(e,t),designType:c?.name,element:d,prop:l,validation:i,graph:a,connectionRules:a.connectionRules,composite:!!p?.length,children:p,model:s?.name}}function B(e){return W(T(e))}function W(e,t=new Set){const o=n.Metadata.properties(e)||[],r=[];for(const n of o){const o=n+"",a=V(e,o);if(a?.schema){const n=j(e,o,a.direction,t);if(n){r.push(...n);continue}}const i=U(e,o,t);i&&r.push(i)}return r}function q(e){return e.flatMap(e=>e.children&&e.children.length?q(e.children):[e])}function H(e){const t=T(e),o=r.Model.uiModelOf(t),a=F(t)||{},i=o?.tag||t.name,s=B(t),d=((e,t)=>{const o=t.portGroups||[],r=new Map(o.map(e=>[e.property,e])),a=[],i=n.Metadata.properties(e)||[];for(const t of i){const o=t+"",i=V(e,o);if(!i?.schema)continue;if(!L(e,o,n.Metadata.validationFor(e,o)))continue;const s=r.get(o);a.push(s?{...s,toggle:s.toggle??"all"}:{property:o,toggle:"all"})}for(const e of o)a.some(t=>t.property===e.property)||a.push(e);return a.length?a:void 0})(t,a),l=a.namespaces?.length?a.namespaces:(e=>{if(null==e)return[];let t,o=e;try{o=n.Metadata.constr(e)}catch{o=e}try{t=n.Metadata.get(o,"auth-namespace")}catch{t=void 0}return C(t)??[]})(t),c=l.length?l:void 0;return{name:t.name,tag:i,kind:a.kind||i,category:a.category,color:a.color,effectiveColor:N(a.color,a.category),group:a.group,height:a.height,icon:a.icon,effectiveIcon:E(a.icon,a.category),labels:a.labels||[],maxChildren:a.maxChildren,minWidth:a.minWidth,width:a.width,shape:a.shape,cornerRadius:a.cornerRadius,sizeRules:a.sizeRules,props:o?.props,ui:o,graph:a,ports:s,portGroups:d,namespaces:c}}const K=new Set,z=new Set;function X(e,t,r){return n.Decoration.for(f.NODE).define({decorator:(e,t,r)=>{const a={kind:t?.kind||e,...t};return t=>{const i=n.apply(o.uimodel(e,r),n.metadata(f.NODE,a))(t);var s;return s=t,K.add(s),i}},args:[e,t,r]}).apply()}function J(e,t){return n.Decoration.for(f.PORT).define({decorator:(e,t)=>(o,r)=>{const a={direction:e,...t};return n.apply(n.propMetadata(n.Metadata.key(f.PORT,r),a))(o,r)},args:[e,t]}).apply()}function Y(e){return J(g.INPUT,{...e,schema:!0})}function Q(e){return J(g.OUTPUT,{...e,schema:!0})}function Z(e){return J(g.CONNECTION,e)}o.RenderingEngine.prototype.renderAsNode=(e,t,...o)=>H(e),n.Metadata.nodes=(()=>[...K]).bind(n.Metadata),n.Metadata.workflows=(()=>[...z]).bind(n.Metadata);const ee=["__proto__","prototype","constructor"];function te(e){return ee.includes(e)}function oe(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ne(e){return null===e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e}function re(e){return!!ne(e)||(Array.isArray(e)?e.every(e=>re(e)):!!oe(e)&&Reflect.ownKeys(e).every(t=>"string"==typeof t&&!te(t)&&re(e[t])))}function ae(e){if(void 0===e)return!1;if("number"==typeof e)return Number.isFinite(e);if("function"==typeof e)return!1;if(re(e))return!0;if(Array.isArray(e))return e.every(e=>ae(e));if(oe(e)){const t=Reflect.ownKeys(e);for(const o of t){if("string"!=typeof o)return!1;if(te(o))return!1;if(!ae(e[o]))return!1}return!0}return!1}function ie(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>ie(e));const t={};for(const[o,n]of Object.entries(e))t[o]=ie(n);return t}const se={string:"string",char:"string",text:"string",textarea:"string",radio:"string",select:"string",number:"number",integer:"number",float:"number",double:"number",decimal:"number",boolean:"boolean",bool:"boolean",checkbox:"boolean",array:"array",list:"array",set:"array",object:"object",model:"model",any:"any",unknown:"any",enum:"enum"},de={date:"date",datetime:"date-time","date-time":"date-time",duration:"duration"};function le(e){return e?se[e.toLowerCase()]??"any":"any"}function ce(e,t){const o=e[t];if(o&&"object"==typeof o)return o.value}function ue(e,t){const o=ce(e,t);return"number"==typeof o&&Number.isFinite(o)?o:void 0}function pe(e,t,o){const n=e??{},a=(e=>{const t=ce(e,r.ValidationKeys.ENUM);if(Array.isArray(t)&&t.every(ne))return t})(n);if(a)return{type:"enum",values:a};const i=(e=>{const t=e[r.ValidationKeys.TYPE],o=t?.customTypes?.[0],n="function"==typeof o?o.name:o?.name;if(n)return n})(n)??o;return i?{type:"model",name:i}:((e,t)=>{switch(le(e)){case"string":{const t=(e=>{if(e)return de[e.toLowerCase()]})(e);return void 0!==t?{type:"string",format:t}:{type:"string"}}case"number":{const o={type:"number"};e&&"integer"===e.toLowerCase()&&(o.integer=!0);const n=ue(t,r.ValidationKeys.MIN),a=ue(t,r.ValidationKeys.MAX);return void 0!==n&&(o.min=n),void 0!==a&&(o.max=a),o}case"boolean":return{type:"boolean"};case"array":return((e,t)=>{const o={type:"array",items:he(e,t)},n=ue(e,r.ValidationKeys.MIN),a=ue(e,r.ValidationKeys.MAX);return void 0!==n&&(o.minItems=n),void 0!==a&&(o.maxItems=a),o})(t,e);case"object":return{type:"object",properties:{}};case"enum":return{type:"enum",values:[]};case"model":return{type:"model",name:e??"any"};default:return{type:"any"}}})(t,n)}function he(e,t){if((e=>{const t=e[r.ValidationKeys.LIST];return!!t?.clazz?.length})(e))return{type:"model",name:fe(e)};const o=ce(e,r.ValidationKeys.TYPE);if("string"==typeof o){const e=le(o);return"model"===e?{type:"model",name:o}:{type:e}}if(t&&"array"!==t){const e=le(t);return"model"===e?{type:"model",name:t}:{type:e}}return{type:"any"}}function fe(e){const t=e[r.ValidationKeys.LIST],o=t?.clazz?.[0];if("function"!=typeof o)return"any";if(o.name)return o.name;try{const e=o();if("function"==typeof e&&e.name)return e.name}catch{return"any"}return"any"}function ge(e){return"workflow"===e.scope}function me(e){return"node"===e.scope}function ye(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"workflow"===t.scope?"string"==typeof t.port&&2===Reflect.ownKeys(t).length:"node"===t.scope&&"string"==typeof t.nodeId&&"string"==typeof t.port&&3===Reflect.ownKeys(t).length}function we(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e.mode;if("edge"===t)return 1===Reflect.ownKeys(e).length;if("literal"===t){const t=e.value;return 2===Object.keys(e).length&&re(t)}return"expression"===t&&2===Object.keys(e).length&&"string"==typeof e.expression}const _e=["any","string","number","boolean","array","object","enum","model"];function be(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(e=>_e.includes(e))(e.type)}function ve(e,t={seen:[]}){if(t.seen.includes(e))throw new a.ValidationError(`Document '${(e=>{const t=e?.id;return"string"==typeof t?t:"<unnamed document>"})(e)}' contains a loop body that references itself (cyclic document)`);if("string"!=typeof e.id||!e.id)throw new a.ValidationError("Document 'id' is required and must be a non-empty string");if("string"!=typeof e.name||!e.name)throw new a.ValidationError("Document 'name' is required and must be a non-empty string");const o=new Set;for(const t of[...e.inputs,...e.outputs]){if("string"!=typeof t.id||!t.id)throw new a.ValidationError("Workflow port 'id' is required and must be a non-empty string");if(o.has(t.id))throw new a.ValidationError(`Workflow port '${t.id}' is declared more than once; workflow port ids must be unique`);if(void 0!==t.schema&&!be(t.schema))throw new a.ValidationError(`Workflow port '${t.id}' schema must be a valid GraphValueSchema`);o.add(t.id)}const n={seen:[...t.seen,e]},r=new Set;for(const t of e.nodes)Ne(t,r);for(const t of e.nodes)t.loop&&Ee(t,t.loop,n),t.errorBoundary&&Ie(t,t.errorBoundary,n);const i=new Set;for(const t of e.edges)Oe(t,i);for(const t of e.edges)ke(t.source,0,o,r,`Edge '${t.id}' source`),ke(t.target,0,o,r,`Edge '${t.id}' target`);if(void 0!==e.settings&&!ae(e.settings))throw new a.ValidationError("Document settings must be JSON-safe (a map of JSON-safe values)");if(void 0!==e.metadata&&!ae(e.metadata))throw new a.ValidationError("Document metadata must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed");if(void 0!==e.ui&&!ae(e.ui))throw new a.ValidationError("Document ui must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed")}function Ne(e,t){if("string"!=typeof e.id||!e.id)throw new a.ValidationError("Node 'id' is required and must be a non-empty string");if(t.has(e.id))throw new a.ValidationError(`Node id '${e.id}' is declared more than once; node ids must be unique`);if("string"!=typeof e.kind||!e.kind)throw new a.ValidationError(`Node '${e.id}' must declare a non-empty string 'kind'`);if(void 0===e.parameters||null===e.parameters)throw new a.ValidationError(`Node '${e.id}' parameters must be present (an empty object when there are none)`);if(t.add(e.id),e.inputBindings)for(const[t,o]of Object.entries(e.inputBindings)){if(te(t))throw new a.ValidationError(`Node '${e.id}' input binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!we(o))throw new a.ValidationError(`Node '${e.id}' input binding for '${t}' must be a valid GraphInputBinding (edge, literal, or expression)`);if("literal"===o.mode&&!ae(o.value))throw new a.ValidationError(`Node '${e.id}' literal binding for '${t}' must contain JSON-safe values`);if("expression"===o.mode&&!o.expression)throw new a.ValidationError(`Node '${e.id}' expression binding for '${t}' must contain a non-empty expression`)}if(e.outputBindings)for(const[t,o]of Object.entries(e.outputBindings)){if(te(t))throw new a.ValidationError(`Node '${e.id}' output binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!o||"object"!=typeof o||Array.isArray(o))throw new a.ValidationError(`Node '${e.id}' output binding for '${t}' must be an object with enabled and alias settings`)}if(!ae(e.parameters))throw new a.ValidationError(`Node '${e.id}' parameters must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`);if(void 0!==e.state){if(!e.state||"object"!=typeof e.state||Array.isArray(e.state))throw new a.ValidationError(`Node '${e.id}' state must be an object when present`);if(!ae(e.state))throw new a.ValidationError(`Node '${e.id}' state must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}}function Ee(e,t,o){if(!t.body||"object"!=typeof t.body)throw new a.ValidationError(`Node '${e.id}' loop configuration requires a body document`);if(ve(t.body,o),!(void 0===t.maxIterations||Number.isFinite(t.maxIterations)&&t.maxIterations>0))throw new a.ValidationError(`Node '${e.id}' loop maxIterations must be a positive number`);if(void 0!==t.timeoutMs&&("number"!=typeof t.timeoutMs||0>=t.timeoutMs))throw new a.ValidationError(`Node '${e.id}' loop timeoutMs must be a positive number in milliseconds`);if(void 0!==t.concurrency&&("number"!=typeof t.concurrency||0>=t.concurrency))throw new a.ValidationError(`Node '${e.id}' loop concurrency must be a positive number`);for(const o of[t.inputMappings,t.outputMappings])if(o)for(const[t,n]of Object.entries(o)){if(te(t))throw new a.ValidationError(`Node '${e.id}' loop mapping key '${t}' is not allowed (unsafe prototype-pollutant key)`);Ae(n,e.id,t)}}function Ie(e,t,o){if(!t.try||"object"!=typeof t.try)throw new a.ValidationError(`Node '${e.id}' error-boundary configuration requires a try body document`);ve(t.try,o);for(const[n,r]of[["catch",t.catch],["finally",t.finally]])if(void 0!==r){if(!r||"object"!=typeof r)throw new a.ValidationError(`Node '${e.id}' error-boundary ${n} body must be a document`);ve(r,o)}}function Ae(e,t,o){if(!e||"object"!=typeof e)throw new a.ValidationError(`Node '${t}' loop mapping '${o}' must reference a workflow port, node port, literal, or expression`);switch(e.source){case"workflow":if("string"!=typeof e.port||!e.port)throw new a.ValidationError(`Node '${t}' loop mapping '${o}' referencing a workflow must reference a port identifier`);break;case"node":if("string"!=typeof e.nodeId||!e.nodeId||"string"!=typeof e.port||!e.port)throw new a.ValidationError(`Node '${t}' loop mapping '${o}' referencing a node must reference a node id and a port`);break;case"literal":if(!ae(e.value))throw new a.ValidationError(`Node '${t}' loop mapping '${o}' literal references must be JSON-safe values`);break;case"expression":if("string"!=typeof e.expression||!e.expression)throw new a.ValidationError(`Node '${t}' loop mapping '${o}' expression references must be non-empty expressions`);break;default:throw new a.ValidationError(`Node '${t}' loop mapping '${o}' must use a workflow, node, literal, or expression reference source`)}}function Oe(e,t){if("string"!=typeof e.id||!e.id)throw new a.ValidationError("Edge 'id' is required and must be a non-empty string");if(t.has(e.id))throw new a.ValidationError(`Edge id '${e.id}' is declared more than once; edge ids must be unique`);if(!ye(e.source))throw new a.ValidationError(`Edge '${e.id}' source endpoint is not a valid GraphEndpoint`);if(!ye(e.target))throw new a.ValidationError(`Edge '${e.id}' target endpoint is not a valid GraphEndpoint`);if("data"!==e.type&&"connection"!==e.type)throw new a.ValidationError(`Edge '${e.id}' type '${e.type+""}' is not a valid edge type (data or connection are allowed)`);if(t.add(e.id),!ae(e))throw new a.ValidationError(`Edge '${e.id}' contains values that are not JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}function ke(e,t,o,n,r){if(ge(e)){if(!o.has(e.port))throw new a.ValidationError(`${r} references workflow port '${e.port}' which is not declared on the document`)}else if(me(e)){if(!n.has(e.nodeId))throw new a.ValidationError(`${r} references node '${e.nodeId}' which is not part of the document`);if("string"!=typeof e.port||!e.port)throw new a.ValidationError(r+" node endpoints must reference a non-empty port identifier")}}const xe=["expression","template"],Se=["javascript","typescript","json","text"];function De(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return!(!(e=>xe.includes(e))(t.mode)||"string"!=typeof t.expression||!t.expression||void 0!==t.language&&!(e=>Se.includes(e))(t.language)||void 0!==t.metadata&&!re(t.metadata))}function Re(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.name&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}function Pe(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.type&&(void 0===t.required||"boolean"==typeof t.required)&&(void 0===t.displayName||"string"==typeof t.displayName)&&(void 0===t.allowedOperations||Array.isArray(t.allowedOperations)&&t.allowedOperations.every(e=>"string"==typeof e))}const Ce=["trigger","loop","branching","stateful","retryable","cancellable","parallel","resource"];function Te(e){return Ce.includes(e)}function $e(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.kind&&"object"==typeof t.display&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.parameters)}function Ge(e){if(!$e(e))throw new a.ValidationError("Graph node manifest does not conform to the required shape");if(!ae(e))throw new a.ValidationError("Graph node manifest contains values that are not JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys or unsafe prototype keys are not allowed on manifests")}function Le(e){return Ge(e),ie(e)}function Me(e){if(!$e(e))throw new a.ValidationError("Serialized graph node manifest does not conform to the required shape");return ie(e)}const Fe=["loadOptions","listSearch","resourceLocator","resourceMapping","validateParameter","action"];function Ve(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.name&&(e=>Fe.includes(e))(t.type)&&(void 0===t.parameter||"string"==typeof t.parameter)&&(void 0===t.dependencies||Array.isArray(t.dependencies)&&t.dependencies.every(e=>"string"==typeof e))}function je(e){const t=e.element?.props?.value,o=t??e.prop?.value??e.validation?.defaultValue;if(void 0!==o&&"function"!=typeof o&&ae(o))try{return JSON.parse(JSON.stringify(o))}catch{return}}function Ue(e){if(e.type&&e.type in de)return{type:"string",format:de[e.type]};const t=(e=>{for(const t of[e.graph?.type,e.element?.props?.type,e.prop?.type])if("string"==typeof t&&"any"!==le(t))return t})(e);return t?pe((e=>{if(!e)return;const t=Object.entries(e).filter(([e])=>e!==r.ValidationKeys.TYPE);return Object.fromEntries(t)})(e.validation),t):pe(e.validation,e.type,e.model)}function Be(e){const t={};for(const[o,n]of Object.entries(e.graph?.metadata??{}))ae(n)&&(t[o]=JSON.parse(JSON.stringify(n)));return Object.keys(t).length?t:void 0}function We(e){switch(e){case"output":return"output";case"connection":return"connection";default:return"input"}}function qe(e){const t=e.graph?.handle;return"connection"!==e.direction&&"string"==typeof t&&t?t:e.path??e.property}function He(e,t){const o={id:qe(e),label:e.label,direction:We(e.direction),schema:Ue(e)};e.required&&(o.required=!0),e.hidden&&(o.hidden=!0);const n=e.graph?.category;"string"==typeof n&&(o.category=n),!0===e.graph?.userControlled&&(o.configurable=!0);const r=e.graph?.handle;"string"==typeof r&&(o.handle=r);const a=ot(e.graph?.connectionRules)??t;a&&(o.connectionPolicy=a);const i=(e=>{const t=e.element;if(!t||!ae(t))return;const o=t.tag;if("string"!=typeof o)return;const n=t.props;return{tag:o,serialize:!0===t.serialize,props:n&&"object"==typeof n&&!Array.isArray(n)?ie(n):{}}})(e);i&&(o.element=i);const s=Be(e);return s&&(o.metadata=s),o}function Ke(e){const t={type:"string",id:qe(e),label:e.label,required:e.required};if(e.hidden)return((e,t)=>{const o={...t,type:"hidden"},n=je(e);return void 0!==n&&(o.defaultValue=n),ze(o)})(e,t);const o=je(e);void 0!==o&&(t.defaultValue=o);const n=(e=>{const t=e.element?.props?.placeholder??e.prop?.placeholder;return"string"==typeof t?t:void 0})(e);n&&(t.placeholder=n);const r=Be(e);if(r&&(t.metadata=r),(e=>{const t=Ye(e);return"code"===t||"code-editor"===t})(e))return ze({...t,type:"code",language:et(e)});const a=Ue(e);switch(a.type){case"number":{const o={...t,type:"number",integer:a.integer,min:a.min,max:a.max},n=Je(e.validation?.step);return void 0!==n&&(o.step=n),ze(o)}case"boolean":return ze({...t,type:"boolean"});case"enum":return ze({...t,type:"options",options:a.values.map(e=>({value:e,label:e+""}))});case"array":{const e={...t,type:"collection"};return void 0!==a.maxItems&&(e.maxItems=a.maxItems),ze(e)}case"object":case"model":return ze({...t,type:"object"});default:return ze({...t,type:"string",multiline:!!Qe(e)||void 0,pattern:Xe(e.validation?.pattern),minLength:Je(e.validation?.minlength),maxLength:Je(e.validation?.maxlength)})}}function ze(e){const t=e;for(const e of Object.keys(t))void 0===t[e]&&delete t[e];return e}function Xe(e){const t=e?.value;return"string"==typeof t?t:void 0}function Je(e){const t=e?.value;return"number"==typeof t&&Number.isFinite(t)?t:void 0}function Ye(e){const t=e.element?.tag;return"string"==typeof t&&t?t:void 0}function Qe(e){return"textarea"===Ye(e)||"textarea"===(e=>{const t=e.element?.props?.type;return"string"==typeof t?t:void 0})(e)}const Ze=["javascript","typescript","json","text"];function et(e){const t=e.element?.props?.language;return"string"==typeof t&&Ze.includes(t)?t:"javascript"}function tt(e,t){const o={name:t.name??e.name},n=e.graph?.metadata?.description??void 0;"string"==typeof n&&n&&(o.description=n);const r=t.category??e.category;"string"==typeof r&&r&&(o.category=r),"string"==typeof e.group&&e.group&&(o.group=e.group),Array.isArray(e.labels)&&(o.labels=e.labels.slice());const a=((e,t)=>{if(t.icon)return t.icon;const o=e.effectiveIcon??e.icon;return"string"==typeof o?{type:"catalogue",name:o}:{type:"catalogue",name:"ph:circuitry"}})(e,t);return a&&(o.icon=a),"string"==typeof e.color&&e.color&&(o.color=e.color),"number"==typeof e.width&&Number.isFinite(e.width)&&(o.width=e.width),"number"==typeof e.minWidth&&Number.isFinite(e.minWidth)&&(o.minWidth=e.minWidth),"number"==typeof e.height&&Number.isFinite(e.height)&&(o.height=e.height),"string"==typeof e.shape&&(o.shape=e.shape),"number"==typeof e.cornerRadius&&Number.isFinite(e.cornerRadius)&&(o.cornerRadius=e.cornerRadius),Array.isArray(e.sizeRules)&&(o.sizeRules=e.sizeRules),o}function ot(e){if(!e)return;const t=e,o={};"boolean"==typeof t.allowSelf&&(o.allowSelf=t.allowSelf),"boolean"==typeof t.allowMultiple&&(o.allowMultiple=t.allowMultiple);const n=t.allowedKinds;Array.isArray(n)&&n.every(e=>"string"==typeof e)&&(o.allowedNodeKinds=n);const r=t.blockedKinds;Array.isArray(r)&&r.every(e=>"string"==typeof e)&&(o.blockedNodeKinds=r);const a=t.maxConnections;return"number"==typeof a&&Number.isFinite(a)&&(o.maxConnections=a),Object.keys(o).length?o:void 0}function nt(e,t={}){const o="function"==typeof e?e:e.constructor;if(!F(o))throw new a.ValidationError(`Node '${o?.name??e+""}' is not decorated with @node and cannot produce a manifest`);const n=H(o),r=q(B(o)),i=[],s=[],d=[],l=[],c=ot(n.graph?.connectionRules);for(const e of r)("connection"===e.direction?d:"output"===e.direction?s:i).push(He(e,c)),"input"===e.direction&&l.push(Ke(e));const u={kind:t.kind??n.kind??n.name,display:tt(n,t),inputs:i,outputs:s,parameters:l};return d.length&&(u.connections=d),n.namespaces?.length&&(u.namespaces=n.namespaces.slice()),Ge(u),u}var rt,at;(e=>{e.READABILITY="readability",e.COMPACTNESS="compactness",e.BALANCED="balanced"})(rt||(rt={})),(e=>{e.TIGHT="tight",e.NORMAL="normal",e.COMFORTABLE="comfortable"})(at||(at={})),at.TIGHT,at.NORMAL,at.COMFORTABLE,rt.READABILITY,at.COMFORTABLE,rt.COMPACTNESS,at.TIGHT,rt.BALANCED,at.NORMAL;let it=class extends s.BaseModel{constructor(e){super(e)}};i.__decorate([s.pk({type:String,generated:!1}),n.description("Unique graph run id"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.id.label",readonly:!0}),i.__metadata("design:type",String)],it.prototype,"runId",void 0),i.__decorate([s.column(),r.required(),s.index(),n.description("Workflow document id the run executes"),o.uilistprop("workflowId"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.workflowId.label"}),i.__metadata("design:type",String)],it.prototype,"workflowId",void 0),i.__decorate([s.column(),n.description("Owning user; absent for anonymous callers"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.owner.label"}),i.__metadata("design:type",String)],it.prototype,"owner",void 0),i.__decorate([s.column(),r.required(),r.type(String),s.index(),n.description("Current run lifecycle status"),o.uilistprop("status"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.status.label",readonly:!0}),i.__metadata("design:type",String)],it.prototype,"status",void 0),i.__decorate([s.column(),n.description("Fingerprint of the executed document"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.fingerprint.label",readonly:!0}),i.__metadata("design:type",String)],it.prototype,"documentFingerprint",void 0),i.__decorate([s.column(),n.prop(),n.description("Workflow input values keyed by input port id"),i.__metadata("design:type",Object)],it.prototype,"inputs",void 0),i.__decorate([s.column(),n.prop(),n.description("Execution result, present on successful completion"),i.__metadata("design:type",Object)],it.prototype,"result",void 0),i.__decorate([s.column(),n.prop(),n.description("Structured error payload, present on failure"),i.__metadata("design:type",Object)],it.prototype,"error",void 0),i.__decorate([r.date(),s.column(),n.description("Run creation timestamp"),i.__metadata("design:type",Date)],it.prototype,"createdAt",void 0),i.__decorate([r.date(),s.column(),n.description("Execution start timestamp, once it has started"),i.__metadata("design:type",Date)],it.prototype,"startedAt",void 0),i.__decorate([r.date(),s.column(),n.description("Terminal-state timestamp, once the run has finished"),i.__metadata("design:type",Date)],it.prototype,"finishedAt",void 0),it=i.__decorate([o.uilistmodel("ngx-decaf-list-item",{icon:"ti-player-play"}),o.uimodel("ngx-decaf-crud-form"),n.description("Persistable graph run lifecycle record"),s.table("graph_run"),r.model(),i.__metadata("design:paramtypes",[Object])],it);let st=class extends s.BaseModel{constructor(e){super(e)}};i.__decorate([s.pk({type:String,generated:!1}),i.__metadata("design:type",String)],st.prototype,"workflowId",void 0),i.__decorate([s.column(),i.__metadata("design:type",String)],st.prototype,"name",void 0),i.__decorate([s.column(),i.__metadata("design:type",Object)],st.prototype,"document",void 0),i.__decorate([s.column(),i.__metadata("design:type",String)],st.prototype,"owner",void 0),i.__decorate([s.column(),i.__metadata("design:type",Object)],st.prototype,"snapshot",void 0),st=i.__decorate([s.table("graph_workflow"),r.model(),i.__metadata("design:paramtypes",[Object])],st);let dt=class extends s.BaseModel{constructor(e){super(e)}};i.__decorate([s.pk({type:String,generated:!1}),i.__metadata("design:type",String)],dt.prototype,"kind",void 0),i.__decorate([s.column(),s.index(),i.__metadata("design:type",String)],dt.prototype,"name",void 0),i.__decorate([s.column(),s.index(),i.__metadata("design:type",String)],dt.prototype,"category",void 0),i.__decorate([s.column(),i.__metadata("design:type",String)],dt.prototype,"group",void 0),i.__decorate([s.column(),i.__metadata("design:type",String)],dt.prototype,"description",void 0),i.__decorate([s.column(),i.__metadata("design:type",Object)],dt.prototype,"manifest",void 0),dt=i.__decorate([s.table("graph_node"),r.model(),i.__metadata("design:paramtypes",[Object])],dt),v("Trigger",{color:"#3b82f6",icon:"ti-bolt"}),v("Flow Control",{color:"#f59e0b",icon:"ti-arrows-split-2"}),v("Utility",{color:"#0d9488",icon:"ti-tool"}),v("Loop",{color:"#eab308",icon:"ti-repeat"}),v("Workflow",{color:"#f97316",icon:"ti-sitemap"}),v("Pipeline",{color:"#0ea5e9",icon:"ti-git-merge"}),v("Node",{color:"#8b5cf6",icon:"ti-point-filled"}),v("Agent",{color:"#7c3aed",icon:"ti-robot"}),v("model",{color:"#3b82f6",icon:"ti-cpu"}),v("memory",{color:"#10b981",icon:"ti-database"}),v("workspace",{color:"#f59e0b",icon:"ti-folder"});const lt=new Set;function ct(e,t){return e.config[t]}function ut(e){return Array.isArray(e)?e.map(e=>e+"").join(", "):e+""}(()=>{const e=[{key:x.NODE_ID,shouldInclude:e=>null!=ct(e,x.NODE_ID),render:e=>ct(e,x.NODE_ID)+""},{key:x.WORKFLOW_ID,shouldInclude:e=>null!=ct(e,x.WORKFLOW_ID),render:e=>ct(e,x.WORKFLOW_ID)+""},{key:x.RUN_ID,shouldInclude:e=>null!=ct(e,x.RUN_ID),render:e=>ct(e,x.RUN_ID)+""},{key:x.USER,shouldInclude:e=>null!=ct(e,x.USER),render:e=>ct(e,x.USER)+""},{key:x.ROLES,shouldInclude(e){const t=ct(e,x.ROLES);return Array.isArray(t)&&t.length>0},render:e=>ut(ct(e,x.ROLES))},{key:x.NAMESPACES,shouldInclude(e){const t=ct(e,x.NAMESPACES);return Array.isArray(t)&&t.length>0},render:e=>ut(ct(e,x.NAMESPACES))},{key:x.ORGANIZATION,shouldInclude:e=>null!=ct(e,x.ORGANIZATION),render:e=>ct(e,x.ORGANIZATION)+""},{key:x.IP,shouldInclude:e=>null!=ct(e,x.IP),render:e=>ct(e,x.IP)+""}];for(const o of e)lt.has(o.key)||(t.logParameterRegistry.register(o),lt.add(o.key))})();const pt="$workflow",ht="local",ft=1e3,gt=1e4,mt=3e4;var yt,wt;e.GraphPinningStrategy=void 0,(yt=e.GraphPinningStrategy||(e.GraphPinningStrategy={})).MANUAL="manual",yt.AUTOMATIC="automatic",yt.DISABLED="disabled",e.GraphConditionType=void 0,(wt=e.GraphConditionType||(e.GraphConditionType={})).TRUTHY="truthy",wt.FALSY="falsy",wt.EQUALS="equals",wt.NOT_EQUALS="notEquals",wt.GREATER_THAN="greaterThan",wt.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",wt.LESS_THAN="lessThan",wt.LESS_THAN_OR_EQUAL="lessThanOrEqual",wt.EXISTS="exists",wt.CUSTOM="custom";class _t extends a.InternalError{constructor(e,t="GRAPH_EXECUTION_ERROR",o){super(e,_t.name,500),this.graphCode=t,this.details=o,this.name=this.constructor.name}}class bt extends _t{constructor(e){super("Graph workflow contains an unsupported cycle","GRAPH_CYCLE_ERROR",e)}}class vt extends _t{constructor(e,t){super(e,"GRAPH_INPUT_ERROR",t)}}class Nt extends _t{constructor(e,t){super(e,"GRAPH_LOOP_LIMIT_ERROR",t)}}class Et extends _t{constructor(e,t){super(e,"GRAPH_PINNING_ERROR",t)}}class It extends _t{constructor(e,t){super(e,"GRAPH_STORE_ERROR",t)}}class At extends _t{constructor(e,t){super(e,"GRAPH_TOPOLOGY_ERROR",t)}}class Ot extends _t{constructor(e){super("Break signal","GRAPH_BREAK_SIGNAL",{value:e}),this.isBreakSignal=!0,this.name="GraphBreakSignal"}}class kt extends _t{constructor(e){super(`Graph run '${e}' was cancelled`,"GRAPH_RUN_CANCELLED",{runId:e}),this.name=kt.name}}class xt extends a.ValidationError{constructor(e){super(`Graph workflow document rejected with ${e.length} issue(s): ${e.map(e=>`${e.code} at ${e.path} (${e.message})`).join("; ")}`),this.name=xt.name,this.issues=e}}class St{constructor(){this.observers=new Set}observe(e){return this.observers.add(e),()=>this.unObserve(e)}unObserve(e){this.observers.delete(e)}async updateObservers(e){await Promise.all(Array.from(this.observers).map(async t=>{try{await Promise.resolve(t.refresh(e))}catch{}}))}}class Dt{constructor(){this.sequence=0}create(e){return{...e,id:this.createEventId(),sequence:++this.sequence,timestamp:new Date}}createEventId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new _t("Cannot generate a graph event id: crypto.randomUUID is unavailable in this runtime","GRAPH_EVENT_ID_ERROR",{runtime:typeof globalThis.crypto});return e.randomUUID()}}function Rt(e){if("string"!=typeof e)return;const t=e.trim();if(!t)return;const o=t.split(".");if(3!==o.length)return;const n=o[0].trim(),r=o[2].trim(),a=o[1].split(",").map(e=>e.trim()).filter(e=>e.length>0);return n&&r&&0!==a.length?{organization:n,departments:a,role:r}:void 0}function Pt(e){return`${e.organization}.${e.departments.join(",")}.${e.role}`}function Ct(e){if(!e||"string"!=typeof e.namespace||!e.parts)return!1;const t=Rt(e.namespace);return!!t&&Pt(t)===Pt(e.parts)}function Tt(e,t){const o="string"==typeof e?e.trim():"";if(o){if(t)for(const e of t)if(e&&e.namespace===o&&Ct(e))return e.parts;return Rt(o)}}function $t(e,t,o={},n){const r=Tt(e,n),a=Tt(t,n);return!(!r||!a)&&r.organization===a.organization&&r.role===a.role&&("exact"===(o.mode??"inherit")?r.departments.length===a.departments.length&&r.departments.every((e,t)=>e===a.departments[t]):r.departments.length<=a.departments.length&&r.departments.every((e,t)=>e===a.departments[t]))}function Gt(e,t,o={},n){return e.filter(e=>!t.some(t=>$t(t,e,o,n)))}function Lt(e){return e.filter(e=>void 0===Rt(e))}function Mt(e,t){const o=new Set;for(const n of e){const e=Tt(n,t);e&&o.add(e.role)}return[...o]}function Ft(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function Vt(e,t){try{const o=e.cache;if(o&&void 0!==o[t]&&null!==o[t])return o[t]}catch{}try{return e.get(t)}catch{return}}function jt(e){if(!e)return{};const t={},o=e.user;"string"==typeof o&&o&&(t.user=o);const n=e.organization;"string"==typeof n&&n&&(t.organization=n);const r=e.ip;"string"==typeof r&&r&&(t.ip=r);const a=Ft(e.roles);a&&(t.roles=a);const i=Ft(e.namespaces);return i&&(t.namespaces=i,t.namespaceCache=Bt(i)),t}function Ut(e){return e?jt({user:Vt(e,"user"),organization:Vt(e,"organization"),ip:Vt(e,"ip"),roles:Vt(e,"roles"),namespaces:Vt(e,"namespaces")}):{}}function Bt(e){const t=[];for(const o of e){const e=Rt(o);e&&t.push({namespace:o,parts:e})}return t}function Wt(...e){const t={};for(const o of e)o&&(void 0!==o.user&&(t.user=o.user),void 0!==o.organization&&(t.organization=o.organization),void 0!==o.ip&&(t.ip=o.ip),void 0!==o.roles&&(t.roles=o.roles),void 0!==o.namespaces&&(t.namespaces=o.namespaces),void 0!==o.namespaces?t.namespaceCache=o.namespaceCache??Bt(o.namespaces):void 0!==o.namespaceCache&&(t.namespaceCache=o.namespaceCache));return t}class qt{constructor(e={}){this.options=e}get enabled(){return!0===this.options.enabled}validate(e,o,n,r){if(!this.enabled)return;const a=r??this.options.logger??t.Logging.for("GraphAuth"),i=e.id||e.name||o.workflowId,s=(e=>{if(!e||"object"!=typeof e)return;const t=e.auth;return t&&"object"==typeof t&&!Array.isArray(t)?(e=>{if(!e)return;const t=C(e.namespaces),o=C(e.roles);if(!t&&!o)return;const n={};return t&&(n.namespaces=t),o&&(n.roles=o),n})(t):void 0})(e.metadata);this.assertGranted(`workflow '${i}'`,s?.namespaces??[],n,s?.roles??[],a);for(const e of o.nodes)this.assertGranted(`node '${e.id}'`,e.manifest.namespaces??[],n,[],a)}assertGranted(e,t,o,n,r){const a=o.namespaces??[],i=Gt(t,a,this.options.match,o.namespaceCache),d=Mt(a,o.namespaceCache),l=n.filter(e=>!d.includes(e));if(0===i.length&&0===l.length)return;const c=[...new Set([...Lt(t),...Lt(a)])],u=[];throw i.length&&u.push("namespace(s) "+i.join(", ")),l.length&&u.push("role(s) "+l.join(", ")),r.warn(`Graph access denied for ${e} for user ${o.user??"anonymous"}: missing ${u.join(" and ")}${c.length?`; malformed namespace(s) ${c.join(", ")} failed closed`:""}`),new s.ForbiddenError(`Access to ${e} requires ${u.join(" and ")}`)}}class Ht{constructor(e){this.baseOptions=e,this.inner=t.Logging.for("GraphRun").for(this.attributeConfig(e))}attributeConfig(e){return{[x.NODE_ID]:e.nodeId,[x.WORKFLOW_ID]:e.workflowId,[x.RUN_ID]:e.runId,[x.USER]:e.user??null,[x.ROLES]:e.roles,[x.NAMESPACES]:e.namespaces,[x.ORGANIZATION]:e.organization,[x.IP]:e.ip}}emit(e,t,o){const n="string"==typeof t?t:t instanceof Error?t.message:t+"",r={level:e,message:n,timestamp:(new Date).toISOString(),runId:this.baseOptions.runId,workflowId:this.baseOptions.workflowId,nodeId:this.baseOptions.nodeId,user:this.baseOptions.user??null};void 0!==this.baseOptions.roles&&(r.roles=this.baseOptions.roles),void 0!==this.baseOptions.namespaces&&(r.namespaces=this.baseOptions.namespaces),void 0!==this.baseOptions.organization&&(r.organization=this.baseOptions.organization),void 0!==this.baseOptions.ip&&(r.ip=this.baseOptions.ip),void 0!==o&&(r.payload=o),this.baseOptions.forward({type:S.GRAPH_RUN_LOG,payload:r}).catch(()=>{}),{benchmark:(e,t)=>this.inner.benchmark(e,t),fatal:(e,t)=>this.inner.fatal(e,t),critical:(e,t)=>this.inner.critical(e,t),silly:(e,t)=>this.inner.silly(e,t),trace:(e,t)=>this.inner.trace(e,t),verbose:(e,t)=>this.inner.verbose(e,t),info:(e,t)=>this.inner.info(e,t),warn:(e,t)=>this.inner.warn(e,t),error:(e,t)=>this.inner.error(e,t),debug:(e,t)=>this.inner.debug(e,t)}[e](n,o)}benchmark(e,t){this.emit("benchmark",e,t)}fatal(e,t,o){this.emit("fatal",e,t??o)}critical(e,t,o){this.emit("critical",e,t??o)}silly(e,t,o){this.emit("silly",e,"object"==typeof t?t:o)}trace(e,t){this.emit("trace",e,t)}verbose(e,t,o){this.emit("verbose",e,"object"==typeof t?t:o)}info(e,t){this.emit("info",e,t)}error(e,t,o){this.emit("error",e,t??o)}warn(e,t){this.emit("warn",e,t)}debug(e,t){this.emit("debug",e,t)}action(e,t,o){this.inner.action(e,t,o)}setConfig(){}for(e,t,...o){return this}clear(){return this}get root(){return this.inner.root}}function Kt(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}class zt extends s.Context{constructor(e,t,o,n,r,a,i,s,d={},l,c,u){super(),this.runId=e,this.parentRunId=t,this.workflowId=o,this.document=n,this.node=r,this.manifest=a,this.path=i,this.emitFn=s,this.metadata=d,this.engine=l,this.abortSignal=c,this.limits=u;const p=jt(d);this.accumulate({...p,operation:"execute"});const h="string"==typeof d?.user?d.user:null;this.runLogger=new Ht({runId:e,workflowId:o,nodeId:r.id,user:h,roles:Kt(d?.roles),namespaces:Kt(d?.namespaces),organization:"string"==typeof d?.organization?d.organization:void 0,ip:"string"==typeof d?.ip?d.ip:void 0,forward:async e=>{await this.emit(e)}})}get logger(){return this.runLogger}get auth(){return Ut(this)}async emit(e){await this.emitFn({...e,runId:this.runId,parentRunId:this.parentRunId,workflowId:this.workflowId,nodeId:this.node.id,path:e.path??this.path})}async progress(e){await this.emit({type:S.NODE_OUTPUT,payload:e})}async log(e,t){await this.emit({type:S.NODE_OUTPUT,payload:{message:e,payload:t}})}}class Xt{constructor(e,t,o,n){this.nodeResults=new Map,this.events=[],this.activeDataEdges=new Set,this.runId=e,this.plan=t,this.valueStore=o,this.eventFactory=n,this.startedAt=new Date}recordNodeResult(e){this.nodeResults.set(e.nodeId,e)}activateDataEdge(e){this.activeDataEdges.add(e)}isDataEdgeActive(e){return this.activeDataEdges.has(e)}appendEvent(e){this.events.push(e)}finish(){this.finishedAt=new Date}}function Jt(e,t,o,n,r){const a=e.valueStore.getWorkflowValues(),i={};for(const[t,o]of e.nodeResults)i[t]=o;const s=[...e.events];return{runId:e.runId,workflowId:t.id||t.name,status:n,document:t,inputs:{...o},outputs:a,nodeResults:i,events:s,startedAt:e.startedAt,finishedAt:e.finishedAt,metadata:r}}class Yt{constructor(e,t,o){this.emitter=e,this.eventFactory=t,this.options=o}get engine(){return this.options.engine}get codeSandboxEvaluator(){return this.options.codeSandboxEvaluator}get frame(){return this._frame}bindFrame(e){this._frame=e}async emit(e){const t=this.eventFactory.create({id:"",sequence:0,timestamp:new Date,runId:this.options.runId,parentRunId:this.options.parentRunId,workflowId:this.options.workflowId,type:S.NODE_OUTPUT,path:this.options.path??[],...e});this._frame?.appendEvent(t),await this.emitter.updateObservers(t)}async updateObservers(e){await this.emitter.updateObservers(e)}}function Qt(e){const t=e.capabilities;return{codeMode:t?.codeMode??e.codeMode,workflows:{list:t?.workflows?.list??("function"==typeof e.listWorkflows?"supported":"not_supported"),get:t?.workflows?.get??("function"==typeof e.getWorkflow?"supported":"not_supported")}}}class Zt{static{this._cache={}}static register(e,t){return Zt._cache[e]=t,t}static get(e){const t=e??Zt._currentFlavour;if(t)return Zt._cache[t]}static getOrFail(e){const t=Zt.get(e);if(!t)throw new _t(`No graph execution backend registered under '${e}'`,"GRAPH_EXECUTION_BACKEND_NOT_REGISTERED");return t}static get current(){return Zt.get()}static get currentFlavour(){return Zt._currentFlavour??ht}static setCurrent(e){Zt._currentFlavour=e}static list(){return Object.entries(Zt._cache).map(([e,t])=>({flavour:e,backend:t}))}static unregister(e){e&&(delete Zt._cache[e],Zt._currentFlavour===e&&(Zt._currentFlavour=void 0))}static clear(){for(const e of Object.keys(Zt._cache))delete Zt._cache[e];Zt._currentFlavour=void 0}}class eo{evaluate(e,t){switch(e.op){case"eq":return this.resolveValue(e.left,t)===this.resolveValue(e.right,t);case"neq":return this.resolveValue(e.left,t)!==this.resolveValue(e.right,t);case"gt":return Number(this.resolveValue(e.left,t))>Number(this.resolveValue(e.right,t));case"gte":return Number(this.resolveValue(e.left,t))>=Number(this.resolveValue(e.right,t));case"lt":return Number(this.resolveValue(e.left,t))<Number(this.resolveValue(e.right,t));case"lte":return Number(this.resolveValue(e.left,t))<=Number(this.resolveValue(e.right,t));case"and":return e.conditions.every(e=>this.evaluate(e,t));case"or":return e.conditions.some(e=>this.evaluate(e,t));case"not":return!this.evaluate(e.condition,t);case"exists":return void 0!==this.resolveValue(e.value,t)&&null!==this.resolveValue(e.value,t);default:throw new _t(`Unknown ConditionExpression op '${e.op}'`,"GRAPH_UNKNOWN_CONDITION_OP",{expr:e})}}resolveValue(e,t){if("const"in e)return e.const;if("path"in e&&!("step"in e))return this.resolvePath(e.path,t);if("step"in e&&"path"in e){const o=t?.nodes;if(o&&"object"==typeof o){const t=o[e.step];return this.resolvePath(e.path,t)}return this.resolvePath(e.path,t)}throw new _t("Invalid ExprValue: must have `const`, `path`, or `step`+`path`","GRAPH_INVALID_EXPR_VALUE",{ref:e})}resolvePath(e,t){if(!e)return t;const o=e.split(".");let n=t;for(const e of o){if(null==n)return;n=n[e]}return n}}function to(e){return"object"==typeof e&&null!==e&&"type"in e&&"code"===e.type}function oo(e){return"object"==typeof e&&null!==e&&"op"in e&&"string"==typeof e.op}async function no(e,t,o){const n=o.engine?.codeSandboxEvaluator;if(!n)throw new _t("Code conditions require a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:e.code});await o.log("Evaluating code condition",{language:e.language??"javascript"});const r=o.metadata;return!!await n.evaluate({code:e.code,language:e.language,input:t,vars:r?.vars??void 0,item:r?.item,index:r?.index,nodes:r?.nodes??void 0,logger:o.logger,abortSignal:o.abortSignal})}function ro(e,t,o){if(oo(e))return(new eo).evaluate(e,t);throw((e,t)=>new _t(`Unknown ${t??"flow"} condition type \u2014 must be ConditionExpression (op) or CodeCondition (type: 'code')`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e}))(e,o)}async function ao(e,t,o){return to(e)?no(e,t.input,o):ro(e,t.state,t.label)}function io(e,t,o,n){if(e&&"object"==typeof e&&!n.has(e))if(n.add(e),to(e))o.push({nodeId:t,kind:"code-condition"});else if(De(e))o.push({nodeId:t,kind:"value-template"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"expression"===t.source&&"string"==typeof t.expression})(e))o.push({nodeId:t,kind:"expression-binding"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.name&&Array.isArray(t.nodes)&&Array.isArray(t.edges)})(e))lo(e,o,n);else if(Array.isArray(e))for(const r of e)io(r,t,o,n);else for(const r of Object.keys(e))io(e[r],t,o,n)}function so(e,t,o){const n=e.id;"core.utility.code"===e.kind&&t.push({nodeId:n,kind:"code-node",detail:e.kind});const r=e.inputBindings??{};for(const[e,o]of Object.entries(r))o&&"expression"===o.mode&&t.push({nodeId:n,kind:"expression-binding",detail:e});io(e.parameters,n,t,o),io(e.metadata,n,t,o),io(e.state,n,t,o),io(e.loop,n,t,o)}function lo(e,t,o){for(const n of e.nodes??[])so(n,t,o)}function co(e){const t=[];return lo(e,t,new Set),t}function uo(e,t){if(!t)return{valid:!0};switch(t.type){case"any":default:return{valid:!0};case"string":return"string"!=typeof e?po("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?t.integer&&!Number.isInteger(e)?{valid:!1,message:"expected an integer number"}:void 0!==t.min&&e<t.min?{valid:!1,message:"expected a number >= "+t.min}:void 0!==t.max&&e>t.max?{valid:!1,message:"expected a number <= "+t.max}:{valid:!0}:po("number");case"boolean":return"boolean"!=typeof e?po("boolean"):{valid:!0};case"array":if(!Array.isArray(e))return po("array");if(void 0!==t.minItems&&e.length<t.minItems)return{valid:!1,message:`expected at least ${t.minItems} items`};if(void 0!==t.maxItems&&e.length>t.maxItems)return{valid:!1,message:`expected at most ${t.maxItems} items`};for(const o of e){const e=uo(o,t.items);if(!e.valid)return e}return{valid:!0};case"object":case"model":{if(null===e||"object"!=typeof e||Array.isArray(e))return po(t.type);const o=t,n=o.properties;if(!n)return{valid:!0};for(const[t,o]of Object.entries(n))if(t in e){const n=uo(e[t],o);if(!n.valid)return{valid:!1,message:`property '${t}': ${n.message}`}}if(o.required)for(const t of o.required)if(!(t in e))return{valid:!1,message:`missing required property '${t}'`};if(!1===o.additionalProperties)for(const t of Object.keys(e))if(!(t in n))return{valid:!1,message:`unexpected property '${t}'`};return{valid:!0}}case"enum":return t.values.some(t=>t===e)?{valid:!0}:{valid:!1,message:"value is not one of the enum values"}}}function po(e){return{valid:!1,message:`expected a ${e} value`}}function ho(e){if("string"==typeof e)return e.length>0;if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.credentialId&&t.credentialId.length>0&&(void 0===t.credentialType||"string"==typeof t.credentialType)}const fo=new Set(["loop"]),go=["secret","secrets","password","passwd","token","accessToken","refreshToken","apiKey","api_key","privateKey","credentials"];class mo{validate(e,t,o,n,r){this.validateParameters(e,t,o,n,r),this.validateMetadataKeys(e,t,o,n),this.validateDisabledBehavior(e,o,n),this.validateBindingShapes(e,t,o,n)}validateParameters(e,t,o,n,r){const a=!0===t.policies?.allowUndeclaredParameters,i=new Map(t.parameters.map(e=>[e.id,e]));for(const[r,s]of Object.entries(e.parameters??{})){const d=i.get(r);if(!d){a||o.push({code:"parameter.undeclared",path:`${n}.parameters.${r}`,message:`Node '${e.id}' sets parameter '${r}' which is not declared by kind '${t.kind}'`,nodeId:e.id,details:{kind:t.kind}});continue}if(void 0===s){o.push({code:"parameter.invalid",path:`${n}.parameters.${r}`,message:`Node '${e.id}' parameter '${r}' must not be undefined`,nodeId:e.id});continue}const l=this.checkParameterValue(s,d);l.valid||o.push({code:"parameter.type-mismatch",path:`${n}.parameters.${r}`,message:`Node '${e.id}' parameter '${r}' is invalid: ${l.message}`,nodeId:e.id,details:{expectedType:d.type}})}for(const a of t.parameters)void 0===(e.parameters??{})[a.id]&&(this.isParameterSatisfiedByInput(e,a.id,r)||(!0===a.required||(a.validation??[]).some(e=>"required"===e.kind))&&void 0===a.defaultValue&&o.push({code:"parameter.required-missing",path:`${n}.parameters.${a.id}`,message:`Node '${e.id}' is missing required parameter '${a.id}' declared by kind '${t.kind}'`,nodeId:e.id}))}isParameterSatisfiedByInput(e,t,o){return void 0!==(e.inputBindings??{})[t]||!0===o?.has(t)}checkParameterValue(e,t){if(De(e))return{valid:!0};switch(t.type){case"string":case"code":case"expression":return"string"!=typeof e?po("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?{valid:!0}:po("number");case"boolean":return"boolean"!=typeof e?po("boolean"):{valid:!0};case"options":{const o=t.options;return o&&o.length&&!o.some(t=>t.value===e)?{valid:!1,message:"value is not one of the declared options"}:{valid:!0}}case"collection":return Array.isArray(e)?{valid:!0}:po("array");case"object":case"resourceLocator":return null===e||"object"!=typeof e||Array.isArray(e)?po("object"):{valid:!0};case"credential":return ho(e)?t.credentialType&&"object"==typeof e&&void 0!==e.credentialType&&e.credentialType!==t.credentialType?{valid:!1,message:`credential type '${e.credentialType}' does not match the declared type '${t.credentialType}'`}:{valid:!0}:{valid:!1,message:"credential parameters must hold a credential reference (credentialId), never a secret"};default:return{valid:!0}}}validateMetadataKeys(e,t,o,n){const r=t.metadata?.allowedInstanceMetadataKeys;for(const a of Object.keys(e.metadata??{}))fo.has(a)?o.push({code:"metadata.key-not-allowed",path:`${n}.metadata.${a}`,message:`Node '${e.id}' metadata key '${a}' is reserved and must not be set directly`,nodeId:e.id}):Array.isArray(r)&&!r.includes(a)&&o.push({code:"metadata.key-not-allowed",path:`${n}.metadata.${a}`,message:`Node '${e.id}' metadata key '${a}' is not in the allowed metadata keys of kind '${t.kind}'`,nodeId:e.id})}validateDisabledBehavior(e,t,o){!0!==e.disabled&&!1!==e.disabled&&void 0!==e.disabled&&t.push({code:"disabled.invalid",path:o+".disabled",message:`Node '${e.id}' disabled flag must be a boolean`,nodeId:e.id});const n=(e.metadata??{}).disabledBehavior;void 0===n||A(n)||t.push({code:"disabled.invalid-behavior",path:o+".metadata.disabledBehavior",message:`Node '${e.id}' disabled behavior '${n+""}' is not one of: ${I.join(", ")}`,nodeId:e.id})}validateBindingShapes(e,t,o,n){for(const[r,a]of Object.entries(e.inputBindings??{})){if("literal"===a.mode){const i=t.inputs.find(e=>e.id===r);if(i?.schema){const t=uo(a.value,i.schema);t.valid||o.push({code:"binding.literal-invalid",path:`${n}.inputBindings.${r}`,message:`Node '${e.id}' literal binding for '${r}' is schema-invalid: ${t.message}`,nodeId:e.id})}}"expression"!==a.mode||"string"==typeof a.expression&&a.expression.trim()||o.push({code:"binding.expression-invalid",path:`${n}.inputBindings.${r}`,message:`Node '${e.id}' expression binding for '${r}' must contain a non-empty expression`,nodeId:e.id})}}validateBindingSatisfaction(e,t,o,n,r,a={}){const i=new Set(o.filter(e=>"data"===e.type).map(e=>e.targetPort)),s=new Set(Object.entries(e.inputBindings??{}).map(([e])=>e));for(const t of i){const o=(e.inputBindings??{})[t];o&&"literal"===o.mode&&!0!==a.allowLiteralAndEdgeBindings&&n.push({code:"binding.conflict",path:`${r}.inputBindings.${t}`,message:`Node '${e.id}' input '${t}' has both an incoming edge and a literal binding`,nodeId:e.id})}for(const o of t.inputs)!0===o.required&&(i.has(o.id)||s.has(o.id)||void 0===(e.parameters??{})[o.id]&&n.push({code:"topology.required-input-unsatisfiable",path:r+".parameters",message:`Node '${e.id}' required input '${o.id}' has no incoming edge or binding`,nodeId:e.id,details:{port:o.id}}))}static disabledBehaviorOf(e,t){const o=(e.metadata??{}).disabledBehavior;if(A(o))return o;const n=t?.disabledBehavior;return A(n)?n:"skip"}}function yo(e){return[e.namespace??"default",e.workflowId,e.nodeId,e.version??"default",e.fingerprint].join(":")}function wo(t){return new e.GraphValueModel({id:yo(t.key),workflowId:t.key.workflowId,nodeId:t.key.nodeId,fingerprint:t.key.fingerprint,...void 0!==t.key.namespace?{namespace:t.key.namespace}:{},...void 0!==t.key.version?{version:t.key.version}:{},pinned:t.pinned,outputs:t.outputs,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt),...t.expiresAt?{expiresAt:new Date(t.expiresAt)}:{},...t.metadata?{metadata:t.metadata}:{}})}function _o(e){return{key:{workflowId:e.workflowId,nodeId:e.nodeId,fingerprint:e.fingerprint,...void 0!==e.namespace?{namespace:e.namespace}:{},...void 0!==e.version?{version:e.version}:{}},outputs:e.outputs,pinned:e.pinned,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString(),...e.expiresAt?{expiresAt:e.expiresAt.toISOString()}:{},...e.metadata?{metadata:e.metadata}:{}}}function bo(t){return new(0,s.Repository.forModel(e.GraphValueModel,t.alias).constructor)(t)}e.GraphValueModel=class extends s.BaseModel{constructor(e){super(e)}},i.__decorate([s.pk({type:String,generated:!1}),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"id",void 0),i.__decorate([s.column(),s.index(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"workflowId",void 0),i.__decorate([s.column(),s.index(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"nodeId",void 0),i.__decorate([s.column(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"fingerprint",void 0),i.__decorate([s.column(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"namespace",void 0),i.__decorate([s.column(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"version",void 0),i.__decorate([s.column(),i.__metadata("design:type",Boolean)],e.GraphValueModel.prototype,"pinned",void 0),i.__decorate([s.column(),i.__metadata("design:type",Object)],e.GraphValueModel.prototype,"outputs",void 0),i.__decorate([s.column(),i.__metadata("design:type",Date)],e.GraphValueModel.prototype,"createdAt",void 0),i.__decorate([s.column(),i.__metadata("design:type",Date)],e.GraphValueModel.prototype,"updatedAt",void 0),i.__decorate([s.column(),i.__metadata("design:type",Date)],e.GraphValueModel.prototype,"expiresAt",void 0),i.__decorate([s.column(),i.__metadata("design:type",Object)],e.GraphValueModel.prototype,"metadata",void 0),e.GraphValueModel=i.__decorate([s.table("graph_value"),r.model(),i.__metadata("design:paramtypes",[Object])],e.GraphValueModel),e.GraphValueRepository=class extends s.Repository{constructor(t){super(t,e.GraphValueModel,!0),this.runtimeValues=new Map}seedWorkflowInputs(e){this.runtimeValues.set(pt,{...e})}setNodeOutputs(e,t){this.runtimeValues.set(e,{...t})}getPort(e,t){return this.runtimeValues.get(e)?.[t]}hasPort(e,t){return Object.prototype.hasOwnProperty.call(this.runtimeValues.get(e)??{},t)}setWorkflowOutput(e,t){const o=this.runtimeValues.get(pt)??{};o[e]=t,this.runtimeValues.set(pt,o)}getWorkflowValues(){return{...this.runtimeValues.get(pt)??{}}}snapshot(){return Object.fromEntries(this.runtimeValues.entries())}async readCached(e,...t){try{return _o(await this.read(yo(e),...t))}catch{return}}async writeCached(e,t,...o){const n=yo(e);let r;try{r=await this.read(n,...o)}catch{r=void 0}r?await this.update(Object.assign(r,wo(t)),...o):await this.create(wo(t),...o)}async deleteCached(e,...t){try{await this.delete(yo(e),...t)}catch{}}async hasCached(e,...t){return void 0!==await this.readCached(e,...t)}async listCached(e,...t){return(await this.select().execute(...t)).map(e=>_o(e)).filter(t=>((e,t)=>!(void 0!==t.workflowId&&e.workflowId!==t.workflowId||void 0!==t.nodeId&&e.nodeId!==t.nodeId||void 0!==t.namespace&&e.namespace!==t.namespace||void 0!==t.version&&e.version!==t.version||void 0!==t.fingerprint&&e.fingerprint!==t.fingerprint))(t.key,e))}async clearRun(e,...t){const o=await this.select().execute(...t);for(const e of o)await this.delete(e.id,...t)}readRuntimeValues(e){return this.runtimeValues.get(e)}writeRuntimeValues(e,t){this.runtimeValues.set(e,{...t})}getAdapter(){return this.adapter}},e.GraphValueRepository=i.__decorate([s.repository(e.GraphValueModel,n.DefaultFlavour),i.__metadata("design:paramtypes",[Function])],e.GraphValueRepository);class vo{static upstreamNodes(e,t,o=!1){const n=new Set,r=[e];for(;r.length;){const e=r.pop(),a=t.get(e)??[];for(const e of a)!o&&this.isBoundary(e.sourceNodeId)||n.has(e.sourceNodeId)||(n.add(e.sourceNodeId),r.push(e.sourceNodeId))}return n}static downstreamNodes(e,t,o=!1){const n=new Set,r=[e];for(;r.length;){const e=r.pop(),a=t.get(e)??[];for(const e of a)!o&&this.isBoundary(e.targetNodeId)||n.has(e.targetNodeId)||(n.add(e.targetNodeId),r.push(e.targetNodeId))}return n}static isBoundary(e){return"$workflow"===e}}class No{constructor(e,t,o){this.store=e,this.policy=t,this.dependencyResolver=o}async pinNode(e){const t=e.plan,o=e.includeDependencies??!0?this.dependencyResolver.getPinSet(t,e.nodeId):new Set([e.nodeId]);for(const e of o){const o=t.nodes.find(t=>t.id===e);if(!o)throw new Et(`Node '${e}' not found in plan`);if(!this.policy.canPin(o))throw new Et(`Node '${e}' is not pinnable`,{nodeId:e})}const n=this.topologicalOrder(t,o);for(const o of n){const n=t.nodes.find(e=>e.id===o),r=e.result.nodeResults[o];if(!r||!r.outputs)throw new Et(`Node '${o}' has no completed output to pin`);const a=r.inputs??{},i=this.dependencyFingerprints(t,o,e.result),s=this.createValueKey(e.document.id,n,a,i),d=(new Date).toISOString(),l={key:s,outputs:r.outputs,pinned:!0,createdAt:d,updatedAt:d,metadata:{...e.result.metadata,nodeId:o}};await this.store.writeCached(s,l)}}async unpinNode(e){const t={workflowId:e.document.id,nodeId:e.nodeId,fingerprint:e.fingerprint,namespace:e.namespace};await this.store.deleteCached(t)}async readPinnedValue(e,t,o,n,r){const a=this.createValueKey(e,t,o,n,r),i=await this.store.readCached(a);if(i&&i.pinned){if(i.expiresAt&&new Date(i.expiresAt)<new Date)return;return i}}createValueKey(e,t,o,n,r){return{workflowId:e,nodeId:t.id,fingerprint:this.computeFingerprint(e,t,o,n),namespace:r}}computeFingerprint(e,t,o,n){const r={workflowId:e,nodeId:t.id,nodeKind:t.kind,parameters:this.stableSerialize(t.instance.parameters??{}),inputBindings:this.stableSerialize(t.instance.inputBindings??{}),metadata:this.stableSerialize(this.relevantMetadata(t)),inputs:this.stableSerialize(o),dependencyFingerprints:this.stableSerialize(n)},a=this.stableSerialize(r);return this.simpleHash(a)}relevantMetadata(e){const t={...e.metadata??{}};return delete t.ui,delete t.position,delete t.visual,t}topologicalOrder(e,t){const o=[],n=new Set,r=a=>{if(n.has(a))return;n.add(a);const i=vo.upstreamNodes(a,e.incomingByNode,!1);for(const e of i)t.has(e)&&r(e);o.push(a)};for(const e of t)r(e);return o}dependencyFingerprints(e,t,o){const n=this.dependencyResolver.getDependencies(e,t),r={};for(const t of n){const n=e.nodes.find(e=>e.id===t);if(n){const a=o.nodeResults[t],i=a?.inputs??{},s=this.dependencyFingerprints(e,t,o);r[t]=this.computeFingerprint(e.workflowId,n,i,s)}}return r}stableSerialize(e){return null===e||"object"!=typeof e?JSON.stringify(e):Array.isArray(e)?`[${e.map(e=>this.stableSerialize(e)).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${this.stableSerialize(e[t])}`).join(",")}}`}simpleHash(e){let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;return`fp_${Math.abs(t).toString(16).padStart(8,"0")}_${e.length}`}}const Eo={enabled:!0,strategy:"manual",includeDependencies:!0};function Io(e){return!0===e?.enabled&&"disabled"!==e.strategy}class Ao{canPin(e){return Io(this.getPinningMetadata(e))}shouldUsePinnedValue(e){const t=this.getPinningMetadata(e);return!0===t.enabled&&"disabled"!==t.strategy}shouldAutoPin(e){const t=this.getPinningMetadata(e);return!0===t.enabled&&"automatic"===t.strategy}getPinningMetadata(e){const t=e.manifest.metadata?.pinnable??e.metadata?.pinnable;return t?{...Eo,...t}:{...Eo,enabled:!1}}}class Oo{getDependencies(e,t){return vo.upstreamNodes(t,e.incomingByNode,!1)}getPinSet(e,t){const o=this.getDependencies(e,t);return o.add(t),o}}class ko{constructor(){this.local=!0,this.codeMode="hostSide",Zt.register(ht,this)}async initialize(e){this.valueAdapter=e.valueAdapter,this.codeSandboxEvaluator=e.codeSandboxEvaluator,this.workflowStore=e.workflowStore,this.engine=e.engine}get capabilities(){const e=this.workflowStore?"supported":"not_supported";return{codeMode:this.codeMode,workflows:{list:e,get:e}}}async listWorkflows(...e){const t=this.workflowStore;if(!t)throw new _t("LocalGraphExecutionBackend has no workflowStore configured; workflow listing is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");return(await t.listWorkflows(...e)).map(e=>({id:e.workflowId,...void 0!==e.name?{name:e.name}:{},...void 0!==e.updatedAt&&null!==e.updatedAt?{updatedAt:e.updatedAt}:{}}))}async getWorkflow(e,...t){const o=this.workflowStore;if(!o)throw new _t("LocalGraphExecutionBackend has no workflowStore configured; workflow lookup is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");return await o.getDocument(e,...t)}async seedWorkflows(e,...t){const o=this.workflowStore,n=o?.seedDocument??o?.saveDocument;if(!o||"function"!=typeof n)throw new _t("LocalGraphExecutionBackend has no writable workflowStore configured; workflow seeding is not supported","GRAPH_BACKEND_SEED_NOT_SUPPORTED");const r=[];for(const a of e)null!==await n.call(o,a.id,a,...t)&&r.push({id:a.id,...void 0!==a.name?{name:a.name}:{}});return r}async execute(e){const{document:t,plan:o,inputs:n,options:r,events:a}=e,i=a,s=i.frame;if(!s)throw new _t("LocalGraphExecutionBackend requires the frame-bound event sink created by GraphExecutionEngine","GRAPH_EXECUTION_FRAME_MISSING");const d=s.valueStore,l=s.runId,c=r.path??[],u=async e=>{await i.emit(e)};try{for(const e of o.layers)this.assertNotAborted(r),await this.executeLayer(s,o,e.nodes,r,u);this.assertNotAborted(r);const e=[...s.nodeResults.values()].find(e=>e.status===O.FAILED);if(e?.error)throw new _t(e.error.message,e.error.code??"GRAPH_EXECUTION_ERROR",e.error.details);return s.finish(),await i.emit({type:S.WORKFLOW_COMPLETED,runId:l,parentRunId:r.parentRunId,workflowId:o.workflowId,path:c,status:O.SUCCEEDED,payload:{outputs:d.getWorkflowValues()}}),Jt(s,t,n,O.SUCCEEDED,r.metadata)}catch(e){if(e instanceof Ot)throw s.finish(),e;s.finish();const a=this.toErrorPayload(e);return e instanceof kt||!0===r.abortSignal?.aborted?(await i.emit({type:S.WORKFLOW_CANCELLED,runId:l,parentRunId:r.parentRunId,workflowId:o.workflowId,path:c,status:O.CANCELLED,error:a}),Jt(s,t,n,O.CANCELLED,r.metadata)):(await i.emit({type:S.WORKFLOW_FAILED,runId:l,parentRunId:r.parentRunId,workflowId:o.workflowId,path:c,status:O.FAILED,error:a}),Jt(s,t,n,O.FAILED,r.metadata))}}async executeLayer(e,t,o,n,r){const a=Math.max(1,n.concurrency??4),i=[...o];for(;i.length>0;){const o=i.splice(0,a);await Promise.all(o.map(o=>this.executeNode(e,t,o,n,r)))}}async executeNode(e,t,o,n,r){if(this.assertNotAborted(n),!this.isNodeActivated(e,t,o))return void await this.skipInactiveNode(e,t,o,n,r);if(!0===o.instance.disabled)return void await this.executeDisabledNode(e,t,o,n,r);const a=new Date,i=[...n.path??[],o.id];await r({type:S.NODE_STARTED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:O.RUNNING}),this.emitNodeStateChanged(e,t,o,i,k.RUNNING,O.RUNNING,r);const s=await this.resolveNodeInputs(e,t,o,n);if(n.usePinnedValues){const n=await this.tryPinnedValue(e,t,o,s);if(n){e.valueStore.setNodeOutputs(o.id,n.outputs),this.routeOutgoingEdges(e,t,o,n.outputs,r);const d=new Date,l={nodeId:o.id,status:O.CACHED,inputs:s,outputs:n.outputs,startedAt:a,finishedAt:d,fromCache:!0,pinned:!0,events:[]};return e.recordNodeResult(l),await r({type:S.NODE_CACHE_HIT,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:O.CACHED,payload:{outputs:n.outputs}}),await r({type:S.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:O.SUCCEEDED,payload:{outputs:n.outputs,fromCache:!0}}),void this.emitNodeStateChanged(e,t,o,i,k.SUCCEEDED,O.SUCCEEDED,r)}}try{const d=new zt(e.runId,n.parentRunId,t.workflowId,t.resolved.document,o.instance,o.manifest,i,r,n.metadata,this.engine,n.abortSignal,this.executionLimits(n)),l=await this.resolveNodeParameters(o,s,n),c={nodeId:o.id,kind:o.kind,inputs:s,parameters:l,credentials:this.collectCredentials(o),metadata:o.instance.metadata},u=await this.invokeExecutor(o,c,d),p=this.validateNodeOutputs(o,u??{});e.valueStore.setNodeOutputs(o.id,p),this.routeOutgoingEdges(e,t,o,p,r);const h=new Date,f={nodeId:o.id,status:O.SUCCEEDED,inputs:s,outputs:p,startedAt:a,finishedAt:h,events:[]};e.recordNodeResult(f),await r({type:S.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:O.SUCCEEDED,payload:{outputs:p}}),this.emitNodeStateChanged(e,t,o,i,k.SUCCEEDED,O.SUCCEEDED,r)}catch(d){if(d instanceof Ot)throw d;const l=new Date,c=this.toErrorPayload(d),u={nodeId:o.id,status:O.FAILED,inputs:s,error:c,startedAt:a,finishedAt:l,events:[]};if(e.recordNodeResult(u),await r({type:S.NODE_FAILED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:O.FAILED,error:c}),this.emitNodeStateChanged(e,t,o,i,k.FAILED,O.FAILED,r),n.failFast??!0)throw d}}isNodeActivated(e,t,o){const n=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type);return 0===n.length||n.some(t=>t.sourceNodeId===pt||e.isDataEdgeActive(t.id))}async skipInactiveNode(e,t,o,n,r){const a=new Date,i=[...n.path??[],o.id];await r({type:S.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:O.SKIPPED,payload:{reason:"branchNotSelected"}});const s={nodeId:o.id,status:O.SKIPPED,inputs:{},startedAt:a,finishedAt:new Date,events:[]};e.recordNodeResult(s),this.emitNodeStateChanged(e,t,o,i,k.SKIPPED,O.SKIPPED,r)}async executeDisabledNode(e,t,o,n,r){const a=new Date,i=[...n.path??[],o.id],s=mo.disabledBehaviorOf(o.instance,t.resolved.document.settings);if(await r({type:S.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:O.SKIPPED,payload:{disabled:!0,behavior:s}}),"skip"===s){const n={nodeId:o.id,status:O.SKIPPED,inputs:{},startedAt:a,finishedAt:new Date,events:[]};return e.recordNodeResult(n),void this.emitNodeStateChanged(e,t,o,i,k.SKIPPED,O.SKIPPED,r)}const d=await this.resolveNodeInputs(e,t,o,n);let l;if("passThroughFirstInput"===s){const n=(t.incomingByNode.get(o.id)??[]).find(e=>"data"===e.type),r=o.manifest.outputs[0]?.id??"value",a=n?e.valueStore.getPort(n.sourceNodeId,n.sourcePort):Object.values(d)[0];l={[r]:a}}else{l={};for(const e of o.manifest.outputs)l[e.id]=e.metadata?.defaultValue}e.valueStore.setNodeOutputs(o.id,l),this.routeOutgoingEdges(e,t,o,l,r);const c={nodeId:o.id,status:O.SUCCEEDED,inputs:d,outputs:l,startedAt:a,finishedAt:new Date,events:[]};e.recordNodeResult(c),this.emitNodeStateChanged(e,t,o,i,k.SUCCEEDED,O.SUCCEEDED,r)}async invokeExecutor(e,t,o){return await e.executor.execute(t,o)}validateNodeOutputs(e,t){const o=e.manifest;if(!0===o.policies?.allowUnknownOutputs)return t;const n=new Set(o.outputs.map(e=>e.id)),r=Object.keys(t).filter(e=>!n.has(e));if(r.length>0)throw new _t(`Node '${e.id}' of kind '${e.kind}' produced unknown output(s): ${r.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,unknownOutputs:r});const a=o.outputs.filter(e=>!0===e.required&&!(e.id in t)).map(e=>e.id);if(a.length>0)throw new _t(`Node '${e.id}' of kind '${e.kind}' did not produce required output(s): ${a.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,missingRequired:a});return t}collectCredentials(e){const t={};for(const o of e.manifest.parameters){if("credential"!==o.type)continue;const n=(e.instance.parameters??{})[o.id];"string"==typeof n&&n.length>0?t[o.id]={credentialId:n,credentialType:o.credentialType??""}:ho(n)&&(t[o.id]={credentialId:n.credentialId,credentialType:n.credentialType})}const o=(e.instance.metadata??{}).credentials;if(o&&"object"==typeof o&&!Array.isArray(o))for(const[e,n]of Object.entries(o)){const o=n;"string"==typeof o&&o.length>0?t[e]={credentialId:o,credentialType:""}:ho(o)&&(t[e]={credentialId:o.credentialId,credentialType:o.credentialType})}return t}async resolveNodeInputs(e,t,o,n){const r={},a=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type),i=new Map;for(const e of a){const t=i.get(e.targetPort)??[];t.push(e),i.set(e.targetPort,t)}for(const[t,o]of i)if(1===o.length)r[t]=e.valueStore.getPort(o[0].sourceNodeId,o[0].sourcePort);else{let n,a=!1;for(const t of o){const o=e.valueStore.getPort(t.sourceNodeId,t.sourcePort);r[t.sourcePort]=o,void 0!==o&&(n=o,a=!0)}a&&void 0===r[t]&&(r[t]=n)}const s=o.instance.inputBindings??{};for(const e of o.manifest.inputs){const t=s[e.id];if("literal"===t?.mode)r[e.id]=t.value;else if("expression"===t?.mode)r[e.id]=await this.evaluateExpressionBinding(o,t.expression,r,n);else if(void 0===r[e.id]){const t=e.metadata?.defaultValue;void 0!==t&&(r[e.id]=t)}}return r}async resolveNodeParameters(e,t,o){const n=e.instance.parameters??{},r={};for(const[a,i]of Object.entries(n))r[a]=De(i)?await this.evaluateValueTemplate(i,e,t,o):i;return r}async evaluateValueTemplate(e,t,o,n){const r=this.codeSandboxEvaluator;if(!r)throw new _t(`Value template on node '${t.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`,"GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{nodeId:t.id});const a=e.language??("expression"===e.mode?"javascript":"text"),i="template"===e.mode?(e=>`\`${e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(e,t)=>`\${${t}}`)}\``)(e.expression):e.expression,s=n.metadata;return await r.evaluate({code:i,language:"typescript"===a?"typescript":"javascript",input:o,vars:s?.vars??void 0,item:s?.item,index:s?.index,abortSignal:n.abortSignal})}async evaluateExpressionBinding(e,t,o,n){const r=this.codeSandboxEvaluator;if(!r)throw new _t(`Expression binding on node '${e.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`,"GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{nodeId:e.id,expression:t});const a=n.metadata;return await r.evaluate({code:t,language:"javascript",input:o,vars:a?.vars??void 0,item:a?.item,index:a?.index,abortSignal:n.abortSignal})}async tryPinnedValue(e,t,o,n){if(!(new Ao).shouldUsePinnedValue(o))return;const r=this.createPinningService(e),a=this.computeDependencyFingerprints(e,t,o.id);return r.readPinnedValue(t.workflowId,o,n,a)}computeDependencyFingerprints(e,t,o){const n=this.createPinningService(e),r=(new Oo).getDependencies(t,o),a={};for(const o of r){const r=t.nodes.find(e=>e.id===o);if(r){const i=e.nodeResults.get(o),s=i?.inputs??{},d=this.computeDependencyFingerprints(e,t,o);a[o]=n.computeFingerprint(t.workflowId,r,s,d)}}return a}routeOutgoingEdges(e,t,o,n,r){const a=(t.outgoingByNode.get(o.id)??[]).filter(e=>"data"===e.type);for(const i of a){if(!Object.prototype.hasOwnProperty.call(n,i.sourcePort))continue;const a=n[i.sourcePort];e.activateDataEdge(i.id),i.targetNodeId===pt&&e.valueStore.setWorkflowOutput(i.targetPort,a),this.emitEdgeStateChanged(e,t,o,i,k.SUCCEEDED,O.SUCCEEDED,r),r({type:S.EDGE_VALUE_ROUTED,runId:e.runId,workflowId:t.workflowId,edgeId:i.id,nodeId:o.id,path:[],payload:{edge:i,value:a}}).catch(()=>{})}}emitNodeStateChanged(e,t,o,n,r,a,i){i({type:S.NODE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:n,status:a,payload:{nodeId:o.id,state:r,runId:e.runId,workflowId:t.workflowId,status:a}}).catch(()=>{})}emitEdgeStateChanged(e,t,o,n,r,a,i){i({type:S.EDGE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,edgeId:n.id,nodeId:o.id,path:[],status:a,payload:{edgeId:n.id,state:r,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,status:a}}).catch(()=>{})}createPinningService(e){const t=bo(e.valueStore.getAdapter()??this.valueAdapter);return new No(t,new Ao,new Oo)}executionLimits(e){return{maxLoopIterations:e.maxLoopIterations??ft,maxForeachIterations:e.maxForeachIterations??gt}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new kt(e.runId??"unknown")}toErrorPayload(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}}class xo{constructor(e){this.catalogue=e}async resolveNodes(e,t,o,...n){const r=new Map;for(const[a,i]of e.entries()){const e=`nodes[${a}]`;if(this.catalogue.has(i.kind,...n))try{const e=await this.catalogue.resolveManifest(i.kind,i,o,...n),t=this.catalogue.getExecutor(i.kind,...n);r.set(i.id,{instance:i,manifest:e,executor:t})}catch(o){t.push({code:"kind.resolution-failed",path:e+".kind",message:`Node '${i.id}' kind '${i.kind}' failed to resolve: ${o.message}`,nodeId:i.id,details:{kind:i.kind}})}else t.push({code:"kind.unknown",path:e+".kind",message:`Node '${i.id}' references kind '${i.kind}' which is not registered in the backend catalogue`,nodeId:i.id,details:{kind:i.kind}})}return r}validateEffectivePorts(e,t,o,n){const r=!0===t.policies?.allowUndeclaredParameters,a=new Set(t.inputs.map(e=>e.id)),i=new Set(t.outputs.map(e=>e.id));for(const i of Object.keys(e.inputBindings??{}))r||a.has(i)||o.push({code:"binding.unknown-port",path:`${n}.inputBindings.${i}`,message:`Node '${e.id}' input binding '${i}' does not refer to an effective input port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveInputs:[...a]}});for(const a of Object.keys(e.outputBindings??{}))r||i.has(a)||o.push({code:"binding.unknown-port",path:`${n}.outputBindings.${a}`,message:`Node '${e.id}' output binding '${a}' does not refer to an effective output port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveOutputs:[...i]}})}}function So(e,t,o="$"){const n=new Set;for(const t of e.edges)"node"===t.source.scope&&n.add(t.source.nodeId),"node"===t.target.scope&&n.add(t.target.nodeId);for(const r of e.nodes){n.has(r.id)||t.push({code:"topology.loose-node",path:`${o}.nodes[${r.id}]`,message:`Node '${r.id}' is connected to nothing; every node must participate in at least one edge`,nodeId:r.id});const e=r.loop?.body;e&&So(e,t,`${o}.nodes[${r.id}].loop.body`)}}class Do{resolveEdges(e,t,o){const n=new Set(e.inputs.map(e=>e.id)),r=new Set(e.outputs.map(e=>e.id)),a=[];for(const[i,s]of(e.edges??[]).entries()){const e=`edges[${i}]`,d=this.resolveEndpoint(s,"source",t,n,r,o,e),l=this.resolveEndpoint(s,"target",t,n,r,o,e);if(!d||!l)continue;if(!this.validateDirectionAndType(s,d,l,t,o,e))continue;const c={id:s.id,type:s.type,sourceNodeId:d.nodeId,sourcePort:d.port,targetNodeId:l.nodeId,targetPort:l.port,metadata:s.metadata,edge:s};void 0!==s.label&&(c.label=s.label),a.push(c)}return a}resolveEndpoint(e,t,o,n,r,a,i){const s=e[t];return ge(s)?("source"===t?n.has(s.port):r.has(s.port))?{nodeId:pt,port:s.port}:void a.push({code:"edge.unknown-port",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} references workflow port '${s.port}' which is not declared on the document boundary`,edgeId:e.id,details:{scope:"workflow",port:s.port}}):me(s)?o.get(s.nodeId)?{nodeId:s.nodeId,port:s.port}:void a.push({code:"edge.unknown-node",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} references node '${s.nodeId}' which is not part of the document or did not resolve`,edgeId:e.id,nodeId:s.nodeId}):void a.push({code:"edge.invalid-endpoint",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} endpoint is not a valid GraphEndpoint`,edgeId:e.id})}validateDirectionAndType(e,t,o,n,r,a){let i=!0;const s=t.nodeId===pt?void 0:n.get(t.nodeId),d=o.nodeId===pt?void 0:n.get(o.nodeId),l=e=>!0===e?.manifest.policies?.allowUndeclaredParameters;if("data"===e.type)!s||l(s)||this.hasPortDirection(s,t.port,"output")||(this.pushPortIssue(e,"source",t,s,r,a),i=!1),!d||l(d)||this.hasPortDirection(d,o.port,"input")||(this.pushPortIssue(e,"target",o,d,r,a),i=!1);else{if(!s||!d)return r.push({code:"edge.boundary-routing",path:a,message:`Connection edge '${e.id}' must connect two node connection ports; the workflow boundary only routes data`,edgeId:e.id}),!1;if(!(l(s)||l(d)||this.hasPortDirection(s,t.port,"connection")&&this.hasPortDirection(d,o.port,"connection")))return r.push({code:"edge.type-mismatch",path:a,message:`Connection edge '${e.id}' endpoints must both be connection ports`,edgeId:e.id,details:{sourcePort:t.port,targetPort:o.port}}),!1}return i}hasPortDirection(e,t,o){return("input"===o?e.manifest.inputs:"output"===o?e.manifest.outputs:e.manifest.connections??[]).some(e=>e.id===t)}pushPortIssue(e,t,o,n,r,a){const i="source"===t?"output":"input";r.push({code:"data"===e.type?"edge.invalid-direction":"edge.type-mismatch",path:`${a}.${t}`,message:`Edge '${e.id}' ${t} port '${o.port}' on node '${o.nodeId}' is not an ${i} port of kind '${n.manifest.kind}'`,edgeId:e.id,nodeId:o.nodeId,details:{port:o.port,expected:i}})}}class Ro{validate(e,t){this.validateDuplicates(e.edges,t),this.validatePolicies(e,t)}validateDuplicates(e,t){const o=new Map;for(const n of e){const e=`${n.sourceNodeId}:${n.sourcePort}->${n.targetNodeId}:${n.targetPort}`,r=o.get(e);r?t.push({code:"connection.duplicate-edge",path:`edges[${n.id}]`,message:`Edge '${n.id}' duplicates the routing of edge '${r.id}' (${e})`,edgeId:n.id,details:{duplicateOf:r.id,routing:e}}):o.set(e,n)}}validatePolicies(e,t){const o=new Map;for(const t of e.edges){if("connection"!==t.type)continue;const e=`${t.targetNodeId}:${t.targetPort}`,n=o.get(e)??[];n.push(t),o.set(e,n)}for(const o of e.edges){if("connection"!==o.type)continue;const n=e.nodeById.get(o.targetNodeId),r=n?.manifest.connections?.find(e=>e.id===o.targetPort)?.connectionPolicy;this.validateEdgePolicy(o,e.nodeById,r,t)}for(const[n,r]of o){const o=n.lastIndexOf(":"),a=n.slice(0,o),i=n.slice(o+1),s=e.nodeById.get(a),d=s?.manifest.connections?.find(e=>e.id===i)?.connectionPolicy;if(!d)continue;const l=void 0!==d.maxConnections?d.maxConnections:!1===d.allowMultiple?1:1/0;r.length>l&&t.push({code:"connection.max-connections",path:`edges[${r[r.length-1].id}]`,message:`Connection port '${i}' on node '${a}' accepts at most ${l} connection(s) but has ${r.length}`,nodeId:a,edgeId:r[r.length-1].id,details:{port:i,max:l,actual:r.length}})}}validateEdgePolicy(e,t,o,n){if(e.sourceNodeId===e.targetNodeId&&!o?.allowSelf)return void n.push({code:"connection.self-connection",path:`edges[${e.id}]`,message:`Edge '${e.id}' connects node '${e.sourceNodeId}' to itself, which the target port policy does not allow`,edgeId:e.id,nodeId:e.sourceNodeId});if(!o)return;const r=t.get(e.sourceNodeId),a=r?.manifest.kind;if(!o.allowedNodeKinds?.length||a&&o.allowedNodeKinds.includes(a)||n.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${a??"unknown"}' is not in the allowed node kinds of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedNodeKinds:o.allowedNodeKinds}}),a&&o.blockedNodeKinds?.includes(a)&&n.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${a}' is blocked by target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{blockedNodeKinds:o.blockedNodeKinds}}),o.allowedPortCategories?.length){const t=r?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category;t&&o.allowedPortCategories.includes(t)||n.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source port '${e.sourcePort}' category '${t??"unknown"}' is not in the allowed port categories of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedPortCategories:o.allowedPortCategories}})}}}class Po{constructor(e){this.authorizer=e}async validate(e,t,o,n){const r=this.collectReferences(e,t);for(const a of t.credentials??[]){const i=r.find(e=>void 0===e.credentialType||e.credentialType===a.type);if(i){if(this.checkType(i,a))o.push({code:"credential.type-mismatch",path:n,message:`Node '${e.id}' credential '${i.credentialId}' has type '${i.credentialType}' but kind '${t.kind}' requires '${a.type}'`,nodeId:e.id,details:{credentialType:i.credentialType??"",requiredType:a.type}});else if(this.authorizer){if(!await this.authorizer.hasCredential(i)){o.push({code:"credential.not-found",path:n,message:`Node '${e.id}' references credential '${i.credentialId}' which does not exist`,nodeId:e.id,details:{credentialId:i.credentialId}});continue}await this.authorizer.authorize(i,a)||o.push({code:"credential.unauthorized",path:n,message:`Node '${e.id}' is not authorized to use credential '${i.credentialId}'`,nodeId:e.id,details:{credentialId:i.credentialId}})}}else!1!==a.required&&o.push({code:"credential.missing",path:n,message:`Node '${e.id}' does not provide the required credential of type '${a.type}'`,nodeId:e.id,details:{credentialType:a.type}})}this.scanPlainSecrets(e,o,n)}collectReferences(e,t){const o=[];for(const n of t.parameters){if("credential"!==n.type)continue;const t=(e.parameters??{})[n.id];ho(t)&&o.push(this.normalize(t,n.credentialType))}const n=(e.metadata??{}).credentials;if(n&&"object"==typeof n&&!Array.isArray(n))for(const e of Object.values(n))ho(e)&&o.push(this.normalize(e));return o}normalize(e,t){return"string"==typeof e?{credentialId:e,credentialType:t??""}:{credentialId:e.credentialId,credentialType:e.credentialType??t??""}}checkType(e,t){return void 0!==e.credentialType&&e.credentialType!==t.type}scanPlainSecrets(e,t,o){const n=new Set(go);for(const[r,a]of Object.entries(e.parameters??{}))this.scanPlainSecretValue(a,[r],e,o+".parameters",n,t);for(const[r,a]of Object.entries(e.metadata??{}))this.scanPlainSecretValue(a,[r],e,o+".metadata",n,t)}scanPlainSecretValue(e,t,o,n,r,a,i=0){const s=t[t.length-1];if(r.has(s))a.push({code:"credential.plain-secret",path:`${n}.${t.join(".")}`,message:`Node '${o.id}' carries plain secret material in '${t.join(".")}'; workflow documents may only hold credential references`,nodeId:o.id});else if(8>i&&null!==e)if(Array.isArray(e))for(const s of e)this.scanPlainSecretValue(s,[...t,"[]"],o,n,r,a,i+1);else if("object"==typeof e)for(const[s,d]of Object.entries(e))this.scanPlainSecretValue(d,[...t,s],o,n,r,a,i+1)}}class Co extends a.ValidationError{constructor(e,t=[]){super(e),this.issues=t,this.name=Co.name}}class To extends a.ValidationError{constructor(e,t){super(e),this.edgeId=t,this.name=To.name}}class $o extends s.AuthorizationError{constructor(e){super(e),this.name=$o.name}}const Go={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},Lo=["node","definition","executor","execute","ports","component"];function Mo(e){if(!e||"object"!=typeof e)return!1;const t=e;return Re(t.document)&&Array.isArray(t.nodes)&&Array.isArray(t.edges)&&t.nodeById instanceof Map&&t.incomingByNode instanceof Map&&t.outgoingByNode instanceof Map&&t.nodes.every(e=>null!==e&&"object"==typeof e&&"object"==typeof e.instance&&"object"==typeof e.manifest&&"object"==typeof e.executor)}function Fo(e,t){const o=[];for(const n of Object.keys(e))Lo.includes(n)&&o.push({code:"document.forbidden-field",path:`${t}.${n}`,message:`Field '${n}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected`,details:{field:n}});return o}class Vo{constructor(e){this.options=e,this.parameterValidator=new mo,this.edgeValidator=new Do,this.connectionPolicyValidator=new Ro,this.nodeValidator=new xo(e.catalogue),this.credentialValidator=new Po(e.credentialAuthorizer)}async validateOrThrow(e,...t){const o=await this.validate(e,0,...t);if(!o.valid||!o.resolved)throw new Co(`Graph workflow document '${e.id}' failed validation with ${o.issues.length} issue(s)`,o.issues);return o.resolved}async validate(e,t=0,...o){const n=[],r={...Go,...this.options.limits};if(!await this.validateStructure(e,r,t,n,...o))return{valid:!1,issues:n};const a=await this.nodeValidator.resolveNodes(e.nodes,n,this.options.resolutionContext,...o),i=e.nodes.filter(e=>a.has(e.id)).map(e=>a.get(e.id)),s=(e=>{const t=new Map;for(const o of e.edges??[]){if("data"!==o.type)continue;const e=o.target;if("node"!==e.scope)continue;const n=t.get(e.nodeId)??new Set;n.add(e.port),t.set(e.nodeId,n)}return t})(e);for(const e of i)this.parameterValidator.validate(e.instance,e.manifest,n,`nodes[${e.instance.id}]`,s.get(e.instance.id));for(const e of i)this.nodeValidator.validateEffectivePorts(e.instance,e.manifest,n,`nodes[${e.instance.id}]`);const d=this.edgeValidator.resolveEdges(e,a,n),l=new Map,c=new Map;for(const e of d){if(e.targetNodeId!==pt){const t=l.get(e.targetNodeId)??[];t.push(e),l.set(e.targetNodeId,t)}if(e.sourceNodeId!==pt){const t=c.get(e.sourceNodeId)??[];t.push(e),c.set(e.sourceNodeId,t)}}this.connectionPolicyValidator.validate({edges:d,nodeById:a},n),this.validateAcyclicity(i,d,e,n),So(e,n);for(const e of i)this.parameterValidator.validateBindingSatisfaction(e.instance,e.manifest,l.get(e.instance.id)??[],n,`nodes[${e.instance.id}]`,{allowLiteralAndEdgeBindings:this.options.allowLiteralAndEdgeBindings});this.validateRequiredWorkflowOutputs(e,c,n);for(const e of i)await this.credentialValidator.validate(e.instance,e.manifest,n,`nodes[${e.instance.id}]`);return this.validateCapabilities(i,n),n.length>0?{valid:!1,issues:n}:{valid:!0,issues:n,resolved:{document:e,nodes:i,edges:d,nodeById:a,incomingByNode:l,outgoingByNode:c}}}async validateStructure(e,t,o,n,...r){if(!Re(e))return n.push({code:"document.shape",path:"$",message:"Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays"}),!1;if(e.id&&e.id.trim()||n.push({code:"document.empty-id",path:"$.id",message:"Workflow document id must be a non-empty string"}),!ae(e))return n.push({code:"document.json-unsafe",path:"$",message:"Document contains JSON-unsafe values: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys are rejected"}),!1;n.push(...Fo(e,"$"));for(const t of[...e.inputs,...e.outputs])n.push(...Fo(t,"ports"));for(const t of e.nodes)n.push(...Fo(t,`nodes[${t.id}]`));for(const t of e.edges)n.push(...Fo(t,`edges[${t.id}]`));this.validateUniqueIds(e,n),this.validateLimits(e,t,o,n);try{ve(e)}catch(e){n.push({code:"document.structure",path:"$",message:e instanceof Error?e.message:e+""})}return await this.validateNestedBodies(e,o,n,...r),!0}validateUniqueIds(e,t){const o=new Set,n=new Set;for(const[r,a]of[["input",e.inputs],["output",e.outputs]]){const e="input"===r?o:n;for(const o of a)e.has(o.id)?t.push({code:"document.duplicate-port-id",path:`${"input"===r?"inputs":"outputs"}[${o.id}]`,message:`Workflow ${r} port '${o.id}' is declared more than once; workflow port ids must be unique`}):e.add(o.id)}const r=new Set;for(const o of e.nodes)r.has(o.id)?t.push({code:"document.duplicate-node-id",path:`nodes[${o.id}]`,message:`Node '${o.id}' is declared more than once; node ids must be unique`,nodeId:o.id}):r.add(o.id);const a=new Set;for(const o of e.edges)a.has(o.id)?t.push({code:"document.duplicate-edge-id",path:`edges[${o.id}]`,message:`Edge '${o.id}' is declared more than once; edge ids must be unique`,edgeId:o.id}):a.add(o.id)}validateLimits(e,t,o,n){e.nodes.length>t.maxNodes&&n.push({code:"document.limit.nodes",path:"$.nodes",message:`Document declares ${e.nodes.length} nodes; at most ${t.maxNodes} are allowed`,details:{count:e.nodes.length,limit:t.maxNodes}}),e.edges.length>t.maxEdges&&n.push({code:"document.limit.edges",path:"$.edges",message:`Document declares ${e.edges.length} edges; at most ${t.maxEdges} are allowed`,details:{count:e.edges.length,limit:t.maxEdges}}),o>t.maxNestingDepth&&n.push({code:"document.limit.depth",path:"$",message:`Document nests loop bodies ${o} levels deep; at most ${t.maxNestingDepth} levels are allowed`,details:{depth:o,limit:t.maxNestingDepth}});const r=Buffer.byteLength(JSON.stringify(e),"utf8");r>t.maxDocumentBytes&&n.push({code:"document.limit.size",path:"$",message:`Document serializes to ${r} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,details:{bytes:r,limit:t.maxDocumentBytes}})}async validateNestedBodies(e,t,o,...n){for(const r of e.nodes){const e=[["loop.body",r.loop?.body],["errorBoundary.try",r.errorBoundary?.try],["errorBoundary.catch",r.errorBoundary?.catch],["errorBoundary.finally",r.errorBoundary?.finally]];for(const[a,i]of e){if(!i)continue;const e=await this.validate(i,t+1,...n);for(const t of e.issues)o.push({...t,path:`nodes[${r.id}].${a}.${t.path}`,nodeId:t.nodeId??r.id})}}}validateAcyclicity(e,t,o,n){const r=new Set(e.map(e=>e.instance.id)),a=new Map(e.map(e=>[e.instance.id,0]));for(const e of t)r.has(e.sourceNodeId)&&a.has(e.targetNodeId)&&a.set(e.targetNodeId,(a.get(e.targetNodeId)??0)+1);const i=[...a.entries()].filter(([,e])=>0===e).map(([e])=>e),s=[];for(;i.length>0;){const e=i.shift();s.push(e);for(const o of t){if(o.sourceNodeId!==e)continue;if(!a.has(o.targetNodeId))continue;const t=(a.get(o.targetNodeId)??1)-1;a.set(o.targetNodeId,t),0===t&&i.push(o.targetNodeId)}}if(s.length!==a.size){const e=[...a.keys()].filter(e=>!s.includes(e));n.push({code:"topology.cycle",path:"$.edges",message:`Workflow '${o.id}' contains an unsupported cycle involving node(s): ${e.join(", ")}`,details:{cyclicNodes:e}})}}validateRequiredWorkflowOutputs(e,t,o){const n=new Set;for(const e of t.values())for(const t of e)t.targetNodeId===pt&&n.add(t.targetPort);for(const t of e.outputs)!0===t.required&&void 0===t.defaultValue&&(n.has(t.id)||o.push({code:"topology.required-output-unsatisfiable",path:`outputs[${t.id}]`,message:`Required workflow output '${t.id}' has no incoming edge from any node`}))}validateCapabilities(e,t){for(const o of e){const e=o.manifest;for(const n of e.capabilities??[])Te(n)||t.push({code:"capability.invalid",path:`nodes[${o.instance.id}]`,message:`Kind '${e.kind}' declares unknown capability '${n+""}'`,nodeId:o.instance.id,details:{capability:n+""}});!0!==e.policies?.allowUndeclaredParameters&&o.instance.loop&&((e.capabilities??[]).includes("loop")||t.push({code:"capability.loop-not-supported",path:`nodes[${o.instance.id}].loop`,message:`Node '${o.instance.id}' carries loop configuration but kind '${e.kind}' does not declare the 'loop' capability`,nodeId:o.instance.id}))}}}e.GraphExecutionPlanner=class extends s.Service{constructor(){super()}async plan(e,...t){const{log:o}=(await this.logCtx(t,"plan",!0)).for(this.plan);if(o.debug(`Planning resolved workflow '${e?.document?.id??"unknown"}'`),!Mo(e))throw new At("GraphExecutionPlanner.plan accepts only a GraphResolvedWorkflow produced by the nine-stage validation gate; raw workflow definitions and inline node definitions are rejected",{received:(n=e,n&&"object"==typeof n?{reason:"input is not a GraphResolvedWorkflow",looksLikeWorkflowDefinition:"nodes"in n&&"relations"in n&&!("nodeById"in n),hasResolvedNodes:Array.isArray(n.nodes)}:{reason:"input is not an object"})});var n;const r=this.buildPlanNodes(e),a=this.buildPlanEdges(e),i=this.buildIncomingMap(a),s=this.buildOutgoingMap(a),d=this.topologicalLayers(r,a);return{resolved:e,workflowId:e.document.id||e.document.name,nodes:r,edges:a,layers:d,incomingByNode:i,outgoingByNode:s}}buildPlanNodes(e){return e.nodes.map(e=>({id:e.instance.id,kind:e.manifest.kind,instance:e.instance,manifest:e.manifest,executor:e.executor,inputPorts:e.manifest.inputs.map(e=>e.id),outputPorts:e.manifest.outputs.map(e=>e.id),connectionPorts:(e.manifest.connections??[]).map(e=>e.id),metadata:e.instance.metadata}))}buildPlanEdges(e){return e.edges.map(e=>({id:e.id,type:e.type,sourceNodeId:e.sourceNodeId,sourcePort:e.sourcePort,targetNodeId:e.targetNodeId,targetPort:e.targetPort,...void 0!==e.label?{label:e.label}:{},metadata:e.metadata}))}buildIncomingMap(e){const t=new Map;for(const o of e){if(o.targetNodeId===pt)continue;const e=t.get(o.targetNodeId)??[];e.push(o),t.set(o.targetNodeId,e)}return t}buildOutgoingMap(e){const t=new Map;for(const o of e){if(o.sourceNodeId===pt)continue;const e=t.get(o.sourceNodeId)??[];e.push(o),t.set(o.sourceNodeId,e)}return t}topologicalLayers(e,t){const o=e.filter(e=>e.id!==pt),n=new Set(o.map(e=>e.id)),r=t.filter(e=>n.has(e.sourceNodeId)&&n.has(e.targetNodeId)),a=new Map;for(const e of o)a.set(e.id,0);for(const e of r)a.set(e.targetNodeId,(a.get(e.targetNodeId)??0)+1);const i=[],s=new Set;let d=o.filter(e=>0===(a.get(e.id)??0)),l=0;for(;d.length>0;){const e={index:l++,nodes:d};i.push(e);const t=[];for(const e of d){s.add(e.id);const n=r.filter(t=>t.sourceNodeId===e.id);for(const e of n){const n=(a.get(e.targetNodeId)??1)-1;if(a.set(e.targetNodeId,n),0===n&&!s.has(e.targetNodeId)){const n=o.find(t=>t.id===e.targetNodeId);n&&t.push(n)}}}d=t}if(s.size!==o.length){const e=o.filter(e=>!s.has(e.id)).map(e=>e.id);throw new bt({unplannedNodes:e,workflowId:o[0]?.manifest.kind})}return i}},e.GraphExecutionPlanner=i.__decorate([s.service(),i.__metadata("design:paramtypes",[])],e.GraphExecutionPlanner);const jo=new Set(["engine","valueAdapter","codeSandboxEvaluator","workflowStore"]);function Uo(e,t){const o={};for(const[n,r]of Object.entries(e??{}))jo.has(n)&&!t.has(n)||(o[n]=r);return o}class Bo extends s.ClientBasedService{constructor(){super()}async initialize(...t){const o=t[0];if(!o||"object"!=typeof o||!o.registry)return this._config=void 0,this._client=void 0,{config:void 0,client:void 0};const n=o.catalogue??o.registry.catalog,r=o.valueAdapter??s.Adapter.current;if(!r)throw new _t("GraphExecutionEngine requires a Decaf adapter for cached/pinned values: pass `valueAdapter` or configure one via `Adapter.setCurrent(...)`","GRAPH_VALUE_ADAPTER_MISSING");const a=o.backend??Zt.current??new ko,i={registry:o.registry,catalogue:n,planner:o.planner??new e.GraphExecutionPlanner,backend:a,valueAdapter:r,eventEmitter:o.eventEmitter??new St,documentValidator:o.documentValidator??new Vo({catalogue:n,limits:o.documentLimits,credentialAuthorizer:o.credentialAuthorizer}),authValidator:new qt({enabled:!0===o.authEnabled,...o.authMatch?{match:o.authMatch}:{}}),...o.codeSandboxEvaluator?{codeSandboxEvaluator:o.codeSandboxEvaluator}:{}};this._config=o,this._client=i;const d=new Set(["engine","valueAdapter"]);o.codeSandboxEvaluator&&d.add("codeSandboxEvaluator"),o.workflowStore&&d.add("workflowStore");const l=Uo(a.config,d);if(await a.initialize({...l,valueAdapter:r,...o.codeSandboxEvaluator?{codeSandboxEvaluator:o.codeSandboxEvaluator}:{},...o.workflowStore?{workflowStore:o.workflowStore}:{},engine:this}),o.seedWorkflows&&o.seedWorkflows.length>0){const e=a.seedWorkflows;if("function"!=typeof e)throw new _t(`Graph execution backend '${a.constructor?.name??"GraphExecutionBackend"}' does not support workflow seeding`,"GRAPH_BACKEND_SEED_NOT_SUPPORTED",{backend:a.constructor?.name??"GraphExecutionBackend"});await e.call(a,o.seedWorkflows,...t.slice(1))}return await(o.onEngineCreated?.(this)),{config:o,client:i}}get codeSandboxEvaluator(){return this.client.codeSandboxEvaluator}get emitter(){return this.client.eventEmitter}get planner(){return this.client.planner}get valueAdapter(){return this.client.valueAdapter}get defaultOptions(){return this.config.defaultOptions??{}}get documentValidator(){return this.client.documentValidator}observe(e){return this.emitter.observe(e)}unObserve(e){this.emitter.unObserve(e)}async dispatchEvent(e){await this.emitter.updateObservers(e)}async execute(e,t={},o={},...n){const{log:r,ctx:a}=(await this.logCtx(n,"execute",!0)).for(this.execute);r.debug(`Executing workflow '${e.id||e.name}'`);const i=this.mergeOptions(o);this.assertNotAborted(i);const s=Wt(Ut(a),i.auth);i.auth=s,i.metadata={...i.metadata??{},...s};const d=i.runId??this.generateRunId();i.runId=d;const l=i.path??[],c=new Dt,u=bo(this.valueAdapter);u.seedWorkflowInputs(this.withWorkflowInputDefaults(e,t));const p=new Yt(this.emitter,c,{runId:d,parentRunId:i.parentRunId,workflowId:e.id||e.name,path:l,engine:this,...this.codeSandboxEvaluator?{codeSandboxEvaluator:this.codeSandboxEvaluator}:{}});await p.emit({type:S.VALIDATION_STARTED,status:O.PLANNING});const h=await this.documentValidator.validate(e,0,a);if(!h.valid||!h.resolved)throw await p.emit({type:S.VALIDATION_FAILED,status:O.FAILED,payload:{issues:h.issues}}),new Co(`Graph workflow document '${e.id}' failed validation with ${h.issues.length} issue(s)`,h.issues);await p.emit({type:S.VALIDATION_COMPLETED,status:O.PLANNING,payload:{issues:h.issues.length}}),this.assertNotAborted(i);const f=await this.planner.plan(h.resolved);this.client.authValidator.validate(e,f,s,r),r.debug(`Authorized workflow '${e.id||e.name}' for user ${s.user??"anonymous"}`),this.assertCodeModeSupported(e);const g=new Xt(d,f,u,c);return p.bindFrame(g),await p.emit({type:S.WORKFLOW_STARTED,runId:d,parentRunId:i.parentRunId,workflowId:f.workflowId,path:l,status:O.RUNNING,payload:{inputs:t}}),await p.emit({type:S.WORKFLOW_PLANNED,runId:d,parentRunId:i.parentRunId,workflowId:f.workflowId,path:l,status:O.PLANNING,payload:{layers:f.layers.length,nodes:f.nodes.length}}),await this.client.backend.execute({document:e,plan:f,inputs:t,options:i,events:p},...n)}get backend(){return this.client.backend}get backendCapabilities(){return Qt(this.client.backend)}async listWorkflows(...e){const t=this.client.backend;if("supported"!==Qt(t).workflows.list||"function"!=typeof t.listWorkflows)throw new _t(`Graph execution backend '${this.backendName}' does not support workflow listing`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:this.backendName});return await t.listWorkflows(...e)}async getWorkflow(e,...t){const o=this.client.backend;if("supported"!==Qt(o).workflows.get||"function"!=typeof o.getWorkflow)throw new _t(`Graph execution backend '${this.backendName}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:this.backendName,workflowId:e});return await o.getWorkflow(e,...t)}async listEngineWorkflows(e,...t){const o=Zt.getOrFail(e);if("supported"!==Qt(o).workflows.list||"function"!=typeof o.listWorkflows)throw new _t(`Graph execution backend '${e}' does not support workflow listing`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e});return await o.listWorkflows(...t)}async getEngineWorkflow(e,t,...o){const n=Zt.getOrFail(e);if("supported"!==Qt(n).workflows.get||"function"!=typeof n.getWorkflow)throw new _t(`Graph execution backend '${e}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e,workflowId:t});return await n.getWorkflow(t,...o)}get backendName(){return this.client.backend.constructor?.name??"GraphExecutionBackend"}assertCodeModeSupported(e){const t=this.client.backend;if(t.local)return;const o=co(e);if(0!==o.length){if("unsupported"===t.codeMode)throw new _t(`Graph execution backend '${this.backendName}' does not support code-mode workflows`,"GRAPH_CODE_MODE_UNSUPPORTED_BACKEND",{backend:this.backendName,surfaces:o});if(!this.codeSandboxEvaluator)throw new _t("Code-mode workflows require a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{backend:this.backendName,surfaces:o})}}async pinNode(e){const t=this.createPinningService();await t.pinNode(e),await this.emitPinningEvent(e.nodeId,S.NODE_PINNED)}async unpinNode(e){const t=this.createPinningService();await t.unpinNode(e),await this.emitPinningEvent(e.nodeId,S.NODE_UNPINNED)}createPinningService(){const e=bo(this.valueAdapter);return new No(e,new Ao,new Oo)}async emitPinningEvent(e,t){const o=(new Dt).create({id:"",sequence:0,timestamp:new Date,runId:"pinning",workflowId:"",type:t,nodeId:e,path:[]});await this.emitter.updateObservers(o)}withWorkflowInputDefaults(e,t){const o={...t};for(const t of e.inputs)void 0===o[t.id]&&void 0!==t.defaultValue&&(o[t.id]=t.defaultValue);return o}mergeOptions(e){return{concurrency:4,failFast:!0,validateInputs:!0,validateOutputs:!0,maxLoopIterations:ft,maxForeachIterations:gt,usePinnedValues:!0,writeThroughCache:!1,path:[],metadata:{},...this.defaultOptions,...e}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new kt(e.runId??"unknown")}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new _t("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime","GRAPH_RUN_ID_ERROR",{runtime:typeof globalThis.crypto});return e.randomUUID()}}const Wo=new Set(["process","require","module","exports","global","globalThis","Function","eval","fetch","XMLHttpRequest","WebSocket","Worker","Deno","Bun","__dispatch"]);class qo extends s.ClientBasedService{constructor(){super()}async initialize(...e){const t=e[0]??{},o=t&&"object"==typeof t?t:{};return this._config=o,this._client=d,{config:o,client:d}}get defaultTimeoutMs(){return this.config.timeoutMs??1e3}get defaultMemoryMb(){return this.config.memoryMb??32}async evaluate(e,...t){(await this.logCtx(t,"evaluate",!0)).for(this.evaluate);const o=e.code;if(!o||"string"!=typeof o||0===o.trim().length)throw new _t("Code sandbox received empty code","GRAPH_CODE_SANDBOX_EMPTY_CODE");const n=((e,t)=>"javascript"===t?e:w.transpileModule(e,{compilerOptions:{target:w.ScriptTarget.ES2022,module:w.ModuleKind.None,strict:!0,noEmitHelpers:!0,importHelpers:!1}}).outputText.replace(/^"use strict";\s*/,""))(o,e.language??"javascript");(e=>{if(e.length>1e5)throw new _t("Code exceeds the maximum length of 100000 characters","GRAPH_CODE_SANDBOX_CODE_TOO_LONG",{length:e.length});let t;try{t=m.parse(`async function __validate() {\n${e}\n}`,{ecmaVersion:"latest",sourceType:"script"})}catch{try{t=m.parse(e,{ecmaVersion:"latest",sourceType:"module"})}catch(t){throw new _t("Code failed to parse: "+t.message,"GRAPH_CODE_SANDBOX_PARSE_ERROR",{code:e,error:t.message})}}y.full(t,e=>{const t=e;if("ImportDeclaration"===t.type)throw new _t("Imports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"import"});if("ExportNamedDeclaration"===t.type||"ExportDefaultDeclaration"===t.type)throw new _t("Exports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"export"});if("Identifier"===t.type&&"string"==typeof t.name&&Wo.has(t.name))throw new _t(`Identifier "${t.name}" is not allowed in Code nodes.`,"GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:t.name});if("NewExpression"===t.type&&"Function"===t.callee?.name)throw new _t("new Function() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"Function"});if("CallExpression"===t.type&&"eval"===t.callee?.name)throw new _t("eval() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"eval"})})})(n);const r=!(e=>/\breturn\b[\s;]/.test(e))(n),a=r?n.replace(/[\s;]+$/,""):n,i={$input:e.input??{},$vars:e.vars??{},$item:e.item,$index:e.index,$node:e.nodes??{},$output:void 0},s=Object.keys(i),l=r?`return (${a});`:a,c=`"use strict";\nasync function __userFunction(${s.join(", ")}) {\n${l}\n}\n__userFunction(${s.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`,u=new d.Isolate({memoryLimit:this.defaultMemoryMb}),p=await u.createContext();try{const t=p.global;e.logger&&await this.injectConsole(p,e.logger);for(const[e,o]of Object.entries(i))await t.set(e,new d.ExternalCopy(void 0===o?null:o).copyInto());let o;try{o=await u.compileScript(c,{filename:"graph-code-node.js"})}catch(e){if(!r)throw new _t("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:n,error:e.message});{const e=a,t=`"use strict";\nasync function __userFunction(${s.join(", ")}) {\n${e}\n}\n__userFunction(${s.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`;try{o=await u.compileScript(t,{filename:"graph-code-node.js"})}catch(e){throw new _t("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:n,error:e.message})}}}const l=e.timeoutMs??this.defaultTimeoutMs;let h;try{h=await this.runBounded(o,p,l,e.abortSignal)}catch(e){if(e instanceof _t)throw e;const t=e.message;if(t.includes("timed out")||t.includes("timeout"))throw new _t(`Code execution timed out after ${l} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:l});if(t.includes("memory")||t.includes("heap"))throw new _t(`Code exceeded the memory limit of ${this.defaultMemoryMb} MB`,"GRAPH_CODE_SANDBOX_MEMORY_LIMIT",{memoryMb:this.defaultMemoryMb});throw new _t("Code execution failed: "+t,"GRAPH_CODE_SANDBOX_RUNTIME_ERROR",{code:n,error:t})}if("string"!=typeof h)throw new _t("Code sandbox returned an unexpected non-string result","GRAPH_CODE_SANDBOX_UNEXPECTED_RESULT",{result:h});return JSON.parse(h).v}finally{p.release(),u.dispose()}}async runBounded(e,t,o,n){const r=e.run(t,{timeout:o,promise:!0});r.catch(()=>{});const a=[r];let i,s;try{return a.push(new Promise((e,t)=>{i=setTimeout(()=>{t(new _t(`Code execution timed out after ${o} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:o}))},o+100)})),n&&a.push(new Promise((e,t)=>{const r=()=>{const e="timeout"===n.reason;t(new _t(e?`Code execution timed out after ${o} ms`:"Code execution aborted",e?"GRAPH_CODE_SANDBOX_TIMEOUT":"GRAPH_CODE_SANDBOX_ABORTED",{timeoutMs:o,reason:n.reason}))};n.aborted?r():(n.addEventListener("abort",r,{once:!0}),s=()=>n.removeEventListener("abort",r))})),await Promise.race(a)}finally{i&&clearTimeout(i),s?.()}}async injectConsole(e,t){const o=new d.Reference((e,o)=>{let n;try{n=JSON.parse(o)}catch{n=[o]}const r=n.map(e=>"string"==typeof e?e:JSON.stringify(e)).join(" "),a=1===n.length?n[0]:n;switch(e){case"log":case"info":default:t.info(r,a);break;case"warn":t.warn(r,a);break;case"error":t.error(r,a);break;case"debug":case"dir":case"dirxml":case"table":t.debug(r,a);break;case"trace":t.trace(r,a);break;case"group":case"groupCollapsed":t.debug("[group] "+r,a);break;case"groupEnd":t.debug("[groupEnd]",void 0);break;case"time":case"timeEnd":case"timeLog":case"count":case"countReset":t.debug(`[${e}] ${r}`,a);break;case"assert":n[0]||t.error("Assertion failed: "+r,a);case"clear":}});await e.evalClosure("\n function __ser() {\n var out = [];\n for (var i = 0; i < arguments.length; i++) {\n var a = arguments[i];\n try { out.push(typeof a === 'object' ? JSON.parse(JSON.stringify(a)) : a); }\n catch (e) { out.push(String(a)); }\n }\n return JSON.stringify(out);\n }\n function __call(level) {\n return function() {\n $0.applySync(undefined, [level, __ser.apply(null, arguments)]);\n };\n }\n globalThis.console = {\n log: __call('log'),\n info: __call('info'),\n warn: __call('warn'),\n error: __call('error'),\n debug: __call('debug'),\n trace: __call('trace'),\n dir: __call('dir'),\n dirxml: __call('dirxml'),\n table: __call('table'),\n group: __call('group'),\n groupCollapsed: __call('groupCollapsed'),\n groupEnd: __call('groupEnd'),\n time: __call('time'),\n timeEnd: __call('timeEnd'),\n timeLog: __call('timeLog'),\n assert: __call('assert'),\n count: __call('count'),\n countReset: __call('countReset'),\n clear: __call('clear')\n };\n ",[o]),o.release()}}class Ho extends a.InternalError{constructor(e){super(e,Ho.name,500)}}class Ko extends a.NotFoundError{constructor(e){super(e),this.name=Ko.name}}class zo extends a.NotFoundError{constructor(e){super(e),this.name=zo.name}}class Xo{constructor(e,t,o={}){this.kind=e,this.declarations=new Map,this.implementations=new Map;for(const e of t){if("string"!=typeof e?.name||!e.name)throw new Ho(`Method declaration for kind '${this.kind}' is missing a name`);if(this.declarations.has(e.name))throw new Ho(`Kind '${this.kind}' declares duplicate method '${e.name}'`);this.declarations.set(e.name,e)}for(const[e,t]of Object.entries(o)){if("function"!=typeof t)throw new Ho(`Method implementation '${e}' for kind '${this.kind}' is not a function`);if(!this.declarations.has(e))throw new Ho(`Kind '${this.kind}' implements method '${e}' which is not declared by its manifest`);this.implementations.set(e,t)}for(const e of this.declarations.keys())if(!this.implementations.has(e))throw new Ho(`Kind '${this.kind}' declares method '${e}' with no implementation`)}has(e){return this.declarations.has(e)}getDeclaration(e){const t=this.declarations.get(e);if(!t)throw new zo(`Kind '${this.kind}' does not declare method '${e}'`);return t}get(e){return this.getDeclaration(e),this.implementations.get(e)}list(){return[...this.declarations.values()].sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0)}}function Jo(e,t){if(!t)return;let o=e;for(const e of t.split(".")){if(!o||"object"!=typeof o)return;o=o[e]}return o}function Yo(e,t,o){const n=Jo(t,e.itemIdPath),r=e.itemLabelPath?Jo(t,e.itemLabelPath):void 0;return{id:"string"==typeof n&&n||"number"==typeof n&&Number.isFinite(n)&&n+""||o+"",label:"string"==typeof r?r:void 0}}function Qo(e,t){switch(t){case"input":return e.inputs;case"output":return e.outputs;default:return e.connections}}function Zo(e,t){const o={inputs:[],outputs:[],connections:[]},n={input:new Set((e.inputs??[]).map(e=>e.id)),output:new Set((e.outputs??[]).map(e=>e.id)),connection:new Set((e.connections??[]).map(e=>e.id))},r=(e,t)=>{const o=n[e];return!o.has(t)&&(o.add(t),!0)};for(const n of e.dynamicPorts??[])if("repeatFromParameter"===n.type){const e=t[n.parameter];if(!Array.isArray(e))continue;const a=Qo(o,n.direction);e.forEach((e,t)=>{const{id:o,label:i}=Yo(n,e,t),s=(d={id:o,index:t,label:i??o},n.portIdTemplate.replaceAll("${id}",d.id).replaceAll("${index}",d.index+"").replaceAll("${label}",d.label));var d;if(!r(n.direction,s))return;const l=n.defaultPort?ie(n.defaultPort):{id:s,label:i??s,direction:n.direction};l.id=s,l.direction=n.direction,i&&(l.label=i),a.push(l)})}else if("togglePort"===n.type){if(t[n.parameter]!==n.equals)continue;const e=ie(n.port);if(!r(e.direction,e.id))continue;Qo(o,e.direction).push(e)}return o}function en(e,t){const o=Zo(e,t),n={kind:e.kind,display:e.display,inputs:[...e.inputs,...o.inputs],outputs:[...e.outputs,...o.outputs],parameters:e.parameters},r=[...e.connections??[],...o.connections];return r.length&&(n.connections=r),e.dynamicPorts?.length&&(n.dynamicPorts=e.dynamicPorts),e.credentials?.length&&(n.credentials=e.credentials),e.capabilities?.length&&(n.capabilities=e.capabilities),e.policies&&(n.policies=e.policies),e.metadata&&(n.metadata=e.metadata),e.namespaces?.length&&(n.namespaces=e.namespaces),ie(n)}class tn{async resolve(e,t,o,n,r){if(o){const a=await o(n,r);if(!(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.kind&&"object"==typeof t.display&&null!==t.display&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.parameters)})(a))throw new Ho(`resolveManifest provider for kind '${e}' returned a value that does not conform to GraphResolvedNodeManifest`);if(!ae(a))throw new Ho(`resolveManifest provider for kind '${e}' returned a non-JSON-safe resolved manifest`);const i=ie(a);return!i.namespaces?.length&&t.namespaces?.length&&(i.namespaces=t.namespaces.slice()),i}return en(t,n.parameters??{})}}const on=["edge","literal","expression"];function nn(e){return on.includes(e)}function rn(e,t,o){if("string"!=typeof o||!o)throw new Ho(`Manifest for kind '${e}' has a ${t} with an empty port id`);if(te(o))throw new Ho(`Manifest for kind '${e}' has a ${t} with unsafe port id '${o}'`)}function an(e){return e}function sn(e){if(!e)return;const t={...e.metadata??{},...e.parameters??{},...e.state??{}};return e.loop&&(t.loop=e.loop),t}e.GraphNodeCatalogue=class extends s.Service{constructor(){super(),this.entries=new Map,this.resolver=new tn,this.fallbackContext=new s.Context}withContext(e){return e[e.length-1]instanceof s.Context?e:[this.fallbackContext]}register(e,t={},...o){const{log:n}=this.logCtx(this.withContext(o),"register").for(this.register);n.debug(`Registering graph node kind '${e?.manifest?.kind??"unknown"}'`),(e=>{if(!e||"object"!=typeof e)throw new Ho("Graph node registration is required");if(!e.manifest||"object"!=typeof e.manifest)throw new Ho("Graph node registration is missing a manifest");if(!e.executor||"function"!=typeof e.executor.execute)throw new Ho(`Graph node registration for kind '${e.manifest?.kind+""}' is missing an executor`)})(e);const r=e.manifest;if("string"!=typeof r.kind||!r.kind.trim())throw new Ho("Graph node manifest kind is required and must be a non-empty string");const a=r.kind;if(this.entries.has(a)&&!t.replace)throw new Ho(`Graph node kind '${a}' is already registered; pass { replace: true } to replace it`);try{Ge(r)}catch(e){throw new Ho(`Manifest for kind '${a}' is not JSON-serializable: ${e.message}`)}((e,t)=>{const o=[["input",t.inputs],["output",t.outputs],["connection",t.connections??[]]];for(const[t,n]of o){const o=new Set;for(const r of n){if(rn(e,t+" port",r?.id),o.has(r.id))throw new Ho(`Manifest for kind '${e}' declares duplicate static ${t} port id '${r.id}'`);if(o.add(r.id),void 0!==r.defaultMode&&!nn(r.defaultMode))throw new Ho(`Manifest for kind '${e}' declares invalid default binding mode '${r.defaultMode+""}' on ${t} port '${r.id}'`)}}})(a,r);const i=((e,t)=>{const o=new Set;for(const n of t.parameters){const t=n?.id;if("string"!=typeof t||!t)throw new Ho(`Manifest for kind '${e}' has a parameter with an empty id`);if(te(t))throw new Ho(`Manifest for kind '${e}' has a parameter with unsafe id '${t}'`);if(o.has(t))throw new Ho(`Manifest for kind '${e}' declares duplicate parameter id '${t}'`);o.add(t)}return o})(a,r);((e,t,o)=>{for(const n of t.dynamicPorts??[]){if(!n||"string"!=typeof n.parameter||!n.parameter)throw new Ho(`Manifest for kind '${e}' has a dynamic-port rule without a parameter reference`);if(!o.has(n.parameter))throw new Ho(`Manifest for kind '${e}' has a dynamic-port rule referencing missing parameter '${n.parameter}'`);if("togglePort"===n.type){if(!n.port)throw new Ho(`Manifest for kind '${e}' has a togglePort rule without a port`);rn(e,"togglePort rule port",n.port.id)}if("repeatFromParameter"===n.type&&"string"!=typeof n.portIdTemplate)throw new Ho(`Manifest for kind '${e}' has a repeatFromParameter rule without a portIdTemplate`)}})(a,r,i),((e,t)=>{for(const o of t.credentials??[]){if(!Pe(o))throw new Ho(`Manifest for kind '${e}' has a malformed credential requirement`);if(!o.type)throw new Ho(`Manifest for kind '${e}' has a credential requirement with an empty type`)}})(a,r),((e,t)=>{for(const o of t.methods??[])if(!Ve(o))throw new Ho(`Manifest for kind '${e}' has a malformed method declaration`)})(a,r);const s=new Xo(a,r.methods??[],e.methods??{});return this.entries.set(a,{registration:e,methods:s,placeholderManifest:!1}),this}registerExecutor(e,t,...o){const{log:n}=this.logCtx(this.withContext(o),"registerExecutor").for(this.registerExecutor);if(n.debug(`Registering graph executor for kind '${e}'`),"string"!=typeof e||!e.trim())throw new Ho("Graph executor kind is required");if(!t||"function"!=typeof t.execute)throw new Ho(`Executor registered for kind '${e}' is missing an execute method`);const r=this.entries.get(e);if(r)return r.registration={...r.registration,executor:t},this;const a={kind:e,display:{name:e},inputs:[],outputs:[],parameters:[],policies:{allowUndeclaredParameters:!0,allowUnknownOutputs:!0}};return this.entries.set(e,{registration:{manifest:a,executor:t},methods:new Xo(e,[],{}),placeholderManifest:!0}),this}unregister(e,...t){const{log:o}=this.logCtx(this.withContext(t),"unregister").for(this.unregister);return o.debug(`Unregistering graph node kind '${e}'`),this.entries.delete(e),this}has(e,...t){return this.logCtx(this.withContext(t),"has").for(this.has),this.entries.has(e)}entry(e){const t=this.entries.get(e);if(!t)throw new Ko(`No graph node kind '${e}' is registered in the catalogue`);return t}getManifest(e,...t){return this.logCtx(this.withContext(t),"getManifest").for(this.getManifest),ie(this.entry(e).registration.manifest)}getExecutor(e,...t){return this.logCtx(this.withContext(t),"getExecutor").for(this.getExecutor),this.entry(e).registration.executor}getMethodDeclaration(e,t,...o){return this.logCtx(this.withContext(o),"getMethodDeclaration").for(this.getMethodDeclaration),this.entry(e).methods.getDeclaration(t)}getMethod(e,t,...o){return this.logCtx(this.withContext(o),"getMethod").for(this.getMethod),this.entry(e).methods.getDeclaration(t),this.entry(e).methods.get(t)}listMethodDeclarations(e,...t){return this.logCtx(this.withContext(t),"listMethodDeclarations").for(this.listMethodDeclarations),this.entry(e).methods.list()}listManifests(e,...t){this.logCtx(this.withContext(t),"listManifests").for(this.listManifests);const o=[...this.entries.keys()].sort(),n=e?.categories?.length?new Set(e.categories):void 0,r=e?.kinds?.length?new Set(e.kinds):void 0,a=[];for(const e of o){if(r&&!r.has(e))continue;const o=this.getManifest(e,...t);n&&!n.has(o.display.category??"")||a.push(o)}return a}listKinds(...e){return this.logCtx(this.withContext(e),"listKinds").for(this.listKinds),[...this.entries.keys()].sort()}get size(){return this.entries.size}async resolveManifest(e,t,o,...n){this.logCtx(this.withContext(n),"resolveManifest").for(this.resolveManifest);const r=this.entry(e);return this.resolver.resolve(e,r.registration.manifest,r.registration.resolveManifest,t,o)}},e.GraphNodeCatalogue=i.__decorate([s.service(),i.__metadata("design:paramtypes",[])],e.GraphNodeCatalogue),e.GraphNodeExecutorRegistry=class extends s.Service{constructor(t=new e.GraphNodeCatalogue){super(),this.catalogue=t}get catalog(){return this.catalogue}register(e,t,...o){const{log:n}=this.logCtx(o,"register").for(this.register);if(n.debug(`Registering graph executor for kind '${e}'`),!e)throw new _t("Graph executor kind is required");return this.catalogue.registerExecutor(e,t,...o),this}unregister(e,...t){const{log:o}=this.logCtx(t,"unregister").for(this.unregister);return o.debug(`Unregistering graph executor for kind '${e}'`),this.catalogue.unregister(e,...t),this}has(e,...t){return this.logCtx(t,"has").for(this.has),this.catalogue.has(e,...t)}resolve(e,...t){this.logCtx(t,"resolve").for(this.resolve);try{return this.catalogue.getExecutor(e,...t)}catch(t){if(t instanceof Ko)throw new _t(`No graph executor registered for kind '${e}'`,"GRAPH_EXECUTOR_NOT_FOUND",{kind:e});throw t}}},e.GraphNodeExecutorRegistry=i.__decorate([s.service(),i.__metadata("design:paramtypes",[e.GraphNodeCatalogue])],e.GraphNodeExecutorRegistry),e.GraphNodeExecutorResolver=class extends s.Service{constructor(e,t){super(),this.registry=e,this.defaultExecutor=t}resolve(e,...t){const{log:o}=this.logCtx(t,"resolve").for(this.resolve);return o.debug(`Resolving graph executor for kind '${e}'`),this.registry.has(e,...t)?this.registry.resolve(e,...t):this.defaultExecutor?this.defaultExecutor:this.registry.resolve(e,...t)}},e.GraphNodeExecutorResolver=i.__decorate([s.service(),i.__metadata("design:paramtypes",[Function,Object])],e.GraphNodeExecutorResolver);class dn extends r.Model{constructor(e){super(),r.Model.fromModel(this,e)}execute(e,t){throw new _t(`Graph node kind '${this.constructor.name}' does not implement execute`,"GRAPH_NODE_EXECUTE_NOT_IMPLEMENTED",{kind:this.constructor.name})}static applyMetadata(e){return null}static instantiate(e){return new this(e)}}function ln(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}e.BreakFlowNode=class extends dn{execute(e,t){throw new Ot(e.inputs.value)}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.break.fields.value.label",placeholder:"graph.node.flow_control.break.fields.value.placeholder",type:"textarea"}),Y({handle:"value"}),i.__metadata("design:type",Object)],e.BreakFlowNode.prototype,"value",void 0),e.BreakFlowNode=i.__decorate([X("core.flow.break",{kind:"core.flow.break",category:"Flow Control",color:"#f59e0b",icon:"ti-square-arrow-right",width:96,height:96,labels:["flow","break","loop","control"],metadata:{title:"graph.node.flow_control.break.name",description:"graph.node.flow_control.break.description"}}),r.model()],e.BreakFlowNode),e.ErrorBoundaryFlowNode=class extends dn{async execute(e,t){const o=t.node.errorBoundary;if(!o?.try)return{result:e.inputs.value??e.inputs};const n=t.engine;if(!n)throw new _t("errorBoundary node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");try{const r=await n.execute(o.try,e.inputs,{parentRunId:t.runId,path:[...t.path,"try"]}),a=Object.values(r.nodeResults).find(e=>e.status===O.FAILED);if(a)throw new _t(a.error?.message??"error boundary try body failed",a.error?.code??"GRAPH_ERROR_BOUNDARY",a.error?.details);return{result:r.outputs.result??r.outputs}}catch(r){let a=r;if(o.catch){const i=await n.execute(o.catch,{...e.inputs,error:ln(r)},{parentRunId:t.runId,path:[...t.path,"catch"]});a=i.outputs.error??i.outputs}return{error:a}}finally{o.finally&&await n.execute(o.finally,e.inputs,{parentRunId:t.runId,path:[...t.path,"finally"]})}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.error_boundary.fields.value.label",placeholder:"graph.node.flow_control.error_boundary.fields.value.placeholder",type:"textarea"}),Y({handle:"value"}),i.__metadata("design:type",Object)],e.ErrorBoundaryFlowNode.prototype,"value",void 0),i.__decorate([Q({handle:"result"}),i.__metadata("design:type",Object)],e.ErrorBoundaryFlowNode.prototype,"result",void 0),i.__decorate([Q({handle:"error"}),i.__metadata("design:type",Object)],e.ErrorBoundaryFlowNode.prototype,"error",void 0),e.ErrorBoundaryFlowNode=i.__decorate([X("core.flow.errorBoundary",{kind:"core.flow.errorBoundary",category:"Flow Control",color:"#f59e0b",icon:"ti-shield-check",width:96,height:96,labels:["flow","error","try-catch"],metadata:{title:"graph.node.flow_control.error_boundary.name",description:"graph.node.flow_control.error_boundary.description",finally:!1}}),r.model()],e.ErrorBoundaryFlowNode),e.HumanApprovalFlowNode=class extends dn{execute(e){const t=e.inputs.value??e.inputs;return!1===this.approved?{rejected:t}:{approved:t}}},i.__decorate([r.required(),Y({handle:"value"}),i.__metadata("design:type",Object)],e.HumanApprovalFlowNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.message.label",placeholder:"graph.node.flow_control.human_approval.fields.message.placeholder",type:"textarea"}),Y({handle:"message",userControlled:!0}),i.__metadata("design:type",String)],e.HumanApprovalFlowNode.prototype,"message",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.approved.label",type:"checkbox"}),Y({handle:"approved",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HumanApprovalFlowNode.prototype,"approved",void 0),i.__decorate([Q({handle:"approved"}),i.__metadata("design:type",Object)],e.HumanApprovalFlowNode.prototype,"approvedOut",void 0),i.__decorate([Q({handle:"rejected"}),i.__metadata("design:type",Object)],e.HumanApprovalFlowNode.prototype,"rejectedOut",void 0),e.HumanApprovalFlowNode=i.__decorate([X("core.flow.humanApproval",{kind:"core.flow.humanApproval",category:"Flow Control",color:"#f59e0b",icon:"ti-user-check",width:96,height:96,labels:["flow","approval","suspend"],metadata:{title:"graph.node.flow_control.human_approval.name",description:"graph.node.flow_control.human_approval.description",approvers:[],timeoutMs:864e5}}),r.model()],e.HumanApprovalFlowNode),e.IfFlowNode=class extends dn{execute(e,t){const o=e.inputs,n=o.value??o;if(!this.condition)throw new _t("If node has no condition configured","GRAPH_IF_NO_CONDITION",{input:o});if(to(this.condition))return no(this.condition,o,t).then(e=>this.route(e,n));const r=ro(this.condition,((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(o,n),"if");return this.route(r,n)}route(e,t){if(e)return{then:t};if(!0===this.else)return{else:t};throw new _t("If node condition evaluated to false and the else branch is disabled","GRAPH_IF_ELSE_DISABLED",{condition:this.condition})}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.value.label",placeholder:"graph.node.flow_control.if.fields.value.placeholder",type:"textarea"}),Y({handle:"value"}),i.__metadata("design:type",Object)],e.IfFlowNode.prototype,"value",void 0),i.__decorate([r.required(),Q({handle:"then"}),i.__metadata("design:type",Object)],e.IfFlowNode.prototype,"then",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.condition.label",placeholder:"graph.node.flow_control.if.fields.condition.placeholder",type:"code"}),Y({handle:"condition",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.IfFlowNode.prototype,"condition",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.else.label",type:"checkbox"}),Y({handle:"else",userControlled:!0}),i.__metadata("design:type",Boolean)],e.IfFlowNode.prototype,"else",void 0),e.IfFlowNode=i.__decorate([X("core.flow.if",{kind:"core.flow.if",category:"Flow Control",color:"#f59e0b",icon:"ti-arrows-split-2",width:96,height:96,labels:["flow","conditional","branch"],metadata:{title:"graph.node.flow_control.if.name",description:"graph.node.flow_control.if.description"}}),r.model()],e.IfFlowNode),e.SwitchFlowNode=class extends dn{async execute(e,t){const o=((e,t)=>{const o={cases:t.cases??[],defaultPort:t.defaultPort??"default",hasDefault:!0===t.hasDefault},n=e.node.metadata?.switch;return n&&Array.isArray(n.cases)?{cases:n.cases,defaultPort:n.defaultPort??o.defaultPort,hasDefault:!0===n.hasDefault||o.hasDefault}:o})(t,this),n=o.cases,r=e.inputs,a=r.value??r,i=((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(r,a);for(const e of n)if(await ao(e.condition,{input:r,state:i,label:"switch case"},t))return{[e.outputPort]:a};if(!0!==o.hasDefault)throw new _t("No switch case matched and default port is not enabled","GRAPH_SWITCH_NO_MATCH",{cases:n.map(e=>e.id)});const s=o.defaultPort??"default";return{[s]:a}}static applyMetadata(e){const t=H(this),o=e.defaultPort??"default",n=!0===e.hasDefault,r=t.ports.filter(t=>!e.cases.some(e=>e.outputPort===t.property)),a=r.filter(e=>e.property!==o),i=r.find(e=>e.property===o),s=[...a,...e.cases.map(e=>({property:e.outputPort,name:e.label,direction:g.OUTPUT,label:e.label,required:!1,hidden:!1,path:e.outputPort}))];return n&&i&&s.push(i),{ports:s,size:b(t,{cases:e.cases.length}),dataPatch:{switchMetadata:e}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.value.label",placeholder:"graph.node.flow_control.switch.fields.value.placeholder",type:"textarea"}),Y({handle:"value"}),i.__metadata("design:type",Object)],e.SwitchFlowNode.prototype,"value",void 0),i.__decorate([r.required(),Q({handle:"default"}),i.__metadata("design:type",Object)],e.SwitchFlowNode.prototype,"default",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.cases.label",type:"collection"}),i.__metadata("design:type",Object)],e.SwitchFlowNode.prototype,"cases",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.hasDefault.label",type:"checkbox"}),i.__metadata("design:type",Boolean)],e.SwitchFlowNode.prototype,"hasDefault",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.defaultPort.label",type:"text"}),i.__metadata("design:type",String)],e.SwitchFlowNode.prototype,"defaultPort",void 0),e.SwitchFlowNode=i.__decorate([X("core.flow.switch",{kind:"core.flow.switch",category:"Flow Control",color:"#f59e0b",icon:"ti-arrows-shuffle",width:120,height:140,sizeRules:[{type:"parameterCount",parameter:"cases",dimension:"height",perItem:24}],labels:["flow","switch","multi-branch"],metadata:{title:"graph.node.flow_control.switch.name",description:"graph.node.flow_control.switch.description"}}),r.model()],e.SwitchFlowNode);const cn={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},un=t.LoggedEnvironment.accumulate({graph:{workflows:{limits:{...cn},allowAnonymousAccess:!1},execution:{maxCodeTimeoutMs:mt}}});function pn(e,t){const o="number"==typeof t?t:Number(t),n=Number.isFinite(o)&&o>0?o:mt,r="number"==typeof e?e:Number(e);return Number.isFinite(r)&&r>0?Math.min(Math.floor(r),n):1e3}const hn=["javascript","typescript"],fn="javascript";e.CodeInputSchema=class extends r.Model{constructor(){super(...arguments),this.language=fn}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.language.label",type:"select"}),r.option([...hn]),r.type(String),i.__metadata("design:type",String)],e.CodeInputSchema.prototype,"language",void 0),i.__decorate([r.required(),o.uielement("code-editor",{label:"graph.node.utility.code.fields.code.label",placeholder:"graph.node.utility.code.fields.code.placeholder"}),Y({handle:"code"}),i.__metadata("design:type",String)],e.CodeInputSchema.prototype,"code",void 0),i.__decorate([o.hidden(),Y({handle:"data"}),i.__metadata("design:type",Object)],e.CodeInputSchema.prototype,"data",void 0),e.CodeInputSchema=i.__decorate([r.model()],e.CodeInputSchema),e.CodeNode=class extends dn{async execute(e,t){const o=e.inputs,n=this.input,r=o.code??e.parameters?.code??n?.code??this.defaultCode,a=n?.language??fn;if(!r||"string"!=typeof r||0===r.trim().length)throw new vt("Code node has no code to execute (input.code is empty)",{input:o});const i=t.engine?.codeSandboxEvaluator;if(!i)throw new _t("Code node execution requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:r});const s=un.graph.execution?.maxCodeTimeoutMs,d="number"==typeof s&&Number.isFinite(s)&&s>0?s:mt,l=pn(this.timeoutMs,d),c=t.metadata,u={code:r,language:a,input:o,vars:c?.vars??void 0,item:c?.item,index:c?.index,nodes:c?.nodes??void 0,logger:t.logger,timeoutMs:l,abortSignal:t.abortSignal};await t.log("Executing code node",{language:a,length:r.length,timeoutMs:l});const p=await i.evaluate(u);return await t.log("Code node executed",{hasResult:void 0!==p}),{result:p}}},i.__decorate([r.required(),Y({handle:"input",model:e.CodeInputSchema}),i.__metadata("design:type",e.CodeInputSchema)],e.CodeNode.prototype,"input",void 0),i.__decorate([r.min(1),r.max(mt),o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.timeoutMs.label",type:"number"}),Y({handle:"timeoutMs"}),i.__metadata("design:type",Number)],e.CodeNode.prototype,"timeoutMs",void 0),i.__decorate([o.uielement("code-editor",{label:"graph.node.utility.code.fields.defaultCode.label",placeholder:"graph.node.utility.code.fields.defaultCode.placeholder"}),Y({handle:"defaultCode",userControlled:!0}),i.__metadata("design:type",String)],e.CodeNode.prototype,"defaultCode",void 0),i.__decorate([r.required(),Q({handle:"result"}),i.__metadata("design:type",Object)],e.CodeNode.prototype,"result",void 0),e.CodeNode=i.__decorate([X("core.utility.code",{kind:"core.utility.code",category:"Utility",color:"#0d9488",icon:"ti-code",width:96,height:96,labels:["utility","code","sandbox","transform"],metadata:{title:"graph.node.utility.code.name",description:"graph.node.utility.code.description"}}),r.model()],e.CodeNode),e.DelayFlowNode=class extends dn{execute(e){return{value:e.inputs.value??e.inputs}}},i.__decorate([r.required(),Y({handle:"value"}),i.__metadata("design:type",Object)],e.DelayFlowNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.delay.fields.timeoutMs.label",type:"number"}),Y({handle:"timeoutMs"}),i.__metadata("design:type",Number)],e.DelayFlowNode.prototype,"timeoutMs",void 0),i.__decorate([r.required(),Q({handle:"value"}),i.__metadata("design:type",Object)],e.DelayFlowNode.prototype,"valueOut",void 0),e.DelayFlowNode=i.__decorate([X("core.flow.delay",{kind:"core.flow.delay",category:"Utility",color:"#0d9488",icon:"ti-clock-hour-4",width:96,height:96,labels:["flow","delay","wait"],metadata:{title:"graph.node.utility.delay.name",description:"graph.node.utility.delay.description"}}),r.model()],e.DelayFlowNode),e.LogFlowNode=class extends dn{execute(e,t){const o=e.inputs.value,n=this.level??"info";return t.logger[n](this.message??"Log node",{value:o}),{value:o}}},i.__decorate([r.required(),Y({handle:"value"}),i.__metadata("design:type",Object)],e.LogFlowNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.message.label",placeholder:"graph.node.utility.log.fields.message.placeholder",type:"textarea"}),Y({handle:"message"}),i.__metadata("design:type",String)],e.LogFlowNode.prototype,"message",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.level.label",placeholder:"graph.node.utility.log.fields.level.placeholder",type:"text"}),Y({handle:"level",userControlled:!0}),i.__metadata("design:type",String)],e.LogFlowNode.prototype,"level",void 0),i.__decorate([r.required(),Q({handle:"value"}),i.__metadata("design:type",Object)],e.LogFlowNode.prototype,"valueOut",void 0),e.LogFlowNode=i.__decorate([X("core.flow.log",{kind:"core.flow.log",category:"Utility",color:"#0d9488",icon:"ti-terminal",width:96,height:96,labels:["flow","log","debug","utility"],metadata:{title:"graph.node.utility.log.name",description:"graph.node.utility.log.description"}}),r.model()],e.LogFlowNode),e.MapNode=class extends dn{execute(e){return{result:{mapped:e.inputs.value??e.inputs}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.map.fields.value.label",placeholder:"graph.node.utility.map.fields.value.placeholder",type:"textarea"}),Y({handle:"value"}),i.__metadata("design:type",Object)],e.MapNode.prototype,"value",void 0),i.__decorate([r.required(),Q({handle:"result"}),i.__metadata("design:type",Object)],e.MapNode.prototype,"result",void 0),e.MapNode=i.__decorate([X("core.utility.map",{kind:"core.utility.map",category:"Utility",color:"#0d9488",icon:"ti-arrows-right-left",width:96,height:96,labels:["utility","map","transform"],metadata:{title:"graph.node.utility.map.name",description:"graph.node.utility.map.description",mapper:{}}}),r.model()],e.MapNode),e.UtilityLogNode=class extends dn{execute(e,t){const o=e.inputs.value,n=this.level??"info";return t.logger[n](this.message??"Log node",{value:o}),{value:o}}},i.__decorate([r.required(),Y({handle:"value"}),i.__metadata("design:type",Object)],e.UtilityLogNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.message.label",placeholder:"graph.node.utility.utility_log.fields.message.placeholder",type:"textarea"}),Y({handle:"message"}),i.__metadata("design:type",String)],e.UtilityLogNode.prototype,"message",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.level.label",placeholder:"graph.node.utility.utility_log.fields.level.placeholder"}),Y({handle:"level",userControlled:!0,type:"string"}),i.__metadata("design:type",String)],e.UtilityLogNode.prototype,"level",void 0),i.__decorate([r.required(),Q({handle:"value"}),i.__metadata("design:type",Object)],e.UtilityLogNode.prototype,"valueOut",void 0),e.UtilityLogNode=i.__decorate([X("core.utility.log",{kind:"core.utility.log",category:"Utility",color:"#0d9488",icon:"ti-terminal",width:96,height:96,labels:["utility","log","debug","observability"],metadata:{title:"graph.node.utility.utility_log.name",description:"graph.node.utility.utility_log.description"}}),r.model()],e.UtilityLogNode),e.ChatTriggerNode=class extends dn{execute(e){return{message:e.inputs.message??null,sessionId:e.inputs.sessionId??null,userId:e.inputs.userId??null}}},i.__decorate([r.required(),Q({handle:"message"}),i.__metadata("design:type",String)],e.ChatTriggerNode.prototype,"message",void 0),i.__decorate([r.required(),Q({handle:"sessionId"}),i.__metadata("design:type",String)],e.ChatTriggerNode.prototype,"sessionId",void 0),i.__decorate([r.required(),Q({handle:"userId"}),i.__metadata("design:type",String)],e.ChatTriggerNode.prototype,"userId",void 0),e.ChatTriggerNode=i.__decorate([X("core.trigger.chat",{kind:"core.trigger.chat",category:"Trigger",color:"#3b82f6",icon:"ti-message-circle",width:96,height:96,labels:["trigger","chat","entrypoint"],metadata:{title:"graph.node.trigger.chat.name",description:"graph.node.trigger.chat.description",trigger:{type:"chat"}}}),r.model()],e.ChatTriggerNode),e.EventTriggerNode=class extends dn{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Q({handle:"payload"}),i.__metadata("design:type",Object)],e.EventTriggerNode.prototype,"payload",void 0),e.EventTriggerNode=i.__decorate([X("core.trigger.event",{kind:"core.trigger.event",category:"Trigger",color:"#3b82f6",icon:"ti-broadcast",width:96,height:96,labels:["trigger","event","bus"],metadata:{title:"graph.node.trigger.event.name",description:"graph.node.trigger.event.description",trigger:{type:"event",topic:"default"}}}),r.model()],e.EventTriggerNode),e.FormTriggerNode=class extends dn{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Y({handle:"schema"}),o.uielement("ngx-decaf-model-builder",{label:"graph.node.trigger.form.fields.schema.label",placeholder:"graph.node.trigger.form.fields.schema.placeholder"}),i.__metadata("design:type",Object)],e.FormTriggerNode.prototype,"schema",void 0),i.__decorate([r.required(),Q({handle:"payload"}),i.__metadata("design:type",Object)],e.FormTriggerNode.prototype,"payload",void 0),e.FormTriggerNode=i.__decorate([X("core.trigger.form",{kind:"core.trigger.form",category:"Trigger",color:"#3b82f6",icon:"ti-forms",width:96,height:96,labels:["trigger","form","public"],metadata:{title:"graph.node.trigger.form.name",description:"graph.node.trigger.form.description",trigger:{type:"form",fields:[]}}}),r.model()],e.FormTriggerNode),e.ManualTriggerNode=class extends dn{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Q({handle:"payload"}),i.__metadata("design:type",Object)],e.ManualTriggerNode.prototype,"payload",void 0),e.ManualTriggerNode=i.__decorate([X("core.trigger.manual",{kind:"core.trigger.manual",category:"Trigger",color:"#3b82f6",icon:"ti-hand-click",width:96,height:96,labels:["trigger","manual","entrypoint"],metadata:{title:"graph.node.trigger.manual.name",description:"graph.node.trigger.manual.description",trigger:{type:"manual",inputSchema:{}}}}),r.model()],e.ManualTriggerNode),e.ScheduleTriggerNode=class extends dn{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Y({handle:"cron"}),o.uielement("app-cron-selector-field",{label:"graph.node.trigger.schedule.fields.cron.label",placeholder:"graph.node.trigger.schedule.fields.cron.placeholder"}),i.__metadata("design:type",String)],e.ScheduleTriggerNode.prototype,"cron",void 0),i.__decorate([r.required(),Q({handle:"payload"}),i.__metadata("design:type",Object)],e.ScheduleTriggerNode.prototype,"payload",void 0),e.ScheduleTriggerNode=i.__decorate([X("core.trigger.schedule",{kind:"core.trigger.schedule",category:"Trigger",color:"#3b82f6",icon:"ti-calendar-time",width:96,height:96,labels:["trigger","schedule","cron"],metadata:{title:"graph.node.trigger.schedule.name",description:"graph.node.trigger.schedule.description",trigger:{type:"schedule",schedule:"0 * * * *",timezone:"UTC"}}}),r.model()],e.ScheduleTriggerNode),e.WebhookTriggerNode=class extends dn{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Y({handle:"schema"}),o.uielement("ngx-decaf-model-builder",{label:"graph.node.trigger.webhook.fields.schema.label",placeholder:"graph.node.trigger.webhook.fields.schema.placeholder"}),i.__metadata("design:type",Object)],e.WebhookTriggerNode.prototype,"schema",void 0),i.__decorate([r.required(),Q({handle:"payload"}),i.__metadata("design:type",Object)],e.WebhookTriggerNode.prototype,"payload",void 0),e.WebhookTriggerNode=i.__decorate([X("core.trigger.webhook",{kind:"core.trigger.webhook",category:"Trigger",color:"#3b82f6",icon:"ti-webhook",width:96,height:96,labels:["trigger","webhook","http"],metadata:{title:"graph.node.trigger.webhook.name",description:"graph.node.trigger.webhook.description",trigger:{type:"webhook",path:"/webhook",method:"POST",auth:"none",responseMode:"onReceived"}}}),r.model()],e.WebhookTriggerNode),e.AgentNode=class extends dn{execute(e){return{response:"[Agent response] "+(e.inputs.prompt??""),actions:[]}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.prompt.label",placeholder:"graph.node.agent.agent.fields.prompt.placeholder",type:"textarea"}),Y({handle:"prompt"}),i.__metadata("design:type",String)],e.AgentNode.prototype,"prompt",void 0),i.__decorate([r.required(),Q({handle:"response"}),i.__metadata("design:type",String)],e.AgentNode.prototype,"response",void 0),i.__decorate([r.required(),Q({handle:"actions"}),i.__metadata("design:type",Array)],e.AgentNode.prototype,"actions",void 0),i.__decorate([Z({category:"model",handle:"model"}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"model",void 0),i.__decorate([Z({category:"memory",handle:"memory"}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"memory",void 0),i.__decorate([Z({category:"workspace",handle:"workspace"}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"workspace",void 0),e.AgentNode=i.__decorate([X("core.agent",{kind:"core.agent",category:"Agent",width:140,height:120,labels:["agent","ai","orchestrator"],metadata:{title:"graph.node.agent.agent.name",description:"graph.node.agent.agent.description",shape:"rectangle"}}),r.model()],e.AgentNode);const gn=[e.AgentNode];function mn(e,t,o,n){const r=t??o;if(null==e)return Math.min(o,r);const a=Number(e);if(!Number.isFinite(a)||0>=a)throw new vt(n+" loop maxIterations must be a positive finite number");return Math.min(Math.floor(a),r)}function yn(e,t,o){const n=t.node.loop,r=t.metadata?.loop;if(!n?.body&&!r?.body)throw new vt(o+" node is missing loop configuration (instance.loop.body)");const a=t=>{const o=e[t]??n?.[t]??r?.[t],a=Number(o);return void 0!==o&&Number.isFinite(a)?a:void 0},i=t=>{const o=e[t]??r?.[t];return"string"==typeof o?o:void 0};return{body:n?.body??r?.body,maxIterations:a("maxIterations"),timeoutMs:a("timeoutMs"),concurrency:a("concurrency"),condition:e.condition??r?.condition,inputPort:i("inputPort"),outputPort:i("outputPort"),itemPort:i("itemPort"),resultPort:i("resultPort"),statePort:i("statePort"),slice:a("slice")}}e.GraphForeachLoopNode=class extends dn{async execute(e,t){const o=yn(this,t,"foreach"),n=e.inputs,r=n.items,a=mn(o.maxIterations,t.limits?.maxForeachIterations,1e3,"foreach");if(!Array.isArray(r))throw new vt("foreach input 'items' must be an array");const i=t.engine;if(!i)throw new _t("foreach node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const s=Number(n.slice??o.slice??1),d=Number.isFinite(s)&&s>0?Math.floor(s):1,l=d>1?Math.ceil(r.length/d):r.length;if(l>a)throw new Nt(`foreach exceeded max iterations (${l} > ${a})`);const c=o.itemPort??"item",u=o.resultPort??"result",p=o.statePort??"state",h=o.body,f=[];let g=n.state,m=!1;await t.emit({type:S.LOOP_STARTED});for(let e=0;l>e;e++){await t.emit({type:S.LOOP_ITERATION_STARTED,iteration:e});const o=d>1?r.slice(e*d,e*d+d):r[e],n={[c]:o,index:e};d>1&&(n.slice=o),void 0!==g&&(n[p]=g);try{const r=await i.execute(h,n,{parentRunId:t.runId,path:[...t.path,"iteration:"+e],metadata:{item:o,index:e,slice:d},auth:t.auth},t);f.push(r.outputs[u]),void 0!==r.outputs[p]&&(g=r.outputs[p])}catch(o){if(o instanceof Ot){const n=o.details?.value;void 0!==n&&f.push(n),m=!0,await t.emit({type:S.LOOP_ITERATION_COMPLETED,iteration:e,metadata:{broken:!0}});break}throw o}await t.emit({type:S.LOOP_ITERATION_COMPLETED,iteration:e})}await t.emit({type:S.LOOP_COMPLETED,metadata:{broken:m}});const y={results:f,completed:f,iterations:f.length,broken:m};return void 0!==g&&(y[p]=g),y}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.items.label",placeholder:"graph.node.loop.foreach.fields.items.placeholder",type:"textarea"}),Y({handle:"items"}),i.__metadata("design:type",Array)],e.GraphForeachLoopNode.prototype,"items",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.slice.label",placeholder:"graph.node.loop.foreach.fields.slice.placeholder",type:"number"}),Y({handle:"slice"}),i.__metadata("design:type",Number)],e.GraphForeachLoopNode.prototype,"slice",void 0),i.__decorate([r.required(),Q({handle:"item"}),i.__metadata("design:type",Object)],e.GraphForeachLoopNode.prototype,"item",void 0),i.__decorate([r.required(),Z({handle:"loop",connectionRules:{allowSelf:!0,maxConnections:1}}),i.__metadata("design:type",Object)],e.GraphForeachLoopNode.prototype,"loop",void 0),i.__decorate([r.required(),Q({handle:"completed"}),i.__metadata("design:type",Array)],e.GraphForeachLoopNode.prototype,"completed",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.maxIterations.label",type:"number"}),Y({handle:"maxIterations",userControlled:!0}),i.__metadata("design:type",Number)],e.GraphForeachLoopNode.prototype,"maxIterations",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.condition.label",type:"code"}),Y({handle:"condition",userControlled:!0}),i.__metadata("design:type",Object)],e.GraphForeachLoopNode.prototype,"condition",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.itemPort.label",type:"text"}),Y({handle:"itemPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphForeachLoopNode.prototype,"itemPort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.resultPort.label",type:"text"}),Y({handle:"resultPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphForeachLoopNode.prototype,"resultPort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.statePort.label",type:"text"}),Y({handle:"statePort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphForeachLoopNode.prototype,"statePort",void 0),e.GraphForeachLoopNode=i.__decorate([X("graph-foreach-loop-node",{kind:"core.loop.foreach",category:"Loop",color:"#eab308",icon:"ti-repeat",width:120,height:140,labels:["loop","iteration","foreach"],metadata:{title:"graph.node.loop.foreach.name",description:"graph.node.loop.foreach.description",loop:{maxIterations:100,itemPort:"item",resultPort:"result",slice:1}}}),r.model()],e.GraphForeachLoopNode);class wn{constructor(){this.expressionEvaluator=new eo}evaluate(t,o){if(this.isConditionExpression(t))return this.expressionEvaluator.evaluate(t,o);const n=this.resolveValue(t.left,o),r=t.right;switch(t.type){case e.GraphConditionType.TRUTHY:return!!n;case e.GraphConditionType.FALSY:return!n;case e.GraphConditionType.EQUALS:return n===r;case e.GraphConditionType.NOT_EQUALS:return n!==r;case e.GraphConditionType.GREATER_THAN:return Number(n)>Number(r);case e.GraphConditionType.GREATER_THAN_OR_EQUAL:return Number(n)>=Number(r);case e.GraphConditionType.LESS_THAN:return Number(r)>Number(n);case e.GraphConditionType.LESS_THAN_OR_EQUAL:return Number(r)>=Number(n);case e.GraphConditionType.EXISTS:return null!=n;case e.GraphConditionType.CUSTOM:throw new _t("Custom condition evaluators are not supported in v1","GRAPH_CUSTOM_CONDITION_UNSUPPORTED");default:throw new _t(`Unknown condition type '${t.type}'`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:t})}}async evaluateAsync(e,t,o,n){return to(e)?no(e,n,o):this.evaluate(e,t)}resolveValue(e,t){if(!e)return t;const o=e.split(".");let n=t;for(const e of o){if(null==n)return;n=n[e]}return n}isConditionExpression(e){return"string"==typeof e.op}}function _n(e,t,o,n={}){return{id:e,label:t,direction:o,...n}}function bn(e){const t=e,o=F(t),n=o?.metadata?.title;return nt(t,n?{name:n}:{})}e.GraphUntilLoopNode=class extends dn{async execute(e,t){const o=yn(this,t,"until"),n=e.inputs,r=mn(o.maxIterations,t.limits?.maxLoopIterations,100,"until"),a=o.condition;if(!a)throw new vt("until node is missing a condition");const i=o.statePort??"state",s=o.inputPort??i,d=o.outputPort??i,l=o.body,c=t.engine;if(!c)throw new _t("until node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let u=n.state,p=0;await t.emit({type:S.LOOP_STARTED});let h=!1;do{if(p>=r)throw await t.emit({type:S.LOOP_LIMIT_REACHED,iteration:p}),new Nt(`until loop exceeded max iterations (${r})`);await t.emit({type:S.LOOP_ITERATION_STARTED,iteration:p}),u=(await c.execute(l,{[s]:u,iteration:p},{parentRunId:t.runId,path:[...t.path,"iteration:"+p],auth:t.auth},t)).outputs[d],await t.emit({type:S.LOOP_ITERATION_COMPLETED,iteration:p});const e=await(new wn).evaluateAsync(a,u,t,{...n,state:u});await t.emit({type:S.LOOP_CONDITION_EVALUATED,iteration:p,payload:{result:e}}),p++,h=e}while(!h);return await t.emit({type:S.LOOP_COMPLETED}),{state:u,iterations:p}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.state.label",placeholder:"graph.node.loop.until.fields.state.placeholder",type:"textarea"}),Y({handle:"state"}),i.__metadata("design:type",Object)],e.GraphUntilLoopNode.prototype,"state",void 0),i.__decorate([r.required(),Q({handle:"state"}),i.__metadata("design:type",Object)],e.GraphUntilLoopNode.prototype,"stateOut",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.maxIterations.label",type:"number"}),Y({handle:"maxIterations",userControlled:!0}),i.__metadata("design:type",Number)],e.GraphUntilLoopNode.prototype,"maxIterations",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.condition.label",type:"code"}),Y({handle:"condition",userControlled:!0}),i.__metadata("design:type",Object)],e.GraphUntilLoopNode.prototype,"condition",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.statePort.label",type:"text"}),Y({handle:"statePort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphUntilLoopNode.prototype,"statePort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.inputPort.label",type:"text"}),Y({handle:"inputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphUntilLoopNode.prototype,"inputPort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.outputPort.label",type:"text"}),Y({handle:"outputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphUntilLoopNode.prototype,"outputPort",void 0),e.GraphUntilLoopNode=i.__decorate([X("graph-until-loop-node",{kind:"core.loop.until",category:"Loop",color:"#eab308",icon:"ti-player-stop",width:96,height:96,labels:["loop","conditional","until"],metadata:{title:"graph.node.loop.until.name",description:"graph.node.loop.until.description",loop:{maxIterations:50,statePort:"state",condition:{type:"greaterThanOrEqual",left:"iteration",right:2}}}}),r.model()],e.GraphUntilLoopNode),e.GraphWhileLoopNode=class extends dn{async execute(e,t){const o=yn(this,t,"while"),n=e.inputs,r=mn(o.maxIterations,t.limits?.maxLoopIterations,100,"while"),a=o.condition;if(!a)throw new vt("while node is missing a condition");const i=o.statePort??"state",s=o.inputPort??i,d=o.outputPort??i,l=o.body,c=t.engine;if(!c)throw new _t("while node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let u=n.state,p=0;for(await t.emit({type:S.LOOP_STARTED});await(new wn).evaluateAsync(a,u,t,{...n,state:u});){if(p>=r)throw await t.emit({type:S.LOOP_LIMIT_REACHED,iteration:p}),new Nt(`while loop exceeded max iterations (${r})`);await t.emit({type:S.LOOP_CONDITION_EVALUATED,iteration:p,payload:{result:!0}}),await t.emit({type:S.LOOP_ITERATION_STARTED,iteration:p}),u=(await c.execute(l,{[s]:u,iteration:p},{parentRunId:t.runId,path:[...t.path,"iteration:"+p],auth:t.auth},t)).outputs[d],await t.emit({type:S.LOOP_ITERATION_COMPLETED,iteration:p}),p++}return await t.emit({type:S.LOOP_COMPLETED}),{state:u,iterations:p}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.state.label",placeholder:"graph.node.loop.while.fields.state.placeholder",type:"textarea"}),Y({handle:"state"}),i.__metadata("design:type",Object)],e.GraphWhileLoopNode.prototype,"state",void 0),i.__decorate([r.required(),Q({handle:"state"}),i.__metadata("design:type",Object)],e.GraphWhileLoopNode.prototype,"stateOut",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.maxIterations.label",type:"number"}),Y({handle:"maxIterations",userControlled:!0}),i.__metadata("design:type",Number)],e.GraphWhileLoopNode.prototype,"maxIterations",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.condition.label",type:"code"}),Y({handle:"condition",userControlled:!0}),i.__metadata("design:type",Object)],e.GraphWhileLoopNode.prototype,"condition",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.statePort.label",type:"text"}),Y({handle:"statePort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphWhileLoopNode.prototype,"statePort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.inputPort.label",type:"text"}),Y({handle:"inputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphWhileLoopNode.prototype,"inputPort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.outputPort.label",type:"text"}),Y({handle:"outputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphWhileLoopNode.prototype,"outputPort",void 0),e.GraphWhileLoopNode=i.__decorate([X("graph-while-loop-node",{kind:"core.loop.while",category:"Loop",color:"#eab308",icon:"ti-arrows-loop",width:96,height:96,labels:["loop","conditional","while"],metadata:{title:"graph.node.loop.while.name",description:"graph.node.loop.while.description",loop:{maxIterations:50,statePort:"state",condition:{type:"lessThan",left:"iteration",right:3}}}}),r.model()],e.GraphWhileLoopNode),e.GraphInputValueNode=class extends dn{execute(e){const t=e.inputs;return{value:t?.value??null}}},i.__decorate([Q({handle:"value",connectionRules:{allowMultiple:!0}}),i.__metadata("design:type",Object)],e.GraphInputValueNode.prototype,"value",void 0),e.GraphInputValueNode=i.__decorate([X("graph-input-value-node",{kind:"value",category:"Boundary",color:"#0f766e",icon:"ti-circle-plus",labels:["workflow","input","value"],metadata:{title:"graph.node.boundary.input.name",description:"graph.node.boundary.input.description"}}),r.model()],e.GraphInputValueNode),e.GraphOutputValueNode=class extends dn{execute(e){return{}}},i.__decorate([r.required(),Y({handle:"value"}),i.__metadata("design:type",Object)],e.GraphOutputValueNode.prototype,"value",void 0),e.GraphOutputValueNode=i.__decorate([X("graph-output-value-node",{kind:"result",category:"Boundary",color:"#0f766e",icon:"ti-circle-minus",width:96,height:96,labels:["workflow","output","value"],metadata:{title:"graph.node.boundary.output.name",description:"graph.node.boundary.output.description"}}),r.model()],e.GraphOutputValueNode);const vn={kind:"core.loop.foreach",capabilities:["loop"],display:{name:"graph.node.loop.foreach.name",description:"graph.node.loop.foreach.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-repeat"},width:120,height:140,labels:["loop","iteration","foreach"]},inputs:[_n("items","graph.node.loop.foreach.ports.input.items.label","input",{required:!0,schema:{type:"array",items:{type:"any"}}}),_n("slice","graph.node.loop.foreach.ports.input.slice.label","input",{schema:{type:"number",integer:!0,min:1}}),_n("state","graph.node.loop.foreach.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[_n("results","graph.node.loop.foreach.ports.output.results.label","output",{schema:{type:"array",items:{type:"any"}}}),_n("completed","graph.node.loop.foreach.ports.output.completed.label","output",{schema:{type:"array",items:{type:"any"}}}),_n("iterations","graph.node.loop.foreach.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}}),_n("broken","graph.node.loop.foreach.ports.output.broken.label","output",{schema:{type:"boolean"}}),_n("state","graph.node.loop.foreach.ports.output.state.label","output",{schema:{type:"any"}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.foreach.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.foreach.fields.condition.label"},{type:"string",id:"itemPort",label:"graph.node.loop.foreach.fields.itemPort.label"},{type:"string",id:"resultPort",label:"graph.node.loop.foreach.fields.resultPort.label"},{type:"string",id:"statePort",label:"graph.node.loop.foreach.fields.statePort.label"},{type:"number",id:"slice",label:"graph.node.loop.foreach.fields.slice.label",integer:!0,min:1}]},Nn={kind:"core.loop.while",capabilities:["loop"],display:{name:"graph.node.loop.while.name",description:"graph.node.loop.while.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-arrows-loop"},width:120,height:140,labels:["loop","conditional","while"]},inputs:[_n("state","graph.node.loop.while.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[_n("state","graph.node.loop.while.ports.output.state.label","output",{schema:{type:"any"}}),_n("iterations","graph.node.loop.while.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.while.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.while.fields.condition.label",required:!0},{type:"string",id:"statePort",label:"graph.node.loop.while.fields.statePort.label"},{type:"string",id:"inputPort",label:"graph.node.loop.while.fields.inputPort.label"},{type:"string",id:"outputPort",label:"graph.node.loop.while.fields.outputPort.label"}]},En={kind:"core.loop.until",capabilities:["loop"],display:{name:"graph.node.loop.until.name",description:"graph.node.loop.until.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-player-stop"},width:120,height:140,labels:["loop","conditional","until"]},inputs:[_n("state","graph.node.loop.until.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[_n("state","graph.node.loop.until.ports.output.state.label","output",{schema:{type:"any"}}),_n("iterations","graph.node.loop.until.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.until.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.until.fields.condition.label",required:!0},{type:"string",id:"statePort",label:"graph.node.loop.until.fields.statePort.label"},{type:"string",id:"inputPort",label:"graph.node.loop.until.fields.inputPort.label"},{type:"string",id:"outputPort",label:"graph.node.loop.until.fields.outputPort.label"}]},In=[bn(e.GraphInputValueNode),bn(e.GraphOutputValueNode),bn(e.ManualTriggerNode),bn(e.WebhookTriggerNode),bn(e.ScheduleTriggerNode),bn(e.EventTriggerNode),bn(e.FormTriggerNode),bn(e.ChatTriggerNode),(An=bn(e.IfFlowNode),{...An,dynamicPorts:[{type:"togglePort",parameter:"else",equals:!0,port:{id:"else",label:"graph.node.flow_control.if.ports.output.else.label",direction:"output",schema:{type:"any"}}}]}),(e=>({...e,outputs:[],parameters:[...e.parameters,{type:"collection",id:"cases",label:"graph.node.flow_control.switch.fields.cases.label",required:!0,itemIdPath:"outputPort",itemLabelPath:"label"},{type:"boolean",id:"hasDefault",label:"graph.node.flow_control.switch.fields.hasDefault.label",defaultValue:!1},{type:"object",id:"switch",label:"graph.node.flow_control.switch.fields.switch.label",required:!1}],dynamicPorts:[{type:"repeatFromParameter",parameter:"cases",itemIdPath:"outputPort",itemLabelPath:"label",direction:"output",portIdTemplate:"${id}",defaultPort:{id:"case",label:"graph.node.flow_control.switch.ports.output.case.label",direction:"output",schema:{type:"any"}}},{type:"togglePort",parameter:"hasDefault",equals:!0,port:{id:"default",label:"graph.node.flow_control.switch.ports.output.default.label",direction:"output",schema:{type:"any"}}}]}))(bn(e.SwitchFlowNode)),bn(e.MapNode),bn(e.DelayFlowNode),bn(e.ErrorBoundaryFlowNode),bn(e.HumanApprovalFlowNode),bn(e.CodeNode),bn(e.LogFlowNode),bn(e.UtilityLogNode),bn(e.BreakFlowNode),bn(e.AgentNode),vn,Nn,En];var An;const On=Object.fromEntries(In.map(e=>[e.kind,e])),kn=[e.ManualTriggerNode,e.WebhookTriggerNode,e.ScheduleTriggerNode,e.EventTriggerNode,e.FormTriggerNode,e.ChatTriggerNode],xn=[e.IfFlowNode,e.SwitchFlowNode,e.DelayFlowNode,e.ErrorBoundaryFlowNode,e.HumanApprovalFlowNode,e.LogFlowNode,e.BreakFlowNode],Sn=[e.CodeNode,e.MapNode,e.UtilityLogNode],Dn=[e.GraphForeachLoopNode,e.GraphWhileLoopNode,e.GraphUntilLoopNode],Rn=[e.GraphInputValueNode,e.GraphOutputValueNode],Pn={value:e.GraphInputValueNode,result:e.GraphOutputValueNode,"core.trigger.manual":e.ManualTriggerNode,"core.trigger.webhook":e.WebhookTriggerNode,"core.trigger.schedule":e.ScheduleTriggerNode,"core.trigger.event":e.EventTriggerNode,"core.trigger.form":e.FormTriggerNode,"core.trigger.chat":e.ChatTriggerNode,"core.flow.if":e.IfFlowNode,"core.flow.switch":e.SwitchFlowNode,"core.utility.map":e.MapNode,"core.flow.delay":e.DelayFlowNode,"core.flow.errorBoundary":e.ErrorBoundaryFlowNode,"core.flow.humanApproval":e.HumanApprovalFlowNode,"core.utility.code":e.CodeNode,"core.flow.log":e.LogFlowNode,"core.utility.log":e.UtilityLogNode,"core.flow.break":e.BreakFlowNode,"core.agent":e.AgentNode,"core.loop.foreach":e.GraphForeachLoopNode,"core.loop.while":e.GraphWhileLoopNode,"core.loop.until":e.GraphUntilLoopNode};function Cn(e){return{execute:(t,o)=>e.instantiate({...sn(o.node),...t.parameters,...o.node.state??{}}).execute(t,o)}}function Tn(){const e=[];for(const[t,o]of Object.entries(On)){const n=Pn[t];n&&e.push(an({manifest:o,executor:Cn(n)}))}return e}const $n=["node","definition","executor","execute","ports","component"];function Gn(e,t,o,n){return{code:e,path:t,message:o,...void 0!==n?.nodeId?{nodeId:n.nodeId}:{},...void 0!==n?.edgeId?{edgeId:n.edgeId}:{},...n?.details?{details:n.details}:{}}}function Ln(e,t){const o=[];for(const n of Object.keys(e))$n.includes(n)&&o.push(Gn("document.forbidden-field",`${t}.${n}`,`Field '${n}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected at the boundary`,{details:{field:n}}));return o}function Mn(e,t){t.push(...Ln(e,"$")),e.inputs.forEach((e,o)=>t.push(...Ln(e,`inputs[${o}]`))),e.outputs.forEach((e,o)=>t.push(...Ln(e,`outputs[${o}]`)));for(const o of e.nodes)t.push(...Ln(o,`nodes[${o.id}]`)),o.loop&&(t.push(...Ln(o.loop,`nodes[${o.id}].loop`)),Mn(o.loop.body,t));for(const o of e.edges)t.push(...Ln(o,`edges[${o.id}]`))}function Fn(e,t){const o=[];e.nodes.length>t.maxNodes&&o.push(Gn("document.limit.nodes","$.nodes",`Document declares ${e.nodes.length} nodes; at most ${t.maxNodes} are allowed`,{details:{count:e.nodes.length,limit:t.maxNodes}})),e.edges.length>t.maxEdges&&o.push(Gn("document.limit.edges","$.edges",`Document declares ${e.edges.length} edges; at most ${t.maxEdges} are allowed`,{details:{count:e.edges.length,limit:t.maxEdges}}));const n=Vn(e);n>t.maxNestingDepth&&o.push(Gn("document.limit.depth","$.nodes",`Document nests loop bodies ${n} levels deep; at most ${t.maxNestingDepth} levels are allowed`,{details:{depth:n,limit:t.maxNestingDepth}}));const r=Buffer.byteLength(JSON.stringify(e),"utf8");return r>t.maxDocumentBytes&&o.push(Gn("document.limit.size","$",`Document serializes to ${r} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,{details:{bytes:r,limit:t.maxDocumentBytes}})),o}function Vn(e,t=0){let o=t;for(const n of e.nodes)n.loop?.body&&(o=Math.max(o,Vn(n.loop.body,t+1)));return o}async function jn(e,t,...o){const n=[];for(const r of e.nodes)t.has(r.kind,...o)||n.push(Gn("node.unknown-kind",`nodes[${r.id}].kind`,`Node '${r.id}' references kind '${r.kind}' which is not registered in the backend catalogue`,{nodeId:r.id,details:{kind:r.kind}})),r.loop?.body&&n.push(...await jn(r.loop.body,t,...o));return n}async function Un(e,t={},...o){const n={...cn,...t.limits},r=[];if(!Re(e))return r.push(Gn("document.shape","$","Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays")),{valid:!1,issues:r};if(!ae(e))return r.push(Gn("document.json-unsafe","$","Document contains JSON-unsafe values: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected")),{valid:!1,issues:r};Mn(e,r),r.push(...(e=>{const t=[],o=new Set;for(const n of[...e.inputs,...e.outputs])o.has(n.id)?t.push(Gn("document.duplicate-port-id",`ports[${n.id}]`,`Workflow port '${n.id}' is declared more than once; workflow port ids must be unique`)):o.add(n.id);const n=new Set;for(const o of e.nodes)n.has(o.id)?t.push(Gn("document.duplicate-node-id",`nodes[${o.id}]`,`Node '${o.id}' is declared more than once; node ids must be unique`,{nodeId:o.id})):n.add(o.id);const r=new Set;for(const o of e.edges)r.has(o.id)?t.push(Gn("document.duplicate-edge-id",`edges[${o.id}]`,`Edge '${o.id}' is declared more than once; edge ids must be unique`,{edgeId:o.id})):r.add(o.id);return t})(e)),r.push(...Fn(e,n)),So(e,r);try{ve(e)}catch(e){const t=e instanceof a.ValidationError?e.message:e+"";r.push(Gn("document.structure","$",t))}return t.catalogue&&r.push(...await jn(e,t.catalogue,...o)),{valid:0===r.length,issues:r}}function Bn(e,t,o={}){const n=e?.owner??null;return!n||n===t||(null==t||""===t)&&!0===o.allowAnonymousAccess}function Wn(e,t){return(e?.owner??null)===(t??null)}function qn(e,t,o){if(!Wn(e,t))throw new s.ForbiddenError(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function Hn(e,t,o){if(!Bn(e,t,o))throw new s.ForbiddenError(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function Kn(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Kn(e)).join(",")}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${Kn(t[e])}`).join(",")}}`}function zn(e){return p.createHash("sha256").update(Kn(e)).digest("hex")}function Xn(e){return new it({runId:e.runId,workflowId:e.workflowId,...e.ownerUser?{owner:e.ownerUser}:{},status:e.status,...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{},...void 0!==e.result?{result:Jn(e.result)}:{},...e.error?{error:Jn(e.error)}:{},createdAt:new Date(e.createdAt),...e.startedAt?{startedAt:new Date(e.startedAt)}:{},...e.finishedAt?{finishedAt:new Date(e.finishedAt)}:{}})}function Jn(e){if(null!=e)return JSON.parse(JSON.stringify(e))}class Yn{constructor(e,t={}){this.sequences=new Map,this.chains=new Map,this.store=e,this.limits={...D,...t}}async publish(e){const t=e.runId,o=(this.sequences.get(t)??0)+1;this.sequences.set(t,o);const n={...e,payload:this.limitPayload(e.payload),sequence:o,timestamp:(new Date).toISOString()},r=(this.chains.get(t)??Promise.resolve()).then(()=>this.store.append(n));return this.chains.set(t,r.catch(()=>{})),await r,n}lastSequence(e){return this.sequences.get(e)??0}release(e){this.sequences.delete(e),this.chains.delete(e)}limitPayload(e){if(void 0===e)return;let t;try{t=JSON.stringify(e)}catch{return{nonSerializable:!0}}return t.length>this.limits.maxEventPayloadBytes?{truncated:!0,reason:"event payload exceeds the configured byte limit",bytes:t.length}:e}}class Qn{constructor(e,t,o,n={},r={}){this.controllers=new Map,this.completions=new Map,this.timeouts=new Map,this.engine=e,this.runStore=t,this.publisher=o,this.hooks=n,this.limits={...D,...r}}begin(e){const t=this.controllers.get(e);if(t)return t;const o=new AbortController;return this.controllers.set(e,o),o}abort(e,t){const o=this.controllers.get(e);return!!o&&(o.signal.aborted||o.abort(t),!0)}isAborted(e){return!0===this.controllers.get(e)?.signal.aborted}abortReason(e){const t=this.controllers.get(e)?.signal;if(t?.aborted)return"timeout"===t.reason?"timeout":"user"}waitFor(e){return this.completions.get(e)}schedule(e,t,o,...n){const r=this.completions.get(e.runId);if(r)return r;const a=this.runExecution({...e},t,o,...n).catch(async t=>{const o=Zn(t);try{await this.emitTerminal({...e},S.WORKFLOW_FAILED,o)}catch{}return await this.finalize({...e},"failed",void 0,o,...n)});return this.completions.set(e.runId,a),a}release(e){this.controllers.delete(e),this.completions.delete(e);const t=this.timeouts.get(e);t&&(clearTimeout(t),this.timeouts.delete(e)),this.publisher.release(e)}armTimeout(e){const t=setTimeout(()=>{this.timeouts.delete(e),this.abort(e,"timeout")},this.limits.executionTimeoutMs);this.timeouts.set(e,t)}async runExecution(e,t,o,...n){const r=e.runId;let a,i,s=!1;const d=this.engine.observe({refresh:async t=>{t.runId===r&&(t.error&&(a=t.error),P((await this.publisher.publish(this.envelopeOf(e,t))).type)?s=!0:t.type===S.WORKFLOW_STARTED&&"validating"===e.status&&(e.status="running",await this.persist(e,...n)))}});this.armTimeout(r);try{if(this.isAborted(r)){const t={name:"GraphRunCancelledError",message:`Graph run '${r}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return a=t,await this.emitTerminal(e,S.WORKFLOW_CANCELLED,t),s=!0,await this.finalize(e,"cancelled",void 0,t,...n)}let d,l;e.status="validating",e.startedAt=(new Date).toISOString(),await this.persist(e,...n);try{({document:d,fingerprint:l}=await t(...n)),e.documentFingerprint=l,await this.persist(e,...n)}catch(t){const o=Zn(t);return a=o,s||(await this.emitTerminal(e,S.WORKFLOW_FAILED,o),s=!0),await this.finalize(e,"failed",void 0,o,...n)}if(this.isAborted(r)){const t={name:"GraphRunCancelledError",message:`Graph run '${r}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return a=t,s||(await this.emitTerminal(e,S.WORKFLOW_CANCELLED,t),s=!0),await this.finalize(e,"cancelled",void 0,t,...n)}try{i=await this.engine.execute(d,o,{runId:r,abortSignal:this.controllers.get(r)?.signal,metadata:{documentFingerprint:l}},...n)}catch(e){a=Zn(e)}const c=this.abortReason(r);let u,p;return"timeout"===c?(u="failed",p=a??{name:"GraphRunTimeoutError",message:`Graph run '${r}' exceeded the configured execution timeout of ${this.limits.executionTimeoutMs}ms`,code:"GRAPH_RUN_TIMEOUT"}):"user"===c?(u="cancelled",p=a):i?.status===O.SUCCEEDED?u="succeeded":i?.status===O.CANCELLED?(u="cancelled",p=a):(u="failed",p=a??Zn(new _t(i?`Graph run '${r}' failed`:`Graph run '${r}' failed without a result`,"GRAPH_RUN_FAILED",{runId:r}))),s||await this.emitTerminal(e,"succeeded"===u?S.WORKFLOW_COMPLETED:"cancelled"===u?S.WORKFLOW_CANCELLED:S.WORKFLOW_FAILED,p),await this.finalize(e,u,i,p,...n)}finally{d();const e=this.timeouts.get(r);e&&(clearTimeout(e),this.timeouts.delete(r))}}async emitTerminal(e,t,o){await this.publisher.publish({runId:e.runId,workflowId:e.workflowId,type:t,error:o})}async finalize(e,t,o,n,...r){e.status=t,o&&(e.result=o),n&&(e.error=n),e.startedAt||(e.startedAt=(new Date).toISOString()),e.finishedAt=(new Date).toISOString(),await this.persist(e,...r);try{await(this.hooks.onRunCompleted?.(e,o))}catch{}return e}async persist(e,...t){await this.runStore.saveRun({...e},...t)}envelopeOf(e,t){return{runId:e.runId,workflowId:t.workflowId??e.workflowId,type:t.type,nodeId:t.nodeId,edgeId:t.edgeId,payload:void 0===t.payload?void 0:re(t.payload)?t.payload:{nonSerializable:!0},error:t.error,parentRunId:t.parentRunId,path:t.path}}}function Zn(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}function er(e){if(!e)return;let t;try{t=e.cache?.user}catch{t=void 0}if(null==t)try{t=e.get("user")}catch{t=void 0}return"string"==typeof t&&t.length>0?t:void 0}function tr(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&Re(e.document)&&!Re(e)}function or(e){return JSON.parse(JSON.stringify(e))}function nr(e){if(null==e)return 0;let t;try{t=e.getTime()}catch{return 0}return Number.isFinite(t)?t:0}e.GraphWorkflowService=class extends s.ModelService{constructor(e){super(st),this.catalogue=e}get limits(){return{...cn,...un.graph.workflows.limits??{}}}get allowAnonymousAccess(){return!0===un.graph.workflows.allowAnonymousAccess}async saveDocument(e,t,...o){const{ctx:n,ctxArgs:r}=(await this.logCtx(o,"saveDocument",!0)).for(this.saveDocument);if(!Re(t))throw new a.ValidationError("Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays");if(t.id!==e)throw new a.ValidationError(`Document id '${t.id}' does not match the workflow id '${e}' from the request path`);const i=await this.validateDocument(t,n);if(!i.valid)throw new xt(i.issues);const s=er(n),d=await this.readExistingForWrite(e,r);d&&this.assertWriteOwnership(e,d,s);const l=new Date;if(d)return d.name=t.name,d.document=or(t),d.updatedAt=l,this.update(d,...r);const c=new st({workflowId:e,name:t.name,document:or(t),...s?{owner:s}:{},updatedAt:l});return this.create(c,...r)}async seedDocument(e,t,...o){const{log:n,ctxArgs:r}=(await this.logCtx(o,"seedDocument",!0)).for(this.seedDocument);try{return await this.saveDocument(e,t,...r)}catch(t){if(t instanceof s.ForbiddenError)return n.warn(`Skipping boot seed of graph workflow '${e}': an existing row is owned by another user`),null;throw t}}async getDocument(e,...t){const{ctx:o,ctxArgs:n}=(await this.logCtx(t,"getDocument",!0)).for(this.getDocument);let r;try{r=await this.read(e,...n)}catch{r=null}if(!r)throw new a.NotFoundError(`No graph workflow found for workflowId '${e}'`);if(this.assertOwnership(e,r,er(o)),r.document)return or(r.document);throw new a.NotFoundError(`Graph workflow '${e}' has no canonical document; legacy definition/state snapshots are no longer supported (DECAF-50 \xa74.26 R2-2)`)}async listWorkflows(...e){const{ctx:t,ctxArgs:o}=(await this.logCtx(e,"listWorkflows",!0)).for(this.listWorkflows),n=await this.listBy("workflowId",s.OrderDirection.ASC,...o),r=er(t);return n.filter(e=>Bn(e,r,{allowAnonymousAccess:this.allowAnonymousAccess})).sort((e,t)=>nr(t.updatedAt)-nr(e.updatedAt))}async assertAccess(e,...t){const{ctx:o,ctxArgs:n}=(await this.logCtx(t,"assertAccess",!0)).for(this.assertAccess);let r;try{r=await this.read(e,...n)}catch{r=null}if(!r)throw new a.NotFoundError(`No graph workflow found for workflowId '${e}'`);return this.assertOwnership(e,r,er(o)),r}async validateDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateDocument",!0)).for(this.validateDocument);return await Un(e,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o)}async saveSnapshot(e,t,...o){const{ctx:n,ctxArgs:r}=(await this.logCtx(o,"saveSnapshot",!0)).for(this.saveSnapshot);if(!ae(t))throw new a.ValidationError("Workflow snapshot payload must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected");if(!tr(t))throw new a.ValidationError("Workflow snapshots must wrap a canonical GraphWorkflowDocument ({ document, editor?, metadata? }): legacy definition/state snapshots are no longer accepted; save canonical documents via PUT /graph/workflows/{workflowId}");const i=er(n),s=await this.readExistingForWrite(e,r);s&&this.assertWriteOwnership(e,s,i);const d=new Date;if(s)return s.snapshot=t,await this.applyCanonicalWrapper(s,t,n),s.updatedAt=d,this.update(s,...r);const l=new st({workflowId:e,snapshot:t,...i?{owner:i}:{},updatedAt:d});return await this.applyCanonicalWrapper(l,t,n),this.create(l,...r)}async loadSnapshot(e,...t){const{ctx:o,ctxArgs:n}=(await this.logCtx(t,"loadSnapshot",!0)).for(this.loadSnapshot);try{const t=await this.read(e,...n);return this.assertOwnership(e,t,er(o)),t}catch{return null}}async readExistingForWrite(e,t){try{return await this.read(e,...t)}catch(e){if(e instanceof a.NotFoundError)return null;throw e}}assertOwnership(e,t,o){Hn(t??null,o??null,{allowAnonymousAccess:this.allowAnonymousAccess,resourceKind:"Graph workflow",resourceId:e})}assertWriteOwnership(e,t,o){qn(t??null,o??null,{resourceKind:"Graph workflow",resourceId:e})}async applyCanonicalWrapper(e,t,o){if(!tr(t))return;if(t.document.id!==e.workflowId)throw new a.ValidationError(`Document id '${t.document.id}' does not match the workflow id '${e.workflowId}' from the request path`);const n=await Un(t.document,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o);if(!n.valid)throw new xt(n.issues);e.document=or(t.document),e.name=t.document.name}},e.GraphWorkflowService=i.__decorate([s.service(st),i.__metadata("design:paramtypes",[Function])],e.GraphWorkflowService),e.GraphRunModelService=class extends s.ModelService{constructor(){super(it)}async saveRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"saveRun",!0)).for(this.saveRun),n=Xn(e);let r;try{r=await super.read(e.runId,...o)}catch{r=null}if(r)return r.workflowId=n.workflowId,r.owner=n.owner,r.status=n.status,r.documentFingerprint=n.documentFingerprint,r.result=n.result,r.error=n.error,r.startedAt=n.startedAt,r.finishedAt=n.finishedAt,void await this.update(r,...o);await this.create(n,...o)}async readRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"readRun",!0)).for(this.readRun);try{return(e=>{const t=e.result;return{runId:e.runId,workflowId:e.workflowId,ownerUser:e.owner??null,status:(o=e.status,"string"==typeof o&&["queued","validating","running","succeeded","failed","cancelled"].includes(o)?e.status:"failed"),createdAt:e.createdAt.toISOString(),...e.startedAt?{startedAt:e.startedAt.toISOString()}:{},...e.finishedAt?{finishedAt:e.finishedAt.toISOString()}:{},...t?{result:t}:{},...e.error?{error:e.error}:{},...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{}};var o})(await super.read(e,...o))}catch{return null}}async listRuns(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"listRuns",!0)).for(this.listRuns);return await this.findBy("workflowId",e,...o)}},e.GraphRunModelService=i.__decorate([s.service(it),i.__metadata("design:paramtypes",[])],e.GraphRunModelService),e.GraphNodeModelService=class extends s.ModelService{constructor(){super(dt)}async upsertManifest(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"upsertManifest",!0)).for(this.upsertManifest),n=(e=>new dt({kind:e.kind,name:e.display?.name,category:e.display?.category,group:e.display?.group,description:e.display?.description,manifest:Me(Le(e))}))(e);let r;try{r=await this.read(n.kind,...o)}catch{r=void 0}return r?(r.name=n.name,r.category=n.category,r.group=n.group,r.description=n.description,r.manifest=n.manifest,await this.update(r,...o)):await this.create(n,...o)}async syncFromCatalogue(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"syncFromCatalogue",!0)).for(this.syncFromCatalogue),n=e.listManifests(void 0,...o),r=[];for(const e of n)r.push(await this.upsertManifest(e,...o));return r}async listNodes(...e){const{ctxArgs:t}=(await this.logCtx(e,"listNodes",!0)).for(this.listNodes);return await this.listBy("kind",s.OrderDirection.ASC,...t)}async listManifests(...e){return(await this.listNodes(...e)).map(e=>(e=>{if(!e.manifest)throw new a.ValidationError(`Graph node row '${e.kind}' has no manifest to convert`);return Me(Le(e.manifest))})(e))}async getNode(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"getNode",!0)).for(this.getNode);try{return await this.read(e,...o)}catch{throw new a.NotFoundError(`Graph node kind '${e}' is not registered`)}}},e.GraphNodeModelService=i.__decorate([s.service(dt),i.__metadata("design:paramtypes",[])],e.GraphNodeModelService),e.ConditionExpressionEvaluator=eo,e.DEFAULT_GRAPH_WORKFLOW_DOCUMENT_LIMITS=cn,e.DEFAULT_GRAPH_WORKFLOW_VALIDATION_LIMITS=Go,e.DEFAULT_PINNING_METADATA=Eo,e.GRAPH_AGENT_NODES=gn,e.GRAPH_BOUNDARY_NODES=Rn,e.GRAPH_BUILT_IN_NODE_CLASSES_BY_KIND=Pn,e.GRAPH_BUILT_IN_NODE_MANIFESTS=In,e.GRAPH_BUILT_IN_NODE_MANIFESTS_BY_KIND=On,e.GRAPH_CODE_DEFAULT_LANGUAGE=fn,e.GRAPH_CODE_DEFAULT_TIMEOUT_MS=1e3,e.GRAPH_CODE_LANGUAGES=hn,e.GRAPH_CODE_MAX_TIMEOUT_MS=mt,e.GRAPH_DEFAULT_CONCURRENCY=4,e.GRAPH_DEFAULT_MAX_FOREACH_ITERATIONS=1e3,e.GRAPH_DEFAULT_MAX_LOOP_ITERATIONS=100,e.GRAPH_DOCUMENT_FORBIDDEN_FIELD_KEYS=Lo,e.GRAPH_FLOW_CONTROL_NODES=xn,e.GRAPH_LOCAL_EXECUTION_BACKEND=ht,e.GRAPH_LOOP_KIND={FOREACH:"core.loop.foreach",WHILE:"core.loop.while",UNTIL:"core.loop.until"},e.GRAPH_LOOP_NODES=Dn,e.GRAPH_MAX_FOREACH_ITERATIONS=gt,e.GRAPH_MAX_LOOP_ITERATIONS=ft,e.GRAPH_PINNING_METADATA_KEY="graph.pinnable",e.GRAPH_PLAIN_SECRET_KEYS=go,e.GRAPH_TRIGGER_NODES=kn,e.GRAPH_UTILITY_NODES=Sn,e.GRAPH_WORKFLOW_BOUNDARY=pt,e.GRAPH_WORKFLOW_FORBIDDEN_FIELD_KEYS=$n,e.GraphAuthValidator=qt,e.GraphBreakSignal=Ot,e.GraphConditionEvaluator=wn,e.GraphConnectionPolicyValidator=Ro,e.GraphConnectionValidationError=To,e.GraphCredentialAuthorizationError=$o,e.GraphCredentialReferenceValidator=Po,e.GraphCycleError=bt,e.GraphDocumentValidationError=Co,e.GraphEdgeInstanceValidator=Do,e.GraphEngineEventSink=Yt,e.GraphEnvironment=un,e.GraphExecutionBackendRegistry=Zt,e.GraphExecutionContext=zt,e.GraphExecutionEngine=Bo,e.GraphExecutionError=_t,e.GraphExecutionEventEmitter=St,e.GraphExecutionEventFactory=Dt,e.GraphExecutionFrame=Xt,e.GraphExecutionSnapshotMapper=class{map(e){const t={};for(const[o,n]of Object.entries(e.nodeResults))t[o]={status:n.status,startedAt:n.startedAt?.toISOString(),finishedAt:n.finishedAt?.toISOString(),error:n.error,outputs:n.outputs,fromCache:n.fromCache,pinned:n.pinned};const o={};for(const t of e.events)t.edgeId&&"edge.valueRouted"===t.type&&(o[t.edgeId]={status:O.SUCCEEDED,lastValue:t.payload?.value,updatedAt:t.timestamp.toISOString()});const n=[...e.events];return{runId:e.runId,status:e.status,nodes:t,edges:o,outputs:e.outputs,events:n}}},e.GraphInputError=vt,e.GraphLoopExecutionContext=class{constructor(e,t){this.iteration=e,this.metadata=t}},e.GraphLoopLimitError=Nt,e.GraphNode=dn,e.GraphNodeInstanceValidator=xo,e.GraphNodeManifestResolver=tn,e.GraphNodeMethodNotFoundError=zo,e.GraphNodeMethodRegistry=Xo,e.GraphNodeNotFoundError=Ko,e.GraphNodeRegistrationError=Ho,e.GraphParameterValidator=mo,e.GraphPinningDependencyResolver=Oo,e.GraphPinningError=Et,e.GraphPinningPolicy=Ao,e.GraphPinningService=No,e.GraphPortError=class extends _t{constructor(e,t){super(e,"GRAPH_PORT_ERROR",t)}},e.GraphPortSchemaResolver=class{resolve(e){const t=this.createValidator(e);return{name:e.name,required:e.required,validate:t}}resolveAll(e){const t={};for(const o of e)t[o.name]=this.resolve(o);return t}createValidator(e){switch((e.type??e.designType??"").toLowerCase()){case"string":return e=>"string"==typeof e;case"number":return e=>"number"==typeof e;case"boolean":return e=>"boolean"==typeof e;case"date":return e=>e instanceof Date||"string"==typeof e&&!isNaN(Date.parse(e));case"array":return e=>Array.isArray(e);case"bigint":return e=>"bigint"==typeof e;default:return()=>!0}}},e.GraphRunCancelledError=kt,e.GraphRunEventPublisher=Yn,e.GraphRunExecutor=Qn,e.GraphRunService=class{constructor(e,t,o,n={}){this.activeByCaller=new Map,this.callerKeysByRun=new Map,this.releaseTimers=new Map,this.engine=e,this.runStore=t,this.eventStore=o,this.publisher=new Yn(o,n.limits),this.executor=new Qn(e,t,this.publisher,{onRunCompleted:n.onRunCompleted},n.limits),this.options={...n,limits:{...D,...n.limits}}}get limits(){return this.options.limits}async createRun(e,t,o,...n){this.validateCreateRequest(e);const r=e.workflowId??e.workflow?.id??"";if(!r)throw new a.ValidationError("Graph run request must carry a workflow document with an id or a saved workflowId");if(e.workflowId&&!this.options.documentResolver)throw new a.ValidationError("Graph run requests by workflowId require a document resolver");const i=o??t??"anonymous",s=this.activeByCaller.get(i)??new Set;if(s.size>=this.options.limits.maxConcurrentRuns)throw new a.ValidationError(`Graph run rejected: the configured limit of ${this.options.limits.maxConcurrentRuns} concurrent runs per caller is exhausted`);const d=this.generateRunId(),l={runId:d,workflowId:r,ownerUser:t,status:"queued",createdAt:(new Date).toISOString()};this.executor.begin(d),await this.runStore.saveRun({...l},...n);const c=this.documentProviderFor(e,t);return s.add(d),this.activeByCaller.set(i,s),this.callerKeysByRun.set(d,i),this.executor.schedule(l,c,e.inputs??{},...n).catch(()=>{}).finally(()=>this.finishActiveRun(d)),l}async getRun(e,t,...o){const n=await this.runStore.readRun(e,...o);if(!n)throw new a.NotFoundError(`No graph run found for runId '${e}'`);return this.assertOwnership(n,t),n}async listRunsByWorkflow(e,t,...o){return(await this.runStore.listRuns(e,...o)).filter(e=>Bn({owner:e.owner},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess})).sort((e,t)=>{const o=e.updatedAt instanceof Date?e.updatedAt.getTime():NaN,n=t.updatedAt instanceof Date?t.updatedAt.getTime():NaN;return(Number.isFinite(n)?n:0)-(Number.isFinite(o)?o:0)})}async cancelRun(e,t,...o){const n=await this.runStore.readRun(e,...o);if(!n)throw new a.NotFoundError(`No graph run found for runId '${e}'`);return this.assertWriteOwnership(n,t),"succeeded"===(r=n.status)||"failed"===r||"cancelled"===r||(this.executor.abort(e,"user"),n.status="cancelled",n.finishedAt=(new Date).toISOString(),await this.runStore.saveRun({...n},...o)),n;var r}async resumeRun(e,t,o,...n){const r=await this.runStore.readRun(e,...n);if(!r)throw new a.NotFoundError(`No graph run found for runId '${e}'`);this.assertWriteOwnership(r,o);const i=this.engine.backend,s=i.resume;if("function"!=typeof s)throw new _t(`Graph execution backend '${i.constructor?.name??"GraphExecutionBackend"}' does not support resume`,"GRAPH_RESUME_UNSUPPORTED_BACKEND",{runId:e});let d;try{d=await s.call(i,e,t,...n)}catch(e){throw(l=e)instanceof _t?new _t(l.message,l.graphCode):l}var l;const c={...d,runId:e,caller:o};return await this.publisher.publish({runId:e,workflowId:r.workflowId,type:S.WORKFLOW_RESUMED,payload:c}),c}async listEvents(e,t,o,...n){return await this.getRun(e,o,...n),this.eventStore.listAfter(e,t)}async subscribeEvents(e,t,o,...n){return await this.getRun(e,t,...n),this.eventStore.subscribe(e,o)}subscribeRunEvents(e,t){return this.eventStore.subscribe(e.runId,t)}async waitForRun(e,t,...o){const n=this.executor.waitFor(e);return n&&await n,this.getRun(e,t,...o)}async executeAndWait(e,t,o,...n){const r=await this.createRun(e,t,o,...n);return this.waitForRun(r.runId,t,...n)}release(e){this.finishActiveRun(e);const t=this.releaseTimers.get(e);t&&(clearTimeout(t),this.releaseTimers.delete(e)),this.executor.release(e),this.eventStore.release?.(e)}finishActiveRun(e){const t=this.callerKeysByRun.get(e);if(void 0!==t){this.callerKeysByRun.delete(e);const o=this.activeByCaller.get(t);o&&(o.delete(e),0===o.size&&this.activeByCaller.delete(t))}if(this.releaseTimers.has(e))return;const o=setTimeout(()=>{this.releaseTimers.delete(e),this.release(e)},this.options.limits.eventReplayWindowMs);o.unref?.(),this.releaseTimers.set(e,o)}validateCreateRequest(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new a.ValidationError("Graph run request must be an object carrying either a workflow document or a workflowId plus inputs");const t=void 0!==e.workflow,o=void 0!==e.workflowId;if(t&&o)throw new a.ValidationError("Graph run request is ambiguous: supply either an unsaved workflow document or a saved workflowId, not both");if(!t&&!o)throw new a.ValidationError("Graph run request must supply either an unsaved workflow document or a saved workflowId");if(t&&!Re(e.workflow))throw new a.ValidationError("Graph run request carries a payload that is not a canonical GraphWorkflowDocument");if(void 0!==e.inputs&&!ae(e.inputs))throw new a.ValidationError("Graph run inputs must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected");const n=(e=>{try{return JSON.stringify(e)?.length??0}catch{return Number.MAX_SAFE_INTEGER}})(e);if(n>this.options.limits.maxRequestBytes)throw new a.ValidationError(`Graph run request of ${n} bytes exceeds the configured limit of ${this.options.limits.maxRequestBytes} bytes`)}documentProviderFor(e,t){if(e.workflow){const t=e.workflow;return async()=>({document:t,fingerprint:zn(t)})}const o=e.workflowId;return async(...e)=>{const n=this.options.documentResolver;if(!n)throw new a.ValidationError("Graph run requests by workflowId require a document resolver");const r=await n.resolve(o,t,...e);return{document:r,fingerprint:zn(r)}}}assertOwnership(e,t){Hn({owner:e.ownerUser},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess,resourceKind:"Graph run",resourceId:e.runId})}assertWriteOwnership(e,t){qn({owner:e.ownerUser},t,{resourceKind:"Graph run",resourceId:e.runId})}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new It("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime",{runtime:typeof globalThis.crypto});return e.randomUUID()}},e.GraphStoreError=It,e.GraphTopology=vo,e.GraphTopologyError=At,e.GraphValueValidator=class{constructor(e){this.resolver=e}validateWorkflowInputs(e,t){this.validatePorts(e.inputs,t,"workflow input")}validateWorkflowOutputs(e,t){this.validatePorts(e.outputs,t,"workflow output")}validateNodeInputs(e,t){const o=(e.ports??[]).filter(e=>"input"===e.direction);this.validatePorts(o,t,`node '${e.name}' input`)}validateNodeOutputs(e,t){const o=(e.ports??[]).filter(e=>"output"===e.direction);this.validatePorts(o,t,`node '${e.name}' output`)}validatePorts(e,t,o){if(e)for(const n of e){const e=Object.prototype.hasOwnProperty.call(t,n.name);if(n.required&&!e)throw new vt(`Missing required ${o} port '${n.name}'`);if(e&&!this.resolver.resolve(n).validate(t[n.name]))throw new vt(`Invalid value for ${o} port '${n.name}'`)}}},e.GraphWorkflowDocumentRejectedError=xt,e.GraphWorkflowDocumentValidator=Vo,e.InMemoryGraphRunEventStore=class{constructor(e={}){this.events=new Map,this.listeners=new Map,this.limits={...D,...e}}async append(e){let t=this.events.get(e.runId);t||(t=[],this.events.set(e.runId,t)),t.push(e),this.enforceRetention(t);for(const t of this.listeners.get(e.runId)??[])try{t(e)}catch{}}async listAfter(e,t){const o=this.events.get(e);return o?o.filter(e=>e.sequence>t):[]}subscribe(e,t){let o=this.listeners.get(e);return o||(o=new Set,this.listeners.set(e,o)),o.add(t),()=>{o.delete(t),0===o.size&&this.listeners.delete(e)}}release(e){this.events.delete(e),this.listeners.delete(e)}enforceRetention(e){const t=this.limits.maxEventsPerRun;for(;e.length>t;){const t=e.findIndex(e=>!P(e.type));if(-1===t)break;e.splice(t,1)}}},e.InMemoryGraphRunStore=class{constructor(){this.runs=new Map}async saveRun(e){this.runs.set(e.runId,{...e})}async readRun(e){const t=this.runs.get(e);return t?{...t}:null}async listRuns(e){return[...this.runs.values()].filter(t=>t.workflowId===e).map(e=>Xn(e))}release(e){this.runs.delete(e)}},e.IsolatedVmCodeSandboxEvaluator=qo,e.LocalGraphExecutionBackend=ko,e.assertGraphResourceOwnership=Hn,e.assertGraphResourceWriteOwnership=qn,e.buildGraphExecutionResult=Jt,e.builtInGraphNodeRegistrations=Tn,e.canAccessGraphResource=Bn,e.canAccessGraphResourcePayload=Wn,e.checkGraphValueAgainstSchema=uo,e.clampGraphCodeTimeoutMs=pn,e.collectLooseNodeIssues=So,e.composeGraphNamespace=Pt,e.createGraphValueRepository=bo,e.declaredGraphNodeMethods=e=>e.methods??[],e.decomposeGraphNamespace=Rt,e.decomposeGraphNamespaces=Bt,e.defineGraphNode=an,e.detectGraphCodeModeSurfaces=co,e.evaluateCodeCondition=no,e.evaluateCondition=ao,e.evaluateConditionSync=ro,e.findMalformedGraphNamespaces=Lt,e.findUngrantedGraphNamespaces=Gt,e.graphAuthDataFromRecord=jt,e.graphAuthDataOf=Ut,e.graphDocumentHasCodeMode=e=>co(e).length>0,e.graphNamespaceCovers=$t,e.graphNamespacePartsOf=Tt,e.graphNodeConfig=sn,e.graphRolesFromNamespaces=Mt,e.graphRunDocumentFingerprint=zn,e.graphWorkflowOwnerOf=er,e.isCodeCondition=to,e.isConditionExpression=oo,e.isGraphCredentialReferenceLike=ho,e.isGraphNamespaceCacheEntryValid=Ct,e.isGraphResolvedWorkflow=Mo,e.isPinnable=Io,e.mergeGraphAuthData=Wt,e.registerBuiltInGraphNodes=(e,...t)=>{for(const o of Tn())e.register(o,{},...t);return e},e.resolveGraphBackendCapabilities=Qt,e.resolveGraphDynamicPorts=Zo,e.resolveGraphNodeManifest=en,e.serializeGraphValueKey=yo,e.stripFacadeOwnedBackendConfig=Uo,e.validateGraphWorkflowDocumentAtBoundary=Un},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decaf-ts/logging"),require("@decaf-ts/ui-decorators"),require("@decaf-ts/decoration"),require("@decaf-ts/decorator-validation"),require("@decaf-ts/db-decorators"),require("tslib"),require("@decaf-ts/core"),require("isolated-vm"),require("acorn"),require("acorn-walk"),require("typescript"),require("node:crypto")):"function"==typeof define&&define.amd?define(["exports","@decaf-ts/logging","@decaf-ts/ui-decorators","@decaf-ts/decoration","@decaf-ts/decorator-validation","@decaf-ts/db-decorators","tslib","@decaf-ts/core","isolated-vm","acorn","acorn-walk","typescript","node:crypto"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["as-graph"]={},e.decafTsLogging,e.decafTsUiDecorators,e.decafTsDecoration,e.decafTsDecoratorValidation,e.decafTsDbDecorators,e.tslib,e.decafTsCore,e.isolatedVm,e.acorn,e.acornWalk,e.typescript,e.node_crypto);
1
+ var e,t;e=this,t=function(e,t,o,a,r,n,i,d,s,l,c,p,u,g,h,m,f,_,y,b,w,N,v,A,x,I,E,S,R,T,C,O,k,D,P,G,M,F,L,j,q,H,U,B,$,W,V,K,z,Q,J,X,Y,Z,ee,te){"use strict";function oe(e){var t=Object.create(null);return e&&Object.keys(e).forEach(o=>{if("default"!==o){var a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,a.get?a:{enumerable:!0,get:()=>e[o]})}}),t.default=e,Object.freeze(t)}var ae,re,ne=oe(l),ie=oe(c),de=oe(p),se=oe(B);r.ValidationKeys.REQUIRED,r.ValidationKeys.MIN,r.ValidationKeys.MIN_LENGTH,r.ValidationKeys.MAX,r.ValidationKeys.MAX_LENGTH,r.ValidationKeys.PATTERN,r.ValidationKeys.URL,r.ValidationKeys.STEP,r.ValidationKeys.DATE,r.ValidationKeys.EMAIL,r.ValidationKeys.PASSWORD,r.ValidationKeys.EQUALS,r.ValidationKeys.DIFF,r.ValidationKeys.LESS_THAN,r.ValidationKeys.LESS_THAN_OR_EQUAL,r.ValidationKeys.GREATER_THAN,r.ValidationKeys.GREATER_THAN_OR_EQUAL,(e=>{e.GRAPH="graph",e.NODE="graph.node",e.EDGE="graph.edge",e.PORT="graph.port",e.STATE="graph.state"})(ae||(ae={})),(e=>{e.INPUT="input",e.OUTPUT="output",e.CONNECTION="connection"})(re||(re={}));const le={};function ce(e,t={}){let o=e.width??96,a=e.height??96;for(const r of e.sizeRules??[]){if("parameterCount"!==r.type)continue;const e=t[r.parameter]??0;e>0&&("width"===r.dimension?o+=e*r.perItem:a+=e*r.perItem)}return{width:o,height:a}}function pe(e,t){le[e]=t}function ue(e,t,o){const a=t?le[t]:void 0;return a?.color?a.color:e||"#64748b"}function ge(e,t,o){const a=t?le[t]:void 0;return a?.icon?a.icon:e||"ti-pointer"}const he=["skip","passThroughFirstInput","emitDefaults"];function me(e){return he.includes(e)}var fe,_e,ye,be;(e=>{e.PENDING="pending",e.PLANNING="planning",e.RUNNING="running",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped",e.CANCELLED="cancelled",e.CACHED="cached"})(fe||(fe={})),(e=>{e.IDLE="idle",e.RUNNING="running",e.BLOCKED="blocked",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped"})(_e||(_e={})),(e=>{e.NODE_ID="nodeId",e.WORKFLOW_ID="workflowId",e.RUN_ID="runId",e.USER="user",e.ROLES="roles",e.NAMESPACES="namespaces",e.ORGANIZATION="organization",e.IP="ip"})(ye||(ye={})),(e=>{e.WORKFLOW_STARTED="workflow.started",e.WORKFLOW_PLANNED="workflow.planned",e.WORKFLOW_COMPLETED="workflow.completed",e.WORKFLOW_FAILED="workflow.failed",e.WORKFLOW_CANCELLED="workflow.cancelled",e.WORKFLOW_SUSPENDED="workflow.suspended",e.WORKFLOW_RESUMED="workflow.resumed",e.NODE_QUEUED="node.queued",e.NODE_STARTED="node.started",e.NODE_OUTPUT="node.output",e.NODE_COMPLETED="node.completed",e.NODE_FAILED="node.failed",e.NODE_SKIPPED="node.skipped",e.NODE_CACHE_HIT="node.cacheHit",e.NODE_PINNED="node.pinned",e.NODE_UNPINNED="node.unpinned",e.NODE_STATE_CHANGED="node.stateChanged",e.EDGE_VALUE_ROUTED="edge.valueRouted",e.EDGE_STATE_CHANGED="edge.stateChanged",e.GRAPH_RUN_LOG="graph.run.log",e.LOOP_STARTED="loop.started",e.LOOP_ITERATION_STARTED="loop.iteration.started",e.LOOP_ITERATION_COMPLETED="loop.iteration.completed",e.LOOP_CONDITION_EVALUATED="loop.condition.evaluated",e.LOOP_COMPLETED="loop.completed",e.LOOP_LIMIT_REACHED="loop.limitReached",e.VALIDATION_STARTED="validation.started",e.VALIDATION_FAILED="validation.failed",e.VALIDATION_COMPLETED="validation.completed",e.STORE_READ="store.read",e.STORE_WRITE="store.write",e.STORE_DELETE="store.delete"})(be||(be={}));const we={maxRequestBytes:4e6,maxConcurrentRuns:32,maxEventsPerRun:1e4,maxEventPayloadBytes:256e3,executionTimeoutMs:6e5,eventReplayWindowMs:3e5},Ne=[be.WORKFLOW_COMPLETED,be.WORKFLOW_FAILED,be.WORKFLOW_CANCELLED];function ve(e){return Ne.includes(e)}function Ae(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function xe(e){if(!e||"object"!=typeof e)return;const t=e.auth;return t&&"object"==typeof t&&!Array.isArray(t)?(e=>{if(!e)return;const t=Ae(e.namespaces),o=Ae(e.roles);if(!t&&!o)return;const a={};return t&&(a.namespaces=t),o&&(a.roles=o),a})(t):void 0}function Ie(e){const t=a.Metadata.constr(e);if("function"==typeof t)return t;const o=e.constructor;return"function"==typeof o?o:e}function Ee(e){if(null!=e)return"string"==typeof e?e:e+""}function Se(e,t,o){return Ee(e?.props?.label??e?.props?.name)??Ee(t?.name)??o??""}function Re(e,t,o){const n=Oe(e,t);if(n?.model&&"function"==typeof n.model&&r.Model.isModel(n.model))return n.model;const i=a.Metadata.type(e,t);if("function"==typeof i&&r.Model.isModel(i))return i;const d=a.Metadata.getPropDesignTypes?.(e,t)?.designTypes||[];for(const e of d)if("function"==typeof e&&r.Model.isModel(e))return e;const s=o?.[r.ValidationKeys.TYPE]?.customTypes||[];for(const e of s)if("function"==typeof e&&r.Model.isModel(e))return e}function Te(e,t){const o=[t,e.path??e.property].filter(Boolean).join(".");return{...e,path:o,children:e.children?.map(e=>Te(e,o))}}function Ce(e){const t=Ie(e);return a.Metadata.get(t,ae.NODE)}function Oe(e,t){const o=Ie(e);return a.Metadata.get(o,a.Metadata.key(ae.PORT,t+""))}function ke(e,t,o,r=new Set){const n=Oe(e,t);if(!n?.schema)return;const i=Re(e,t,a.Metadata.validationFor(e,t));if(!i)return;if(r.has(i))return[];const d=new Set(r);return d.add(e),d.add(i),Ge(i,d).filter(e=>e.direction===o)}function De(e,t,o=new Set){const n=Oe(e,t);if(!n)return;const i=a.Metadata.validationFor(e,t),d=Re(e,t,i);if(n.schema&&d)return;const s=r.Model.uiElementOf(e,t)||void 0,l=r.Model.uiDecorationOf(e,t,"uiprop"),c=a.Metadata.type(e,t),p=Ee(n.type??i?.[r.ValidationKeys.TYPE]?.customTypes?.[0]?.name??s?.props?.type??l?.type??c?.name),u=(n.expand||d&&!o.has(d))&&d?(()=>{const a=new Set(o);return a.add(e),a.add(d),Ge(d,a).map(e=>Te(e,t))})():void 0;return{property:t,path:t,direction:n.direction,name:t,label:Se(s,l,t),type:p?.toLowerCase(),required:!!i?.[r.ValidationKeys.REQUIRED],hidden:!!r.Model.uiIsHidden(e,t),designType:c?.name,element:s,prop:l,validation:i,graph:n,connectionRules:n.connectionRules,composite:!!u?.length,children:u,model:d?.name}}function Pe(e){return Ge(Ie(e))}function Ge(e,t=new Set){const o=a.Metadata.properties(e)||[],r=[];for(const a of o){const o=a+"",n=Oe(e,o);if(n?.schema){const a=ke(e,o,n.direction,t);if(a){r.push(...a);continue}}const i=De(e,o,t);i&&r.push(i)}return r}function Me(e){return e.flatMap(e=>e.children&&e.children.length?Me(e.children):[e])}function Fe(e){const t=Ie(e),o=r.Model.uiModelOf(t),n=Ce(t)||{},i=o?.tag||t.name,d=Pe(t),s=((e,t)=>{const o=t.portGroups||[],r=new Map(o.map(e=>[e.property,e])),n=[],i=a.Metadata.properties(e)||[];for(const t of i){const o=t+"",i=Oe(e,o);if(!i?.schema)continue;if(!Re(e,o,a.Metadata.validationFor(e,o)))continue;const d=r.get(o);n.push(d?{...d,toggle:d.toggle??"all"}:{property:o,toggle:"all"})}for(const e of o)n.some(t=>t.property===e.property)||n.push(e);return n.length?n:void 0})(t,n),l=n.namespaces?.length?n.namespaces:(e=>{if(null==e)return[];let t,o=e;try{o=a.Metadata.constr(e)}catch{o=e}try{t=a.Metadata.get(o,"auth-namespace")}catch{t=void 0}return Ae(t)??[]})(t),c=l.length?l:void 0;return{name:t.name,tag:i,kind:n.kind||i,category:n.category,color:n.color,effectiveColor:ue(n.color,n.category),group:n.group,height:n.height,icon:n.icon,effectiveIcon:ge(n.icon,n.category),labels:n.labels||[],maxChildren:n.maxChildren,minWidth:n.minWidth,width:n.width,shape:n.shape,cornerRadius:n.cornerRadius,sizeRules:n.sizeRules,props:o?.props,ui:o,graph:n,ports:d,portGroups:s,namespaces:c}}const Le=new Set,je=new Set;function qe(e,t,r){return a.Decoration.for(ae.NODE).define({decorator:(e,t,r)=>{const n={kind:t?.kind||e,...t};return t=>{const i=a.apply(o.uimodel(e,r),a.metadata(ae.NODE,n))(t);var d;return d=t,Le.add(d),i}},args:[e,t,r]}).apply()}function He(e,t){return a.Decoration.for(ae.PORT).define({decorator:(e,t)=>(o,r)=>{const n={direction:e,...t};return a.apply(a.propMetadata(a.Metadata.key(ae.PORT,r),n))(o,r)},args:[e,t]}).apply()}function Ue(e){return He(re.INPUT,{...e,schema:!0})}function Be(e){return He(re.OUTPUT,{...e,schema:!0})}function $e(e){return He(re.CONNECTION,e)}o.RenderingEngine.prototype.renderAsNode=(e,t,...o)=>Fe(e),a.Metadata.nodes=(()=>[...Le]).bind(a.Metadata),a.Metadata.workflows=(()=>[...je]).bind(a.Metadata);const We=["__proto__","prototype","constructor"];function Ve(e){return We.includes(e)}function Ke(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ze(e){return null===e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e}function Qe(e){return!!ze(e)||(Array.isArray(e)?e.every(e=>Qe(e)):!!Ke(e)&&Reflect.ownKeys(e).every(t=>"string"==typeof t&&!Ve(t)&&Qe(e[t])))}function Je(e){if(void 0===e)return!1;if("number"==typeof e)return Number.isFinite(e);if("function"==typeof e)return!1;if(Qe(e))return!0;if(Array.isArray(e))return e.every(e=>Je(e));if(Ke(e)){const t=Reflect.ownKeys(e);for(const o of t){if("string"!=typeof o)return!1;if(Ve(o))return!1;if(!Je(e[o]))return!1}return!0}return!1}function Xe(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>Xe(e));const t={};for(const[o,a]of Object.entries(e))t[o]=Xe(a);return t}const Ye={string:"string",char:"string",text:"string",textarea:"string",radio:"string",select:"string",number:"number",integer:"number",float:"number",double:"number",decimal:"number",boolean:"boolean",bool:"boolean",checkbox:"boolean",array:"array",list:"array",set:"array",object:"object",model:"model",any:"any",unknown:"any",enum:"enum"},Ze={date:"date",datetime:"date-time","date-time":"date-time",duration:"duration"},et={string:"string",number:"number",boolean:"boolean",array:"array",object:"object",date:"date"};function tt(e){return e?Ye[e.toLowerCase()]??"any":"any"}function ot(e){if(e)return Ze[e.toLowerCase()]}function at(e,t){const o=e[t];if(o&&"object"==typeof o)return o.value}function rt(e,t){const o=at(e,t);return"number"==typeof o&&Number.isFinite(o)?o:void 0}function nt(e,t,o){const a=e??{},n=(e=>{const t=at(e,r.ValidationKeys.ENUM);if(Array.isArray(t)&&t.every(ze))return t})(a);if(n)return{type:"enum",values:n};const i=(e=>{const t=e[r.ValidationKeys.TYPE],o=t?.customTypes?.[0],a="function"==typeof o?o.name:o?.name;if(a)return a})(a);if(i){const e=et[i.toLowerCase()];if(!e)return{type:"model",name:i};const t=ot(e);return void 0!==t?{type:"string",format:t}:it(e,a)}return o?{type:"model",name:o}:it(t,a)}function it(e,t){switch(tt(e)){case"string":{const t=ot(e);return void 0!==t?{type:"string",format:t}:{type:"string"}}case"number":{const o={type:"number"};e&&"integer"===e.toLowerCase()&&(o.integer=!0);const a=rt(t,r.ValidationKeys.MIN),n=rt(t,r.ValidationKeys.MAX);return void 0!==a&&(o.min=a),void 0!==n&&(o.max=n),o}case"boolean":return{type:"boolean"};case"array":return((e,t)=>{const o={type:"array",items:dt(e,t)},a=rt(e,r.ValidationKeys.MIN),n=rt(e,r.ValidationKeys.MAX);return void 0!==a&&(o.minItems=a),void 0!==n&&(o.maxItems=n),o})(t,e);case"object":return{type:"object",properties:{}};case"enum":return{type:"enum",values:[]};case"model":return{type:"model",name:e??"any"};default:return{type:"any"}}}function dt(e,t){if((e=>{const t=e[r.ValidationKeys.LIST];return!!t?.clazz?.length})(e))return{type:"model",name:st(e)};const o=at(e,r.ValidationKeys.TYPE);if("string"==typeof o){const e=tt(o);return"model"===e?{type:"model",name:o}:{type:e}}if(t&&"array"!==t){const e=tt(t);return"model"===e?{type:"model",name:t}:{type:e}}return{type:"any"}}function st(e){const t=e[r.ValidationKeys.LIST],o=t?.clazz?.[0];if("function"!=typeof o)return"any";if(o.name)return o.name;try{const e=o();if("function"==typeof e&&e.name)return e.name}catch{return"any"}return"any"}function lt(e){return"workflow"===e.scope}function ct(e){return"node"===e.scope}function pt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"workflow"===t.scope?"string"==typeof t.port&&2===Reflect.ownKeys(t).length:"node"===t.scope&&"string"==typeof t.nodeId&&"string"==typeof t.port&&3===Reflect.ownKeys(t).length}function ut(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e.mode;if("edge"===t)return 1===Reflect.ownKeys(e).length;if("literal"===t){const t=e.value;return 2===Object.keys(e).length&&Qe(t)}return"expression"===t&&2===Object.keys(e).length&&"string"==typeof e.expression}const gt=["any","string","number","boolean","array","object","enum","model"];function ht(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(e=>gt.includes(e))(e.type)}function mt(e,t={seen:[]}){if(t.seen.includes(e))throw new n.ValidationError(`Document '${(e=>{const t=e?.id;return"string"==typeof t?t:"<unnamed document>"})(e)}' contains a loop body that references itself (cyclic document)`);if("string"!=typeof e.id||!e.id)throw new n.ValidationError("Document 'id' is required and must be a non-empty string");if("string"!=typeof e.name||!e.name)throw new n.ValidationError("Document 'name' is required and must be a non-empty string");const o=new Set;for(const t of[...e.inputs,...e.outputs]){if("string"!=typeof t.id||!t.id)throw new n.ValidationError("Workflow port 'id' is required and must be a non-empty string");if(o.has(t.id))throw new n.ValidationError(`Workflow port '${t.id}' is declared more than once; workflow port ids must be unique`);if(void 0!==t.schema&&!ht(t.schema))throw new n.ValidationError(`Workflow port '${t.id}' schema must be a valid GraphValueSchema`);o.add(t.id)}const a={seen:[...t.seen,e]},r=new Set;for(const t of e.nodes)ft(t,r);for(const t of e.nodes)t.loop&&_t(t,t.loop,a),t.errorBoundary&&yt(t,t.errorBoundary,a);const i=new Set;for(const t of e.edges)wt(t,i);for(const t of e.edges)Nt(t.source,0,o,r,`Edge '${t.id}' source`),Nt(t.target,0,o,r,`Edge '${t.id}' target`);if(void 0!==e.settings&&!Je(e.settings))throw new n.ValidationError("Document settings must be JSON-safe (a map of JSON-safe values)");if(void 0!==e.metadata&&!Je(e.metadata))throw new n.ValidationError("Document metadata must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed");if(void 0!==e.ui&&!Je(e.ui))throw new n.ValidationError("Document ui must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed")}function ft(e,t){if("string"!=typeof e.id||!e.id)throw new n.ValidationError("Node 'id' is required and must be a non-empty string");if(t.has(e.id))throw new n.ValidationError(`Node id '${e.id}' is declared more than once; node ids must be unique`);if("string"!=typeof e.kind||!e.kind)throw new n.ValidationError(`Node '${e.id}' must declare a non-empty string 'kind'`);if(void 0===e.parameters||null===e.parameters)throw new n.ValidationError(`Node '${e.id}' parameters must be present (an empty object when there are none)`);if(t.add(e.id),e.inputBindings)for(const[t,o]of Object.entries(e.inputBindings)){if(Ve(t))throw new n.ValidationError(`Node '${e.id}' input binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!ut(o))throw new n.ValidationError(`Node '${e.id}' input binding for '${t}' must be a valid GraphInputBinding (edge, literal, or expression)`);if("literal"===o.mode&&!Je(o.value))throw new n.ValidationError(`Node '${e.id}' literal binding for '${t}' must contain JSON-safe values`);if("expression"===o.mode&&!o.expression)throw new n.ValidationError(`Node '${e.id}' expression binding for '${t}' must contain a non-empty expression`)}if(e.outputBindings)for(const[t,o]of Object.entries(e.outputBindings)){if(Ve(t))throw new n.ValidationError(`Node '${e.id}' output binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!o||"object"!=typeof o||Array.isArray(o))throw new n.ValidationError(`Node '${e.id}' output binding for '${t}' must be an object with enabled and alias settings`)}if(!Je(e.parameters))throw new n.ValidationError(`Node '${e.id}' parameters must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`);if(void 0!==e.state){if(!e.state||"object"!=typeof e.state||Array.isArray(e.state))throw new n.ValidationError(`Node '${e.id}' state must be an object when present`);if(!Je(e.state))throw new n.ValidationError(`Node '${e.id}' state must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}}function _t(e,t,o){if(!t.body||"object"!=typeof t.body)throw new n.ValidationError(`Node '${e.id}' loop configuration requires a body document`);if(mt(t.body,o),!(void 0===t.maxIterations||Number.isFinite(t.maxIterations)&&t.maxIterations>0))throw new n.ValidationError(`Node '${e.id}' loop maxIterations must be a positive number`);if(void 0!==t.timeoutMs&&("number"!=typeof t.timeoutMs||0>=t.timeoutMs))throw new n.ValidationError(`Node '${e.id}' loop timeoutMs must be a positive number in milliseconds`);if(void 0!==t.concurrency&&("number"!=typeof t.concurrency||0>=t.concurrency))throw new n.ValidationError(`Node '${e.id}' loop concurrency must be a positive number`);for(const o of[t.inputMappings,t.outputMappings])if(o)for(const[t,a]of Object.entries(o)){if(Ve(t))throw new n.ValidationError(`Node '${e.id}' loop mapping key '${t}' is not allowed (unsafe prototype-pollutant key)`);bt(a,e.id,t)}}function yt(e,t,o){if(!t.try||"object"!=typeof t.try)throw new n.ValidationError(`Node '${e.id}' error-boundary configuration requires a try body document`);mt(t.try,o);for(const[a,r]of[["catch",t.catch],["finally",t.finally]])if(void 0!==r){if(!r||"object"!=typeof r)throw new n.ValidationError(`Node '${e.id}' error-boundary ${a} body must be a document`);mt(r,o)}}function bt(e,t,o){if(!e||"object"!=typeof e)throw new n.ValidationError(`Node '${t}' loop mapping '${o}' must reference a workflow port, node port, literal, or expression`);switch(e.source){case"workflow":if("string"!=typeof e.port||!e.port)throw new n.ValidationError(`Node '${t}' loop mapping '${o}' referencing a workflow must reference a port identifier`);break;case"node":if("string"!=typeof e.nodeId||!e.nodeId||"string"!=typeof e.port||!e.port)throw new n.ValidationError(`Node '${t}' loop mapping '${o}' referencing a node must reference a node id and a port`);break;case"literal":if(!Je(e.value))throw new n.ValidationError(`Node '${t}' loop mapping '${o}' literal references must be JSON-safe values`);break;case"expression":if("string"!=typeof e.expression||!e.expression)throw new n.ValidationError(`Node '${t}' loop mapping '${o}' expression references must be non-empty expressions`);break;default:throw new n.ValidationError(`Node '${t}' loop mapping '${o}' must use a workflow, node, literal, or expression reference source`)}}function wt(e,t){if("string"!=typeof e.id||!e.id)throw new n.ValidationError("Edge 'id' is required and must be a non-empty string");if(t.has(e.id))throw new n.ValidationError(`Edge id '${e.id}' is declared more than once; edge ids must be unique`);if(!pt(e.source))throw new n.ValidationError(`Edge '${e.id}' source endpoint is not a valid GraphEndpoint`);if(!pt(e.target))throw new n.ValidationError(`Edge '${e.id}' target endpoint is not a valid GraphEndpoint`);if("data"!==e.type&&"connection"!==e.type)throw new n.ValidationError(`Edge '${e.id}' type '${e.type+""}' is not a valid edge type (data or connection are allowed)`);if(t.add(e.id),!Je(e))throw new n.ValidationError(`Edge '${e.id}' contains values that are not JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}function Nt(e,t,o,a,r){if(lt(e)){if(!o.has(e.port))throw new n.ValidationError(`${r} references workflow port '${e.port}' which is not declared on the document`)}else if(ct(e)){if(!a.has(e.nodeId))throw new n.ValidationError(`${r} references node '${e.nodeId}' which is not part of the document`);if("string"!=typeof e.port||!e.port)throw new n.ValidationError(r+" node endpoints must reference a non-empty port identifier")}}const vt=["expression","template"],At=["javascript","typescript","json","text"];function xt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return!(!(e=>vt.includes(e))(t.mode)||"string"!=typeof t.expression||!t.expression||void 0!==t.language&&!(e=>At.includes(e))(t.language)||void 0!==t.metadata&&!Qe(t.metadata))}function It(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.name&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}function Et(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.type&&(void 0===t.required||"boolean"==typeof t.required)&&(void 0===t.displayName||"string"==typeof t.displayName)&&(void 0===t.allowedOperations||Array.isArray(t.allowedOperations)&&t.allowedOperations.every(e=>"string"==typeof e))}const St=["trigger","loop","branching","stateful","retryable","cancellable","parallel","resource"];function Rt(e){return St.includes(e)}function Tt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.kind&&"object"==typeof t.display&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.parameters)}function Ct(e){if(!Tt(e))throw new n.ValidationError("Graph node manifest does not conform to the required shape");if(!Je(e))throw new n.ValidationError("Graph node manifest contains values that are not JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys or unsafe prototype keys are not allowed on manifests")}function Ot(e){return Ct(e),Xe(e)}function kt(e){if(!Tt(e))throw new n.ValidationError("Serialized graph node manifest does not conform to the required shape");return Xe(e)}const Dt=["loadOptions","listSearch","resourceLocator","resourceMapping","validateParameter","action"];function Pt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.name&&(e=>Dt.includes(e))(t.type)&&(void 0===t.parameter||"string"==typeof t.parameter)&&(void 0===t.dependencies||Array.isArray(t.dependencies)&&t.dependencies.every(e=>"string"==typeof e))}function Gt(e){const t=e.element?.props?.value,o=t??e.prop?.value??e.validation?.defaultValue;if(void 0!==o&&"function"!=typeof o&&Je(o))try{return JSON.parse(JSON.stringify(o))}catch{return}}function Mt(e){if(e.type&&e.type in Ze)return{type:"string",format:Ze[e.type]};const t=(e=>{for(const t of[e.graph?.type,e.element?.props?.type,e.prop?.type])if("string"==typeof t&&"any"!==tt(t))return t})(e);return t?nt((e=>{if(!e)return;const t=Object.entries(e).filter(([e])=>e!==r.ValidationKeys.TYPE);return Object.fromEntries(t)})(e.validation),t):nt(e.validation,e.type,e.model)}function Ft(e){const t={};for(const[o,a]of Object.entries(e.graph?.metadata??{}))Je(a)&&(t[o]=JSON.parse(JSON.stringify(a)));return Object.keys(t).length?t:void 0}function Lt(e){switch(e){case"output":return"output";case"connection":return"connection";default:return"input"}}function jt(e){const t=e.graph?.handle;return"connection"!==e.direction&&"string"==typeof t&&t?t:e.path??e.property}const qt=["top","bottom","left","right"],Ht=["start","center","end"];function Ut(e,t){const o={id:jt(e),label:e.label,direction:Lt(e.direction),schema:Mt(e)};e.required&&(o.required=!0),e.hidden&&(o.hidden=!0);const a=e.graph?.category;"string"==typeof a&&(o.category=a);const r=(e=>{const t=e.graph?.zone;if(!t||"object"!=typeof t||Array.isArray(t))return;const o=t,a=o.side;if("string"!=typeof a||!qt.includes(a))return;const r={side:a},n=o.align;"string"==typeof n&&Ht.includes(n)&&(r.align=n);const i=o.order;return"number"==typeof i&&Number.isFinite(i)&&(r.order=i),r})(e);r&&(o.zone=r),!0===e.graph?.userControlled&&(o.configurable=!0);const n=e.graph?.handle;"string"==typeof n&&(o.handle=n);const i=Yt(e.graph?.connectionRules)??t;i&&(o.connectionPolicy=i);const d=(e=>{const t=e.element;if(!t||!Je(t))return;const o=t.tag;if("string"!=typeof o)return;const a=t.props;return{tag:o,serialize:!0===t.serialize,props:a&&"object"==typeof a&&!Array.isArray(a)?Xe(a):{}}})(e);d&&(o.element=d);const s=Ft(e);return s&&(o.metadata=s),o}function Bt(e){const t={type:"string",id:jt(e),label:e.label,required:e.required};if(e.hidden)return((e,t)=>{const o={...t,type:"hidden"},a=Gt(e);return void 0!==a&&(o.defaultValue=a),$t(o)})(e,t);const o=Gt(e);void 0!==o&&(t.defaultValue=o);const a=(e=>{const t=e.element?.props?.placeholder??e.prop?.placeholder;return"string"==typeof t?t:void 0})(e);a&&(t.placeholder=a);const r=Ft(e);if(r&&(t.metadata=r),(e=>{const t=Kt(e);return"code"===t||"code-editor"===t})(e))return $t({...t,type:"code",language:Jt(e)});const n=Mt(e);switch(n.type){case"number":{const o={...t,type:"number",integer:n.integer,min:n.min,max:n.max},a=Vt(e.validation?.step);return void 0!==a&&(o.step=a),$t(o)}case"boolean":return $t({...t,type:"boolean"});case"enum":return $t({...t,type:"options",options:n.values.map(e=>({value:e,label:e+""}))});case"array":{const e={...t,type:"collection"};return void 0!==n.maxItems&&(e.maxItems=n.maxItems),$t(e)}case"object":case"model":return $t({...t,type:"object"});default:return $t({...t,type:"string",multiline:!!zt(e)||void 0,pattern:Wt(e.validation?.pattern),minLength:Vt(e.validation?.minlength),maxLength:Vt(e.validation?.maxlength)})}}function $t(e){const t=e;for(const e of Object.keys(t))void 0===t[e]&&delete t[e];return e}function Wt(e){const t=e?.value;return"string"==typeof t?t:void 0}function Vt(e){const t=e?.value;return"number"==typeof t&&Number.isFinite(t)?t:void 0}function Kt(e){const t=e.element?.tag;return"string"==typeof t&&t?t:void 0}function zt(e){return"textarea"===Kt(e)||"textarea"===(e=>{const t=e.element?.props?.type;return"string"==typeof t?t:void 0})(e)}const Qt=["javascript","typescript","json","text"];function Jt(e){const t=e.element?.props?.language;return"string"==typeof t&&Qt.includes(t)?t:"javascript"}function Xt(e,t){const o={name:t.name??e.name},a=e.graph?.metadata?.description??void 0;"string"==typeof a&&a&&(o.description=a);const r=t.category??e.category;"string"==typeof r&&r&&(o.category=r),"string"==typeof e.group&&e.group&&(o.group=e.group),Array.isArray(e.labels)&&(o.labels=e.labels.slice());const n=((e,t)=>{if(t.icon)return t.icon;const o=e.effectiveIcon??e.icon;return"string"==typeof o?{type:"catalogue",name:o}:{type:"catalogue",name:"ph:circuitry"}})(e,t);return n&&(o.icon=n),"string"==typeof e.color&&e.color&&(o.color=e.color),"number"==typeof e.width&&Number.isFinite(e.width)&&(o.width=e.width),"number"==typeof e.minWidth&&Number.isFinite(e.minWidth)&&(o.minWidth=e.minWidth),"number"==typeof e.height&&Number.isFinite(e.height)&&(o.height=e.height),"string"==typeof e.shape&&(o.shape=e.shape),"number"==typeof e.cornerRadius&&Number.isFinite(e.cornerRadius)&&(o.cornerRadius=e.cornerRadius),Array.isArray(e.sizeRules)&&(o.sizeRules=e.sizeRules),o}function Yt(e){if(!e)return;const t=e,o={};"boolean"==typeof t.allowSelf&&(o.allowSelf=t.allowSelf),"boolean"==typeof t.allowMultiple&&(o.allowMultiple=t.allowMultiple);const a=t.allowedKinds;Array.isArray(a)&&a.every(e=>"string"==typeof e)&&(o.allowedNodeKinds=a);const r=t.blockedKinds;Array.isArray(r)&&r.every(e=>"string"==typeof e)&&(o.blockedNodeKinds=r);const n=t.allowedPortCategories;Array.isArray(n)&&n.every(e=>"string"==typeof e)&&(o.allowedPortCategories=n);const i=t.maxConnections;return"number"==typeof i&&Number.isFinite(i)&&(o.maxConnections=i),Object.keys(o).length?o:void 0}function Zt(e,t={}){const o="function"==typeof e?e:e.constructor;if(!Ce(o))throw new n.ValidationError(`Node '${o?.name??e+""}' is not decorated with @node and cannot produce a manifest`);const a=Fe(o),r=Me(Pe(o)),i=[],d=[],s=[],l=[],c=Yt(a.graph?.connectionRules);for(const e of r)("connection"===e.direction?s:"output"===e.direction?d:i).push(Ut(e,c)),"input"===e.direction&&l.push(Bt(e));const p={kind:t.kind??a.kind??a.name,display:Xt(a,t),inputs:i,outputs:d,parameters:l};return s.length&&(p.connections=s),a.namespaces?.length&&(p.namespaces=a.namespaces.slice()),Ct(p),p}var eo,to;(e=>{e.READABILITY="readability",e.COMPACTNESS="compactness",e.BALANCED="balanced"})(eo||(eo={})),(e=>{e.TIGHT="tight",e.NORMAL="normal",e.COMFORTABLE="comfortable"})(to||(to={})),to.TIGHT,to.NORMAL,to.COMFORTABLE,eo.READABILITY,to.COMFORTABLE,eo.COMPACTNESS,to.TIGHT,eo.BALANCED,to.NORMAL;let oo=class extends d.BaseModel{constructor(e){super(e)}};i.__decorate([d.pk({type:String,generated:!1}),a.description("Unique graph run id"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.id.label",readonly:!0}),i.__metadata("design:type",String)],oo.prototype,"runId",void 0),i.__decorate([d.column(),r.required(),d.index(),a.description("Workflow document id the run executes"),o.uilistprop("workflowId"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.workflowId.label"}),i.__metadata("design:type",String)],oo.prototype,"workflowId",void 0),i.__decorate([d.column(),a.description("Owning user; absent for anonymous callers"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.owner.label"}),i.__metadata("design:type",String)],oo.prototype,"owner",void 0),i.__decorate([d.column(),r.required(),r.type(String),d.index(),a.description("Current run lifecycle status"),o.uilistprop("status"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.status.label",readonly:!0}),i.__metadata("design:type",String)],oo.prototype,"status",void 0),i.__decorate([d.column(),a.description("Fingerprint of the executed document"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.fingerprint.label",readonly:!0}),i.__metadata("design:type",String)],oo.prototype,"documentFingerprint",void 0),i.__decorate([d.column(),a.prop(),a.description("Workflow input values keyed by input port id"),i.__metadata("design:type",Object)],oo.prototype,"inputs",void 0),i.__decorate([d.column(),a.prop(),a.description("Execution result, present on successful completion"),i.__metadata("design:type",Object)],oo.prototype,"result",void 0),i.__decorate([d.column(),a.prop(),a.description("Structured error payload, present on failure"),i.__metadata("design:type",Object)],oo.prototype,"error",void 0),i.__decorate([r.date(),d.column(),a.description("Run creation timestamp"),i.__metadata("design:type",Date)],oo.prototype,"createdAt",void 0),i.__decorate([r.date(),d.column(),a.description("Execution start timestamp, once it has started"),i.__metadata("design:type",Date)],oo.prototype,"startedAt",void 0),i.__decorate([r.date(),d.column(),a.description("Terminal-state timestamp, once the run has finished"),i.__metadata("design:type",Date)],oo.prototype,"finishedAt",void 0),oo=i.__decorate([o.uilistmodel("ngx-decaf-list-item",{icon:"ti-player-play"}),o.uimodel("ngx-decaf-crud-form"),a.description("Persistable graph run lifecycle record"),d.table("graph_run"),r.model(),i.__metadata("design:paramtypes",[Object])],oo);let ao=class extends d.BaseModel{constructor(e){super(e)}};i.__decorate([d.pk({type:String,generated:!1}),i.__metadata("design:type",String)],ao.prototype,"workflowId",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],ao.prototype,"name",void 0),i.__decorate([d.column(),i.__metadata("design:type",Object)],ao.prototype,"document",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],ao.prototype,"owner",void 0),i.__decorate([d.column(),i.__metadata("design:type",Object)],ao.prototype,"snapshot",void 0),i.__decorate([d.noValidateOnUpdate(),i.__metadata("design:type",Date)],ao.prototype,"createdAt",void 0),ao=i.__decorate([d.table("graph_workflow"),r.model(),i.__metadata("design:paramtypes",[Object])],ao);let ro=class extends d.BaseModel{constructor(e){super(e)}};i.__decorate([d.pk({type:String,generated:!1}),i.__metadata("design:type",String)],ro.prototype,"kind",void 0),i.__decorate([d.column(),d.index(),i.__metadata("design:type",String)],ro.prototype,"name",void 0),i.__decorate([d.column(),d.index(),i.__metadata("design:type",String)],ro.prototype,"category",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],ro.prototype,"group",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],ro.prototype,"description",void 0),i.__decorate([d.column(),i.__metadata("design:type",Object)],ro.prototype,"manifest",void 0),i.__decorate([d.noValidateOnUpdate(),i.__metadata("design:type",Date)],ro.prototype,"createdAt",void 0),ro=i.__decorate([d.table("graph_node"),r.model(),i.__metadata("design:paramtypes",[Object])],ro),pe("Trigger",{color:"#3b82f6",icon:"ti-bolt"}),pe("Flow Control",{color:"#f59e0b",icon:"ti-arrows-split-2"}),pe("Utility",{color:"#0d9488",icon:"ti-tool"}),pe("Loop",{color:"#eab308",icon:"ti-repeat"}),pe("Workflow",{color:"#f97316",icon:"ti-sitemap"}),pe("Pipeline",{color:"#0ea5e9",icon:"ti-git-merge"}),pe("Node",{color:"#8b5cf6",icon:"ti-point-filled"}),pe("Agent",{color:"#7c3aed",icon:"ti-robot"}),pe("Data",{color:"#8b5cf6",icon:"ti-table"}),pe("IO",{color:"#0ea5e9",icon:"ti-world-www"}),pe("Storage",{color:"#0f766e",icon:"ti-database"}),pe("DevOps",{color:"#475569",icon:"ti-terminal-2"}),pe("Comms",{color:"#d946ef",icon:"ti-message-circle"}),pe("model",{color:"#3b82f6",icon:"ti-cpu"}),pe("memory",{color:"#10b981",icon:"ti-database"}),pe("workspace",{color:"#f59e0b",icon:"ti-folder"}),pe("tools",{color:"#0ea5e9",icon:"ti-tools"}),pe("hooks",{color:"#f97316",icon:"ti-webhook"}),pe("skill",{color:"#8b5cf6",icon:"ti-bulb"}),pe("sandbox",{color:"#14b8a6",icon:"ti-box"}),pe("scorers",{color:"#ec4899",icon:"ti-star"}),pe("embedding",{color:"#6366f1",icon:"ti-vector"});const no=new Set;function io(e,t){return e.config[t]}function so(e){return Array.isArray(e)?e.map(e=>e+"").join(", "):e+""}(()=>{const e=[{key:ye.NODE_ID,shouldInclude:e=>null!=io(e,ye.NODE_ID),render:e=>io(e,ye.NODE_ID)+""},{key:ye.WORKFLOW_ID,shouldInclude:e=>null!=io(e,ye.WORKFLOW_ID),render:e=>io(e,ye.WORKFLOW_ID)+""},{key:ye.RUN_ID,shouldInclude:e=>null!=io(e,ye.RUN_ID),render:e=>io(e,ye.RUN_ID)+""},{key:ye.USER,shouldInclude:e=>null!=io(e,ye.USER),render:e=>io(e,ye.USER)+""},{key:ye.ROLES,shouldInclude(e){const t=io(e,ye.ROLES);return Array.isArray(t)&&t.length>0},render:e=>so(io(e,ye.ROLES))},{key:ye.NAMESPACES,shouldInclude(e){const t=io(e,ye.NAMESPACES);return Array.isArray(t)&&t.length>0},render:e=>so(io(e,ye.NAMESPACES))},{key:ye.ORGANIZATION,shouldInclude:e=>null!=io(e,ye.ORGANIZATION),render:e=>io(e,ye.ORGANIZATION)+""},{key:ye.IP,shouldInclude:e=>null!=io(e,ye.IP),render:e=>io(e,ye.IP)+""}];for(const o of e)no.has(o.key)||(t.logParameterRegistry.register(o),no.add(o.key))})();const lo="$workflow",co="local",po="GRAPH_LOCAL_UNSUPPORTED_NODE_KIND",uo=1e3,go=1e4,ho=3e4,mo=3e5,fo=10485760,_o=1048576,yo=1e4,bo=1048576,wo=1e4;var No,vo;e.GraphPinningStrategy=void 0,(No=e.GraphPinningStrategy||(e.GraphPinningStrategy={})).MANUAL="manual",No.AUTOMATIC="automatic",No.DISABLED="disabled",e.GraphConditionType=void 0,(vo=e.GraphConditionType||(e.GraphConditionType={})).TRUTHY="truthy",vo.FALSY="falsy",vo.EQUALS="equals",vo.NOT_EQUALS="notEquals",vo.GREATER_THAN="greaterThan",vo.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",vo.LESS_THAN="lessThan",vo.LESS_THAN_OR_EQUAL="lessThanOrEqual",vo.EXISTS="exists",vo.CUSTOM="custom";class Ao extends n.InternalError{constructor(e,t="GRAPH_EXECUTION_ERROR",o){super(e,Ao.name,500),this.graphCode=t,this.details=o,this.name=this.constructor.name}}class xo extends Ao{constructor(e){super("Graph workflow contains an unsupported cycle","GRAPH_CYCLE_ERROR",e)}}class Io extends Ao{constructor(e,t){super(e,"GRAPH_INPUT_ERROR",t)}}class Eo extends Ao{constructor(e,t){super(e,"GRAPH_LOOP_LIMIT_ERROR",t)}}class So extends Ao{constructor(e,t){super(e,"GRAPH_PINNING_ERROR",t)}}class Ro extends Ao{constructor(e,t){super(e,"GRAPH_STORE_ERROR",t)}}class To extends Ao{constructor(e,t){super(e,"GRAPH_TOPOLOGY_ERROR",t)}}class Co extends Ao{constructor(e){super("Break signal","GRAPH_BREAK_SIGNAL",{value:e}),this.isBreakSignal=!0,this.name="GraphBreakSignal"}}class Oo extends Ao{constructor(e){super(`Graph run '${e}' was cancelled`,"GRAPH_RUN_CANCELLED",{runId:e}),this.name=Oo.name}}class ko extends n.ValidationError{constructor(e){super(`Graph workflow document rejected with ${e.length} issue(s): ${e.map(e=>`${e.code} at ${e.path} (${e.message})`).join("; ")}`),this.name=ko.name,this.issues=e}}class Do{constructor(){this.observers=new Set}observe(e){return this.observers.add(e),()=>this.unObserve(e)}unObserve(e){this.observers.delete(e)}async updateObservers(e){await Promise.all(Array.from(this.observers).map(async t=>{try{await Promise.resolve(t.refresh(e))}catch{}}))}}class Po{constructor(){this.sequence=0}create(e){return{...e,id:this.createEventId(),sequence:++this.sequence,timestamp:new Date}}createEventId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new Ao("Cannot generate a graph event id: crypto.randomUUID is unavailable in this runtime","GRAPH_EVENT_ID_ERROR",{runtime:typeof globalThis.crypto});return e.randomUUID()}}function Go(e){if("string"!=typeof e)return;const t=e.trim();if(!t)return;const o=t.split(".");if(3!==o.length)return;const a=o[0].trim(),r=o[2].trim(),n=o[1].split(",").map(e=>e.trim()).filter(e=>e.length>0);return a&&r&&0!==n.length?{organization:a,departments:n,role:r}:void 0}function Mo(e){return`${e.organization}.${e.departments.join(",")}.${e.role}`}function Fo(e){if(!e||"string"!=typeof e.namespace||!e.parts)return!1;const t=Go(e.namespace);return!!t&&Mo(t)===Mo(e.parts)}function Lo(e,t){const o="string"==typeof e?e.trim():"";if(o){if(t)for(const e of t)if(e&&e.namespace===o&&Fo(e))return e.parts;return Go(o)}}function jo(e,t,o={},a){const r=Lo(e,a),n=Lo(t,a);return!(!r||!n)&&r.organization===n.organization&&r.role===n.role&&("exact"===(o.mode??"inherit")?r.departments.length===n.departments.length&&r.departments.every((e,t)=>e===n.departments[t]):r.departments.length<=n.departments.length&&r.departments.every((e,t)=>e===n.departments[t]))}function qo(e,t,o={},a){return e.filter(e=>!t.some(t=>jo(t,e,o,a)))}function Ho(e){return e.filter(e=>void 0===Go(e))}function Uo(e,t){const o=new Set;for(const a of e){const e=Lo(a,t);e&&o.add(e.role)}return[...o]}function Bo(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function $o(e,t){try{const o=e.cache;if(o&&void 0!==o[t]&&null!==o[t])return o[t]}catch{}try{return e.get(t)}catch{return}}function Wo(e){if(!e)return{};const t={},o=e.user;"string"==typeof o&&o&&(t.user=o);const a=e.organization;"string"==typeof a&&a&&(t.organization=a);const r=e.ip;"string"==typeof r&&r&&(t.ip=r);const n=Bo(e.roles);n&&(t.roles=n);const i=Bo(e.namespaces);return i&&(t.namespaces=i,t.namespaceCache=Ko(i)),t}function Vo(e){return e?Wo({user:$o(e,"user"),organization:$o(e,"organization"),ip:$o(e,"ip"),roles:$o(e,"roles"),namespaces:$o(e,"namespaces")}):{}}function Ko(e){const t=[];for(const o of e){const e=Go(o);e&&t.push({namespace:o,parts:e})}return t}function zo(...e){const t={};for(const o of e)o&&(void 0!==o.user&&(t.user=o.user),void 0!==o.organization&&(t.organization=o.organization),void 0!==o.ip&&(t.ip=o.ip),void 0!==o.roles&&(t.roles=o.roles),void 0!==o.namespaces&&(t.namespaces=o.namespaces),void 0!==o.namespaces?t.namespaceCache=o.namespaceCache??Ko(o.namespaces):void 0!==o.namespaceCache&&(t.namespaceCache=o.namespaceCache));return t}class Qo{constructor(e={}){this.options=e}get enabled(){return!0===this.options.enabled}validate(e,o,a,r){if(!this.enabled)return;const n=r??this.options.logger??t.Logging.for("GraphAuth"),i=e.id||e.name||o.workflowId,d=xe(e.metadata);this.assertGranted(`workflow '${i}'`,d?.namespaces??[],a,d?.roles??[],n);for(const e of o.nodes)this.assertGranted(`node '${e.id}'`,e.manifest.namespaces??[],a,[],n)}validateWorkflowRead(e,o,a){if(!this.enabled)return;const r=a??this.options.logger??t.Logging.for("GraphAuth"),n=xe(e.metadata);this.assertGranted(`workflow '${e.id||e.name}'`,n?.namespaces??[],o,n?.roles??[],r)}assertGranted(e,t,o,a,r){const n=o.namespaces??[],i=qo(t,n,this.options.match,o.namespaceCache),s=Uo(n,o.namespaceCache),l=a.filter(e=>!s.includes(e));if(0===i.length&&0===l.length)return;const c=[...new Set([...Ho(t),...Ho(n)])],p=[];throw i.length&&p.push("namespace(s) "+i.join(", ")),l.length&&p.push("role(s) "+l.join(", ")),r.warn(`Graph access denied for ${e} for user ${o.user??"anonymous"}: missing ${p.join(" and ")}${c.length?`; malformed namespace(s) ${c.join(", ")} failed closed`:""}`),new d.ForbiddenError(`Access to ${e} requires ${p.join(" and ")}`)}}class Jo{constructor(e){this.services=e}async resolve(e,t,o,a,r){if(!e){if(o)throw new Ao(`${a} node requires a credential of type '${t}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:t});return}if(e.credentialType&&e.credentialType!==t)throw new Ao(`${a} node credential has type '${e.credentialType}' but requires '${t}'`,"GRAPH_CREDENTIAL_TYPE_MISMATCH",{credentialId:e.credentialId,credentialType:e.credentialType});let n;try{n=await this.services.credentialService.getCredential(e.credentialId,r)}catch(t){throw new Ao(`${a} node credential '${e.credentialId}' could not be resolved`,"GRAPH_CREDENTIAL_NOT_FOUND",{credentialId:e.credentialId,cause:t instanceof Error?t.message:t+""})}if(!1===n.enabled)throw new Ao(`${a} node credential '${e.credentialId}' is disabled`,"GRAPH_CREDENTIAL_DISABLED",{credentialId:e.credentialId});if((e=>{if(!e)return!1;const t=e instanceof Date?e.getTime():Date.parse(e);return Number.isFinite(t)&&Date.now()>=t})(n.expiresAt))throw new Ao(`${a} node credential '${e.credentialId}' has expired`,"GRAPH_CREDENTIAL_EXPIRED",{credentialId:e.credentialId});if(n.credentialType&&n.credentialType!==t)throw new Ao(`${a} node credential '${e.credentialId}' has type '${n.credentialType}' but requires '${t}'`,"GRAPH_CREDENTIAL_TYPE_MISMATCH",{credentialId:e.credentialId,credentialType:n.credentialType});const i=this.secretServiceFor(n.provider,a),d=await i.retrieve(n.secretName,{},r);return await(this.services.credentialService.markCredentialUsed?.(e.credentialId,r).catch(()=>{})),(e=>{if(null!=e)return"string"==typeof e?e:e instanceof Uint8Array?(new TextDecoder).decode(e):"object"!=typeof e||Array.isArray(e)?e+"":e})(d)}secretServiceFor(e,t){if("model"===e)return this.services.modelSecretService;if("filesystem"===e){if(!this.services.fsSecretService)throw new Ao(`${t} node credential provider '${e}' requires a configured filesystem secret service`,"GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{provider:e});return this.services.fsSecretService}throw new Ao(`${t} node credential provider '${e}' is not supported`,"GRAPH_CREDENTIAL_PROVIDER_UNSUPPORTED",{provider:e})}}async function Xo(e,t,o,a,r,n="credentialRef"){const i=t?.[n];if(!i){if(!a)return;throw new Ao(`${r} node requires a credential of type '${o}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:o})}const d=e?.engine,s=d?.nodeCredentials;if(!s)throw new Ao(r+" node requires ctx-bound credential services, but the engine has none configured","GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{node:r,credentialType:o});return s.resolve(i,o,a,r,e)}class Yo{constructor(e){this.baseOptions=e,this.inner=t.Logging.for("GraphRun").for(this.attributeConfig(e))}attributeConfig(e){return{[ye.NODE_ID]:e.nodeId,[ye.WORKFLOW_ID]:e.workflowId,[ye.RUN_ID]:e.runId,[ye.USER]:e.user??null,[ye.ROLES]:e.roles,[ye.NAMESPACES]:e.namespaces,[ye.ORGANIZATION]:e.organization,[ye.IP]:e.ip}}emit(e,t,o){const a="string"==typeof t?t:t instanceof Error?t.message:t+"",r={level:e,message:a,timestamp:(new Date).toISOString(),runId:this.baseOptions.runId,workflowId:this.baseOptions.workflowId,nodeId:this.baseOptions.nodeId,user:this.baseOptions.user??null};void 0!==this.baseOptions.roles&&(r.roles=this.baseOptions.roles),void 0!==this.baseOptions.namespaces&&(r.namespaces=this.baseOptions.namespaces),void 0!==this.baseOptions.organization&&(r.organization=this.baseOptions.organization),void 0!==this.baseOptions.ip&&(r.ip=this.baseOptions.ip),void 0!==o&&(r.payload=o),this.baseOptions.forward({type:be.GRAPH_RUN_LOG,payload:r}).catch(()=>{}),{benchmark:(e,t)=>this.inner.benchmark(e,t),fatal:(e,t)=>this.inner.fatal(e,t),critical:(e,t)=>this.inner.critical(e,t),silly:(e,t)=>this.inner.silly(e,t),trace:(e,t)=>this.inner.trace(e,t),verbose:(e,t)=>this.inner.verbose(e,t),info:(e,t)=>this.inner.info(e,t),warn:(e,t)=>this.inner.warn(e,t),error:(e,t)=>this.inner.error(e,t),debug:(e,t)=>this.inner.debug(e,t)}[e](a,o)}benchmark(e,t){this.emit("benchmark",e,t)}fatal(e,t,o){this.emit("fatal",e,t??o)}critical(e,t,o){this.emit("critical",e,t??o)}silly(e,t,o){this.emit("silly",e,"object"==typeof t?t:o)}trace(e,t){this.emit("trace",e,t)}verbose(e,t,o){this.emit("verbose",e,"object"==typeof t?t:o)}info(e,t){this.emit("info",e,t)}error(e,t,o){this.emit("error",e,t??o)}warn(e,t){this.emit("warn",e,t)}debug(e,t){this.emit("debug",e,t)}action(e,t,o){this.inner.action(e,t,o)}setConfig(){}for(e,t,...o){return this}clear(){return this}get root(){return this.inner.root}}function Zo(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}class ea extends d.Context{constructor(e,t,o,a,r,n,i,d,s={},l,c,p){super(),this.runId=e,this.parentRunId=t,this.workflowId=o,this.document=a,this.node=r,this.manifest=n,this.path=i,this.emitFn=d,this.metadata=s,this.engine=l,this.abortSignal=c,this.limits=p;const u=Wo(s);this.accumulate({...u,operation:"execute"});const g="string"==typeof s?.user?s.user:null;this.runLogger=new Yo({runId:e,workflowId:o,nodeId:r.id,user:g,roles:Zo(s?.roles),namespaces:Zo(s?.namespaces),organization:"string"==typeof s?.organization?s.organization:void 0,ip:"string"==typeof s?.ip?s.ip:void 0,forward:async e=>{await this.emit(e)}})}get logger(){return this.runLogger}get auth(){return Vo(this)}async emit(e){await this.emitFn({...e,runId:this.runId,parentRunId:this.parentRunId,workflowId:this.workflowId,nodeId:this.node.id,path:e.path??this.path})}async progress(e){await this.emit({type:be.NODE_OUTPUT,payload:e})}async log(e,t){await this.emit({type:be.NODE_OUTPUT,payload:{message:e,payload:t}})}}class ta{constructor(e,t,o,a){this.nodeResults=new Map,this.events=[],this.activeDataEdges=new Set,this.runId=e,this.plan=t,this.valueStore=o,this.eventFactory=a,this.startedAt=new Date}recordNodeResult(e){this.nodeResults.set(e.nodeId,e)}activateDataEdge(e){this.activeDataEdges.add(e)}isDataEdgeActive(e){return this.activeDataEdges.has(e)}appendEvent(e){this.events.push(e)}finish(){this.finishedAt=new Date}}function oa(e,t,o,a,r){const n=e.valueStore.getWorkflowValues(),i={};for(const[t,o]of e.nodeResults)i[t]=o;const d=[...e.events];return{runId:e.runId,workflowId:t.id||t.name,status:a,document:t,inputs:{...o},outputs:n,nodeResults:i,events:d,startedAt:e.startedAt,finishedAt:e.finishedAt,metadata:r}}class aa{constructor(e,t,o){this.emitter=e,this.eventFactory=t,this.options=o}get engine(){return this.options.engine}get codeSandboxEvaluator(){return this.options.codeSandboxEvaluator}get frame(){return this._frame}bindFrame(e){this._frame=e}async emit(e){const t=this.eventFactory.create({id:"",sequence:0,timestamp:new Date,runId:this.options.runId,parentRunId:this.options.parentRunId,workflowId:this.options.workflowId,type:be.NODE_OUTPUT,path:this.options.path??[],...e});this._frame?.appendEvent(t),await this.emitter.updateObservers(t)}async updateObservers(e){await this.emitter.updateObservers(e)}}function ra(e){const t=e.capabilities;return{codeMode:t?.codeMode??e.codeMode,workflows:{list:t?.workflows?.list??("function"==typeof e.listWorkflows?"supported":"not_supported"),get:t?.workflows?.get??("function"==typeof e.getWorkflow?"supported":"not_supported")}}}class na{static{this._cache={}}static register(e,t){return na._cache[e]=t,t}static get(e){const t=e??na._currentFlavour;if(t)return na._cache[t]}static getOrFail(e){const t=na.get(e);if(!t)throw new Ao(`No graph execution backend registered under '${e}'`,"GRAPH_EXECUTION_BACKEND_NOT_REGISTERED");return t}static get current(){return na.get()}static get currentFlavour(){return na._currentFlavour??co}static setCurrent(e){na._currentFlavour=e}static list(){return Object.entries(na._cache).map(([e,t])=>({flavour:e,backend:t}))}static unregister(e){e&&(delete na._cache[e],na._currentFlavour===e&&(na._currentFlavour=void 0))}static clear(){for(const e of Object.keys(na._cache))delete na._cache[e];na._currentFlavour=void 0}}class ia{evaluate(e,t){switch(e.op){case"eq":return this.resolveValue(e.left,t)===this.resolveValue(e.right,t);case"neq":return this.resolveValue(e.left,t)!==this.resolveValue(e.right,t);case"gt":return Number(this.resolveValue(e.left,t))>Number(this.resolveValue(e.right,t));case"gte":return Number(this.resolveValue(e.left,t))>=Number(this.resolveValue(e.right,t));case"lt":return Number(this.resolveValue(e.left,t))<Number(this.resolveValue(e.right,t));case"lte":return Number(this.resolveValue(e.left,t))<=Number(this.resolveValue(e.right,t));case"and":return e.conditions.every(e=>this.evaluate(e,t));case"or":return e.conditions.some(e=>this.evaluate(e,t));case"not":return!this.evaluate(e.condition,t);case"exists":return void 0!==this.resolveValue(e.value,t)&&null!==this.resolveValue(e.value,t);default:throw new Ao(`Unknown ConditionExpression op '${e.op}'`,"GRAPH_UNKNOWN_CONDITION_OP",{expr:e})}}resolveValue(e,t){if("const"in e)return e.const;if("path"in e&&!("step"in e))return this.resolvePath(e.path,t);if("step"in e&&"path"in e){const o=t?.nodes;if(o&&"object"==typeof o){const t=o[e.step];return this.resolvePath(e.path,t)}return this.resolvePath(e.path,t)}throw new Ao("Invalid ExprValue: must have `const`, `path`, or `step`+`path`","GRAPH_INVALID_EXPR_VALUE",{ref:e})}resolvePath(e,t){if(!e)return t;const o=e.split(".");let a=t;for(const e of o){if(null==a)return;a=a[e]}return a}}function da(e){return"object"==typeof e&&null!==e&&"type"in e&&"code"===e.type}function sa(e){return"object"==typeof e&&null!==e&&"op"in e&&"string"==typeof e.op}async function la(e,t,o){const a=o.engine?.codeSandboxEvaluator;if(!a)throw new Ao("Code conditions require a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:e.code});await o.log("Evaluating code condition",{language:e.language??"javascript"});const r=o.metadata;return!!await a.evaluate({code:e.code,language:e.language,input:t,vars:r?.vars??void 0,item:r?.item,index:r?.index,nodes:r?.nodes??void 0,logger:o.logger,abortSignal:o.abortSignal})}function ca(e,t,o){if(sa(e))return(new ia).evaluate(e,t);throw((e,t)=>new Ao(`Unknown ${t??"flow"} condition type \u2014 must be ConditionExpression (op) or CodeCondition (type: 'code')`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e}))(e,o)}async function pa(e,t,o){return da(e)?la(e,t.input,o):ca(e,t.state,t.label)}function ua(e,t,o,a){if(e&&"object"==typeof e&&!a.has(e))if(a.add(e),da(e))o.push({nodeId:t,kind:"code-condition"});else if(xt(e))o.push({nodeId:t,kind:"value-template"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"expression"===t.source&&"string"==typeof t.expression})(e))o.push({nodeId:t,kind:"expression-binding"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.name&&Array.isArray(t.nodes)&&Array.isArray(t.edges)})(e))ha(e,o,a);else if(Array.isArray(e))for(const r of e)ua(r,t,o,a);else for(const r of Object.keys(e))ua(e[r],t,o,a)}function ga(e,t,o){const a=e.id;"core.utility.code"===e.kind&&t.push({nodeId:a,kind:"code-node",detail:e.kind});const r=e.inputBindings??{};for(const[e,o]of Object.entries(r))o&&"expression"===o.mode&&t.push({nodeId:a,kind:"expression-binding",detail:e});ua(e.parameters,a,t,o),ua(e.metadata,a,t,o),ua(e.state,a,t,o),ua(e.loop,a,t,o)}function ha(e,t,o){for(const a of e.nodes??[])ga(a,t,o)}function ma(e){const t=[];return ha(e,t,new Set),t}function fa(e){return"value-template"!==e.kind}function _a(e){return ma(e).filter(fa)}const ya="core.agent";function ba(e,t){if(!t)return{valid:!0};switch(t.type){case"any":default:return{valid:!0};case"string":return"string"!=typeof e?wa("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?t.integer&&!Number.isInteger(e)?{valid:!1,message:"expected an integer number"}:void 0!==t.min&&e<t.min?{valid:!1,message:"expected a number >= "+t.min}:void 0!==t.max&&e>t.max?{valid:!1,message:"expected a number <= "+t.max}:{valid:!0}:wa("number");case"boolean":return"boolean"!=typeof e?wa("boolean"):{valid:!0};case"array":if(!Array.isArray(e))return wa("array");if(void 0!==t.minItems&&e.length<t.minItems)return{valid:!1,message:`expected at least ${t.minItems} items`};if(void 0!==t.maxItems&&e.length>t.maxItems)return{valid:!1,message:`expected at most ${t.maxItems} items`};for(const o of e){const e=ba(o,t.items);if(!e.valid)return e}return{valid:!0};case"object":case"model":{if(null===e||"object"!=typeof e||Array.isArray(e))return wa(t.type);const o=t,a=o.properties;if(!a)return{valid:!0};for(const[t,o]of Object.entries(a))if(t in e){const a=ba(e[t],o);if(!a.valid)return{valid:!1,message:`property '${t}': ${a.message}`}}if(o.required)for(const t of o.required)if(!(t in e))return{valid:!1,message:`missing required property '${t}'`};if(!1===o.additionalProperties)for(const t of Object.keys(e))if(!(t in a))return{valid:!1,message:`unexpected property '${t}'`};return{valid:!0}}case"enum":return t.values.some(t=>t===e)?{valid:!0}:{valid:!1,message:"value is not one of the enum values"}}}function wa(e){return{valid:!1,message:`expected a ${e} value`}}function Na(e){if("string"==typeof e)return e.length>0;if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.credentialId&&t.credentialId.length>0&&(void 0===t.credentialType||"string"==typeof t.credentialType)}const va=new Set(["loop"]),Aa=["secret","secrets","password","passwd","token","accessToken","refreshToken","apiKey","api_key","privateKey","credentials","authorization","proxy-authorization","x-api-key","x-auth-token","cookie","set-cookie"];class xa{validate(e,t,o,a,r){this.validateParameters(e,t,o,a,r),this.validateMetadataKeys(e,t,o,a),this.validateDisabledBehavior(e,o,a),this.validateBindingShapes(e,t,o,a)}validateParameters(e,t,o,a,r){const n=!0===t.policies?.allowUndeclaredParameters,i=new Map(t.parameters.map(e=>[e.id,e]));for(const[r,d]of Object.entries(e.parameters??{})){const s=i.get(r);if(!s){n||o.push({code:"parameter.undeclared",path:`${a}.parameters.${r}`,message:`Node '${e.id}' sets parameter '${r}' which is not declared by kind '${t.kind}'`,nodeId:e.id,details:{kind:t.kind}});continue}if(void 0===d){o.push({code:"parameter.invalid",path:`${a}.parameters.${r}`,message:`Node '${e.id}' parameter '${r}' must not be undefined`,nodeId:e.id});continue}const l=this.checkParameterValue(d,s);l.valid||o.push({code:"parameter.type-mismatch",path:`${a}.parameters.${r}`,message:`Node '${e.id}' parameter '${r}' is invalid: ${l.message}`,nodeId:e.id,details:{expectedType:s.type}})}for(const n of t.parameters)void 0===(e.parameters??{})[n.id]&&(this.isParameterSatisfiedByInput(e,n.id,r)||(!0===n.required||(n.validation??[]).some(e=>"required"===e.kind))&&void 0===n.defaultValue&&o.push({code:"parameter.required-missing",path:`${a}.parameters.${n.id}`,message:`Node '${e.id}' is missing required parameter '${n.id}' declared by kind '${t.kind}'`,nodeId:e.id}))}isParameterSatisfiedByInput(e,t,o){return void 0!==(e.inputBindings??{})[t]||!0===o?.has(t)}checkParameterValue(e,t){if(xt(e))return{valid:!0};switch(t.type){case"string":case"code":case"expression":return"string"!=typeof e?wa("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?{valid:!0}:wa("number");case"boolean":return"boolean"!=typeof e?wa("boolean"):{valid:!0};case"options":{const o=t.options;return o&&o.length&&!o.some(t=>t.value===e)?{valid:!1,message:"value is not one of the declared options"}:{valid:!0}}case"collection":return Array.isArray(e)?{valid:!0}:wa("array");case"object":case"resourceLocator":return null===e||"object"!=typeof e||Array.isArray(e)?wa("object"):{valid:!0};case"credential":return Na(e)?t.credentialType&&"object"==typeof e&&void 0!==e.credentialType&&e.credentialType!==t.credentialType?{valid:!1,message:`credential type '${e.credentialType}' does not match the declared type '${t.credentialType}'`}:{valid:!0}:{valid:!1,message:"credential parameters must hold a credential reference (credentialId), never a secret"};default:return{valid:!0}}}validateMetadataKeys(e,t,o,a){const r=t.metadata?.allowedInstanceMetadataKeys;for(const n of Object.keys(e.metadata??{}))va.has(n)?o.push({code:"metadata.key-not-allowed",path:`${a}.metadata.${n}`,message:`Node '${e.id}' metadata key '${n}' is reserved and must not be set directly`,nodeId:e.id}):Array.isArray(r)&&!r.includes(n)&&o.push({code:"metadata.key-not-allowed",path:`${a}.metadata.${n}`,message:`Node '${e.id}' metadata key '${n}' is not in the allowed metadata keys of kind '${t.kind}'`,nodeId:e.id})}validateDisabledBehavior(e,t,o){!0!==e.disabled&&!1!==e.disabled&&void 0!==e.disabled&&t.push({code:"disabled.invalid",path:o+".disabled",message:`Node '${e.id}' disabled flag must be a boolean`,nodeId:e.id});const a=(e.metadata??{}).disabledBehavior;void 0===a||me(a)||t.push({code:"disabled.invalid-behavior",path:o+".metadata.disabledBehavior",message:`Node '${e.id}' disabled behavior '${a+""}' is not one of: ${he.join(", ")}`,nodeId:e.id})}validateBindingShapes(e,t,o,a){for(const[r,n]of Object.entries(e.inputBindings??{})){if("literal"===n.mode){const i=t.inputs.find(e=>e.id===r);if(i?.schema){const t=ba(n.value,i.schema);t.valid||o.push({code:"binding.literal-invalid",path:`${a}.inputBindings.${r}`,message:`Node '${e.id}' literal binding for '${r}' is schema-invalid: ${t.message}`,nodeId:e.id})}}"expression"!==n.mode||"string"==typeof n.expression&&n.expression.trim()||o.push({code:"binding.expression-invalid",path:`${a}.inputBindings.${r}`,message:`Node '${e.id}' expression binding for '${r}' must contain a non-empty expression`,nodeId:e.id})}}validateBindingSatisfaction(e,t,o,a,r,n={}){const i=new Set(o.filter(e=>"data"===e.type).map(e=>e.targetPort)),d=new Set(Object.entries(e.inputBindings??{}).map(([e])=>e));for(const t of i){const o=(e.inputBindings??{})[t];o&&"literal"===o.mode&&!0!==n.allowLiteralAndEdgeBindings&&a.push({code:"binding.conflict",path:`${r}.inputBindings.${t}`,message:`Node '${e.id}' input '${t}' has both an incoming edge and a literal binding`,nodeId:e.id})}for(const o of t.inputs)!0===o.required&&(i.has(o.id)||d.has(o.id)||void 0===(e.parameters??{})[o.id]&&a.push({code:"topology.required-input-unsatisfiable",path:r+".parameters",message:`Node '${e.id}' required input '${o.id}' has no incoming edge or binding`,nodeId:e.id,details:{port:o.id}}))}static disabledBehaviorOf(e,t){const o=(e.metadata??{}).disabledBehavior;if(me(o))return o;const a=t?.disabledBehavior;return me(a)?a:"skip"}}function Ia(e){return[e.namespace??"default",e.workflowId,e.nodeId,e.version??"default",e.fingerprint].join(":")}function Ea(t){return new e.GraphValueModel({id:Ia(t.key),workflowId:t.key.workflowId,nodeId:t.key.nodeId,fingerprint:t.key.fingerprint,...void 0!==t.key.namespace?{namespace:t.key.namespace}:{},...void 0!==t.key.version?{version:t.key.version}:{},pinned:t.pinned,outputs:t.outputs,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt),...t.expiresAt?{expiresAt:new Date(t.expiresAt)}:{},...t.metadata?{metadata:t.metadata}:{}})}function Sa(e){return{key:{workflowId:e.workflowId,nodeId:e.nodeId,fingerprint:e.fingerprint,...void 0!==e.namespace?{namespace:e.namespace}:{},...void 0!==e.version?{version:e.version}:{}},outputs:e.outputs,pinned:e.pinned,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString(),...e.expiresAt?{expiresAt:e.expiresAt.toISOString()}:{},...e.metadata?{metadata:e.metadata}:{}}}function Ra(t){return new(0,d.Repository.forModel(e.GraphValueModel,t.alias).constructor)(t)}e.GraphValueModel=class extends d.BaseModel{constructor(e){super(e)}},i.__decorate([d.pk({type:String,generated:!1}),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"id",void 0),i.__decorate([d.column(),d.index(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"workflowId",void 0),i.__decorate([d.column(),d.index(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"nodeId",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"fingerprint",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"namespace",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],e.GraphValueModel.prototype,"version",void 0),i.__decorate([d.column(),i.__metadata("design:type",Boolean)],e.GraphValueModel.prototype,"pinned",void 0),i.__decorate([d.column(),i.__metadata("design:type",Object)],e.GraphValueModel.prototype,"outputs",void 0),i.__decorate([d.column(),i.__metadata("design:type",Date)],e.GraphValueModel.prototype,"createdAt",void 0),i.__decorate([d.column(),i.__metadata("design:type",Date)],e.GraphValueModel.prototype,"updatedAt",void 0),i.__decorate([d.column(),i.__metadata("design:type",Date)],e.GraphValueModel.prototype,"expiresAt",void 0),i.__decorate([d.column(),i.__metadata("design:type",Object)],e.GraphValueModel.prototype,"metadata",void 0),e.GraphValueModel=i.__decorate([d.table("graph_value"),r.model(),i.__metadata("design:paramtypes",[Object])],e.GraphValueModel),e.GraphValueRepository=class extends d.Repository{constructor(t){super(t,e.GraphValueModel,!0),this.runtimeValues=new Map}seedWorkflowInputs(e){this.runtimeValues.set(lo,{...e})}setNodeOutputs(e,t){this.runtimeValues.set(e,{...t})}getPort(e,t){return this.runtimeValues.get(e)?.[t]}hasPort(e,t){return Object.prototype.hasOwnProperty.call(this.runtimeValues.get(e)??{},t)}setWorkflowOutput(e,t){const o=this.runtimeValues.get(lo)??{};o[e]=t,this.runtimeValues.set(lo,o)}getWorkflowValues(){return{...this.runtimeValues.get(lo)??{}}}snapshot(){return Object.fromEntries(this.runtimeValues.entries())}async readCached(e,...t){try{return Sa(await this.read(Ia(e),...t))}catch{return}}async writeCached(e,t,...o){const a=Ia(e);let r;try{r=await this.read(a,...o)}catch{r=void 0}r?await this.update(Object.assign(r,Ea(t)),...o):await this.create(Ea(t),...o)}async deleteCached(e,...t){try{await this.delete(Ia(e),...t)}catch{}}async hasCached(e,...t){return void 0!==await this.readCached(e,...t)}async listCached(e,...t){return(await this.select().execute(...t)).map(e=>Sa(e)).filter(t=>((e,t)=>!(void 0!==t.workflowId&&e.workflowId!==t.workflowId||void 0!==t.nodeId&&e.nodeId!==t.nodeId||void 0!==t.namespace&&e.namespace!==t.namespace||void 0!==t.version&&e.version!==t.version||void 0!==t.fingerprint&&e.fingerprint!==t.fingerprint))(t.key,e))}async clearRun(e,...t){const o=await this.select().execute(...t);for(const e of o)await this.delete(e.id,...t)}readRuntimeValues(e){return this.runtimeValues.get(e)}writeRuntimeValues(e,t){this.runtimeValues.set(e,{...t})}getAdapter(){return this.adapter}},e.GraphValueRepository=i.__decorate([d.repository(e.GraphValueModel,a.DefaultFlavour),i.__metadata("design:paramtypes",[Function])],e.GraphValueRepository);class Ta{static upstreamNodes(e,t,o=!1){const a=new Set,r=[e];for(;r.length;){const e=r.pop(),n=t.get(e)??[];for(const e of n)!o&&this.isBoundary(e.sourceNodeId)||a.has(e.sourceNodeId)||(a.add(e.sourceNodeId),r.push(e.sourceNodeId))}return a}static downstreamNodes(e,t,o=!1){const a=new Set,r=[e];for(;r.length;){const e=r.pop(),n=t.get(e)??[];for(const e of n)!o&&this.isBoundary(e.targetNodeId)||a.has(e.targetNodeId)||(a.add(e.targetNodeId),r.push(e.targetNodeId))}return a}static isBoundary(e){return"$workflow"===e}}class Ca{constructor(e,t,o){this.store=e,this.policy=t,this.dependencyResolver=o}async pinNode(e){const t=e.plan,o=e.includeDependencies??!0?this.dependencyResolver.getPinSet(t,e.nodeId):new Set([e.nodeId]);for(const e of o){const o=t.nodes.find(t=>t.id===e);if(!o)throw new So(`Node '${e}' not found in plan`);if(!this.policy.canPin(o))throw new So(`Node '${e}' is not pinnable`,{nodeId:e})}const a=this.topologicalOrder(t,o);for(const o of a){const a=t.nodes.find(e=>e.id===o),r=e.result.nodeResults[o];if(!r||!r.outputs)throw new So(`Node '${o}' has no completed output to pin`);const n=r.inputs??{},i=this.dependencyFingerprints(t,o,e.result),d=this.createValueKey(e.document.id,a,n,i),s=(new Date).toISOString(),l={key:d,outputs:r.outputs,pinned:!0,createdAt:s,updatedAt:s,metadata:{...e.result.metadata,nodeId:o}};await this.store.writeCached(d,l)}}async unpinNode(e){const t={workflowId:e.document.id,nodeId:e.nodeId,fingerprint:e.fingerprint,namespace:e.namespace};await this.store.deleteCached(t)}async readPinnedValue(e,t,o,a,r){const n=this.createValueKey(e,t,o,a,r),i=await this.store.readCached(n);if(i&&i.pinned){if(i.expiresAt&&new Date(i.expiresAt)<new Date)return;return i}}createValueKey(e,t,o,a,r){return{workflowId:e,nodeId:t.id,fingerprint:this.computeFingerprint(e,t,o,a),namespace:r}}computeFingerprint(e,t,o,a){const r={workflowId:e,nodeId:t.id,nodeKind:t.kind,parameters:this.stableSerialize(t.instance.parameters??{}),inputBindings:this.stableSerialize(t.instance.inputBindings??{}),metadata:this.stableSerialize(this.relevantMetadata(t)),inputs:this.stableSerialize(o),dependencyFingerprints:this.stableSerialize(a)},n=this.stableSerialize(r);return this.simpleHash(n)}relevantMetadata(e){const t={...e.metadata??{}};return delete t.ui,delete t.position,delete t.visual,t}topologicalOrder(e,t){const o=[],a=new Set,r=n=>{if(a.has(n))return;a.add(n);const i=Ta.upstreamNodes(n,e.incomingByNode,!1);for(const e of i)t.has(e)&&r(e);o.push(n)};for(const e of t)r(e);return o}dependencyFingerprints(e,t,o){const a=this.dependencyResolver.getDependencies(e,t),r={};for(const t of a){const a=e.nodes.find(e=>e.id===t);if(a){const n=o.nodeResults[t],i=n?.inputs??{},d=this.dependencyFingerprints(e,t,o);r[t]=this.computeFingerprint(e.workflowId,a,i,d)}}return r}stableSerialize(e){return null===e||"object"!=typeof e?JSON.stringify(e):Array.isArray(e)?`[${e.map(e=>this.stableSerialize(e)).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${this.stableSerialize(e[t])}`).join(",")}}`}simpleHash(e){let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;return`fp_${Math.abs(t).toString(16).padStart(8,"0")}_${e.length}`}}const Oa={enabled:!0,strategy:"manual",includeDependencies:!0};function ka(e){return!0===e?.enabled&&"disabled"!==e.strategy}class Da{canPin(e){return ka(this.getPinningMetadata(e))}shouldUsePinnedValue(e){const t=this.getPinningMetadata(e);return!0===t.enabled&&"disabled"!==t.strategy}shouldAutoPin(e){const t=this.getPinningMetadata(e);return!0===t.enabled&&"automatic"===t.strategy}getPinningMetadata(e){const t=e.manifest.metadata?.pinnable??e.metadata?.pinnable;return t?{...Oa,...t}:{...Oa,enabled:!1}}}class Pa{getDependencies(e,t){return Ta.upstreamNodes(t,e.incomingByNode,!1)}getPinSet(e,t){const o=this.getDependencies(e,t);return o.add(t),o}}class Ga{constructor(){this.local=!0,this.codeMode="hostSide",na.register(co,this)}async initialize(e){this.valueAdapter=e.valueAdapter,this.codeSandboxEvaluator=e.codeSandboxEvaluator,this.workflowStore=e.workflowStore,this.engine=e.engine}get capabilities(){const e=this.workflowStore?"supported":"not_supported";return{codeMode:this.codeMode,workflows:{list:e,get:e}}}async listWorkflows(...e){const t=this.workflowStore;if(!t)throw new Ao("LocalGraphExecutionBackend has no workflowStore configured; workflow listing is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");return(await t.listWorkflows(...e)).map(e=>({id:e.workflowId,...void 0!==e.name?{name:e.name}:{},...void 0!==e.updatedAt&&null!==e.updatedAt?{updatedAt:e.updatedAt}:{}}))}async getWorkflow(e,...t){const o=this.workflowStore;if(!o)throw new Ao("LocalGraphExecutionBackend has no workflowStore configured; workflow lookup is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");const a=await o.getDocument(e,...t);return this.engine&&this.engine.assertWorkflowReadAccess(a,(e=>Vo((e=>{for(let t=e.length-1;t>=0;t-=1){const o=e[t];if(!o||"object"!=typeof o)continue;const a=o;if("function"==typeof a.get&&"function"==typeof a.accumulate&&void 0!==a.cache)return o}})(e)))(t)),a}async seedWorkflows(e,...t){const o=this.workflowStore,a=o?.seedDocument??o?.saveDocument;if(!o||"function"!=typeof a)throw new Ao("LocalGraphExecutionBackend has no writable workflowStore configured; workflow seeding is not supported","GRAPH_BACKEND_SEED_NOT_SUPPORTED");const r=[];for(const n of e)null!==await a.call(o,n.id,n,...t)&&r.push({id:n.id,...void 0!==n.name?{name:n.name}:{}});return r}async execute(e){const{document:t,plan:o,inputs:a,options:r,events:n}=e,i=n,d=i.frame;if(!d)throw new Ao("LocalGraphExecutionBackend requires the frame-bound event sink created by GraphExecutionEngine","GRAPH_EXECUTION_FRAME_MISSING");const s=d.valueStore,l=d.runId,c=r.path??[],p=async e=>{await i.emit(e)};try{for(const e of o.layers)this.assertNotAborted(r),await this.executeLayer(d,o,e.nodes,r,p);this.assertNotAborted(r);const e=[...d.nodeResults.values()].find(e=>e.status===fe.FAILED);if(e?.error)throw new Ao(e.error.message,e.error.code??"GRAPH_EXECUTION_ERROR",e.error.details);return d.finish(),await i.emit({type:be.WORKFLOW_COMPLETED,runId:l,parentRunId:r.parentRunId,workflowId:o.workflowId,path:c,status:fe.SUCCEEDED,payload:{outputs:s.getWorkflowValues()}}),oa(d,t,a,fe.SUCCEEDED,r.metadata)}catch(e){if(e instanceof Co)throw d.finish(),e;d.finish();const n=this.toErrorPayload(e);return e instanceof Oo||!0===r.abortSignal?.aborted?(await i.emit({type:be.WORKFLOW_CANCELLED,runId:l,parentRunId:r.parentRunId,workflowId:o.workflowId,path:c,status:fe.CANCELLED,error:n}),oa(d,t,a,fe.CANCELLED,r.metadata)):(await i.emit({type:be.WORKFLOW_FAILED,runId:l,parentRunId:r.parentRunId,workflowId:o.workflowId,path:c,status:fe.FAILED,error:n}),oa(d,t,a,fe.FAILED,r.metadata))}}async executeLayer(e,t,o,a,r){const n=Math.max(1,a.concurrency??4),i=[...o];for(;i.length>0;){const o=i.splice(0,n);await Promise.all(o.map(o=>this.executeNode(e,t,o,a,r)))}}async executeNode(e,t,o,a,r){if(this.assertNotAborted(a),!this.isNodeActivated(e,t,o))return void await this.skipInactiveNode(e,t,o,a,r);if(!0===o.instance.disabled)return void await this.executeDisabledNode(e,t,o,a,r);const n=new Date,i=[...a.path??[],o.id];await r({type:be.NODE_STARTED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:fe.RUNNING}),this.emitNodeStateChanged(e,t,o,i,_e.RUNNING,fe.RUNNING,r);const d=await this.resolveNodeInputs(e,t,o,a);if(a.usePinnedValues){const a=await this.tryPinnedValue(e,t,o,d);if(a){e.valueStore.setNodeOutputs(o.id,a.outputs),this.routeOutgoingEdges(e,t,o,a.outputs,r);const s=new Date,l={nodeId:o.id,status:fe.CACHED,inputs:d,outputs:a.outputs,startedAt:n,finishedAt:s,fromCache:!0,pinned:!0,events:[]};return e.recordNodeResult(l),await r({type:be.NODE_CACHE_HIT,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:fe.CACHED,payload:{outputs:a.outputs}}),await r({type:be.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:fe.SUCCEEDED,payload:{outputs:a.outputs,fromCache:!0}}),void this.emitNodeStateChanged(e,t,o,i,_e.SUCCEEDED,fe.SUCCEEDED,r)}}try{const s=new ea(e.runId,a.parentRunId,t.workflowId,t.resolved.document,o.instance,o.manifest,i,r,a.metadata,this.engine,a.abortSignal,this.executionLimits(a)),l=await this.resolveNodeParameters(o,d,a),c={nodeId:o.id,kind:o.kind,inputs:d,parameters:l,credentials:this.collectCredentials(o),metadata:o.instance.metadata},p=await this.invokeExecutor(o,c,s),u=this.validateNodeOutputs(o,p??{});e.valueStore.setNodeOutputs(o.id,u),this.routeOutgoingEdges(e,t,o,u,r);const g=new Date,h={nodeId:o.id,status:fe.SUCCEEDED,inputs:d,outputs:u,startedAt:n,finishedAt:g,events:[]};e.recordNodeResult(h),await r({type:be.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:fe.SUCCEEDED,payload:{outputs:u}}),this.emitNodeStateChanged(e,t,o,i,_e.SUCCEEDED,fe.SUCCEEDED,r)}catch(s){if(s instanceof Co)throw s;const l=new Date,c=this.toErrorPayload(s),p={nodeId:o.id,status:fe.FAILED,inputs:d,error:c,startedAt:n,finishedAt:l,events:[]};if(e.recordNodeResult(p),await r({type:be.NODE_FAILED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:fe.FAILED,error:c}),this.emitNodeStateChanged(e,t,o,i,_e.FAILED,fe.FAILED,r),a.failFast??!0)throw s}}isNodeActivated(e,t,o){const a=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type);return 0===a.length||a.some(t=>t.sourceNodeId===lo||e.isDataEdgeActive(t.id))}async skipInactiveNode(e,t,o,a,r){const n=new Date,i=[...a.path??[],o.id];await r({type:be.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:fe.SKIPPED,payload:{reason:"branchNotSelected"}});const d={nodeId:o.id,status:fe.SKIPPED,inputs:{},startedAt:n,finishedAt:new Date,events:[]};e.recordNodeResult(d),this.emitNodeStateChanged(e,t,o,i,_e.SKIPPED,fe.SKIPPED,r)}async executeDisabledNode(e,t,o,a,r){const n=new Date,i=[...a.path??[],o.id],d=xa.disabledBehaviorOf(o.instance,t.resolved.document.settings);if(await r({type:be.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:fe.SKIPPED,payload:{disabled:!0,behavior:d}}),"skip"===d){const a={nodeId:o.id,status:fe.SKIPPED,inputs:{},startedAt:n,finishedAt:new Date,events:[]};return e.recordNodeResult(a),void this.emitNodeStateChanged(e,t,o,i,_e.SKIPPED,fe.SKIPPED,r)}const s=await this.resolveNodeInputs(e,t,o,a);let l;if("passThroughFirstInput"===d){const a=(t.incomingByNode.get(o.id)??[]).find(e=>"data"===e.type),r=o.manifest.outputs[0]?.id??"value",n=a?e.valueStore.getPort(a.sourceNodeId,a.sourcePort):Object.values(s)[0];l={[r]:n}}else{l={};for(const e of o.manifest.outputs)l[e.id]=e.metadata?.defaultValue}e.valueStore.setNodeOutputs(o.id,l),this.routeOutgoingEdges(e,t,o,l,r);const c={nodeId:o.id,status:fe.SUCCEEDED,inputs:s,outputs:l,startedAt:n,finishedAt:new Date,events:[]};e.recordNodeResult(c),this.emitNodeStateChanged(e,t,o,i,_e.SUCCEEDED,fe.SUCCEEDED,r)}async invokeExecutor(e,t,o){if((a=e.kind)===ya||a.startsWith(ya+"."))throw new Ao(`Node '${e.id}' of kind '${e.kind}' requires the mastra engine, which the local backend does not provide`,po,{nodeId:e.id,kind:e.kind,backend:co});var a;return await e.executor.execute(t,o)}validateNodeOutputs(e,t){const o=e.manifest;if(!0===o.policies?.allowUnknownOutputs)return t;const a=new Set(o.outputs.map(e=>e.id)),r=Object.keys(t).filter(e=>!a.has(e));if(r.length>0)throw new Ao(`Node '${e.id}' of kind '${e.kind}' produced unknown output(s): ${r.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,unknownOutputs:r});const n=o.outputs.filter(e=>!0===e.required&&!(e.id in t)).map(e=>e.id);if(n.length>0)throw new Ao(`Node '${e.id}' of kind '${e.kind}' did not produce required output(s): ${n.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,missingRequired:n});return t}collectCredentials(e){const t={};for(const o of e.manifest.parameters){if("credential"!==o.type)continue;const a=(e.instance.parameters??{})[o.id];"string"==typeof a&&a.length>0?t[o.id]={credentialId:a,credentialType:o.credentialType??""}:Na(a)&&(t[o.id]={credentialId:a.credentialId,credentialType:a.credentialType})}const o=(e.instance.metadata??{}).credentials;if(o&&"object"==typeof o&&!Array.isArray(o))for(const[e,a]of Object.entries(o)){const o=a;"string"==typeof o&&o.length>0?t[e]={credentialId:o,credentialType:""}:Na(o)&&(t[e]={credentialId:o.credentialId,credentialType:o.credentialType})}return t}async resolveNodeInputs(e,t,o,a){const r={},n=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type),i=new Map;for(const e of n){const t=i.get(e.targetPort)??[];t.push(e),i.set(e.targetPort,t)}for(const[t,o]of i)if(1===o.length)r[t]=e.valueStore.getPort(o[0].sourceNodeId,o[0].sourcePort);else{let a,n=!1;for(const t of o){const o=e.valueStore.getPort(t.sourceNodeId,t.sourcePort);r[t.sourcePort]=o,void 0!==o&&(a=o,n=!0)}n&&void 0===r[t]&&(r[t]=a)}const d=o.instance.inputBindings??{};for(const e of o.manifest.inputs){const t=d[e.id];if("literal"===t?.mode)r[e.id]=t.value;else if("expression"===t?.mode)r[e.id]=await this.evaluateExpressionBinding(o,t.expression,r,a);else if(void 0===r[e.id]){const t=e.metadata?.defaultValue;void 0!==t&&(r[e.id]=t)}}return r}async resolveNodeParameters(e,t,o){const a=e.instance.parameters??{},r={};for(const[n,i]of Object.entries(a))r[n]=xt(i)?await this.evaluateValueTemplate(i,e,t,o):i;return r}async evaluateValueTemplate(e,t,o,a){const r=this.codeSandboxEvaluator;if(!r)throw new Ao(`Value template on node '${t.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`,"GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{nodeId:t.id});const n=e.language??("expression"===e.mode?"javascript":"text"),i="template"===e.mode?(e=>`\`${e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(e,t)=>`\${${t}}`)}\``)(e.expression):e.expression,d=a.metadata;return await r.evaluate({code:i,language:"typescript"===n?"typescript":"javascript",input:o,vars:d?.vars??void 0,item:d?.item,index:d?.index,abortSignal:a.abortSignal})}async evaluateExpressionBinding(e,t,o,a){const r=this.codeSandboxEvaluator;if(!r)throw new Ao(`Expression binding on node '${e.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`,"GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{nodeId:e.id,expression:t});const n=a.metadata;return await r.evaluate({code:t,language:"javascript",input:o,vars:n?.vars??void 0,item:n?.item,index:n?.index,abortSignal:a.abortSignal})}async tryPinnedValue(e,t,o,a){if(!(new Da).shouldUsePinnedValue(o))return;const r=this.createPinningService(e),n=this.computeDependencyFingerprints(e,t,o.id);return r.readPinnedValue(t.workflowId,o,a,n)}computeDependencyFingerprints(e,t,o){const a=this.createPinningService(e),r=(new Pa).getDependencies(t,o),n={};for(const o of r){const r=t.nodes.find(e=>e.id===o);if(r){const i=e.nodeResults.get(o),d=i?.inputs??{},s=this.computeDependencyFingerprints(e,t,o);n[o]=a.computeFingerprint(t.workflowId,r,d,s)}}return n}routeOutgoingEdges(e,t,o,a,r){const n=(t.outgoingByNode.get(o.id)??[]).filter(e=>"data"===e.type);for(const i of n){if(!Object.prototype.hasOwnProperty.call(a,i.sourcePort))continue;const n=a[i.sourcePort];e.activateDataEdge(i.id),i.targetNodeId===lo&&e.valueStore.setWorkflowOutput(i.targetPort,n),this.emitEdgeStateChanged(e,t,o,i,_e.SUCCEEDED,fe.SUCCEEDED,r),r({type:be.EDGE_VALUE_ROUTED,runId:e.runId,workflowId:t.workflowId,edgeId:i.id,nodeId:o.id,path:[],payload:{edge:i,value:n}}).catch(()=>{})}}emitNodeStateChanged(e,t,o,a,r,n,i){i({type:be.NODE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:n,payload:{nodeId:o.id,state:r,runId:e.runId,workflowId:t.workflowId,status:n}}).catch(()=>{})}emitEdgeStateChanged(e,t,o,a,r,n,i){i({type:be.EDGE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,edgeId:a.id,nodeId:o.id,path:[],status:n,payload:{edgeId:a.id,state:r,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,status:n}}).catch(()=>{})}createPinningService(e){const t=Ra(e.valueStore.getAdapter()??this.valueAdapter);return new Ca(t,new Da,new Pa)}executionLimits(e){return{maxLoopIterations:e.maxLoopIterations??uo,maxForeachIterations:e.maxForeachIterations??go}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new Oo(e.runId??"unknown")}toErrorPayload(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}}const Ma={execute:()=>{throw new Ao("A deployment-projection node cannot be executed by the facade; the backend must bind and run the authoritative deployment artifact","GRAPH_DEPLOYMENT_PROJECTION_NOT_EXECUTABLE")}};function Fa(e){return{kind:e,display:{name:e},inputs:[],outputs:[],parameters:[],policies:{allowUndeclaredParameters:!0,allowUnknownOutputs:!0}}}class La{constructor(e,t={}){this.catalogue=e,this.options=t}async resolveNodes(e,t,o,...a){const r=new Map;for(const[n,i]of e.entries()){const e=`nodes[${n}]`;if(this.catalogue.has(i.kind,...a))try{const e=await this.catalogue.resolveManifest(i.kind,i,o,...a),t=this.catalogue.getExecutor(i.kind,...a);r.set(i.id,{instance:i,manifest:e,executor:t})}catch(o){t.push({code:"kind.resolution-failed",path:e+".kind",message:`Node '${i.id}' kind '${i.kind}' failed to resolve: ${o.message}`,nodeId:i.id,details:{kind:i.kind}})}else{if(!0===this.options.deploymentProjection){r.set(i.id,{instance:i,manifest:Fa(i.kind),executor:Ma});continue}t.push({code:"kind.unknown",path:e+".kind",message:`Node '${i.id}' references kind '${i.kind}' which is not registered in the backend catalogue`,nodeId:i.id,details:{kind:i.kind}})}}return r}validateEffectivePorts(e,t,o,a){const r=!0===t.policies?.allowUndeclaredParameters,n=new Set(t.inputs.map(e=>e.id)),i=new Set(t.outputs.map(e=>e.id));for(const i of Object.keys(e.inputBindings??{}))r||n.has(i)||o.push({code:"binding.unknown-port",path:`${a}.inputBindings.${i}`,message:`Node '${e.id}' input binding '${i}' does not refer to an effective input port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveInputs:[...n]}});for(const n of Object.keys(e.outputBindings??{}))r||i.has(n)||o.push({code:"binding.unknown-port",path:`${a}.outputBindings.${n}`,message:`Node '${e.id}' output binding '${n}' does not refer to an effective output port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveOutputs:[...i]}})}}function ja(e,t,o="$"){const a=new Set;for(const t of e.edges)"node"===t.source.scope&&a.add(t.source.nodeId),"node"===t.target.scope&&a.add(t.target.nodeId);for(const r of e.nodes){a.has(r.id)||t.push({code:"topology.loose-node",path:`${o}.nodes[${r.id}]`,message:`Node '${r.id}' is connected to nothing; every node must participate in at least one edge`,nodeId:r.id});const e=r.loop?.body;e&&ja(e,t,`${o}.nodes[${r.id}].loop.body`)}}class qa{resolveEdges(e,t,o){const a=new Set(e.inputs.map(e=>e.id)),r=new Set(e.outputs.map(e=>e.id)),n=[];for(const[i,d]of(e.edges??[]).entries()){const e=`edges[${i}]`,s=this.resolveEndpoint(d,"source",t,a,r,o,e),l=this.resolveEndpoint(d,"target",t,a,r,o,e);if(!s||!l)continue;if(!this.validateDirectionAndType(d,s,l,t,o,e))continue;const c={id:d.id,type:d.type,sourceNodeId:s.nodeId,sourcePort:s.port,targetNodeId:l.nodeId,targetPort:l.port,metadata:d.metadata,edge:d};void 0!==d.label&&(c.label=d.label),n.push(c)}return n}resolveEndpoint(e,t,o,a,r,n,i){const d=e[t];return lt(d)?("source"===t?a.has(d.port):r.has(d.port))?{nodeId:lo,port:d.port}:void n.push({code:"edge.unknown-port",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} references workflow port '${d.port}' which is not declared on the document boundary`,edgeId:e.id,details:{scope:"workflow",port:d.port}}):ct(d)?o.get(d.nodeId)?{nodeId:d.nodeId,port:d.port}:void n.push({code:"edge.unknown-node",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} references node '${d.nodeId}' which is not part of the document or did not resolve`,edgeId:e.id,nodeId:d.nodeId}):void n.push({code:"edge.invalid-endpoint",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} endpoint is not a valid GraphEndpoint`,edgeId:e.id})}validateDirectionAndType(e,t,o,a,r,n){let i=!0;const d=t.nodeId===lo?void 0:a.get(t.nodeId),s=o.nodeId===lo?void 0:a.get(o.nodeId),l=e=>!0===e?.manifest.policies?.allowUndeclaredParameters;if("data"===e.type)!d||l(d)||this.hasPortDirection(d,t.port,"output")||(this.pushPortIssue(e,"source",t,d,r,n),i=!1),!s||l(s)||this.hasPortDirection(s,o.port,"input")||(this.pushPortIssue(e,"target",o,s,r,n),i=!1);else{if(!d||!s)return r.push({code:"edge.boundary-routing",path:n,message:`Connection edge '${e.id}' must connect two node connection ports; the workflow boundary only routes data`,edgeId:e.id}),!1;if(!(l(d)||l(s)||this.hasPortDirection(d,t.port,"connection")&&this.hasPortDirection(s,o.port,"connection")))return r.push({code:"edge.type-mismatch",path:n,message:`Connection edge '${e.id}' endpoints must both be connection ports`,edgeId:e.id,details:{sourcePort:t.port,targetPort:o.port}}),!1}return i}hasPortDirection(e,t,o){return("input"===o?e.manifest.inputs:"output"===o?e.manifest.outputs:e.manifest.connections??[]).some(e=>e.id===t)}pushPortIssue(e,t,o,a,r,n){const i="source"===t?"output":"input";r.push({code:"data"===e.type?"edge.invalid-direction":"edge.type-mismatch",path:`${n}.${t}`,message:`Edge '${e.id}' ${t} port '${o.port}' on node '${o.nodeId}' is not an ${i} port of kind '${a.manifest.kind}'`,edgeId:e.id,nodeId:o.nodeId,details:{port:o.port,expected:i}})}}class Ha{validate(e,t){this.validateDuplicates(e.edges,t),this.validatePolicies(e,t)}validateDuplicates(e,t){const o=new Map;for(const a of e){const e=`${a.sourceNodeId}:${a.sourcePort}->${a.targetNodeId}:${a.targetPort}`,r=o.get(e);r?t.push({code:"connection.duplicate-edge",path:`edges[${a.id}]`,message:`Edge '${a.id}' duplicates the routing of edge '${r.id}' (${e})`,edgeId:a.id,details:{duplicateOf:r.id,routing:e}}):o.set(e,a)}}validatePolicies(e,t){const o=new Map;for(const t of e.edges){if("connection"!==t.type)continue;const e=`${t.targetNodeId}:${t.targetPort}`,a=o.get(e)??[];a.push(t),o.set(e,a)}for(const o of e.edges){if("connection"!==o.type)continue;const a=e.nodeById.get(o.targetNodeId),r=a?.manifest.connections?.find(e=>e.id===o.targetPort)?.connectionPolicy;this.validateEdgePolicy(o,e.nodeById,r,t),this.validateCategoryMatch(o,e.nodeById,t)}for(const[a,r]of o){const o=a.lastIndexOf(":"),n=a.slice(0,o),i=a.slice(o+1),d=e.nodeById.get(n),s=d?.manifest.connections?.find(e=>e.id===i)?.connectionPolicy;if(!s)continue;const l=void 0!==s.maxConnections?s.maxConnections:!1===s.allowMultiple?1:1/0;r.length>l&&t.push({code:"connection.max-connections",path:`edges[${r[r.length-1].id}]`,message:`Connection port '${i}' on node '${n}' accepts at most ${l} connection(s) but has ${r.length}`,nodeId:n,edgeId:r[r.length-1].id,details:{port:i,max:l,actual:r.length}})}}validateCategoryMatch(e,t,o){const a=t.get(e.sourceNodeId),r=t.get(e.targetNodeId),n=a?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category,i=r?.manifest.connections?.find(t=>t.id===e.targetPort)?.category;n&&i&&n!==i&&o.push({code:"connection.category-mismatch",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' joins source port '${e.sourcePort}' (category '${n}') to target port '${e.targetPort}' (category '${i}'); connection categories must match`,edgeId:e.id,nodeId:e.sourceNodeId,details:{sourceCategory:n,targetCategory:i}})}validateEdgePolicy(e,t,o,a){if(e.sourceNodeId===e.targetNodeId&&!o?.allowSelf)return void a.push({code:"connection.self-connection",path:`edges[${e.id}]`,message:`Edge '${e.id}' connects node '${e.sourceNodeId}' to itself, which the target port policy does not allow`,edgeId:e.id,nodeId:e.sourceNodeId});if(!o)return;const r=t.get(e.sourceNodeId),n=r?.manifest.kind;if(!o.allowedNodeKinds?.length||n&&o.allowedNodeKinds.includes(n)||a.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${n??"unknown"}' is not in the allowed node kinds of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedNodeKinds:o.allowedNodeKinds}}),n&&o.blockedNodeKinds?.includes(n)&&a.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${n}' is blocked by target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{blockedNodeKinds:o.blockedNodeKinds}}),o.allowedPortCategories?.length){const t=r?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category;t&&o.allowedPortCategories.includes(t)||a.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source port '${e.sourcePort}' category '${t??"unknown"}' is not in the allowed port categories of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedPortCategories:o.allowedPortCategories}})}}}class Ua{constructor(e){this.authorizer=e}async validate(e,t,o,a){const r=this.collectReferences(e,t);for(const n of t.credentials??[]){const i=r.find(e=>void 0===e.credentialType||e.credentialType===n.type);if(i){if(this.checkType(i,n))o.push({code:"credential.type-mismatch",path:a,message:`Node '${e.id}' credential '${i.credentialId}' has type '${i.credentialType}' but kind '${t.kind}' requires '${n.type}'`,nodeId:e.id,details:{credentialType:i.credentialType??"",requiredType:n.type}});else if(this.authorizer){if(!await this.authorizer.hasCredential(i)){o.push({code:"credential.not-found",path:a,message:`Node '${e.id}' references credential '${i.credentialId}' which does not exist`,nodeId:e.id,details:{credentialId:i.credentialId}});continue}await this.authorizer.authorize(i,n)||o.push({code:"credential.unauthorized",path:a,message:`Node '${e.id}' is not authorized to use credential '${i.credentialId}'`,nodeId:e.id,details:{credentialId:i.credentialId}})}}else!1!==n.required&&o.push({code:"credential.missing",path:a,message:`Node '${e.id}' does not provide the required credential of type '${n.type}'`,nodeId:e.id,details:{credentialType:n.type}})}this.scanPlainSecrets(e,o,a)}collectReferences(e,t){const o=[];for(const a of t.parameters){if("credential"!==a.type)continue;const t=(e.parameters??{})[a.id];Na(t)&&o.push(this.normalize(t,a.credentialType))}const a=(e.metadata??{}).credentials;if(a&&"object"==typeof a&&!Array.isArray(a))for(const e of Object.values(a))Na(e)&&o.push(this.normalize(e));return o}normalize(e,t){return"string"==typeof e?{credentialId:e,credentialType:t??""}:{credentialId:e.credentialId,credentialType:e.credentialType??t??""}}checkType(e,t){return void 0!==e.credentialType&&e.credentialType!==t.type}scanPlainSecrets(e,t,o){const a=new Set(Aa.map(e=>e.toLowerCase()));for(const[r,n]of Object.entries(e.parameters??{}))this.scanPlainSecretValue(n,[r],e,o+".parameters",a,t);for(const[r,n]of Object.entries(e.metadata??{}))this.scanPlainSecretValue(n,[r],e,o+".metadata",a,t)}scanPlainSecretValue(e,t,o,a,r,n,i=0){const d=t[t.length-1];if(r.has(d.toLowerCase()))n.push({code:"credential.plain-secret",path:`${a}.${t.join(".")}`,message:`Node '${o.id}' carries plain secret material in '${t.join(".")}'; workflow documents may only hold credential references`,nodeId:o.id});else if(8>i&&null!==e)if(Array.isArray(e))for(const d of e)this.scanPlainSecretValue(d,[...t,"[]"],o,a,r,n,i+1);else if("object"==typeof e)for(const[d,s]of Object.entries(e))this.scanPlainSecretValue(s,[...t,d],o,a,r,n,i+1)}}class Ba extends n.ValidationError{constructor(e,t=[]){super(e),this.issues=t,this.name=Ba.name}}class $a extends n.ValidationError{constructor(e,t){super(e),this.edgeId=t,this.name=$a.name}}class Wa extends d.AuthorizationError{constructor(e){super(e),this.name=Wa.name}}const Va={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},Ka=["node","definition","executor","execute","ports","component"];function za(e){if(!e||"object"!=typeof e)return!1;const t=e;return It(t.document)&&Array.isArray(t.nodes)&&Array.isArray(t.edges)&&t.nodeById instanceof Map&&t.incomingByNode instanceof Map&&t.outgoingByNode instanceof Map&&t.nodes.every(e=>null!==e&&"object"==typeof e&&"object"==typeof e.instance&&"object"==typeof e.manifest&&"object"==typeof e.executor)}function Qa(e,t){const o=[];for(const a of Object.keys(e))Ka.includes(a)&&o.push({code:"document.forbidden-field",path:`${t}.${a}`,message:`Field '${a}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected`,details:{field:a}});return o}class Ja{constructor(e){this.options=e,this.parameterValidator=new xa,this.edgeValidator=new qa,this.connectionPolicyValidator=new Ha,this.nodeValidator=new La(e.catalogue,{deploymentProjection:!0===e.deploymentProjection}),this.credentialValidator=new Ua(e.credentialAuthorizer)}async validateOrThrow(e,...t){const o=await this.validate(e,0,...t);if(!o.valid||!o.resolved)throw new Ba(`Graph workflow document '${e.id}' failed validation with ${o.issues.length} issue(s)`,o.issues);return o.resolved}async validate(e,t=0,...o){const a=[],r={...Va,...this.options.limits};if(!await this.validateStructure(e,r,t,a,...o))return{valid:!1,issues:a};const n=await this.nodeValidator.resolveNodes(e.nodes,a,this.options.resolutionContext,...o),i=e.nodes.filter(e=>n.has(e.id)).map(e=>n.get(e.id)),d=(e=>{const t=new Map;for(const o of e.edges??[]){if("data"!==o.type)continue;const e=o.target;if("node"!==e.scope)continue;const a=t.get(e.nodeId)??new Set;a.add(e.port),t.set(e.nodeId,a)}return t})(e);for(const e of i)this.parameterValidator.validate(e.instance,e.manifest,a,`nodes[${e.instance.id}]`,d.get(e.instance.id));for(const e of i)this.nodeValidator.validateEffectivePorts(e.instance,e.manifest,a,`nodes[${e.instance.id}]`);const s=this.edgeValidator.resolveEdges(e,n,a),l=new Map,c=new Map;for(const e of s){if(e.targetNodeId!==lo){const t=l.get(e.targetNodeId)??[];t.push(e),l.set(e.targetNodeId,t)}if(e.sourceNodeId!==lo){const t=c.get(e.sourceNodeId)??[];t.push(e),c.set(e.sourceNodeId,t)}}this.connectionPolicyValidator.validate({edges:s,nodeById:n},a),this.validateAcyclicity(i,s,e,a),!0!==this.options.deploymentProjection&&ja(e,a);for(const e of i)this.parameterValidator.validateBindingSatisfaction(e.instance,e.manifest,l.get(e.instance.id)??[],a,`nodes[${e.instance.id}]`,{allowLiteralAndEdgeBindings:this.options.allowLiteralAndEdgeBindings});this.validateRequiredWorkflowOutputs(e,c,a);for(const e of i)await this.credentialValidator.validate(e.instance,e.manifest,a,`nodes[${e.instance.id}]`);return this.validateCapabilities(i,a),a.length>0?{valid:!1,issues:a}:{valid:!0,issues:a,resolved:{document:e,nodes:i,edges:s,nodeById:n,incomingByNode:l,outgoingByNode:c}}}async validateStructure(e,t,o,a,...r){if(!It(e))return a.push({code:"document.shape",path:"$",message:"Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays"}),!1;if(e.id&&e.id.trim()||a.push({code:"document.empty-id",path:"$.id",message:"Workflow document id must be a non-empty string"}),!Je(e))return a.push({code:"document.json-unsafe",path:"$",message:"Document contains JSON-unsafe values: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys are rejected"}),!1;a.push(...Qa(e,"$"));for(const t of[...e.inputs,...e.outputs])a.push(...Qa(t,"ports"));for(const t of e.nodes)a.push(...Qa(t,`nodes[${t.id}]`));for(const t of e.edges)a.push(...Qa(t,`edges[${t.id}]`));this.validateUniqueIds(e,a),this.validateLimits(e,t,o,a);try{mt(e)}catch(e){a.push({code:"document.structure",path:"$",message:e instanceof Error?e.message:e+""})}return await this.validateNestedBodies(e,o,a,...r),!0}validateUniqueIds(e,t){const o=new Set,a=new Set;for(const[r,n]of[["input",e.inputs],["output",e.outputs]]){const e="input"===r?o:a;for(const o of n)e.has(o.id)?t.push({code:"document.duplicate-port-id",path:`${"input"===r?"inputs":"outputs"}[${o.id}]`,message:`Workflow ${r} port '${o.id}' is declared more than once; workflow port ids must be unique`}):e.add(o.id)}const r=new Set;for(const o of e.nodes)r.has(o.id)?t.push({code:"document.duplicate-node-id",path:`nodes[${o.id}]`,message:`Node '${o.id}' is declared more than once; node ids must be unique`,nodeId:o.id}):r.add(o.id);const n=new Set;for(const o of e.edges)n.has(o.id)?t.push({code:"document.duplicate-edge-id",path:`edges[${o.id}]`,message:`Edge '${o.id}' is declared more than once; edge ids must be unique`,edgeId:o.id}):n.add(o.id)}validateLimits(e,t,o,a){e.nodes.length>t.maxNodes&&a.push({code:"document.limit.nodes",path:"$.nodes",message:`Document declares ${e.nodes.length} nodes; at most ${t.maxNodes} are allowed`,details:{count:e.nodes.length,limit:t.maxNodes}}),e.edges.length>t.maxEdges&&a.push({code:"document.limit.edges",path:"$.edges",message:`Document declares ${e.edges.length} edges; at most ${t.maxEdges} are allowed`,details:{count:e.edges.length,limit:t.maxEdges}}),o>t.maxNestingDepth&&a.push({code:"document.limit.depth",path:"$",message:`Document nests loop bodies ${o} levels deep; at most ${t.maxNestingDepth} levels are allowed`,details:{depth:o,limit:t.maxNestingDepth}});const r=Buffer.byteLength(JSON.stringify(e),"utf8");r>t.maxDocumentBytes&&a.push({code:"document.limit.size",path:"$",message:`Document serializes to ${r} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,details:{bytes:r,limit:t.maxDocumentBytes}})}async validateNestedBodies(e,t,o,...a){for(const r of e.nodes){const e=[["loop.body",r.loop?.body],["errorBoundary.try",r.errorBoundary?.try],["errorBoundary.catch",r.errorBoundary?.catch],["errorBoundary.finally",r.errorBoundary?.finally]];for(const[n,i]of e){if(!i)continue;const e=await this.validate(i,t+1,...a);for(const t of e.issues)o.push({...t,path:`nodes[${r.id}].${n}.${t.path}`,nodeId:t.nodeId??r.id})}}}validateAcyclicity(e,t,o,a){const r=new Set(e.map(e=>e.instance.id)),n=new Map(e.map(e=>[e.instance.id,0]));for(const e of t)r.has(e.sourceNodeId)&&n.has(e.targetNodeId)&&n.set(e.targetNodeId,(n.get(e.targetNodeId)??0)+1);const i=[...n.entries()].filter(([,e])=>0===e).map(([e])=>e),d=[];for(;i.length>0;){const e=i.shift();d.push(e);for(const o of t){if(o.sourceNodeId!==e)continue;if(!n.has(o.targetNodeId))continue;const t=(n.get(o.targetNodeId)??1)-1;n.set(o.targetNodeId,t),0===t&&i.push(o.targetNodeId)}}if(d.length!==n.size){const e=[...n.keys()].filter(e=>!d.includes(e));a.push({code:"topology.cycle",path:"$.edges",message:`Workflow '${o.id}' contains an unsupported cycle involving node(s): ${e.join(", ")}`,details:{cyclicNodes:e}})}}validateRequiredWorkflowOutputs(e,t,o){const a=new Set;for(const e of t.values())for(const t of e)t.targetNodeId===lo&&a.add(t.targetPort);for(const t of e.outputs)!0===t.required&&void 0===t.defaultValue&&(a.has(t.id)||o.push({code:"topology.required-output-unsatisfiable",path:`outputs[${t.id}]`,message:`Required workflow output '${t.id}' has no incoming edge from any node`}))}validateCapabilities(e,t){for(const o of e){const e=o.manifest;for(const a of e.capabilities??[])Rt(a)||t.push({code:"capability.invalid",path:`nodes[${o.instance.id}]`,message:`Kind '${e.kind}' declares unknown capability '${a+""}'`,nodeId:o.instance.id,details:{capability:a+""}});!0!==e.policies?.allowUndeclaredParameters&&o.instance.loop&&((e.capabilities??[]).includes("loop")||t.push({code:"capability.loop-not-supported",path:`nodes[${o.instance.id}].loop`,message:`Node '${o.instance.id}' carries loop configuration but kind '${e.kind}' does not declare the 'loop' capability`,nodeId:o.instance.id}))}}}e.GraphExecutionPlanner=class extends d.Service{constructor(){super()}async plan(e,...t){const{log:o}=(await this.logCtx(t,"plan",!0)).for(this.plan);if(o.debug(`Planning resolved workflow '${e?.document?.id??"unknown"}'`),!za(e))throw new To("GraphExecutionPlanner.plan accepts only a GraphResolvedWorkflow produced by the nine-stage validation gate; raw workflow definitions and inline node definitions are rejected",{received:(a=e,a&&"object"==typeof a?{reason:"input is not a GraphResolvedWorkflow",looksLikeWorkflowDefinition:"nodes"in a&&"relations"in a&&!("nodeById"in a),hasResolvedNodes:Array.isArray(a.nodes)}:{reason:"input is not an object"})});var a;const r=this.buildPlanNodes(e),n=this.buildPlanEdges(e),i=this.buildIncomingMap(n),d=this.buildOutgoingMap(n),s=this.topologicalLayers(r,n);return{resolved:e,workflowId:e.document.id||e.document.name,nodes:r,edges:n,layers:s,incomingByNode:i,outgoingByNode:d}}buildPlanNodes(e){return e.nodes.map(e=>({id:e.instance.id,kind:e.manifest.kind,instance:e.instance,manifest:e.manifest,executor:e.executor,inputPorts:e.manifest.inputs.map(e=>e.id),outputPorts:e.manifest.outputs.map(e=>e.id),connectionPorts:(e.manifest.connections??[]).map(e=>e.id),metadata:e.instance.metadata}))}buildPlanEdges(e){return e.edges.map(e=>({id:e.id,type:e.type,sourceNodeId:e.sourceNodeId,sourcePort:e.sourcePort,targetNodeId:e.targetNodeId,targetPort:e.targetPort,...void 0!==e.label?{label:e.label}:{},metadata:e.metadata}))}buildIncomingMap(e){const t=new Map;for(const o of e){if(o.targetNodeId===lo)continue;const e=t.get(o.targetNodeId)??[];e.push(o),t.set(o.targetNodeId,e)}return t}buildOutgoingMap(e){const t=new Map;for(const o of e){if(o.sourceNodeId===lo)continue;const e=t.get(o.sourceNodeId)??[];e.push(o),t.set(o.sourceNodeId,e)}return t}topologicalLayers(e,t){const o=e.filter(e=>e.id!==lo),a=new Set(o.map(e=>e.id)),r=t.filter(e=>a.has(e.sourceNodeId)&&a.has(e.targetNodeId)),n=new Map;for(const e of o)n.set(e.id,0);for(const e of r)n.set(e.targetNodeId,(n.get(e.targetNodeId)??0)+1);const i=[],d=new Set;let s=o.filter(e=>0===(n.get(e.id)??0)),l=0;for(;s.length>0;){const e={index:l++,nodes:s};i.push(e);const t=[];for(const e of s){d.add(e.id);const a=r.filter(t=>t.sourceNodeId===e.id);for(const e of a){const a=(n.get(e.targetNodeId)??1)-1;if(n.set(e.targetNodeId,a),0===a&&!d.has(e.targetNodeId)){const a=o.find(t=>t.id===e.targetNodeId);a&&t.push(a)}}}s=t}if(d.size!==o.length){const e=o.filter(e=>!d.has(e.id)).map(e=>e.id);throw new xo({unplannedNodes:e,workflowId:o[0]?.manifest.kind})}return i}},e.GraphExecutionPlanner=i.__decorate([d.service(),i.__metadata("design:paramtypes",[])],e.GraphExecutionPlanner);class Xa{constructor(){this.pending=new Map}register(e,t){return this.cancel(e),new Promise((o,a)=>{const r={resolve:o};void 0!==t&&Number.isFinite(t)&&t>0&&(r.timer=setTimeout(()=>{this.pending.delete(e),a(new Ao(`No webhook response was produced for run '${e}' within ${t}ms`,"GRAPH_WEBHOOK_RESPONSE_TIMEOUT",{runId:e,timeoutMs:t}))},t),r.timer.unref?.()),this.pending.set(e,r)})}has(e){return this.pending.has(e)}deliver(e,t){const o=this.pending.get(e);return!!o&&(o.timer&&clearTimeout(o.timer),this.pending.delete(e),o.resolve(t),!0)}cancel(e){const t=this.pending.get(e);t&&(t.timer&&clearTimeout(t.timer),this.pending.delete(e))}clear(){for(const e of[...this.pending.keys()])this.cancel(e)}}e.GraphDataTableModel=class extends d.BaseModel{constructor(e){super(e)}},i.__decorate([d.pk({type:String,generated:!1}),i.__metadata("design:type",String)],e.GraphDataTableModel.prototype,"id",void 0),i.__decorate([d.column(),d.index(),i.__metadata("design:type",String)],e.GraphDataTableModel.prototype,"tableName",void 0),i.__decorate([d.column(),d.index(),i.__metadata("design:type",String)],e.GraphDataTableModel.prototype,"rowId",void 0),i.__decorate([d.column(),i.__metadata("design:type",Object)],e.GraphDataTableModel.prototype,"data",void 0),i.__decorate([d.column(),i.__metadata("design:type",Date)],e.GraphDataTableModel.prototype,"createdAt",void 0),i.__decorate([d.column(),i.__metadata("design:type",Date)],e.GraphDataTableModel.prototype,"updatedAt",void 0),e.GraphDataTableModel=i.__decorate([d.table("graph_data_table"),r.model(),i.__metadata("design:paramtypes",[Object])],e.GraphDataTableModel);const Ya=/^[A-Za-z0-9_.-]+$/;function Za(e,t){return`${e}:${t}`}function er(e){if(!e||e.length>128||!Ya.test(e))throw new Ao(`Data table name '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_NAME",{tableName:e})}function tr(e){if(!e||e.length>256)throw new Ao(`Data table row id '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_ROW_ID",{rowId:e})}function or(e){let t;try{t=JSON.stringify(e)}catch{throw new Ao("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:bo})}if(void 0===t)throw new Ao("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:bo});const o=Buffer.byteLength(t,"utf8");if(o>bo)throw new Ao("Data table row payload exceeds the 1048576-byte limit","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{bytes:o,limitBytes:bo})}function ar(e){return{...e.data,id:e.rowId}}function rr(t){return new(0,d.Repository.forModel(e.GraphDataTableModel,t.alias).constructor)(t)}e.GraphDataTableRepository=class extends d.Repository{constructor(t){super(t,e.GraphDataTableModel,!0)}async insertRow(t,o,a,...r){er(t),tr(o),or(a),await this.assertRowCapacity(t,...r);const n=new Date,i=new e.GraphDataTableModel({id:Za(t,o),tableName:t,rowId:o,data:{...a},createdAt:n,updatedAt:n});return ar(await this.create(i,...r))}async upsertRow(e,t,o,...a){if(er(e),tr(t),or(o),!await this.readRow(e,t,...a))return this.insertRow(e,t,o,...a);const r=await this.read(Za(e,t),...a);return r.data={...o},r.updatedAt=new Date,ar(await this.update(r,...a))}async readRow(e,t,...o){er(e),tr(t);try{return ar(await this.read(Za(e,t),...o))}catch{return}}async listRows(e,t,...o){er(e);const a=void 0!==t&&Number.isFinite(t)&&t>=0?Math.floor(t):wo;if(0===a)return[];const r=Math.min(a,wo);return(await this.select().where(d.Condition.attr("tableName").eq(e)).orderBy("rowId",d.OrderDirection.ASC).limit(r).execute(...o)).map(ar)}async assertRowCapacity(e,...t){if((await this.listRows(e,yo,...t)).length>=yo)throw new Ao(`Data table '${e}' reached the 10000-row limit`,"GRAPH_DATA_TABLE_ROW_LIMIT_EXCEEDED",{tableName:e,limit:yo})}async deleteRow(e,t,...o){er(e),tr(t);try{return await this.delete(Za(e,t),...o),!0}catch{return!1}}async clearTable(e,...t){const o=await this.listRows(e,void 0,...t);for(const a of o)await this.deleteRow(e,a.id+"",...t);return o.length}},e.GraphDataTableRepository=i.__decorate([d.repository(e.GraphDataTableModel,a.DefaultFlavour),i.__metadata("design:paramtypes",[Function])],e.GraphDataTableRepository);const nr=new Set(["engine","valueAdapter","codeSandboxEvaluator","workflowStore"]);function ir(e){for(let t=e.length-1;t>=0;t-=1){const o=e[t];if(!o||"object"!=typeof o)continue;const a=o;if("function"==typeof a.get&&"function"==typeof a.accumulate&&void 0!==a.cache)return Vo(o)}return{}}function dr(e,t){const o={};for(const[a,r]of Object.entries(e??{}))nr.has(a)&&!t.has(a)||(o[a]=r);return o}class sr extends d.ClientBasedService{constructor(){super(),this.webhookResponseRegistry=new Xa,this.runSubWorkflowDepth=new Map,this.runRootId=new Map,this.rootChildRunCounts=new Map}async initialize(...t){const o=t[0];if(!o||"object"!=typeof o||!o.registry)return this._config=void 0,this._client=void 0,{config:void 0,client:void 0};const a=o.catalogue??o.registry.catalog,r=o.valueAdapter??d.Adapter.current;if(!r)throw new Ao("GraphExecutionEngine requires a Decaf adapter for cached/pinned values: pass `valueAdapter` or configure one via `Adapter.setCurrent(...)`","GRAPH_VALUE_ADAPTER_MISSING");const n=o.backend??na.current??new Ga;if("deployment"===n.documentValidation&&n.local)throw new Ao("A local execution backend cannot declare deployment document validation: deployment projection relaxes catalogue kind resolution and must stay bound to the remote backend that owns the authoritative deployment artifact","GRAPH_DEPLOYMENT_PROJECTION_REQUIRES_REMOTE_BACKEND");const i={registry:o.registry,catalogue:a,planner:o.planner??new e.GraphExecutionPlanner,backend:n,valueAdapter:r,eventEmitter:o.eventEmitter??new Do,documentValidator:o.documentValidator??new Ja({catalogue:a,limits:o.documentLimits,credentialAuthorizer:o.credentialAuthorizer,deploymentProjection:"deployment"===n.documentValidation}),authValidator:new Qo({enabled:!0===o.authEnabled,...o.authMatch?{match:o.authMatch}:{}}),...o.codeSandboxEvaluator?{codeSandboxEvaluator:o.codeSandboxEvaluator}:{},...o.nodeCredentials?{nodeCredentials:new Jo(o.nodeCredentials)}:{}};this._config=o,this._client=i;const s=new Set(["engine","valueAdapter"]);o.codeSandboxEvaluator&&s.add("codeSandboxEvaluator"),o.workflowStore&&s.add("workflowStore");const l=dr(n.config,s);if(await n.initialize({...l,valueAdapter:r,...o.codeSandboxEvaluator?{codeSandboxEvaluator:o.codeSandboxEvaluator}:{},...o.workflowStore?{workflowStore:o.workflowStore}:{},engine:this}),o.seedWorkflows&&o.seedWorkflows.length>0){const e=n.seedWorkflows;if("function"!=typeof e)throw new Ao(`Graph execution backend '${n.constructor?.name??"GraphExecutionBackend"}' does not support workflow seeding`,"GRAPH_BACKEND_SEED_NOT_SUPPORTED",{backend:n.constructor?.name??"GraphExecutionBackend"});await e.call(n,o.seedWorkflows,...t.slice(1))}return await(o.onEngineCreated?.(this)),{config:o,client:i}}get codeSandboxEvaluator(){return this.client.codeSandboxEvaluator}get nodeCredentials(){return this.client.nodeCredentials}get dataTableStore(){return this.dataTableRepository||(this.dataTableRepository=rr(this.valueAdapter)),this.dataTableRepository}get webhookResponses(){return this.webhookResponseRegistry}get emitter(){return this.client.eventEmitter}get planner(){return this.client.planner}get valueAdapter(){return this.client.valueAdapter}get defaultOptions(){return this.config.defaultOptions??{}}get documentValidator(){return this.client.documentValidator}async validateWorkflowDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateWorkflowDocument",!0)).for(this.validateWorkflowDocument);return this.documentValidator.validate(e,0,o)}observe(e){return this.emitter.observe(e)}unObserve(e){this.emitter.unObserve(e)}async dispatchEvent(e){await this.emitter.updateObservers(e)}async execute(e,t={},o={},...a){const{log:r,ctx:n}=(await this.logCtx(a,"execute",!0)).for(this.execute);r.debug(`Executing workflow '${e.id||e.name}'`);const i=this.mergeOptions(o);this.assertNotAborted(i);const d=zo(Vo(n),i.auth);i.auth=d,i.metadata={...i.metadata??{},...d};const s=i.runId??this.generateRunId();i.runId=s;const l=i.path??[];this.enterExecutionBudget(s,i);try{const o=new Po,c=Ra(this.valueAdapter);c.seedWorkflowInputs(this.withWorkflowInputDefaults(e,t));const p=new aa(this.emitter,o,{runId:s,parentRunId:i.parentRunId,workflowId:e.id||e.name,path:l,engine:this,...this.codeSandboxEvaluator?{codeSandboxEvaluator:this.codeSandboxEvaluator}:{}});await p.emit({type:be.VALIDATION_STARTED,status:fe.PLANNING});const u=await this.documentValidator.validate(e,0,n);if(!u.valid||!u.resolved)throw await p.emit({type:be.VALIDATION_FAILED,status:fe.FAILED,payload:{issues:u.issues}}),new Ba(`Graph workflow document '${e.id}' failed validation with ${u.issues.length} issue(s)`,u.issues);await p.emit({type:be.VALIDATION_COMPLETED,status:fe.PLANNING,payload:{issues:u.issues.length}}),this.assertNotAborted(i);const g=await this.planner.plan(u.resolved);this.client.authValidator.validate(e,g,d,r),r.debug(`Authorized workflow '${e.id||e.name}' for user ${d.user??"anonymous"}`),this.assertCodeModeSupported(e);const h=new ta(s,g,c,o);return p.bindFrame(h),await p.emit({type:be.WORKFLOW_STARTED,runId:s,parentRunId:i.parentRunId,workflowId:g.workflowId,path:l,status:fe.RUNNING,payload:{inputs:t}}),await p.emit({type:be.WORKFLOW_PLANNED,runId:s,parentRunId:i.parentRunId,workflowId:g.workflowId,path:l,status:fe.PLANNING,payload:{layers:g.layers.length,nodes:g.nodes.length}}),await this.client.backend.execute({document:e,plan:g,inputs:t,options:i,events:p},...a)}finally{this.releaseExecutionBudget(s)}}get backend(){return this.client.backend}get backendCapabilities(){return ra(this.client.backend)}async listWorkflows(...e){const t=this.client.backend;if("supported"!==ra(t).workflows.list||"function"!=typeof t.listWorkflows)throw new Ao(`Graph execution backend '${this.backendName}' does not support workflow listing`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:this.backendName});return await t.listWorkflows(...e)}async getWorkflow(e,...t){const o=this.client.backend;if("supported"!==ra(o).workflows.get||"function"!=typeof o.getWorkflow)throw new Ao(`Graph execution backend '${this.backendName}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:this.backendName,workflowId:e});const a=await o.getWorkflow(e,...t);return this.assertWorkflowReadAccess(a,ir(t)),a}assertWorkflowReadAccess(e,t,o){this.client.authValidator.validateWorkflowRead(e,t,o)}async listEngineWorkflows(e,...t){const o=na.getOrFail(e);if("supported"!==ra(o).workflows.list||"function"!=typeof o.listWorkflows)throw new Ao(`Graph execution backend '${e}' does not support workflow listing`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e});return await o.listWorkflows(...t)}async getEngineWorkflow(e,t,...o){const a=na.getOrFail(e);if("supported"!==ra(a).workflows.get||"function"!=typeof a.getWorkflow)throw new Ao(`Graph execution backend '${e}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e,workflowId:t});const r=await a.getWorkflow(t,...o);return this.assertWorkflowReadAccess(r,ir(o)),r}get backendName(){return this.client.backend.constructor?.name??"GraphExecutionBackend"}assertCodeModeSupported(e){const t=this.client.backend;if(t.local)return;const o=_a(e);if(0!==o.length){if("unsupported"===t.codeMode)throw new Ao(`Graph execution backend '${this.backendName}' does not support code-mode workflows`,"GRAPH_CODE_MODE_UNSUPPORTED_BACKEND",{backend:this.backendName,surfaces:o});if(!this.codeSandboxEvaluator)throw new Ao("Code-mode workflows require a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{backend:this.backendName,surfaces:o})}}async pinNode(e){const t=this.createPinningService();await t.pinNode(e),await this.emitPinningEvent(e.nodeId,be.NODE_PINNED)}async unpinNode(e){const t=this.createPinningService();await t.unpinNode(e),await this.emitPinningEvent(e.nodeId,be.NODE_UNPINNED)}createPinningService(){const e=Ra(this.valueAdapter);return new Ca(e,new Da,new Pa)}async emitPinningEvent(e,t){const o=(new Po).create({id:"",sequence:0,timestamp:new Date,runId:"pinning",workflowId:"",type:t,nodeId:e,path:[]});await this.emitter.updateObservers(o)}withWorkflowInputDefaults(e,t){const o={...t};for(const t of e.inputs)void 0===o[t.id]&&void 0!==t.defaultValue&&(o[t.id]=t.defaultValue);return o}mergeOptions(e){return{concurrency:4,failFast:!0,validateInputs:!0,validateOutputs:!0,maxLoopIterations:uo,maxForeachIterations:go,usePinnedValues:!0,writeThroughCache:!1,path:[],metadata:{},...this.defaultOptions,...e}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new Oo(e.runId??"unknown")}enterExecutionBudget(e,t){const o=t.parentRunId,a=t.path??[],r="subworkflow"===a[a.length-1],n=a.filter(e=>"subworkflow"===e).length,i=o?this.runSubWorkflowDepth.get(o)??Math.max(0,n-(r?1:0)):0,d=o?i+(r?1:0):0,s=t.maxSubWorkflowDepth??10;if(d>s)throw new Ao(`Graph run '${e}' exceeds the maximum sub-workflow depth of ${s}`,"GRAPH_SUB_WORKFLOW_DEPTH_EXCEEDED",{runId:e,parentRunId:o,depth:d,maxDepth:s});if(!o)return this.runSubWorkflowDepth.set(e,d),this.runRootId.set(e,e),void this.rootChildRunCounts.set(e,0);const l=this.runRootId.get(o)??o,c=t.maxChildRuns??1e3;let p=this.rootChildRunCounts.get(l)??0;if(r){if(p+=1,p>c)throw new Ao(`Graph run '${l}' exceeds the maximum of ${c} sub-workflow child runs`,"GRAPH_SUB_WORKFLOW_CHILD_LIMIT_EXCEEDED",{runId:e,rootRunId:l,parentRunId:o,childCount:p,maxChildren:c});this.rootChildRunCounts.set(l,p)}this.runSubWorkflowDepth.set(e,d),this.runRootId.set(e,l)}releaseExecutionBudget(e){const t=this.runRootId.get(e);this.runSubWorkflowDepth.delete(e),this.runRootId.delete(e),t===e&&this.rootChildRunCounts.delete(e)}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new Ao("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime","GRAPH_RUN_ID_ERROR",{runtime:typeof globalThis.crypto});return e.randomUUID()}}const lr=new Set(["process","require","module","exports","global","globalThis","Function","eval","fetch","XMLHttpRequest","WebSocket","Worker","Deno","Bun","__dispatch"]);class cr extends d.ClientBasedService{constructor(){super()}async initialize(...e){const t=e[0]??{},o=t&&"object"==typeof t?t:{};return this._config=o,this._client=s,{config:o,client:s}}get defaultTimeoutMs(){return this.config.timeoutMs??1e3}get defaultMemoryMb(){return this.config.memoryMb??32}async evaluate(e,...t){(await this.logCtx(t,"evaluate",!0)).for(this.evaluate);const o=e.code;if(!o||"string"!=typeof o||0===o.trim().length)throw new Ao("Code sandbox received empty code","GRAPH_CODE_SANDBOX_EMPTY_CODE");const a=((e,t)=>"javascript"===t?e:de.transpileModule(e,{compilerOptions:{target:de.ScriptTarget.ES2022,module:de.ModuleKind.None,strict:!0,noEmitHelpers:!0,importHelpers:!1}}).outputText.replace(/^"use strict";\s*/,""))(o,e.language??"javascript");(e=>{if(e.length>1e5)throw new Ao("Code exceeds the maximum length of 100000 characters","GRAPH_CODE_SANDBOX_CODE_TOO_LONG",{length:e.length});let t;try{t=ne.parse(`async function __validate() {\n${e}\n}`,{ecmaVersion:"latest",sourceType:"script"})}catch{try{t=ne.parse(e,{ecmaVersion:"latest",sourceType:"module"})}catch(t){throw new Ao("Code failed to parse: "+t.message,"GRAPH_CODE_SANDBOX_PARSE_ERROR",{code:e,error:t.message})}}ie.full(t,e=>{const t=e;if("ImportDeclaration"===t.type)throw new Ao("Imports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"import"});if("ExportNamedDeclaration"===t.type||"ExportDefaultDeclaration"===t.type)throw new Ao("Exports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"export"});if("Identifier"===t.type&&"string"==typeof t.name&&lr.has(t.name))throw new Ao(`Identifier "${t.name}" is not allowed in Code nodes.`,"GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:t.name});if("NewExpression"===t.type&&"Function"===t.callee?.name)throw new Ao("new Function() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"Function"});if("CallExpression"===t.type&&"eval"===t.callee?.name)throw new Ao("eval() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"eval"})})})(a);const r=!(e=>/\breturn\b[\s;]/.test(e))(a),n=r?a.replace(/[\s;]+$/,""):a,i={$input:e.input??{},$vars:e.vars??{},$item:e.item,$index:e.index,$node:e.nodes??{},$output:void 0},d=Object.keys(i),l=r?`return (${n});`:n,c=`"use strict";\nasync function __userFunction(${d.join(", ")}) {\n${l}\n}\n__userFunction(${d.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`,p=new s.Isolate({memoryLimit:this.defaultMemoryMb}),u=await p.createContext();try{const t=u.global;e.logger&&await this.injectConsole(u,e.logger);for(const[e,o]of Object.entries(i))await t.set(e,new s.ExternalCopy(void 0===o?null:o).copyInto());let o;try{o=await p.compileScript(c,{filename:"graph-code-node.js"})}catch(e){if(!r)throw new Ao("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:a,error:e.message});{const e=n,t=`"use strict";\nasync function __userFunction(${d.join(", ")}) {\n${e}\n}\n__userFunction(${d.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`;try{o=await p.compileScript(t,{filename:"graph-code-node.js"})}catch(e){throw new Ao("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:a,error:e.message})}}}const l=e.timeoutMs??this.defaultTimeoutMs;let g;try{g=await this.runBounded(o,u,l,e.abortSignal)}catch(e){if(e instanceof Ao)throw e;const t=e.message;if(t.includes("timed out")||t.includes("timeout"))throw new Ao(`Code execution timed out after ${l} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:l});if(t.includes("memory")||t.includes("heap"))throw new Ao(`Code exceeded the memory limit of ${this.defaultMemoryMb} MB`,"GRAPH_CODE_SANDBOX_MEMORY_LIMIT",{memoryMb:this.defaultMemoryMb});throw new Ao("Code execution failed: "+t,"GRAPH_CODE_SANDBOX_RUNTIME_ERROR",{code:a,error:t})}if("string"!=typeof g)throw new Ao("Code sandbox returned an unexpected non-string result","GRAPH_CODE_SANDBOX_UNEXPECTED_RESULT",{result:g});return JSON.parse(g).v}finally{u.release(),p.dispose()}}async runBounded(e,t,o,a){const r=e.run(t,{timeout:o,promise:!0});r.catch(()=>{});const n=[r];let i,d;try{return n.push(new Promise((e,t)=>{i=setTimeout(()=>{t(new Ao(`Code execution timed out after ${o} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:o}))},o+100)})),a&&n.push(new Promise((e,t)=>{const r=()=>{const e="timeout"===a.reason;t(new Ao(e?`Code execution timed out after ${o} ms`:"Code execution aborted",e?"GRAPH_CODE_SANDBOX_TIMEOUT":"GRAPH_CODE_SANDBOX_ABORTED",{timeoutMs:o,reason:a.reason}))};a.aborted?r():(a.addEventListener("abort",r,{once:!0}),d=()=>a.removeEventListener("abort",r))})),await Promise.race(n)}finally{i&&clearTimeout(i),d?.()}}async injectConsole(e,t){const o=new s.Reference((e,o)=>{let a;try{a=JSON.parse(o)}catch{a=[o]}const r=a.map(e=>"string"==typeof e?e:JSON.stringify(e)).join(" "),n=1===a.length?a[0]:a;switch(e){case"log":case"info":default:t.info(r,n);break;case"warn":t.warn(r,n);break;case"error":t.error(r,n);break;case"debug":case"dir":case"dirxml":case"table":t.debug(r,n);break;case"trace":t.trace(r,n);break;case"group":case"groupCollapsed":t.debug("[group] "+r,n);break;case"groupEnd":t.debug("[groupEnd]",void 0);break;case"time":case"timeEnd":case"timeLog":case"count":case"countReset":t.debug(`[${e}] ${r}`,n);break;case"assert":a[0]||t.error("Assertion failed: "+r,n);case"clear":}});await e.evalClosure("\n function __ser() {\n var out = [];\n for (var i = 0; i < arguments.length; i++) {\n var a = arguments[i];\n try { out.push(typeof a === 'object' ? JSON.parse(JSON.stringify(a)) : a); }\n catch (e) { out.push(String(a)); }\n }\n return JSON.stringify(out);\n }\n function __call(level) {\n return function() {\n $0.applySync(undefined, [level, __ser.apply(null, arguments)]);\n };\n }\n globalThis.console = {\n log: __call('log'),\n info: __call('info'),\n warn: __call('warn'),\n error: __call('error'),\n debug: __call('debug'),\n trace: __call('trace'),\n dir: __call('dir'),\n dirxml: __call('dirxml'),\n table: __call('table'),\n group: __call('group'),\n groupCollapsed: __call('groupCollapsed'),\n groupEnd: __call('groupEnd'),\n time: __call('time'),\n timeEnd: __call('timeEnd'),\n timeLog: __call('timeLog'),\n assert: __call('assert'),\n count: __call('count'),\n countReset: __call('countReset'),\n clear: __call('clear')\n };\n ",[o]),o.release()}}class pr extends n.InternalError{constructor(e){super(e,pr.name,500)}}class ur extends n.NotFoundError{constructor(e){super(e),this.name=ur.name}}class gr extends n.NotFoundError{constructor(e){super(e),this.name=gr.name}}class hr{constructor(e,t,o={}){this.kind=e,this.declarations=new Map,this.implementations=new Map;for(const e of t){if("string"!=typeof e?.name||!e.name)throw new pr(`Method declaration for kind '${this.kind}' is missing a name`);if(this.declarations.has(e.name))throw new pr(`Kind '${this.kind}' declares duplicate method '${e.name}'`);this.declarations.set(e.name,e)}for(const[e,t]of Object.entries(o)){if("function"!=typeof t)throw new pr(`Method implementation '${e}' for kind '${this.kind}' is not a function`);if(!this.declarations.has(e))throw new pr(`Kind '${this.kind}' implements method '${e}' which is not declared by its manifest`);this.implementations.set(e,t)}for(const e of this.declarations.keys())if(!this.implementations.has(e))throw new pr(`Kind '${this.kind}' declares method '${e}' with no implementation`)}has(e){return this.declarations.has(e)}getDeclaration(e){const t=this.declarations.get(e);if(!t)throw new gr(`Kind '${this.kind}' does not declare method '${e}'`);return t}get(e){return this.getDeclaration(e),this.implementations.get(e)}list(){return[...this.declarations.values()].sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0)}}function mr(e,t){if(!t)return;let o=e;for(const e of t.split(".")){if(!o||"object"!=typeof o)return;o=o[e]}return o}function fr(e,t,o){const a=mr(t,e.itemIdPath),r=e.itemLabelPath?mr(t,e.itemLabelPath):void 0;return{id:"string"==typeof a&&a||"number"==typeof a&&Number.isFinite(a)&&a+""||o+"",label:"string"==typeof r?r:void 0}}function _r(e,t){switch(t){case"input":return e.inputs;case"output":return e.outputs;default:return e.connections}}function yr(e,t){const o={inputs:[],outputs:[],connections:[]},a={input:new Set((e.inputs??[]).map(e=>e.id)),output:new Set((e.outputs??[]).map(e=>e.id)),connection:new Set((e.connections??[]).map(e=>e.id))},r=(e,t)=>{const o=a[e];return!o.has(t)&&(o.add(t),!0)};for(const a of e.dynamicPorts??[])if("repeatFromParameter"===a.type){const e=t[a.parameter];if(!Array.isArray(e))continue;const n=_r(o,a.direction);e.forEach((e,t)=>{const{id:o,label:i}=fr(a,e,t),d=(s={id:o,index:t,label:i??o},a.portIdTemplate.replaceAll("${id}",s.id).replaceAll("${index}",s.index+"").replaceAll("${label}",s.label));var s;if(!r(a.direction,d))return;const l=a.defaultPort?Xe(a.defaultPort):{id:d,label:i??d,direction:a.direction};l.id=d,l.direction=a.direction,i&&(l.label=i),n.push(l)})}else if("togglePort"===a.type){if(t[a.parameter]!==a.equals)continue;const e=Xe(a.port);if(!r(e.direction,e.id))continue;_r(o,e.direction).push(e)}return o}function br(e,t){const o=yr(e,t),a={kind:e.kind,display:e.display,inputs:[...e.inputs,...o.inputs],outputs:[...e.outputs,...o.outputs],parameters:e.parameters},r=[...e.connections??[],...o.connections];return r.length&&(a.connections=r),e.dynamicPorts?.length&&(a.dynamicPorts=e.dynamicPorts),e.credentials?.length&&(a.credentials=e.credentials),e.capabilities?.length&&(a.capabilities=e.capabilities),e.policies&&(a.policies=e.policies),e.metadata&&(a.metadata=e.metadata),e.namespaces?.length&&(a.namespaces=e.namespaces),Xe(a)}class wr{async resolve(e,t,o,a,r){if(o){const n=await o(a,r);if(!(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.kind&&"object"==typeof t.display&&null!==t.display&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.parameters)})(n))throw new pr(`resolveManifest provider for kind '${e}' returned a value that does not conform to GraphResolvedNodeManifest`);if(!Je(n))throw new pr(`resolveManifest provider for kind '${e}' returned a non-JSON-safe resolved manifest`);const i=Xe(n);return!i.namespaces?.length&&t.namespaces?.length&&(i.namespaces=t.namespaces.slice()),i}return br(t,a.parameters??{})}}const Nr=["edge","literal","expression"];function vr(e){return Nr.includes(e)}function Ar(e,t,o){if("string"!=typeof o||!o)throw new pr(`Manifest for kind '${e}' has a ${t} with an empty port id`);if(Ve(o))throw new pr(`Manifest for kind '${e}' has a ${t} with unsafe port id '${o}'`)}function xr(e){return e}function Ir(e){if(!e)return;const t={...e.metadata??{},...e.parameters??{},...e.state??{}};return e.loop&&(t.loop=e.loop),t}e.GraphNodeCatalogue=class extends d.Service{constructor(){super(),this.entries=new Map,this.resolver=new wr,this.fallbackContext=new d.Context}withContext(e){return e[e.length-1]instanceof d.Context?e:[this.fallbackContext]}register(e,t={},...o){const{log:a}=this.logCtx(this.withContext(o),"register").for(this.register);a.debug(`Registering graph node kind '${e?.manifest?.kind??"unknown"}'`),(e=>{if(!e||"object"!=typeof e)throw new pr("Graph node registration is required");if(!e.manifest||"object"!=typeof e.manifest)throw new pr("Graph node registration is missing a manifest");if(!e.executor||"function"!=typeof e.executor.execute)throw new pr(`Graph node registration for kind '${e.manifest?.kind+""}' is missing an executor`)})(e);const r=e.manifest;if("string"!=typeof r.kind||!r.kind.trim())throw new pr("Graph node manifest kind is required and must be a non-empty string");const n=r.kind;if(this.entries.has(n)&&!t.replace)throw new pr(`Graph node kind '${n}' is already registered; pass { replace: true } to replace it`);try{Ct(r)}catch(e){throw new pr(`Manifest for kind '${n}' is not JSON-serializable: ${e.message}`)}((e,t)=>{const o=[["input",t.inputs],["output",t.outputs],["connection",t.connections??[]]];for(const[t,a]of o){const o=new Set;for(const r of a){if(Ar(e,t+" port",r?.id),o.has(r.id))throw new pr(`Manifest for kind '${e}' declares duplicate static ${t} port id '${r.id}'`);if(o.add(r.id),void 0!==r.defaultMode&&!vr(r.defaultMode))throw new pr(`Manifest for kind '${e}' declares invalid default binding mode '${r.defaultMode+""}' on ${t} port '${r.id}'`)}}})(n,r);const i=((e,t)=>{const o=new Set;for(const a of t.parameters){const t=a?.id;if("string"!=typeof t||!t)throw new pr(`Manifest for kind '${e}' has a parameter with an empty id`);if(Ve(t))throw new pr(`Manifest for kind '${e}' has a parameter with unsafe id '${t}'`);if(o.has(t))throw new pr(`Manifest for kind '${e}' declares duplicate parameter id '${t}'`);o.add(t)}return o})(n,r);((e,t,o)=>{for(const a of t.dynamicPorts??[]){if(!a||"string"!=typeof a.parameter||!a.parameter)throw new pr(`Manifest for kind '${e}' has a dynamic-port rule without a parameter reference`);if(!o.has(a.parameter))throw new pr(`Manifest for kind '${e}' has a dynamic-port rule referencing missing parameter '${a.parameter}'`);if("togglePort"===a.type){if(!a.port)throw new pr(`Manifest for kind '${e}' has a togglePort rule without a port`);Ar(e,"togglePort rule port",a.port.id)}if("repeatFromParameter"===a.type&&"string"!=typeof a.portIdTemplate)throw new pr(`Manifest for kind '${e}' has a repeatFromParameter rule without a portIdTemplate`)}})(n,r,i),((e,t)=>{for(const o of t.credentials??[]){if(!Et(o))throw new pr(`Manifest for kind '${e}' has a malformed credential requirement`);if(!o.type)throw new pr(`Manifest for kind '${e}' has a credential requirement with an empty type`)}})(n,r),((e,t)=>{for(const o of t.methods??[])if(!Pt(o))throw new pr(`Manifest for kind '${e}' has a malformed method declaration`)})(n,r);const d=new hr(n,r.methods??[],e.methods??{});return this.entries.set(n,{registration:e,methods:d,placeholderManifest:!1}),this}registerExecutor(e,t,...o){const{log:a}=this.logCtx(this.withContext(o),"registerExecutor").for(this.registerExecutor);if(a.debug(`Registering graph executor for kind '${e}'`),"string"!=typeof e||!e.trim())throw new pr("Graph executor kind is required");if(!t||"function"!=typeof t.execute)throw new pr(`Executor registered for kind '${e}' is missing an execute method`);const r=this.entries.get(e);if(r)return r.registration={...r.registration,executor:t},this;const n={kind:e,display:{name:e},inputs:[],outputs:[],parameters:[],policies:{allowUndeclaredParameters:!0,allowUnknownOutputs:!0}};return this.entries.set(e,{registration:{manifest:n,executor:t},methods:new hr(e,[],{}),placeholderManifest:!0}),this}unregister(e,...t){const{log:o}=this.logCtx(this.withContext(t),"unregister").for(this.unregister);return o.debug(`Unregistering graph node kind '${e}'`),this.entries.delete(e),this}has(e,...t){return this.logCtx(this.withContext(t),"has").for(this.has),this.entries.has(e)}entry(e){const t=this.entries.get(e);if(!t)throw new ur(`No graph node kind '${e}' is registered in the catalogue`);return t}getManifest(e,...t){return this.logCtx(this.withContext(t),"getManifest").for(this.getManifest),Xe(this.entry(e).registration.manifest)}getExecutor(e,...t){return this.logCtx(this.withContext(t),"getExecutor").for(this.getExecutor),this.entry(e).registration.executor}getMethodDeclaration(e,t,...o){return this.logCtx(this.withContext(o),"getMethodDeclaration").for(this.getMethodDeclaration),this.entry(e).methods.getDeclaration(t)}getMethod(e,t,...o){return this.logCtx(this.withContext(o),"getMethod").for(this.getMethod),this.entry(e).methods.getDeclaration(t),this.entry(e).methods.get(t)}listMethodDeclarations(e,...t){return this.logCtx(this.withContext(t),"listMethodDeclarations").for(this.listMethodDeclarations),this.entry(e).methods.list()}listManifests(e,...t){this.logCtx(this.withContext(t),"listManifests").for(this.listManifests);const o=[...this.entries.keys()].sort(),a=e?.categories?.length?new Set(e.categories):void 0,r=e?.kinds?.length?new Set(e.kinds):void 0,n=[];for(const e of o){if(r&&!r.has(e))continue;const o=this.getManifest(e,...t);a&&!a.has(o.display.category??"")||n.push(o)}return n}listKinds(...e){return this.logCtx(this.withContext(e),"listKinds").for(this.listKinds),[...this.entries.keys()].sort()}get size(){return this.entries.size}async resolveManifest(e,t,o,...a){this.logCtx(this.withContext(a),"resolveManifest").for(this.resolveManifest);const r=this.entry(e);return this.resolver.resolve(e,r.registration.manifest,r.registration.resolveManifest,t,o)}},e.GraphNodeCatalogue=i.__decorate([d.service(),i.__metadata("design:paramtypes",[])],e.GraphNodeCatalogue),e.GraphNodeExecutorRegistry=class extends d.Service{constructor(t=new e.GraphNodeCatalogue){super(),this.catalogue=t}get catalog(){return this.catalogue}register(e,t,...o){const{log:a}=this.logCtx(o,"register").for(this.register);if(a.debug(`Registering graph executor for kind '${e}'`),!e)throw new Ao("Graph executor kind is required");return this.catalogue.registerExecutor(e,t,...o),this}unregister(e,...t){const{log:o}=this.logCtx(t,"unregister").for(this.unregister);return o.debug(`Unregistering graph executor for kind '${e}'`),this.catalogue.unregister(e,...t),this}has(e,...t){return this.logCtx(t,"has").for(this.has),this.catalogue.has(e,...t)}resolve(e,...t){this.logCtx(t,"resolve").for(this.resolve);try{return this.catalogue.getExecutor(e,...t)}catch(t){if(t instanceof ur)throw new Ao(`No graph executor registered for kind '${e}'`,"GRAPH_EXECUTOR_NOT_FOUND",{kind:e});throw t}}},e.GraphNodeExecutorRegistry=i.__decorate([d.service(),i.__metadata("design:paramtypes",[e.GraphNodeCatalogue])],e.GraphNodeExecutorRegistry),e.GraphNodeExecutorResolver=class extends d.Service{constructor(e,t){super(),this.registry=e,this.defaultExecutor=t}resolve(e,...t){const{log:o}=this.logCtx(t,"resolve").for(this.resolve);return o.debug(`Resolving graph executor for kind '${e}'`),this.registry.has(e,...t)?this.registry.resolve(e,...t):this.defaultExecutor?this.defaultExecutor:this.registry.resolve(e,...t)}},e.GraphNodeExecutorResolver=i.__decorate([d.service(),i.__metadata("design:paramtypes",[Function,Object])],e.GraphNodeExecutorResolver);class Er extends r.Model{constructor(e){super(),r.Model.fromModel(this,e)}execute(e,t){throw new Ao(`Graph node kind '${this.constructor.name}' does not implement execute`,"GRAPH_NODE_EXECUTE_NOT_IMPLEMENTED",{kind:this.constructor.name})}static applyMetadata(e){return null}static instantiate(e){return new this(e)}}function Sr(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}e.BreakFlowNode=class extends Er{execute(e,t){throw new Co(e.inputs.value)}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.break.fields.value.label",placeholder:"graph.node.flow_control.break.fields.value.placeholder",type:"textarea"}),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.BreakFlowNode.prototype,"value",void 0),e.BreakFlowNode=i.__decorate([qe("core.flow.break",{kind:"core.flow.break",category:"Flow Control",color:"#f59e0b",icon:"ti-square-arrow-right",width:96,height:96,labels:["flow","break","loop","control"],metadata:{title:"graph.node.flow_control.break.name",description:"graph.node.flow_control.break.description"}}),r.model()],e.BreakFlowNode),e.ErrorBoundaryFlowNode=class extends Er{async execute(e,t){const o=t.node.errorBoundary;if(!o?.try)return{result:e.inputs.value??e.inputs};const a=t.engine;if(!a)throw new Ao("errorBoundary node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");try{const r=await a.execute(o.try,e.inputs,{parentRunId:t.runId,path:[...t.path,"try"]}),n=Object.values(r.nodeResults).find(e=>e.status===fe.FAILED);if(n)throw new Ao(n.error?.message??"error boundary try body failed",n.error?.code??"GRAPH_ERROR_BOUNDARY",n.error?.details);return{result:r.outputs.result??r.outputs}}catch(r){let n=r;if(o.catch){const i=await a.execute(o.catch,{...e.inputs,error:Sr(r)},{parentRunId:t.runId,path:[...t.path,"catch"]});n=i.outputs.error??i.outputs}return{error:n}}finally{o.finally&&await a.execute(o.finally,e.inputs,{parentRunId:t.runId,path:[...t.path,"finally"]})}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.error_boundary.fields.value.label",placeholder:"graph.node.flow_control.error_boundary.fields.value.placeholder",type:"textarea"}),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.ErrorBoundaryFlowNode.prototype,"value",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.ErrorBoundaryFlowNode.prototype,"result",void 0),i.__decorate([Be({handle:"error"}),i.__metadata("design:type",Object)],e.ErrorBoundaryFlowNode.prototype,"error",void 0),e.ErrorBoundaryFlowNode=i.__decorate([qe("core.flow.errorBoundary",{kind:"core.flow.errorBoundary",category:"Flow Control",color:"#f59e0b",icon:"ti-shield-check",width:96,height:96,labels:["flow","error","try-catch"],metadata:{title:"graph.node.flow_control.error_boundary.name",description:"graph.node.flow_control.error_boundary.description",finally:!1}}),r.model()],e.ErrorBoundaryFlowNode),e.HumanApprovalFlowNode=class extends Er{execute(e){const t=e.inputs.value??e.inputs;return!1===this.approved?{rejected:t}:{approved:t}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.HumanApprovalFlowNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.message.label",placeholder:"graph.node.flow_control.human_approval.fields.message.placeholder",type:"textarea"}),Ue({handle:"message",userControlled:!0}),i.__metadata("design:type",String)],e.HumanApprovalFlowNode.prototype,"message",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.approved.label",type:"checkbox"}),Ue({handle:"approved",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HumanApprovalFlowNode.prototype,"approved",void 0),i.__decorate([Be({handle:"approved"}),i.__metadata("design:type",Object)],e.HumanApprovalFlowNode.prototype,"approvedOut",void 0),i.__decorate([Be({handle:"rejected"}),i.__metadata("design:type",Object)],e.HumanApprovalFlowNode.prototype,"rejectedOut",void 0),e.HumanApprovalFlowNode=i.__decorate([qe("core.flow.humanApproval",{kind:"core.flow.humanApproval",category:"Flow Control",color:"#f59e0b",icon:"ti-user-check",width:96,height:96,labels:["flow","approval","suspend"],metadata:{title:"graph.node.flow_control.human_approval.name",description:"graph.node.flow_control.human_approval.description",approvers:[],timeoutMs:864e5}}),r.model()],e.HumanApprovalFlowNode),e.IfFlowNode=class extends Er{execute(e,t){const o=e.inputs,a=o.value??o;if(!this.condition)throw new Ao("If node has no condition configured","GRAPH_IF_NO_CONDITION",{input:o});if(da(this.condition))return la(this.condition,o,t).then(e=>this.route(e,a));const r=ca(this.condition,((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(o,a),"if");return this.route(r,a)}route(e,t){if(e)return{then:t};if(!0===this.else)return{else:t};throw new Ao("If node condition evaluated to false and the else branch is disabled","GRAPH_IF_ELSE_DISABLED",{condition:this.condition})}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.value.label",placeholder:"graph.node.flow_control.if.fields.value.placeholder",type:"textarea"}),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.IfFlowNode.prototype,"value",void 0),i.__decorate([r.required(),Be({handle:"then"}),i.__metadata("design:type",Object)],e.IfFlowNode.prototype,"then",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.condition.label",placeholder:"graph.node.flow_control.if.fields.condition.placeholder",type:"code"}),Ue({handle:"condition",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.IfFlowNode.prototype,"condition",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.else.label",type:"checkbox"}),Ue({handle:"else",userControlled:!0}),i.__metadata("design:type",Boolean)],e.IfFlowNode.prototype,"else",void 0),e.IfFlowNode=i.__decorate([qe("core.flow.if",{kind:"core.flow.if",category:"Flow Control",color:"#f59e0b",icon:"ti-arrows-split-2",width:96,height:96,labels:["flow","conditional","branch"],metadata:{title:"graph.node.flow_control.if.name",description:"graph.node.flow_control.if.description"}}),r.model()],e.IfFlowNode),e.SwitchFlowNode=class extends Er{async execute(e,t){const o=((e,t)=>{const o={cases:t.cases??[],defaultPort:t.defaultPort??"default",hasDefault:!0===t.hasDefault},a=e.node.metadata?.switch;return a&&Array.isArray(a.cases)?{cases:a.cases,defaultPort:a.defaultPort??o.defaultPort,hasDefault:!0===a.hasDefault||o.hasDefault}:o})(t,this),a=o.cases,r=e.inputs,n=r.value??r,i=((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(r,n);for(const e of a)if(await pa(e.condition,{input:r,state:i,label:"switch case"},t))return{[e.outputPort]:n};if(!0!==o.hasDefault)throw new Ao("No switch case matched and default port is not enabled","GRAPH_SWITCH_NO_MATCH",{cases:a.map(e=>e.id)});const d=o.defaultPort??"default";return{[d]:n}}static applyMetadata(e){const t=Fe(this),o=e.defaultPort??"default",a=!0===e.hasDefault,r=t.ports.filter(t=>!e.cases.some(e=>e.outputPort===t.property)),n=r.filter(e=>e.property!==o),i=r.find(e=>e.property===o),d=[...n,...e.cases.map(e=>({property:e.outputPort,name:e.label,direction:re.OUTPUT,label:e.label,required:!1,hidden:!1,path:e.outputPort}))];return a&&i&&d.push(i),{ports:d,size:ce(t,{cases:e.cases.length}),dataPatch:{switchMetadata:e}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.value.label",placeholder:"graph.node.flow_control.switch.fields.value.placeholder",type:"textarea"}),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.SwitchFlowNode.prototype,"value",void 0),i.__decorate([r.required(),Be({handle:"default"}),i.__metadata("design:type",Object)],e.SwitchFlowNode.prototype,"default",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.cases.label",type:"collection"}),i.__metadata("design:type",Object)],e.SwitchFlowNode.prototype,"cases",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.hasDefault.label",type:"checkbox"}),i.__metadata("design:type",Boolean)],e.SwitchFlowNode.prototype,"hasDefault",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.defaultPort.label",type:"text"}),i.__metadata("design:type",String)],e.SwitchFlowNode.prototype,"defaultPort",void 0),e.SwitchFlowNode=i.__decorate([qe("core.flow.switch",{kind:"core.flow.switch",category:"Flow Control",color:"#f59e0b",icon:"ti-arrows-shuffle",width:120,height:140,sizeRules:[{type:"parameterCount",parameter:"cases",dimension:"height",perItem:24}],labels:["flow","switch","multi-branch"],metadata:{title:"graph.node.flow_control.switch.name",description:"graph.node.flow_control.switch.description"}}),r.model()],e.SwitchFlowNode);const Rr={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},Tr=t.LoggedEnvironment.accumulate({graph:{workflows:{limits:{...Rr},allowAnonymousAccess:!1},execution:{maxCodeTimeoutMs:ho}}});function Cr(e,t){const o="number"==typeof t?t:Number(t),a=Number.isFinite(o)&&o>0?o:ho,r="number"==typeof e?e:Number(e);return Number.isFinite(r)&&r>0?Math.min(Math.floor(r),a):1e3}const Or=["javascript","typescript"],kr="javascript";e.CodeInputSchema=class extends r.Model{constructor(){super(...arguments),this.language=kr}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.language.label",type:"select"}),r.option([...Or]),r.type(String),i.__metadata("design:type",String)],e.CodeInputSchema.prototype,"language",void 0),i.__decorate([r.required(),o.uielement("code-editor",{label:"graph.node.utility.code.fields.code.label",placeholder:"graph.node.utility.code.fields.code.placeholder"}),Ue({handle:"code"}),i.__metadata("design:type",String)],e.CodeInputSchema.prototype,"code",void 0),i.__decorate([o.hidden(),Ue({handle:"data"}),i.__metadata("design:type",Object)],e.CodeInputSchema.prototype,"data",void 0),e.CodeInputSchema=i.__decorate([r.model()],e.CodeInputSchema),e.CodeNode=class extends Er{async execute(e,t){const o=e.inputs,a=this.input,r=o.code??e.parameters?.code??a?.code??this.defaultCode,n=a?.language??kr;if(!r||"string"!=typeof r||0===r.trim().length)throw new Io("Code node has no code to execute (input.code is empty)",{input:o});const i=t.engine?.codeSandboxEvaluator;if(!i)throw new Ao("Code node execution requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:r});const d=Tr.graph.execution?.maxCodeTimeoutMs,s="number"==typeof d&&Number.isFinite(d)&&d>0?d:ho,l=Cr(this.timeoutMs,s),c=t.metadata,p={code:r,language:n,input:o,vars:c?.vars??void 0,item:c?.item,index:c?.index,nodes:c?.nodes??void 0,logger:t.logger,timeoutMs:l,abortSignal:t.abortSignal};await t.log("Executing code node",{language:n,length:r.length,timeoutMs:l});const u=await i.evaluate(p);return await t.log("Code node executed",{hasResult:void 0!==u}),{result:u}}},i.__decorate([r.required(),Ue({handle:"input",model:e.CodeInputSchema}),i.__metadata("design:type",e.CodeInputSchema)],e.CodeNode.prototype,"input",void 0),i.__decorate([r.min(1),r.max(ho),o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.timeoutMs.label",type:"number"}),Ue({handle:"timeoutMs"}),i.__metadata("design:type",Number)],e.CodeNode.prototype,"timeoutMs",void 0),i.__decorate([o.uielement("code-editor",{label:"graph.node.utility.code.fields.defaultCode.label",placeholder:"graph.node.utility.code.fields.defaultCode.placeholder"}),Ue({handle:"defaultCode",userControlled:!0}),i.__metadata("design:type",String)],e.CodeNode.prototype,"defaultCode",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.CodeNode.prototype,"result",void 0),e.CodeNode=i.__decorate([qe("core.utility.code",{kind:"core.utility.code",category:"Utility",color:"#0d9488",icon:"ti-code",width:96,height:96,labels:["utility","code","sandbox","transform"],metadata:{title:"graph.node.utility.code.name",description:"graph.node.utility.code.description"}}),r.model()],e.CodeNode),e.DelayFlowNode=class extends Er{execute(e){return{value:e.inputs.value??e.inputs}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.DelayFlowNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.delay.fields.timeoutMs.label",type:"number"}),Ue({handle:"timeoutMs"}),i.__metadata("design:type",Number)],e.DelayFlowNode.prototype,"timeoutMs",void 0),i.__decorate([r.required(),Be({handle:"value"}),i.__metadata("design:type",Object)],e.DelayFlowNode.prototype,"valueOut",void 0),e.DelayFlowNode=i.__decorate([qe("core.flow.delay",{kind:"core.flow.delay",category:"Utility",color:"#0d9488",icon:"ti-clock-hour-4",width:96,height:96,labels:["flow","delay","wait"],metadata:{title:"graph.node.utility.delay.name",description:"graph.node.utility.delay.description"}}),r.model()],e.DelayFlowNode),e.LogFlowNode=class extends Er{execute(e,t){const o=e.inputs.value,a=this.level??"info";return t.logger[a](this.message??"Log node",{value:o}),{value:o}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.LogFlowNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.message.label",placeholder:"graph.node.utility.log.fields.message.placeholder",type:"textarea"}),Ue({handle:"message"}),i.__metadata("design:type",String)],e.LogFlowNode.prototype,"message",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.level.label",placeholder:"graph.node.utility.log.fields.level.placeholder",type:"text"}),Ue({handle:"level",userControlled:!0}),i.__metadata("design:type",String)],e.LogFlowNode.prototype,"level",void 0),i.__decorate([r.required(),Be({handle:"value"}),i.__metadata("design:type",Object)],e.LogFlowNode.prototype,"valueOut",void 0),e.LogFlowNode=i.__decorate([qe("core.flow.log",{kind:"core.flow.log",category:"Utility",color:"#0d9488",icon:"ti-terminal",width:96,height:96,labels:["flow","log","debug","utility"],metadata:{title:"graph.node.utility.log.name",description:"graph.node.utility.log.description"}}),r.model()],e.LogFlowNode),e.MapNode=class extends Er{execute(e){return{result:{mapped:e.inputs.value??e.inputs}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.map.fields.value.label",placeholder:"graph.node.utility.map.fields.value.placeholder",type:"textarea"}),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.MapNode.prototype,"value",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.MapNode.prototype,"result",void 0),e.MapNode=i.__decorate([qe("core.utility.map",{kind:"core.utility.map",category:"Utility",color:"#0d9488",icon:"ti-arrows-right-left",width:96,height:96,labels:["utility","map","transform"],metadata:{title:"graph.node.utility.map.name",description:"graph.node.utility.map.description",mapper:{}}}),r.model()],e.MapNode),e.UtilityLogNode=class extends Er{execute(e,t){const o=e.inputs.value,a=this.level??"info";return t.logger[a](this.message??"Log node",{value:o}),{value:o}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.UtilityLogNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.message.label",placeholder:"graph.node.utility.utility_log.fields.message.placeholder",type:"textarea"}),Ue({handle:"message"}),i.__metadata("design:type",String)],e.UtilityLogNode.prototype,"message",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.level.label",placeholder:"graph.node.utility.utility_log.fields.level.placeholder"}),Ue({handle:"level",userControlled:!0,type:"string"}),i.__metadata("design:type",String)],e.UtilityLogNode.prototype,"level",void 0),i.__decorate([r.required(),Be({handle:"value"}),i.__metadata("design:type",Object)],e.UtilityLogNode.prototype,"valueOut",void 0),e.UtilityLogNode=i.__decorate([qe("core.utility.log",{kind:"core.utility.log",category:"Utility",color:"#0d9488",icon:"ti-terminal",width:96,height:96,labels:["utility","log","debug","observability"],metadata:{title:"graph.node.utility.utility_log.name",description:"graph.node.utility.utility_log.description"}}),r.model()],e.UtilityLogNode);const Dr=new Set(["__proto__","constructor","prototype"]);function Pr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Gr(e){return null==e?[]:(Array.isArray(e)?e:[e]).filter(e=>null!=e)}function Mr(e,t){if(Dr.has(t))throw new Ao(`Graph data path '${e}' contains the reserved segment '${t}'`,"GRAPH_DATA_UNSAFE_PATH",{path:e,segment:t})}function Fr(e,t){return t?(e=>{const t=(e=>e.split(".").map(e=>e.trim()).filter(e=>e.length>0))(e);for(const o of t)Mr(e,o);return t})(e):(Mr(e,e),[e])}function Lr(e,t,o=!0){if(!t)return e;const a=Fr(t,o);let r=e;for(const e of a){if(!Pr(r))return;r=r[e]}return r}function jr(e,t,o,a=!0){const r=Fr(t,a);if(0===r.length)return;let n=e;for(let e=0;e<r.length-1;e++){const t=r[e],o=n[t];if(Pr(o))n=o;else{const e={};n[t]=e,n=e}}n[r[r.length-1]]=o}function qr(e,t,o=!0){const a=Fr(t,o);if(0===a.length)return;let r=e;for(let e=0;e<a.length-1;e++){const t=r[a[e]];if(!Pr(t))return;r=t}delete r[a[a.length-1]]}function Hr(e,t="json"){if(null==e)return e;switch(t){case"string":return e+"";case"number":{const t=Number(e);if(!Number.isFinite(t))throw new Ao(`Value '${e+""}' cannot be converted to a number`,"GRAPH_DATA_INVALID_NUMBER",{value:e});return t}case"boolean":return"string"==typeof e?"true"===e||"1"===e:!!e;case"array":return Array.isArray(e)?e:[e];case"object":return Pr(e)?e:{};default:if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}}function Ur(e,t,o="auto"){const a=null==e,r=null==t;return a&&r?0:a?1:r?-1:"string"===o?(e+"").localeCompare(t+""):"number"===o?Number(e)-Number(t):"date"===o?new Date(e).getTime()-new Date(t).getTime():"number"==typeof e&&"number"==typeof t?e-t:"boolean"==typeof e&&"boolean"==typeof t?Number(e)-Number(t):(e+"").localeCompare(t+"")}function Br(e,t){if(!t||"iso"===t)return e.toISOString();const o=(e,t=2)=>(e+"").padStart(t,"0"),a={yyyy:e.getUTCFullYear()+"",yy:(e.getUTCFullYear()+"").slice(-2),MM:o(e.getUTCMonth()+1),M:e.getUTCMonth()+1+"",dd:o(e.getUTCDate()),d:e.getUTCDate()+"",HH:o(e.getUTCHours()),H:e.getUTCHours()+"",mm:o(e.getUTCMinutes()),m:e.getUTCMinutes()+"",ss:o(e.getUTCSeconds()),s:e.getUTCSeconds()+"",SSS:o(e.getUTCMilliseconds(),3)};return t.replace(/yyyy|yy|MM|M|dd|d|HH|H|mm|m|ss|s|SSS/g,e=>a[e]??e)}function $r(e,t,o){const a=new Date(e.getTime());switch(o){case"seconds":a.setUTCSeconds(a.getUTCSeconds()+t);break;case"minutes":a.setUTCMinutes(a.getUTCMinutes()+t);break;case"hours":a.setUTCHours(a.getUTCHours()+t);break;case"days":a.setUTCDate(a.getUTCDate()+t);break;case"weeks":a.setUTCDate(a.getUTCDate()+7*t);break;case"months":a.setUTCMonth(a.getUTCMonth()+t);break;case"years":a.setUTCFullYear(a.getUTCFullYear()+t)}return a}function Wr(e){if(e instanceof Date){if(Number.isNaN(e.getTime()))throw new Ao("Date value is invalid","GRAPH_DATA_INVALID_DATE",{value:e});return e}if("number"==typeof e){const t=new Date(e);if(!Number.isNaN(t.getTime()))return t}if("string"==typeof e&&e.trim().length>0){const t=new Date(e);if(!Number.isNaN(t.getTime()))return t}throw new Ao("Date & Time node requires a valid date value","GRAPH_DATA_INVALID_DATE",{value:e})}function Vr(e){return"undefined"!=typeof Buffer&&Buffer.isBuffer(e)||e instanceof Uint8Array||e instanceof ArrayBuffer}function Kr(e,t){return Pr(t)?{...e,...t,item:t}:{...e,item:t}}function zr(e,t,o){const a={...e};for(const[e,r]of Object.entries(t))"keepFirst"===o&&Object.prototype.hasOwnProperty.call(a,e)||(a[e]=r);return a}function Qr(e,t,o){const a={...e};for(const e of t){if(!e||!e.from||!e.to||e.from===e.to)continue;const t=Lr(a,e.from,o);void 0!==t&&(qr(a,e.from,o),jr(a,e.to,t,o))}return a}function Jr(e,t="Fields"){if(null==e)return[];if("string"==typeof e)return e.split(",").map(e=>e.trim()).filter(e=>e.length>0);if(Array.isArray(e))return e.filter(e=>"string"==typeof e).map(e=>e.trim()).filter(e=>e.length>0);throw new Ao(`The '${t}' parameter must be a comma-separated string or an array of strings`,"GRAPH_DATA_INVALID_FIELDS",{fieldName:t})}function Xr(e){return e.replace(/]/g,"").replace(/\[/g,"").replace(/"/g,"").replace(/[ .]/g,"_")}function Yr(e){const t=e=>Array.isArray(e)?e.map(t):e instanceof Date?e.toISOString():Pr(e)?Object.keys(e).sort().reduce((o,a)=>(Mr(a,a),o[a]=t(e[a]),o),{}):"number"==typeof e&&Number.isNaN(e)?"@NaN":void 0===e?"@undefined":"bigint"==typeof e?e.toString()+"n":e;return JSON.stringify(t(e))}function Zr(e,t){if(e===t)return!0;if("number"==typeof e&&"number"==typeof t&&Number.isNaN(e)&&Number.isNaN(t))return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,o)=>Zr(e,t[o]));if(Pr(e)&&Pr(t)){const o=Object.keys(e),a=Object.keys(t);return o.length===a.length&&o.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&Zr(e[o],t[o]))}return!1}function en(e){return null==e||""===e||!1===e||(Array.isArray(e)?0===e.length:!!Pr(e)&&0===Object.keys(e).length)}function tn(e,t){if(null!==e&&null!==t&&typeof e==typeof t)return Zr(e,t);if(en(e)&&en(t))return!0;if(en(e)&&void 0===t)return!0;if(void 0===e&&en(t))return!0;if("number"==typeof e&&"string"==typeof t)return e.toString()===t;if("string"==typeof e&&"number"==typeof t)return e===t.toString();if(Pr(e)&&"string"==typeof t)try{return Zr(e,JSON.parse(t))}catch{return!1}if("string"==typeof e&&Pr(t))try{return Zr(JSON.parse(e),t)}catch{return!1}return Zr(e,t)}function on(e,t,o=[]){if(!Pr(e)||Array.isArray(e))return o.length?[o.join(".")]:[];if(!t)return o.length?[o.join(".")]:Object.keys(e);const a=Object.keys(e);if(0===a.length)return o.length?[o.join(".")]:[];const r=[];for(const n of a){const a=e[n];if(Pr(a)&&!Array.isArray(a)){const e=on(a,t,[...o,n]);0===e.length?r.push([...o,n].join(".")):r.push(...e)}else r.push([...o,n].join("."))}return r}function an(e,t,o){if(!Pr(e)||Array.isArray(e))return e;const a={...e};for(const e of t)e&&qr(a,e,o);return a}function rn(e,t,o){if(!Pr(e)||Array.isArray(e))return e;const a={};for(const r of t)jr(a,r,Lr(e,r,o),o);return a}function nn(e,t,o){return t.outputFieldName?t.outputFieldName:o&&e.includes(".")?e.split(".").pop()??e:e}function dn(e,t,o={}){const a=!1!==o.dotNotation,r={},n=new Set;for(const i of t){const t=i?.field??i?.fieldToAggregate;if(!t)continue;const d=nn(t,i,a);if(n.has(d))throw new Ao(`The '${d}' output field is used more than once`,"GRAPH_AGGREGATE_DUPLICATE_FIELD",{field:d});n.add(d);const s=[];for(const r of e){let e=Lr(r,t,a);if(Array.isArray(e)&&!o.keepMissing)e=e.filter(e=>null!=e);else if(!o.keepMissing&&null==e)continue;Array.isArray(e)&&o.mergeLists?s.push(...e):s.push(e)}jr(r,d,s,a)}return r}function sn(e,t={}){const o=t.include??"allFields",a=t.fieldsToInclude??[],r=t.fieldsToExclude??[],n=[];for(const t of e){const e=Pr(t)?{...t}:void 0===t?{}:{value:t},i=Object.keys(e);let d=i;"specifiedFields"===o?d=i.filter(e=>a.includes(e)):"allFieldsExcept"===o&&(d=i.filter(e=>!r.includes(e)));const s={};for(const t of d)Mr(t,t),s[t]=e[t];Object.keys(s).length>0&&n.push(s)}return n}function ln(e,t,o,a="auto"){const r=[...e],n=t.filter(e=>e&&"string"==typeof e.field);return 0===n.length||r.sort((e,t)=>{for(const r of n){const n=Ur(Lr(e,r.field,o),Lr(t,r.field,o),a);if(0!==n)return"desc"===r.direction?-n:n}return 0}),r}function cn(e,t,o={}){const a=!1!==o.dotNotation,r=[];for(const n of e){const e=Lr(n,t,a);if(null==e)continue;const i=Array.isArray(e)?e:[e];for(const e of i){if(null==e)continue;if("allOtherFields"!==o.include){r.push(e);continue}const a=o.destinationField||t,i=Pr(n)?{...n}:{};qr(i,t,!0),jr(i,a,e,!0),r.push(i)}}return r}function pn(e,t={}){const o=!1!==t.dotNotation,a=t.compare??"allFields";let r;if("selectedFields"===a){if(r=Jr(t.fieldsToCompare,"Fields To Compare"),0===r.length)throw new Ao("No fields specified to compare on","GRAPH_REMOVE_DUPLICATES_FIELDS_REQUIRED");if(!e.some(e=>r.some(t=>void 0!==Lr(e,t,o))))throw new Ao(`The fields '${r.join(", ")}' are not present in any input item`,"GRAPH_REMOVE_DUPLICATES_FIELD_MISSING",{fields:r})}else if("allFieldsExcept"===a){const a=Jr(t.fieldsToExclude,"Fields To Exclude");if(0===a.length)throw new Ao("No fields specified to exclude from comparison","GRAPH_REMOVE_DUPLICATES_FIELDS_REQUIRED");const n=new Set;for(const t of e)for(const e of on(t,o))n.add(e);r=Array.from(n).filter(e=>!a.includes(e))}else{const t=new Set;for(const a of e)for(const e of on(a,o))t.add(e);r=Array.from(t)}const n=[],i=[],d=new Set;for(const a of e){const e=Pr(a)?Yr(r.map(e=>Lr(a,e,o))):Yr(a);d.has(e)?i.push(a):(d.add(e),n.push(t.removeOtherFields?rn(a,r,o):a))}return{kept:n,discarded:i}}e.DateTimeNode=class extends Er{constructor(){super(...arguments),this.operation="current",this.amount=0,this.unit="days"}execute(e){const t=e.inputs.value??this.value;if(Array.isArray(t)){const e=t.filter(e=>null!=e).map(e=>this.convert(e));return{result:e.map(e=>e.result),iso:e.map(e=>e.iso),timestamp:e.map(e=>e.timestamp)}}const o=this.convert(t);return{result:o.result,iso:o.iso,timestamp:o.timestamp}}convert(e){let t;switch(this.operation){case"current":t=new Date;break;case"add":t=$r(Wr(e),this.amount??0,this.unit??"days");break;case"subtract":t=$r(Wr(e),-(this.amount??0),this.unit??"days");break;case"parse":case"format":t=Wr(e);break;default:throw new Ao(`Unsupported Date & Time operation '${this.operation+""}'`,"GRAPH_DATE_TIME_UNSUPPORTED_OPERATION",{operation:this.operation})}return{result:Br(t,this.format),iso:t.toISOString(),timestamp:t.getTime()}}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.DateTimeNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.DateTimeNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.format.label",placeholder:"graph.node.data.date_time.fields.format.placeholder",type:"text"}),Ue({handle:"format",userControlled:!0}),i.__metadata("design:type",String)],e.DateTimeNode.prototype,"format",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.amount.label",type:"number"}),Ue({handle:"amount",userControlled:!0}),i.__metadata("design:type",Number)],e.DateTimeNode.prototype,"amount",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.unit.label",type:"select"}),Ue({handle:"unit",userControlled:!0}),i.__metadata("design:type",String)],e.DateTimeNode.prototype,"unit",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.DateTimeNode.prototype,"result",void 0),i.__decorate([Be({handle:"iso"}),i.__metadata("design:type",String)],e.DateTimeNode.prototype,"iso",void 0),i.__decorate([Be({handle:"timestamp"}),i.__metadata("design:type",Number)],e.DateTimeNode.prototype,"timestamp",void 0),e.DateTimeNode=i.__decorate([qe("core.data.dateTime",{kind:"core.data.dateTime",category:"Data",color:"#8b5cf6",icon:"ti-calendar-time",width:96,height:96,labels:["data","date","time"],metadata:{title:"graph.node.data.date_time.name",description:"graph.node.data.date_time.description"}}),r.model()],e.DateTimeNode),e.DataTableNode=class extends Er{constructor(){super(...arguments),this.operation="insert",this.tableName="default"}async execute(e,t){const o=t.engine?.dataTableStore;if(!o)throw new Ao("Data table node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");if(!this.tableName)throw new Ao("Data table node requires a table name","GRAPH_DATA_TABLE_NAME_REQUIRED");switch(this.operation){case"insert":return{result:await this.insertRows(e,o,t)};case"upsert":return{result:await this.upsertRows(e,o,t)};case"get":if(!this.rowId)throw new Ao("Data table 'get' requires a row id","GRAPH_DATA_TABLE_ROW_ID_REQUIRED");return{result:await o.readRow(this.tableName,this.rowId,t)??null};case"list":{const e=await o.listRows(this.tableName,this.limit,t);return{result:e,count:e.length}}case"delete":{if(!this.rowId)throw new Ao("Data table 'delete' requires a row id","GRAPH_DATA_TABLE_ROW_ID_REQUIRED");const e=await o.deleteRow(this.tableName,this.rowId,t);return{result:e,count:e?1:0}}case"clear":{const e=await o.clearTable(this.tableName,t);return{result:e,count:e}}default:throw new Ao(`Unsupported data table operation '${this.operation+""}'`,"GRAPH_DATA_TABLE_UNSUPPORTED_OPERATION",{operation:this.operation})}}rowsOf(e){const t=Gr(e.inputs.value).filter(Pr);return t.length>0?t:Pr(this.row)?[this.row]:[]}async insertRows(e,t,o){const a=this.rowsOf(e),r=[];for(const e of a){const a=this.rowId??this.rowIdOf(e)??u.randomUUID();r.push(await t.insertRow(this.tableName,a,e,o))}return r}async upsertRows(e,t,o){const a=this.rowsOf(e),r=[];for(const e of a){const a=this.rowId??this.rowIdOf(e)??u.randomUUID();r.push(await t.upsertRow(this.tableName,a,e,o))}return r}rowIdOf(e){const t=e[this.rowIdField||"id"];return"string"==typeof t&&t.length>0?t:"number"==typeof t?t+"":void 0}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.DataTableNode.prototype,"value",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.DataTableNode.prototype,"operation",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.tableName.label",placeholder:"graph.node.data.data_table.fields.tableName.placeholder",type:"text"}),Ue({handle:"tableName",userControlled:!0}),i.__metadata("design:type",String)],e.DataTableNode.prototype,"tableName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.rowId.label",placeholder:"graph.node.data.data_table.fields.rowId.placeholder",type:"text"}),Ue({handle:"rowId",userControlled:!0}),i.__metadata("design:type",String)],e.DataTableNode.prototype,"rowId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.rowIdField.label",placeholder:"graph.node.data.data_table.fields.rowIdField.placeholder",type:"text"}),Ue({handle:"rowIdField",userControlled:!0}),i.__metadata("design:type",String)],e.DataTableNode.prototype,"rowIdField",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.row.label",type:"json"}),Ue({handle:"row",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.DataTableNode.prototype,"row",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.DataTableNode.prototype,"limit",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.DataTableNode.prototype,"result",void 0),i.__decorate([Be({handle:"count"}),i.__metadata("design:type",Number)],e.DataTableNode.prototype,"count",void 0),e.DataTableNode=i.__decorate([qe("core.data.dataTable",{kind:"core.data.dataTable",category:"Data",color:"#8b5cf6",icon:"ti-table",width:96,height:96,labels:["data","table","persistence"],metadata:{title:"graph.node.data.data_table.name",description:"graph.node.data.data_table.description"}}),r.model()],e.DataTableNode),e.FilterNode=class extends Er{constructor(){super(...arguments),this.negate=!1}async execute(e,t){if(!this.condition)throw new Ao("Filter node has no condition configured","GRAPH_FILTER_NO_CONDITION");const o=Gr(e.inputs.value),a=[];for(let r=0;r<o.length;r++){const n=o[r];await pa(this.condition,{input:{...e.inputs,item:n,index:r},state:Kr(e.inputs,n),label:"filter"},t)!==(!0===this.negate)&&a.push(n)}return{result:a}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.FilterNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.filter.fields.condition.label",placeholder:"graph.node.data.filter.fields.condition.placeholder",type:"code"}),Ue({handle:"condition",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.FilterNode.prototype,"condition",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.filter.fields.negate.label",type:"checkbox"}),Ue({handle:"negate",userControlled:!0}),i.__metadata("design:type",Boolean)],e.FilterNode.prototype,"negate",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Array)],e.FilterNode.prototype,"result",void 0),e.FilterNode=i.__decorate([qe("core.data.filter",{kind:"core.data.filter",category:"Data",color:"#8b5cf6",icon:"ti-filter",width:96,height:96,labels:["data","filter","condition"],metadata:{title:"graph.node.data.filter.name",description:"graph.node.data.filter.description"}}),r.model()],e.FilterNode),e.LimitNode=class extends Er{constructor(){super(...arguments),this.maxItems=1,this.keep="firstItems"}execute(e){const t=Gr(e.inputs.value),o=Math.max(0,Math.floor(Number(this.maxItems??1)));return o<t.length?"lastItems"===this.keep?{result:t.slice(t.length-o)}:{result:t.slice(0,o)}:{result:t}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.LimitNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.limit.fields.maxItems.label",type:"number"}),Ue({handle:"maxItems",userControlled:!0}),i.__metadata("design:type",Number)],e.LimitNode.prototype,"maxItems",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.limit.fields.keep.label",type:"select"}),Ue({handle:"keep",userControlled:!0}),i.__metadata("design:type",String)],e.LimitNode.prototype,"keep",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Array)],e.LimitNode.prototype,"result",void 0),e.LimitNode=i.__decorate([qe("core.data.limit",{kind:"core.data.limit",category:"Data",color:"#8b5cf6",icon:"ti-arrows-bar-to-line",width:96,height:96,labels:["data","limit","slice"],metadata:{title:"graph.node.data.limit.name",description:"graph.node.data.limit.description"}}),r.model()],e.LimitNode),e.MergeNode=class extends Er{constructor(){super(...arguments),this.mode="append",this.combineBy="position",this.joinMode="inner",this.clashHandling="keepFirst"}execute(e){const t=Gr(e.inputs.input),o=Gr(e.inputs.input2);if("append"===this.mode)return{result:[...t,...o]};if("fields"===this.combineBy)return{result:this.mergeByFields(t,o)};const a=Math.max(t.length,o.length),r=[];for(let e=0;a>e;e++){if(e>=t.length){if("inner"===this.joinMode||"left"===this.joinMode)continue;r.push(o[e]);continue}if(e>=o.length){if("inner"===this.joinMode||"right"===this.joinMode)continue;r.push(t[e]);continue}const a=t[e],n=o[e];Pr(a)&&Pr(n)?r.push(zr(a,n,this.clashHandling)):r.push([a,n])}return{result:r}}mergeByFields(e,t){const o=this.joinField;if(!o)throw new Ao("Merge node in 'fields' mode requires a join field","GRAPH_MERGE_JOIN_FIELD_REQUIRED");const a=new Map;for(const e of t){if(!Pr(e))continue;const t=Lr(e,o);if(null==t)continue;const r=a.get(t);a.set(t,r?zr(r,e,this.clashHandling):e)}const r=[],n=new Set;for(const t of e){if(!Pr(t)){"inner"!==this.joinMode&&"right"!==this.joinMode&&r.push(t);continue}const e=Lr(t,o),i=a.get(e);i?(n.add(e),r.push(zr(t,i,this.clashHandling))):"inner"!==this.joinMode&&"right"!==this.joinMode&&r.push(t)}if("right"===this.joinMode||"outer"===this.joinMode)for(const[e,t]of a)n.has(e)||r.push(t);return r}},i.__decorate([r.required(),Ue({handle:"input"}),i.__metadata("design:type",Object)],e.MergeNode.prototype,"input",void 0),i.__decorate([Ue({handle:"input2"}),i.__metadata("design:type",Object)],e.MergeNode.prototype,"input2",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.mode.label",type:"select"}),Ue({handle:"mode",userControlled:!0}),i.__metadata("design:type",String)],e.MergeNode.prototype,"mode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.combineBy.label",type:"select"}),Ue({handle:"combineBy",userControlled:!0}),i.__metadata("design:type",String)],e.MergeNode.prototype,"combineBy",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.joinMode.label",type:"select"}),Ue({handle:"joinMode",userControlled:!0}),i.__metadata("design:type",String)],e.MergeNode.prototype,"joinMode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.joinField.label",placeholder:"graph.node.data.merge.fields.joinField.placeholder",type:"text"}),Ue({handle:"joinField",userControlled:!0}),i.__metadata("design:type",String)],e.MergeNode.prototype,"joinField",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.clashHandling.label",type:"select"}),Ue({handle:"clashHandling",userControlled:!0}),i.__metadata("design:type",String)],e.MergeNode.prototype,"clashHandling",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Array)],e.MergeNode.prototype,"result",void 0),e.MergeNode=i.__decorate([qe("core.data.merge",{kind:"core.data.merge",category:"Data",color:"#8b5cf6",icon:"ti-git-merge",width:96,height:96,labels:["data","merge","join"],metadata:{title:"graph.node.data.merge.name",description:"graph.node.data.merge.description"}}),r.model()],e.MergeNode),e.RenameKeysNode=class extends Er{constructor(){super(...arguments),this.renames=[],this.dotNotation=!0}execute(e){const t=(this.renames??[]).filter(e=>e&&"string"==typeof e.from&&"string"==typeof e.to),o=e.inputs.value,a=!1!==this.dotNotation;return Array.isArray(o)?{result:o.filter(e=>null!=e).map(e=>Pr(e)?Qr(e,t,a):e)}:Pr(o)?{result:Qr(o,t,a)}:{result:Gr(o)}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.RenameKeysNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.rename_keys.fields.renames.label",placeholder:"graph.node.data.rename_keys.fields.renames.placeholder",type:"collection"}),Ue({handle:"renames",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.RenameKeysNode.prototype,"renames",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.rename_keys.fields.dotNotation.label",type:"checkbox"}),Ue({handle:"dotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.RenameKeysNode.prototype,"dotNotation",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.RenameKeysNode.prototype,"result",void 0),e.RenameKeysNode=i.__decorate([qe("core.data.renameKeys",{kind:"core.data.renameKeys",category:"Data",color:"#8b5cf6",icon:"ti-key",width:96,height:96,labels:["data","rename","keys"],metadata:{title:"graph.node.data.rename_keys.name",description:"graph.node.data.rename_keys.description"}}),r.model()],e.RenameKeysNode),e.SetNode=class extends Er{constructor(){super(...arguments),this.assignments=[],this.includeOtherFields=!0,this.dotNotation=!0}execute(e){const t=e.inputs.value;return Array.isArray(t)?{result:t.filter(e=>null!=e).map(e=>this.applyTo(e))}:{result:this.applyTo(t)}}applyTo(e){const t=this.includeOtherFields?Pr(e)?{...e}:void 0===e?{}:{value:e}:{};for(const e of this.assignments??[]){if(!e||"string"!=typeof e.name)continue;const o=Hr(e.value,e.type??"json");null!=o&&jr(t,e.name,o,!1!==this.dotNotation)}return t}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.SetNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.assignments.label",placeholder:"graph.node.data.set.fields.assignments.placeholder",type:"collection"}),Ue({handle:"assignments",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.SetNode.prototype,"assignments",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.includeOtherFields.label",type:"checkbox"}),Ue({handle:"includeOtherFields",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SetNode.prototype,"includeOtherFields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.dotNotation.label",type:"checkbox"}),Ue({handle:"dotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SetNode.prototype,"dotNotation",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.SetNode.prototype,"result",void 0),e.SetNode=i.__decorate([qe("core.data.set",{kind:"core.data.set",category:"Data",color:"#8b5cf6",icon:"ti-adjustments-horizontal",width:96,height:96,labels:["data","set","assign"],metadata:{title:"graph.node.data.set.name",description:"graph.node.data.set.description"}}),r.model()],e.SetNode),e.SortNode=class extends Er{constructor(){super(...arguments),this.sortFields=[],this.valueType="auto",this.dotNotation=!0}execute(e){const t=[...Gr(e.inputs.value)],o=(this.sortFields??[]).filter(e=>e&&"string"==typeof e.field);return 0===o.length||t.sort((e,t)=>{for(const a of o){const o=Ur(Lr(e,a.field,!1!==this.dotNotation),Lr(t,a.field,!1!==this.dotNotation),this.valueType??"auto");if(0!==o)return"desc"===a.direction?-o:o}return 0}),{result:t}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.SortNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.sortFields.label",placeholder:"graph.node.data.sort.fields.sortFields.placeholder",type:"collection"}),Ue({handle:"sortFields",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.SortNode.prototype,"sortFields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.valueType.label",type:"select"}),Ue({handle:"valueType",userControlled:!0}),i.__metadata("design:type",String)],e.SortNode.prototype,"valueType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.dotNotation.label",type:"checkbox"}),Ue({handle:"dotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SortNode.prototype,"dotNotation",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Array)],e.SortNode.prototype,"result",void 0),e.SortNode=i.__decorate([qe("core.data.sort",{kind:"core.data.sort",category:"Data",color:"#8b5cf6",icon:"ti-sort-ascending",width:96,height:96,labels:["data","sort","order"],metadata:{title:"graph.node.data.sort.name",description:"graph.node.data.sort.description"}}),r.model()],e.SortNode),e.SplitOutNode=class extends Er{constructor(){super(...arguments),this.field="",this.include="noOtherFields"}execute(e){if(!this.field)throw new Ao("Split Out node requires a field name","GRAPH_SPLIT_OUT_FIELD_REQUIRED");const t=Gr(e.inputs.value),o=[];for(const e of t){const t=Lr(e,this.field,!0);if(null==t)continue;const a=Array.isArray(t)?t:[t];for(const t of a){if(null==t)continue;if("allOtherFields"!==this.include){o.push(t);continue}const a=this.destinationField||this.field,r=Pr(e)?{...e}:{};qr(r,this.field,!0),jr(r,a,t,!0),o.push(r)}}return{result:o}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.SplitOutNode.prototype,"value",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.field.label",placeholder:"graph.node.data.split_out.fields.field.placeholder",type:"text"}),Ue({handle:"field",userControlled:!0}),i.__metadata("design:type",String)],e.SplitOutNode.prototype,"field",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.include.label",type:"select"}),Ue({handle:"include",userControlled:!0}),i.__metadata("design:type",String)],e.SplitOutNode.prototype,"include",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.destinationField.label",placeholder:"graph.node.data.split_out.fields.destinationField.placeholder",type:"text"}),Ue({handle:"destinationField",userControlled:!0}),i.__metadata("design:type",String)],e.SplitOutNode.prototype,"destinationField",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Array)],e.SplitOutNode.prototype,"result",void 0),e.SplitOutNode=i.__decorate([qe("core.data.splitOut",{kind:"core.data.splitOut",category:"Data",color:"#8b5cf6",icon:"ti-arrows-split-2",width:96,height:96,labels:["data","split","array"],metadata:{title:"graph.node.data.split_out.name",description:"graph.node.data.split_out.description"}}),r.model()],e.SplitOutNode);const un={append:"appended_",average:"average_",concatenate:"concatenated_",count:"count_",countUnique:"unique_count_",max:"max_",min:"min_",sum:"sum_"};function gn(e,t,o){const a=t.field??"",r=e.map(e=>a?Lr(e,a,o):e),n=t.includeEmpty?r:r.filter(e=>!(e=>null==e||""===e)(e));switch(t.aggregation){case"append":return n;case"concatenate":{const e="other"===t.separator?t.customSeparator??"":t.separator??",";return n.map(e=>void 0===e?"undefined":"object"==typeof e?JSON.stringify(e):e+"").join(e)}case"average":{const e=n.filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===e.length?null:e.reduce((e,t)=>e+t,0)/e.length}case"sum":return n.filter(e=>"number"==typeof e&&Number.isFinite(e)).reduce((e,t)=>e+t,0);case"min":{let e;for(const t of n)null!=t&&""!==t&&(void 0===e||e>t)&&(e=t);return e??null}case"max":{let e;for(const t of n)null!=t&&""!==t&&(void 0===e||t>e)&&(e=t);return e??null}case"countUnique":return new Set(n.map(e=>Yr(e))).size;default:return n.length}}function hn(e,t,o){const a={};for(const r of t){const t=r.field??"",n=Xr(`${un[r.aggregation]??"count_"}${t}`);Mr(n,n),a[n]=gn(e,r,o)}return a}function mn(e){return void 0===e?"undefined":null===e?"null":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?e+"":Yr(e)}function fn(e,t,o,a,r){if(o>=t.length)return[];const n=t[o],i=new Map;for(const t of e){let e=Lr(t,n,a);if(e&&"object"==typeof e&&(e=JSON.stringify(e)),r&&"number"!=typeof e&&!e)continue;const o=Yr(e),d=i.get(o)??{value:e,items:[]};d.items.push(t),i.set(o,d)}const d=o===t.length-1;return Array.from(i.values()).map(e=>({field:n,value:e.value,...d?{items:e.items}:{children:fn(e.items,t,o+1,a,r)}}))}function _n(e,t,o={}){const a=!1!==o.dotNotation,r=Jr(o.fieldsToSplitBy,"Fields To Split By"),n=o.outputFormat??"separateItems";if(!o.continueIfFieldNotFound)for(const o of t){const t=o.field??"";if(t&&!e.some(e=>void 0!==Lr(e,t,a)))throw new Ao(`The field '${t}' does not exist in any items`,"GRAPH_SUMMARIZE_FIELD_NOT_FOUND",{field:t})}if(0===r.length)return[hn(e,t,a)];const i=fn(e,r,r.length>0?0:-1,a,!0===o.skipEmptySplitFields);if("singleItem"===n){const o=hn(e,t,a),r=(e,o)=>{for(const n of e){const e=Xr(n.field);Mr(e,e);const i=o[e]??{};o[e]=i;const d=mn(n.value);if(Mr(d,d),n.children&&n.children.length>0){const e=i[d]??{};i[d]=e,r(n.children,e)}else n.items&&(i[d]=hn(n.items,t,a))}};return r(i,o),[o]}const d=[],s=(e,o,r)=>{for(const n of e){const e=[...o,n.field],i=[...r,n.value];if(n.children&&n.children.length>0)s(n.children,e,i);else if(n.items){const o=hn(n.items,t,a);e.forEach((e,t)=>{const a=Xr(e);Mr(a,a),o[a]=i[t]}),d.push(o)}}};return s(i,[],[]),d}function yn(e){const t=e?.field1??e?.fieldA,o=e?.field2??e?.fieldB;if(t&&o)return{a:t,b:o}}function bn(e){return Pr(e)?Object.keys(e):[]}function wn(e,t,o,a){const r=Pr(e)?e:{value:e},n=Pr(t)?t:{value:t},i={};for(const e of o)i[e.a]=Lr(r,e.a,a.dotNotation);const d=Array.from(new Set([...bn(r),...bn(n)])),s={},l={};for(const e of d){if(a.skipFields.includes(e))continue;const t=Lr(r,e,a.dotNotation),o=Lr(n,e,a.dotNotation);a.equals(t,o)?s[e]=t:l[e]={inputA:t,inputB:o}}return{keys:i,same:s,different:l}}function Nn(e,t){if("string"==typeof e){if(e.startsWith("data:")){const t=e.indexOf(",");if(t>=0)return Buffer.from(e.slice(t+1),"base64").toString("utf8")}return"base64"===t?Buffer.from(e,"base64").toString("utf8"):e}if(Vr(e))return(Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e)).toString("utf8");if(Pr(e)){if("string"==typeof e.data)return Nn(e.data,t);if("string"==typeof e.content)return Nn(e.content,t);throw new Ao("Extract from File node received an object without file content","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT")}throw new Ao("Extract from File node requires a file payload","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT",{valueType:typeof e})}e.AggregateNode=class extends Er{constructor(){super(...arguments),this.aggregate="aggregateIndividualFields",this.fieldsToAggregate=[],this.destinationFieldName="data",this.include="allFields",this.mergeLists=!1,this.keepMissing=!1,this.disableDotNotation=!1}execute(e){const t=Gr(e.inputs.value);if("aggregateAllItemData"===this.aggregate){const e=this.destinationFieldName||"data";return{result:{[e]:sn(t,{include:this.include,fieldsToInclude:Jr(this.fieldsToInclude,"Fields To Include"),fieldsToExclude:Jr(this.fieldsToExclude,"Fields To Exclude")})}}}const o=(this.fieldsToAggregate??[]).filter(e=>e&&(e.field||e.fieldToAggregate));if(0===o.length)throw new Ao("Aggregate node requires at least one field to aggregate","GRAPH_AGGREGATE_FIELDS_REQUIRED");return{result:dn(t,o,{dotNotation:!0!==this.disableDotNotation,mergeLists:!0===this.mergeLists,keepMissing:!0===this.keepMissing})}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.AggregateNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.aggregate.label",type:"select"}),Ue({handle:"aggregate",userControlled:!0}),i.__metadata("design:type",String)],e.AggregateNode.prototype,"aggregate",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.fieldsToAggregate.label",placeholder:"graph.node.data.aggregate.fields.fieldsToAggregate.placeholder",type:"collection"}),Ue({handle:"fieldsToAggregate",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.AggregateNode.prototype,"fieldsToAggregate",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.destinationFieldName.label",type:"text"}),Ue({handle:"destinationFieldName",userControlled:!0}),i.__metadata("design:type",String)],e.AggregateNode.prototype,"destinationFieldName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.include.label",type:"select"}),Ue({handle:"include",userControlled:!0}),i.__metadata("design:type",String)],e.AggregateNode.prototype,"include",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.fieldsToInclude.label",placeholder:"graph.node.data.aggregate.fields.fieldsToInclude.placeholder",type:"text"}),Ue({handle:"fieldsToInclude",userControlled:!0}),i.__metadata("design:type",Object)],e.AggregateNode.prototype,"fieldsToInclude",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.fieldsToExclude.label",placeholder:"graph.node.data.aggregate.fields.fieldsToExclude.placeholder",type:"text"}),Ue({handle:"fieldsToExclude",userControlled:!0}),i.__metadata("design:type",Object)],e.AggregateNode.prototype,"fieldsToExclude",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.mergeLists.label",type:"checkbox"}),Ue({handle:"mergeLists",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AggregateNode.prototype,"mergeLists",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.keepMissing.label",type:"checkbox"}),Ue({handle:"keepMissing",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AggregateNode.prototype,"keepMissing",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.disableDotNotation.label",type:"checkbox"}),Ue({handle:"disableDotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AggregateNode.prototype,"disableDotNotation",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.AggregateNode.prototype,"result",void 0),e.AggregateNode=i.__decorate([qe("core.data.aggregate",{kind:"core.data.aggregate",category:"Data",color:"#8b5cf6",icon:"ti-box-multiple",width:96,height:96,labels:["data","aggregate","group"],metadata:{title:"graph.node.data.aggregate.name",description:"graph.node.data.aggregate.description"}}),r.model()],e.AggregateNode),e.ItemListsNode=class extends Er{constructor(){super(...arguments),this.operation="concatenateItems",this.aggregate="aggregateIndividualFields",this.fieldsToAggregate=[],this.destinationFieldName="data",this.include="allFields",this.mergeLists=!1,this.keepMissing=!1,this.maxItems=1,this.keep="firstItems",this.compareMode="allFields",this.removeOtherFields=!1,this.sortFields=[],this.sortValueType="auto",this.field="",this.splitOutInclude="noOtherFields",this.fieldsToSummarize=[],this.outputFormat="separateItems",this.skipEmptySplitFields=!1,this.continueIfFieldNotFound=!1,this.disableDotNotation=!1}execute(e){const t=Gr(e.inputs.value);switch(this.operation){case"limit":{const e=Math.max(0,Math.floor(Number(this.maxItems??1)));return{result:"lastItems"===this.keep?t.slice(Math.max(0,t.length-e)):t.slice(0,e)}}case"removeDuplicates":{const{kept:e,discarded:o}=pn(t,{compare:this.compareMode,fieldsToExclude:this.fieldsToExclude,fieldsToCompare:this.fieldsToCompare,removeOtherFields:!0===this.removeOtherFields,dotNotation:!0!==this.disableDotNotation});return{result:e,discarded:o}}case"sort":return{result:ln(t,this.sortFields??[],!0!==this.disableDotNotation,this.sortValueType??"auto")};case"splitOutItems":if(!this.field)throw new Ao("Item Lists node split out operation requires a field name","GRAPH_ITEM_LISTS_FIELD_REQUIRED");return{result:cn(t,this.field,{include:this.splitOutInclude,destinationField:this.destinationField,dotNotation:!0!==this.disableDotNotation})};case"summarize":{const e=(this.fieldsToSummarize??[]).filter(e=>e&&"string"==typeof e.aggregation);if(0===e.length)throw new Ao("Item Lists node summarize operation requires at least one field","GRAPH_SUMMARIZE_FIELDS_REQUIRED");return{result:_n(t,e,{fieldsToSplitBy:Jr(this.fieldsToSplitBy,"Fields To Split By"),outputFormat:this.outputFormat,skipEmptySplitFields:!0===this.skipEmptySplitFields,dotNotation:!0!==this.disableDotNotation,continueIfFieldNotFound:!0===this.continueIfFieldNotFound})}}case"concatenateItems":break;default:throw new Ao(`Item Lists operation '${this.operation+""}' is not supported`,"GRAPH_ITEM_LISTS_UNSUPPORTED_OPERATION",{operation:this.operation})}if("aggregateAllItemData"===this.aggregate){const e=this.destinationFieldName||"data";return{result:{[e]:sn(t,{include:this.include,fieldsToInclude:Jr(this.fieldsToInclude,"Fields To Include"),fieldsToExclude:Jr(this.fieldsToExclude,"Fields To Exclude")})}}}const o=(this.fieldsToAggregate??[]).filter(e=>e&&(e.field||e.fieldToAggregate));if(0===o.length)throw new Ao("Item Lists node concatenate operation requires at least one field","GRAPH_AGGREGATE_FIELDS_REQUIRED");return{result:dn(t,o,{dotNotation:!0!==this.disableDotNotation,mergeLists:!0===this.mergeLists,keepMissing:!0===this.keepMissing})}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.ItemListsNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.aggregate.label",type:"select"}),Ue({handle:"aggregate",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"aggregate",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToAggregate.label",placeholder:"graph.node.data.item_lists.fields.fieldsToAggregate.placeholder",type:"collection"}),Ue({handle:"fieldsToAggregate",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.ItemListsNode.prototype,"fieldsToAggregate",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.destinationFieldName.label",type:"text"}),Ue({handle:"destinationFieldName",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"destinationFieldName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.include.label",type:"select"}),Ue({handle:"include",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"include",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToInclude.label",placeholder:"graph.node.data.item_lists.fields.fieldsToInclude.placeholder",type:"text"}),Ue({handle:"fieldsToInclude",userControlled:!0}),i.__metadata("design:type",Object)],e.ItemListsNode.prototype,"fieldsToInclude",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToExclude.label",placeholder:"graph.node.data.item_lists.fields.fieldsToExclude.placeholder",type:"text"}),Ue({handle:"fieldsToExclude",userControlled:!0}),i.__metadata("design:type",Object)],e.ItemListsNode.prototype,"fieldsToExclude",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.mergeLists.label",type:"checkbox"}),Ue({handle:"mergeLists",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ItemListsNode.prototype,"mergeLists",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.keepMissing.label",type:"checkbox"}),Ue({handle:"keepMissing",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ItemListsNode.prototype,"keepMissing",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.maxItems.label",type:"number"}),Ue({handle:"maxItems",userControlled:!0}),i.__metadata("design:type",Number)],e.ItemListsNode.prototype,"maxItems",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.keep.label",type:"select"}),Ue({handle:"keep",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"keep",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.compareMode.label",type:"select"}),Ue({handle:"compareMode",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"compareMode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToCompare.label",placeholder:"graph.node.data.item_lists.fields.fieldsToCompare.placeholder",type:"text"}),Ue({handle:"fieldsToCompare",userControlled:!0}),i.__metadata("design:type",Object)],e.ItemListsNode.prototype,"fieldsToCompare",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.removeOtherFields.label",type:"checkbox"}),Ue({handle:"removeOtherFields",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ItemListsNode.prototype,"removeOtherFields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.sortFields.label",placeholder:"graph.node.data.item_lists.fields.sortFields.placeholder",type:"collection"}),Ue({handle:"sortFields",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.ItemListsNode.prototype,"sortFields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.sortValueType.label",type:"select"}),Ue({handle:"sortValueType",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"sortValueType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.field.label",placeholder:"graph.node.data.item_lists.fields.field.placeholder",type:"text"}),Ue({handle:"field",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"field",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.splitOutInclude.label",type:"select"}),Ue({handle:"splitOutInclude",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"splitOutInclude",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.destinationField.label",placeholder:"graph.node.data.item_lists.fields.destinationField.placeholder",type:"text"}),Ue({handle:"destinationField",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"destinationField",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToSummarize.label",placeholder:"graph.node.data.item_lists.fields.fieldsToSummarize.placeholder",type:"collection"}),Ue({handle:"fieldsToSummarize",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.ItemListsNode.prototype,"fieldsToSummarize",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToSplitBy.label",placeholder:"graph.node.data.item_lists.fields.fieldsToSplitBy.placeholder",type:"text"}),Ue({handle:"fieldsToSplitBy",userControlled:!0}),i.__metadata("design:type",Object)],e.ItemListsNode.prototype,"fieldsToSplitBy",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.outputFormat.label",type:"select"}),Ue({handle:"outputFormat",userControlled:!0}),i.__metadata("design:type",String)],e.ItemListsNode.prototype,"outputFormat",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.skipEmptySplitFields.label",type:"checkbox"}),Ue({handle:"skipEmptySplitFields",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ItemListsNode.prototype,"skipEmptySplitFields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.continueIfFieldNotFound.label",type:"checkbox"}),Ue({handle:"continueIfFieldNotFound",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ItemListsNode.prototype,"continueIfFieldNotFound",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.disableDotNotation.label",type:"checkbox"}),Ue({handle:"disableDotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ItemListsNode.prototype,"disableDotNotation",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.ItemListsNode.prototype,"result",void 0),i.__decorate([Be({handle:"discarded"}),i.__metadata("design:type",Array)],e.ItemListsNode.prototype,"discarded",void 0),e.ItemListsNode=i.__decorate([qe("core.data.itemLists",{kind:"core.data.itemLists",category:"Data",color:"#8b5cf6",icon:"ti-list-details",width:96,height:96,labels:["data","list","items","transform"],metadata:{title:"graph.node.data.item_lists.name",description:"graph.node.data.item_lists.description"}}),r.model()],e.ItemListsNode),e.CompareDatasetsNode=class extends Er{constructor(){super(...arguments),this.fieldsToMatch=[],this.resolve="includeBoth",this.multipleMatches="first",this.fuzzyCompare=!1,this.preferWhenMix="input1",this.disableDotNotation=!1}execute(e){const t=(this.fieldsToMatch??[]).map(yn).filter(e=>void 0!==e);if(0===t.length)throw new Ao("Compare Datasets node requires at least one pair of fields to match on","GRAPH_COMPARE_DATASETS_MATCH_FIELDS_REQUIRED");const o=!0!==this.disableDotNotation,a=this.fuzzyCompare?tn:Zr,r=Jr(this.skipFields,"Fields to Skip"),n=Jr(this.exceptWhenMix,"For Everything Except"),i=Gr(e.inputs.input),d=Gr(e.inputs.input2),s="all"===this.multipleMatches?"all":"first",l=this.resolve??"includeBoth",c=[],p=[],u=[],g=[],h=new Set;for(const e of i){if(t.map(t=>({field:t.b,value:Lr(e,t.a,o)})).some(e=>void 0===e.value)){c.push(e);continue}const i=[];for(let r=0;r<d.length;r++){const n=d[r];if(t.every(t=>a(Lr(e,t.a,o),Lr(n,t.b,o)))&&(i.push({item:n,index:r}),"first"===s))break}if(0===i.length){c.push(e);continue}let g;for(const d of i){h.add(d.index);const i=an(e,r,o),s=an(d.item,r,o);if(a(i,s))void 0===g&&(g=this.fuzzyCompare&&"preferInput2"===l?d.item:e);else switch(l){case"preferInput1":u.push(e);break;case"preferInput2":u.push(d.item);break;case"mix":{const t="input2"===this.preferWhenMix?d.item:e,a="input2"===this.preferWhenMix?e:d.item;if(0===n.length){u.push(t);break}const r=Pr(t)?{...t}:{value:t},i=Pr(a)?a:{value:a};for(const e of n){const t=Lr(i,e,o);if(!o){r[e]=t;continue}const a=e.split(".").filter(Boolean);let n=r;for(let e=0;e<a.length-1;e++){const t=n[a[e]];if(Pr(t))n=t;else{const t={};n[a[e]]=t,n=t}}n[a[a.length-1]]=t}u.push(r);break}default:u.push(wn(e,d.item,t,{skipFields:r,dotNotation:o,equals:a}))}}void 0!==g&&p.push(g)}return d.forEach((e,t)=>{h.has(t)||g.push(e)}),{onlyInA:c,same:p,different:u,onlyInB:g}}},i.__decorate([r.required(),Ue({handle:"input"}),i.__metadata("design:type",Object)],e.CompareDatasetsNode.prototype,"input",void 0),i.__decorate([r.required(),Ue({handle:"input2"}),i.__metadata("design:type",Object)],e.CompareDatasetsNode.prototype,"input2",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.fieldsToMatch.label",placeholder:"graph.node.data.compare_datasets.fields.fieldsToMatch.placeholder",type:"collection"}),Ue({handle:"fieldsToMatch",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.CompareDatasetsNode.prototype,"fieldsToMatch",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.resolve.label",type:"select"}),Ue({handle:"resolve",userControlled:!0}),i.__metadata("design:type",String)],e.CompareDatasetsNode.prototype,"resolve",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.multipleMatches.label",type:"select"}),Ue({handle:"multipleMatches",userControlled:!0}),i.__metadata("design:type",String)],e.CompareDatasetsNode.prototype,"multipleMatches",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.fuzzyCompare.label",type:"checkbox"}),Ue({handle:"fuzzyCompare",userControlled:!0}),i.__metadata("design:type",Boolean)],e.CompareDatasetsNode.prototype,"fuzzyCompare",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.preferWhenMix.label",type:"select"}),Ue({handle:"preferWhenMix",userControlled:!0}),i.__metadata("design:type",String)],e.CompareDatasetsNode.prototype,"preferWhenMix",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.exceptWhenMix.label",placeholder:"graph.node.data.compare_datasets.fields.exceptWhenMix.placeholder",type:"text"}),Ue({handle:"exceptWhenMix",userControlled:!0}),i.__metadata("design:type",Object)],e.CompareDatasetsNode.prototype,"exceptWhenMix",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.skipFields.label",placeholder:"graph.node.data.compare_datasets.fields.skipFields.placeholder",type:"text"}),Ue({handle:"skipFields",userControlled:!0}),i.__metadata("design:type",Object)],e.CompareDatasetsNode.prototype,"skipFields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.disableDotNotation.label",type:"checkbox"}),Ue({handle:"disableDotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.CompareDatasetsNode.prototype,"disableDotNotation",void 0),i.__decorate([r.required(),Be({handle:"onlyInA"}),i.__metadata("design:type",Array)],e.CompareDatasetsNode.prototype,"onlyInA",void 0),i.__decorate([Be({handle:"same"}),i.__metadata("design:type",Array)],e.CompareDatasetsNode.prototype,"same",void 0),i.__decorate([Be({handle:"different"}),i.__metadata("design:type",Array)],e.CompareDatasetsNode.prototype,"different",void 0),i.__decorate([Be({handle:"onlyInB"}),i.__metadata("design:type",Array)],e.CompareDatasetsNode.prototype,"onlyInB",void 0),e.CompareDatasetsNode=i.__decorate([qe("core.data.compareDatasets",{kind:"core.data.compareDatasets",category:"Data",color:"#8b5cf6",icon:"ti-git-compare",width:96,height:96,labels:["data","compare","diff","datasets"],metadata:{title:"graph.node.data.compare_datasets.name",description:"graph.node.data.compare_datasets.description"}}),r.model()],e.CompareDatasetsNode),e.SummarizeNode=class extends Er{constructor(){super(...arguments),this.fieldsToSummarize=[],this.outputFormat="separateItems",this.skipEmptySplitFields=!1,this.disableDotNotation=!1,this.continueIfFieldNotFound=!1}execute(e){const t=Gr(e.inputs.value),o=(this.fieldsToSummarize??[]).filter(e=>e&&"string"==typeof e.aggregation);if(0===o.length)throw new Ao("Summarize node requires at least one field to summarize","GRAPH_SUMMARIZE_FIELDS_REQUIRED");return{result:_n(t,o,{fieldsToSplitBy:Jr(this.fieldsToSplitBy,"Fields To Split By"),outputFormat:this.outputFormat,skipEmptySplitFields:!0===this.skipEmptySplitFields,dotNotation:!0!==this.disableDotNotation,continueIfFieldNotFound:!0===this.continueIfFieldNotFound})}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.SummarizeNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.fieldsToSummarize.label",placeholder:"graph.node.data.summarize.fields.fieldsToSummarize.placeholder",type:"collection"}),Ue({handle:"fieldsToSummarize",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.SummarizeNode.prototype,"fieldsToSummarize",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.fieldsToSplitBy.label",placeholder:"graph.node.data.summarize.fields.fieldsToSplitBy.placeholder",type:"text"}),Ue({handle:"fieldsToSplitBy",userControlled:!0}),i.__metadata("design:type",Object)],e.SummarizeNode.prototype,"fieldsToSplitBy",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.outputFormat.label",type:"select"}),Ue({handle:"outputFormat",userControlled:!0}),i.__metadata("design:type",String)],e.SummarizeNode.prototype,"outputFormat",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.skipEmptySplitFields.label",type:"checkbox"}),Ue({handle:"skipEmptySplitFields",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SummarizeNode.prototype,"skipEmptySplitFields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.disableDotNotation.label",type:"checkbox"}),Ue({handle:"disableDotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SummarizeNode.prototype,"disableDotNotation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.continueIfFieldNotFound.label",type:"checkbox"}),Ue({handle:"continueIfFieldNotFound",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SummarizeNode.prototype,"continueIfFieldNotFound",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Array)],e.SummarizeNode.prototype,"result",void 0),e.SummarizeNode=i.__decorate([qe("core.data.summarize",{kind:"core.data.summarize",category:"Data",color:"#8b5cf6",icon:"ti-chart-dots",width:96,height:96,labels:["data","summarize","pivot","aggregate"],metadata:{title:"graph.node.data.summarize.name",description:"graph.node.data.summarize.description"}}),r.model()],e.SummarizeNode),e.RemoveDuplicatesNode=class extends Er{constructor(){super(...arguments),this.compareMode="allFields",this.removeOtherFields=!1,this.disableDotNotation=!1}execute(e){const t=Gr(e.inputs.value),{kept:o,discarded:a}=pn(t,{compare:this.compareMode,fieldsToExclude:this.fieldsToExclude,fieldsToCompare:this.fieldsToCompare,removeOtherFields:!0===this.removeOtherFields,dotNotation:!0!==this.disableDotNotation});return{result:o,discarded:a}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.RemoveDuplicatesNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.compareMode.label",type:"select"}),Ue({handle:"compareMode",userControlled:!0}),i.__metadata("design:type",String)],e.RemoveDuplicatesNode.prototype,"compareMode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.fieldsToCompare.label",placeholder:"graph.node.data.remove_duplicates.fields.fieldsToCompare.placeholder",type:"text"}),Ue({handle:"fieldsToCompare",userControlled:!0}),i.__metadata("design:type",Object)],e.RemoveDuplicatesNode.prototype,"fieldsToCompare",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.fieldsToExclude.label",placeholder:"graph.node.data.remove_duplicates.fields.fieldsToExclude.placeholder",type:"text"}),Ue({handle:"fieldsToExclude",userControlled:!0}),i.__metadata("design:type",Object)],e.RemoveDuplicatesNode.prototype,"fieldsToExclude",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.removeOtherFields.label",type:"checkbox"}),Ue({handle:"removeOtherFields",userControlled:!0}),i.__metadata("design:type",Boolean)],e.RemoveDuplicatesNode.prototype,"removeOtherFields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.disableDotNotation.label",type:"checkbox"}),Ue({handle:"disableDotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.RemoveDuplicatesNode.prototype,"disableDotNotation",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Array)],e.RemoveDuplicatesNode.prototype,"result",void 0),i.__decorate([Be({handle:"discarded"}),i.__metadata("design:type",Array)],e.RemoveDuplicatesNode.prototype,"discarded",void 0),e.RemoveDuplicatesNode=i.__decorate([qe("core.data.removeDuplicates",{kind:"core.data.removeDuplicates",category:"Data",color:"#8b5cf6",icon:"ti-copy-off",width:96,height:96,labels:["data","dedupe","duplicates","unique"],metadata:{title:"graph.node.data.remove_duplicates.name",description:"graph.node.data.remove_duplicates.description"}}),r.model()],e.RemoveDuplicatesNode),e.ExtractFromFileNode=class extends Er{constructor(){super(...arguments),this.format="json",this.encoding="utf8",this.delimiter=",",this.headerRow=!0}execute(e){const t=Nn(e.inputs.value,this.encoding??"utf8");switch(this.format){case"json":try{return{result:JSON.parse(t)}}catch(e){throw new Ao("Extract from File node could not parse JSON: "+(e instanceof Error?e.message:e+""),"GRAPH_EXTRACT_FROM_FILE_INVALID_JSON")}case"csv":{const e=((e,t,o)=>{const a=((e,t)=>{const o=[];let a=[],r="",n=!1;for(let i=0;i<e.length;i++){const d=e[i];n?'"'===d?'"'===e[i+1]?(r+='"',i++):n=!1:r+=d:'"'!==d?d!==t?"\n"!==d?"\r"!==d&&(r+=d):(a.push(r),o.push(a),a=[],r=""):(a.push(r),r=""):n=!0}return(r.length>0||a.length>0)&&(a.push(r),o.push(a)),o.filter(e=>e.length>1||(e[0]??"").trim().length>0)})(e,t);if(0===a.length)return[];const r=o?a[0]:a[0].map((e,t)=>"column"+t);return(o?a.slice(1):a).map(e=>{const t={};for(let o=0;o<r.length;o++)t[r[o]]=e[o]??"";return t})})(t,this.delimiter||",",!1!==this.headerRow);return{result:e,rows:e.length}}case"text":return{result:t};default:throw new Ao(`Unsupported file extraction format '${this.format+""}'`,"GRAPH_EXTRACT_FROM_FILE_UNSUPPORTED_FORMAT",{format:this.format})}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.ExtractFromFileNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.format.label",type:"select"}),Ue({handle:"format",userControlled:!0}),i.__metadata("design:type",String)],e.ExtractFromFileNode.prototype,"format",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.encoding.label",type:"select"}),Ue({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],e.ExtractFromFileNode.prototype,"encoding",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.delimiter.label",type:"text"}),Ue({handle:"delimiter",userControlled:!0}),i.__metadata("design:type",String)],e.ExtractFromFileNode.prototype,"delimiter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.headerRow.label",type:"checkbox"}),Ue({handle:"headerRow",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ExtractFromFileNode.prototype,"headerRow",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.ExtractFromFileNode.prototype,"result",void 0),i.__decorate([Be({handle:"rows"}),i.__metadata("design:type",Number)],e.ExtractFromFileNode.prototype,"rows",void 0),e.ExtractFromFileNode=i.__decorate([qe("core.io.extractFromFile",{kind:"core.io.extractFromFile",category:"IO",color:"#0ea5e9",icon:"ti-file-import",width:96,height:96,labels:["io","file","extract"],metadata:{title:"graph.node.io.extract_from_file.name",description:"graph.node.io.extract_from_file.description"}}),r.model()],e.ExtractFromFileNode);const vn=new Set(["http:","https:"]);function An(e,t){if("string"==typeof e){if(e.startsWith("data:")){const t=e.indexOf(",");return Buffer.from(e.slice(t+1),"base64")}return"base64"===t?Buffer.from(e,"base64"):Buffer.from(e,"utf8")}if(Pr(e)){const o=e.data??e.content;if(void 0!==o)return An(o,t)}if(Vr(e))return Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e);throw new Ao("Read PDF node requires a PDF file payload","GRAPH_READ_PDF_INVALID_INPUT",{valueType:typeof e})}e.HttpRequestNode=class extends Er{constructor(){super(...arguments),this.url="",this.method="GET",this.responseFormat="json",this.failOnError=!1}async execute(e,t){if(!this.url)throw new Ao("HTTP Request node requires a URL","GRAPH_HTTP_URL_REQUIRED");let o;try{o=new URL(this.url)}catch{throw new Ao(`HTTP Request node URL '${this.url}' is invalid`,"GRAPH_HTTP_INVALID_URL",{url:this.url})}if(!vn.has(o.protocol))throw new Ao(`HTTP Request node protocol '${o.protocol}' is not allowed`,"GRAPH_HTTP_PROTOCOL_NOT_ALLOWED",{protocol:o.protocol});this.appendQuery(o);const a=this.method??"GET",r={};for(const[e,t]of Object.entries(this.headers??{}))"string"==typeof t&&e.trim().length>0&&(r[e.trim()]=t);const n=this.resolveBody(e,a);void 0!==n&&void 0===r["content-type"]&&(r["content-type"]="application/json");const i=this.resolveTimeoutMs(),d=new AbortController,s=setTimeout(()=>d.abort(),i);s.unref?.();const l=()=>d.abort();t.abortSignal?.addEventListener("abort",l,{once:!0});try{const{response:e,url:t}=await this.fetchFollowingRedirects(o,{method:a,headers:r,body:n,signal:d.signal}),i=await this.readCappedResponseText(e),s=Object.fromEntries(e.headers.entries()),l="text"===this.responseFormat?i:this.parseResponse(i);if(!0===this.failOnError&&!e.ok)throw new Ao("HTTP Request node received status "+e.status,"GRAPH_HTTP_REQUEST_FAILED",{status:e.status,url:t.toString()});return{result:l,status:e.status,headers:s}}catch(e){if(e instanceof Ao)throw e;if(d.signal.aborted)throw new Ao(`HTTP Request node timed out after ${i}ms`,"GRAPH_HTTP_REQUEST_TIMEOUT",{url:o.toString(),timeoutMs:i});throw new Ao("HTTP Request node failed: "+(e instanceof Error?e.message:e+""),"GRAPH_HTTP_REQUEST_FAILED",{url:o.toString()})}finally{clearTimeout(s),t.abortSignal?.removeEventListener("abort",l)}}resolveTimeoutMs(){const e=Number(this.timeoutMs);return Number.isFinite(e)&&e>0?Math.min(e,mo):3e4}async fetchFollowingRedirects(e,t){let o=e,a=t;for(let e=0;5>=e;e++){const t=await fetch(o,{...a,redirect:"manual"});if(!this.isRedirectStatus(t.status))return{response:t,url:o};const r=t.headers.get("location");if(!r)return{response:t,url:o};if(5===e)throw await this.discardResponseBody(t),new Ao("HTTP Request node exceeded the maximum of 5 redirects","GRAPH_HTTP_TOO_MANY_REDIRECTS",{url:o.toString(),maxRedirects:5});let n;try{n=new URL(r,o)}catch{throw await this.discardResponseBody(t),new Ao(`HTTP Request node redirect target '${r}' is invalid`,"GRAPH_HTTP_INVALID_URL",{location:r})}if(!vn.has(n.protocol))throw await this.discardResponseBody(t),new Ao(`HTTP Request node redirect protocol '${n.protocol}' is not allowed`,"GRAPH_HTTP_PROTOCOL_NOT_ALLOWED",{protocol:n.protocol,url:n.toString()});if(await this.discardResponseBody(t),303===t.status){a={...a,method:"GET",body:void 0};const e={...a.headers};for(const t of Object.keys(e))"content-type"===t.toLowerCase()&&delete e[t];a={...a,headers:e}}o=n}return{response:void 0,url:o}}isRedirectStatus(e){return 301===e||302===e||303===e||307===e||308===e}async discardResponseBody(e){try{await(e.body?.cancel())}catch{}}async readCappedResponseText(e){if(!e.body)return"";const t=e.body.getReader(),o=[];let a=0;try{for(;;){const{done:e,value:r}=await t.read();if(e)break;if(r){if(a+=r.byteLength,a>fo){try{await t.cancel()}catch{}throw new Ao("HTTP Request node response body exceeds the 10485760-byte limit","GRAPH_HTTP_RESPONSE_TOO_LARGE",{limitBytes:fo})}o.push(r)}}}finally{t.releaseLock?.()}return Buffer.concat(o.map(e=>Buffer.from(e))).toString("utf8")}appendQuery(e){for(const[t,o]of Object.entries(this.query??{}))if(null!=o)if(Array.isArray(o))for(const a of o)null!=a&&e.searchParams.append(t,a+"");else e.searchParams.append(t,o+"")}resolveBody(e,t){if("GET"===t||"HEAD"===t)return;const o=void 0!==this.body?this.body:e.inputs.value;return null!=o?"string"==typeof o||"undefined"!=typeof Buffer&&Buffer.isBuffer(o)||o instanceof Uint8Array?o:JSON.stringify(o):void 0}parseResponse(e){if(0===e.length)return null;try{return JSON.parse(e)}catch{return e}}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.HttpRequestNode.prototype,"value",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.url.label",placeholder:"graph.node.io.http_request.fields.url.placeholder",type:"text"}),Ue({handle:"url",userControlled:!0}),i.__metadata("design:type",String)],e.HttpRequestNode.prototype,"url",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.method.label",type:"select"}),Ue({handle:"method",userControlled:!0}),i.__metadata("design:type",String)],e.HttpRequestNode.prototype,"method",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.headers.label",type:"json"}),Ue({handle:"headers",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.HttpRequestNode.prototype,"headers",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.query.label",type:"json"}),Ue({handle:"query",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.HttpRequestNode.prototype,"query",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.body.label",type:"json"}),Ue({handle:"body",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.HttpRequestNode.prototype,"body",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.responseFormat.label",type:"select"}),Ue({handle:"responseFormat",userControlled:!0}),i.__metadata("design:type",String)],e.HttpRequestNode.prototype,"responseFormat",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.timeoutMs.label",type:"number"}),Ue({handle:"timeoutMs",userControlled:!0}),i.__metadata("design:type",Number)],e.HttpRequestNode.prototype,"timeoutMs",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.failOnError.label",type:"checkbox"}),Ue({handle:"failOnError",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HttpRequestNode.prototype,"failOnError",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.HttpRequestNode.prototype,"result",void 0),i.__decorate([Be({handle:"status"}),i.__metadata("design:type",Number)],e.HttpRequestNode.prototype,"status",void 0),i.__decorate([Be({handle:"headers"}),i.__metadata("design:type",Object)],e.HttpRequestNode.prototype,"headersOut",void 0),e.HttpRequestNode=i.__decorate([qe("core.io.httpRequest",{kind:"core.io.httpRequest",category:"IO",color:"#0ea5e9",icon:"ti-world-www",width:96,height:96,labels:["io","http","request"],metadata:{title:"graph.node.io.http_request.name",description:"graph.node.io.http_request.description"}}),r.model()],e.HttpRequestNode),e.ReadPDFNode=class extends Er{constructor(){super(...arguments),this.encoding="utf8"}async execute(e){const t=An(e.inputs.value,this.encoding??"utf8");let o;try{o=await(import("pdf-parse"))}catch(e){throw new Ao("Read PDF node requires the 'pdf-parse' dependency: "+(e instanceof Error?e.message:e+""),"GRAPH_READ_PDF_DEPENDENCY_MISSING")}const a=o.PDFParse;if(!a)throw new Ao("Read PDF node could not resolve the PDF parser","GRAPH_READ_PDF_DEPENDENCY_MISSING");const r=new a({data:t,...this.password?{password:this.password}:{}});try{const e=await r.getText();return{result:e.text??"",pages:(e.pages??[]).map((e,t)=>({pageNumber:t+1,text:e.text??""}))}}catch(e){throw new Ao("Read PDF node failed to extract text: "+(e instanceof Error?e.message:e+""),"GRAPH_READ_PDF_FAILED")}finally{await(r.destroy?.())}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.ReadPDFNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_pdf.fields.encoding.label",type:"select"}),Ue({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],e.ReadPDFNode.prototype,"encoding",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_pdf.fields.password.label",placeholder:"graph.node.io.read_pdf.fields.password.placeholder",type:"password"}),Ue({handle:"password",userControlled:!0}),i.__metadata("design:type",String)],e.ReadPDFNode.prototype,"password",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",String)],e.ReadPDFNode.prototype,"result",void 0),i.__decorate([Be({handle:"pages"}),i.__metadata("design:type",Array)],e.ReadPDFNode.prototype,"pages",void 0),e.ReadPDFNode=i.__decorate([qe("core.io.readPDF",{kind:"core.io.readPDF",category:"IO",color:"#0ea5e9",icon:"ti-file-type-pdf",width:96,height:96,labels:["io","pdf","extract"],metadata:{title:"graph.node.io.read_pdf.name",description:"graph.node.io.read_pdf.description"}}),r.model()],e.ReadPDFNode);const xn=new Set(["workdocs"]);function In(){return["/etc","/proc","/root",g.resolve(h.homedir(),".ssh")]}function En(e,t){const o=g.relative(e,t);return""===o||!o.startsWith("..")&&!g.isAbsolute(o)}function Sn(e,t,o){if(!En(e,t))throw new Ao(`Read/Write Files from Disk node path '${o}' resolves outside the configured file IO base`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o,base:e});for(const e of In())if(En(e,t))throw new Ao(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o});const a=g.relative(e,t).split(g.sep).filter(Boolean);for(const e of a)if(xn.has(e.toLowerCase()))throw new Ao(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o,segment:e})}async function Rn(e){let t=e;for(;;)try{return await f.realpath(t)}catch{const e=g.dirname(t);if(e===t)return;t=e}}function Tn(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:void 0}function Cn(e){return"string"==typeof e&&e.trim().length>0?e.trim():void 0}function On(e,t=!1){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===e.toLowerCase())return!0;if("false"===e.toLowerCase())return!1}return t}function kn(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&e.trim().length>0){const t=Number(e);return Number.isFinite(t)?t:void 0}}function Dn(e){return Array.isArray(e)?e:void 0}function Pn(e,t){try{const t=Tn(e);if(t)return t;const o=Tn(JSON.parse(e));if(!o)throw Error("not an object");return o}catch{throw new Ao(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}function Gn(e,t){if(e){if("string"!=typeof e)return Array.isArray(e)?void 0:e;if(e.trim().startsWith("{"))try{const t=Tn(JSON.parse(e));if(!t)throw Error("not an object");return t}catch{throw new Ao(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}}function Mn(e,t,o){const a=Gn(e,o);return a?Cn(a[t]):"token"===t&&"string"==typeof e?Cn(e):void 0}function Fn(e,t){return Mn(e,"token",t)}function Ln(e,t,o){if("string"==typeof e)return Cn(e);const a=Gn(e,o);if(a)for(const e of Array.isArray(t)?t:[t]){const t=Cn(a[e]);if(t)return t}}e.ReadWriteFileNode=class extends Er{constructor(){super(...arguments),this.operation="read",this.path="",this.encoding="utf8",this.append=!1,this.createDirectories=!1}async execute(e){if(!this.path)throw new Ao("Read/Write Files from Disk node requires a path","GRAPH_READ_WRITE_FILE_PATH_REQUIRED");if(this.path.includes("\0"))throw new Ao("Read/Write Files from Disk node path contains a NUL byte","GRAPH_READ_WRITE_FILE_INVALID_PATH",{path:this.path});const{base:t,candidate:o}=(e=>{const t=(()=>{const e=process.env.GRAPH_FILE_IO_BASE?.trim(),t=g.resolve(e&&e.length>0?e:process.cwd());try{return m.realpathSync(t)}catch{return t}})();(e=>{if(!g.isAbsolute(e))return;const t=g.resolve(e);for(const o of In())if(En(o,t))throw new Ao(`Read/Write Files from Disk node path '${e}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:e})})(e);const o=e.replace(/^[/\\]+/,""),a=g.resolve(t,o);return Sn(t,a,e),{base:t,candidate:a}})(this.path);if("read"===this.operation){let e;try{e=await f.realpath(o)}catch{throw new Ao(`Read/Write Files from Disk node path '${this.path}' does not exist`,"GRAPH_READ_WRITE_FILE_INVALID_PATH",{path:this.path})}Sn(t,e,this.path);const a=await f.readFile(e);return{result:"base64"===this.encoding?a.toString("base64"):a.toString("utf8"),bytes:a.byteLength}}const a=void 0!==this.content?this.content:e.inputs.value;if(null==a)throw new Ao("Read/Write Files from Disk node requires content to write","GRAPH_READ_WRITE_FILE_CONTENT_REQUIRED");const r="string"==typeof a?"base64"===this.encoding?Buffer.from(a,"base64"):Buffer.from(a,"utf8"):Buffer.isBuffer(a)?a:a instanceof Uint8Array?Buffer.from(a):Buffer.from(a+"","utf8"),n=await Rn(o);n&&Sn(t,n,this.path),this.createDirectories&&await f.mkdir(g.dirname(o),{recursive:!0}),Sn(t,await f.realpath(g.dirname(o)),this.path);const i=await Rn(o);return i&&Sn(t,i,this.path),this.append?await f.appendFile(o,r):await f.writeFile(o,r),{result:{path:this.path,bytes:r.byteLength},bytes:r.byteLength}}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.ReadWriteFileNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.ReadWriteFileNode.prototype,"operation",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.path.label",placeholder:"graph.node.io.read_write_file.fields.path.placeholder",type:"text"}),Ue({handle:"path",userControlled:!0}),i.__metadata("design:type",String)],e.ReadWriteFileNode.prototype,"path",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.encoding.label",type:"select"}),Ue({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],e.ReadWriteFileNode.prototype,"encoding",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.content.label",type:"textarea"}),Ue({handle:"content",userControlled:!0}),i.__metadata("design:type",String)],e.ReadWriteFileNode.prototype,"content",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.append.label",type:"checkbox"}),Ue({handle:"append",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ReadWriteFileNode.prototype,"append",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.createDirectories.label",type:"checkbox"}),Ue({handle:"createDirectories",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ReadWriteFileNode.prototype,"createDirectories",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.ReadWriteFileNode.prototype,"result",void 0),i.__decorate([Be({handle:"bytes"}),i.__metadata("design:type",Number)],e.ReadWriteFileNode.prototype,"bytes",void 0),e.ReadWriteFileNode=i.__decorate([qe("core.io.readWriteFile",{kind:"core.io.readWriteFile",category:"IO",color:"#0ea5e9",icon:"ti-device-floppy",width:96,height:96,labels:["io","file","disk"],metadata:{title:"graph.node.io.read_write_file.name",description:"graph.node.io.read_write_file.description"}}),r.model()],e.ReadWriteFileNode),e.RespondToWebhookNode=class extends Er{constructor(){super(...arguments),this.respondWith="firstIncomingItem",this.responseCode=200}async execute(e,t){const o=this.resolveBody(e),a={};for(const[e,t]of Object.entries(this.responseHeaders??{}))"string"==typeof t&&e.trim().length>0&&(a[e.trim()]=t);null!=o&&"string"!=typeof o&&void 0===a["content-type"]&&(a["content-type"]="application/json");const r={statusCode:this.responseCode??200,headers:a,body:o,runId:t.runId,respondedAt:(new Date).toISOString()},n=t.engine?.webhookResponses.deliver(t.runId,r)??!1;return await t.progress({...r,delivered:n}),{response:r,delivered:n}}resolveBody(e){const t=e.inputs.value;switch(this.respondWith){case"noData":return null;case"allIncomingItems":return Gr(t);case"firstIncomingItem":return Gr(t)[0]??null;case"text":return void 0===this.responseBody?null==t?"":t+"":this.responseBody+"";default:if("string"==typeof this.responseBody)try{return JSON.parse(this.responseBody)}catch{return this.responseBody}return void 0!==this.responseBody?this.responseBody:t??null}}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.RespondToWebhookNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.respondWith.label",type:"select"}),Ue({handle:"respondWith",userControlled:!0}),i.__metadata("design:type",String)],e.RespondToWebhookNode.prototype,"respondWith",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseCode.label",type:"number"}),Ue({handle:"responseCode",userControlled:!0}),i.__metadata("design:type",Number)],e.RespondToWebhookNode.prototype,"responseCode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseHeaders.label",type:"json"}),Ue({handle:"responseHeaders",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.RespondToWebhookNode.prototype,"responseHeaders",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseBody.label",type:"json"}),Ue({handle:"responseBody",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.RespondToWebhookNode.prototype,"responseBody",void 0),i.__decorate([r.required(),Be({handle:"response"}),i.__metadata("design:type",Object)],e.RespondToWebhookNode.prototype,"response",void 0),i.__decorate([Be({handle:"delivered"}),i.__metadata("design:type",Boolean)],e.RespondToWebhookNode.prototype,"delivered",void 0),e.RespondToWebhookNode=i.__decorate([qe("core.io.respondToWebhook",{kind:"core.io.respondToWebhook",category:"IO",color:"#0ea5e9",icon:"ti-corner-up-left",width:96,height:96,labels:["io","webhook","response"],metadata:{title:"graph.node.io.respond_to_webhook.name",description:"graph.node.io.respond_to_webhook.description"}}),r.model()],e.RespondToWebhookNode);const jn={postgres:5432,mysql:3306,mssql:1433};class qn extends Er{constructor(){super(...arguments),this.ssl=!1,this.acceptSelfSigned=!1}dataSourceOptions(e,t,o,a,r){const n=On(this.ssl,!1),i=On(this.acceptSelfSigned,!1),d={host:e,port:t,database:o,username:a,password:r,entities:[],synchronize:!1};return"postgres"===this.driver?{...d,type:"postgres",ssl:!!n&&{rejectUnauthorized:!i}}:"mysql"===this.driver?{...d,type:"mysql",ssl:n?{}:void 0}:{...d,type:"mssql",options:{encrypt:n,trustServerCertificate:!n}}}async execute(e,t){const o=this.constructor.name,a=this.sql?.trim();if(!a)throw new Ao(o+" node requires a SQL statement","GRAPH_DATABASE_SQL_REQUIRED");const r=this.host?.trim(),n=this.database?.trim(),i=this.username?.trim();if(!r||!n||!i)throw new Ao(o+" node requires host, database, and username","GRAPH_DATABASE_CONNECTION_REQUIRED");const s=Ln(await Xo(t,e.credentials,this.credentialType,!1,o),["password","secret","token"],o),l=Dn(this.parameters)??(Array.isArray(e.inputs.value)?e.inputs.value:[]),c=`as-graph-${this.driver}-${Date.now()}-${Math.random().toString(36).slice(2)}`,p=new _.TypeORMAdapter(this.dataSourceOptions(r,kn(this.port)??jn[this.driver],n,i,s),c),u=new d.Context;try{await p.initialize(u);const e=await p.raw({query:a,values:l},!0,u),{rows:t,rowCount:o}=(e=>{if(Array.isArray(e))return{rows:e,rowCount:e.length};const t=Tn(e);if(!t)return{rows:[],rowCount:0};if(Array.isArray(t.recordsets)){const e=t.recordsets.flat(),o=t.rowsAffected;return{rows:e,rowCount:Array.isArray(o)?o.reduce((e,t)=>e+Number(t||0),0):e.length}}if(Array.isArray(t.rows)){const e=t.rows;return{rows:e,rowCount:kn(t.rowCount)??e.length}}if(Array.isArray(t.recordset)){const e=t.recordset;return{rows:e,rowCount:e.length}}if(Array.isArray(t.data)){const e=t.data;return{rows:e,rowCount:kn(t.count)??e.length}}return{rows:[],rowCount:kn(t.affectedRows)??0}})(e);return{result:t,rows:t,rowCount:o}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`${o} node query failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_DATABASE_QUERY_FAILED",{driver:this.driver})}finally{await p.shutdown().catch(()=>{}),d.Adapter.unregister(c)}}}i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.host.label",type:"string"}),Ue({handle:"host",userControlled:!0}),i.__metadata("design:type",String)],qn.prototype,"host",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.port.label",type:"number"}),Ue({handle:"port",userControlled:!0}),i.__metadata("design:type",Number)],qn.prototype,"port",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.database.label",type:"string"}),Ue({handle:"database",userControlled:!0}),i.__metadata("design:type",String)],qn.prototype,"database",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.username.label",type:"string"}),Ue({handle:"username",userControlled:!0}),i.__metadata("design:type",String)],qn.prototype,"username",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.ssl.label",type:"boolean"}),Ue({handle:"ssl",userControlled:!0}),i.__metadata("design:type",Boolean)],qn.prototype,"ssl",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.acceptSelfSigned.label",type:"boolean"}),Ue({handle:"acceptSelfSigned",userControlled:!0}),i.__metadata("design:type",Boolean)],qn.prototype,"acceptSelfSigned",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sql.label",type:"textarea"}),Ue({handle:"sql",userControlled:!0}),i.__metadata("design:type",String)],qn.prototype,"sql",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.parameters.label",type:"array"}),Ue({handle:"parameters",userControlled:!0}),i.__metadata("design:type",Array)],qn.prototype,"parameters",void 0),i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],qn.prototype,"value",void 0),i.__decorate([r.required(),Be({handle:"result",type:"array"}),i.__metadata("design:type",Array)],qn.prototype,"result",void 0),i.__decorate([Be({handle:"rows",type:"array"}),i.__metadata("design:type",Array)],qn.prototype,"rows",void 0),i.__decorate([Be({handle:"rowCount",type:"number"}),i.__metadata("design:type",Number)],qn.prototype,"rowCount",void 0),e.PostgresNode=class extends qn{constructor(){super(...arguments),this.driver="postgres",this.credentialType="postgres"}},e.PostgresNode=i.__decorate([qe("core.storage.postgres",{kind:"core.storage.postgres",category:"Storage",color:"#336791",icon:"ti-database",width:96,height:96,labels:["storage","database","postgres","sql"],metadata:{title:"graph.node.storage.postgres.name",description:"graph.node.storage.postgres.description"}}),r.model()],e.PostgresNode),e.MySqlNode=class extends qn{constructor(){super(...arguments),this.driver="mysql",this.credentialType="mysql"}},e.MySqlNode=i.__decorate([qe("core.storage.mySql",{kind:"core.storage.mySql",category:"Storage",color:"#00758f",icon:"ti-database",width:96,height:96,labels:["storage","database","mysql","sql"],metadata:{title:"graph.node.storage.my_sql.name",description:"graph.node.storage.my_sql.description"}}),r.model()],e.MySqlNode),e.MicrosoftSqlNode=class extends qn{constructor(){super(...arguments),this.driver="mssql",this.credentialType="mssql"}},e.MicrosoftSqlNode=i.__decorate([qe("core.storage.microsoftSql",{kind:"core.storage.microsoftSql",category:"Storage",color:"#cc2927",icon:"ti-database",width:96,height:96,labels:["storage","database","mssql","sqlserver","sql"],metadata:{title:"graph.node.storage.microsoft_sql.name",description:"graph.node.storage.microsoft_sql.description"}}),r.model()],e.MicrosoftSqlNode);const Hn=["get","set","delete","incr","keys","llen","lpop","rpop","lpush","rpush","publish","info"];function Un(e){if(null===e)return null;try{return JSON.parse(e)}catch{return e}}function Bn(e){return"string"==typeof e?e:null==e?"":JSON.stringify(e)}e.RedisNode=class extends Er{constructor(){super(...arguments),this.operation="get",this.tls=!1}async execute(e,t){const o=Hn.includes(this.operation)?this.operation:"get",a=Ln(await Xo(t,e.credentials,"redis",!1,"Redis"),["password","secret","token"],"Redis"),r=Cn(this.host)??"localhost",n=kn(this.port)??6379,i=Cn(this.key),s=Cn(this.prefix),l=e=>s?`${s}:${e}`:e,c=Cn(this.pattern),p=Cn(this.channel),u=this.value??e.inputs.value;if(!("info"===o||i||"keys"===o&&c||"publish"===o&&p))throw new Ao(`Redis node operation '${o}' requires a key`,"GRAPH_REDIS_KEY_REQUIRED",{operation:o});const g=`as-graph-redis-${Date.now()}-${Math.random().toString(36).slice(2)}`,h=new y.RedisAdapter({host:r,port:n,username:Cn(this.username),password:a,database:kn(this.database),tls:!!this.tls||void 0},g);try{await h.initialize();const e=h.client;switch(o){case"get":return{result:Un(await e.get(l(i)))};case"set":{const t=kn(this.ttlSeconds);return{result:await e.set(l(i),Bn(u),t&&t>0?{EX:Math.floor(t)}:void 0)}}case"delete":{const t=await e.del(l(i));return{result:t,count:t}}case"incr":{const t=await e.incr(l(i));return{result:t,count:t}}case"keys":{const t=await e.keys(l(c??i??"*"));return{result:t,count:t.length}}case"llen":{const t=await e.lLen(l(i));return{result:t,count:t}}case"lpop":return{result:Un(await e.lPop(l(i)))};case"rpop":return{result:Un(await e.rPop(l(i)))};case"lpush":{const t=await e.lPush(l(i),Bn(u));return{result:t,count:t}}case"rpush":{const t=await e.rPush(l(i),Bn(u));return{result:t,count:t}}case"publish":{const t=await e.publish(p??i,Bn(u));return{result:t,count:t}}default:return{result:await e.info(Cn(this.section))}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Redis node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_REDIS_OPERATION_FAILED",{operation:o})}finally{await h.shutdown().catch(()=>{}),d.Adapter.unregister(g)}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.RedisNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.host.label",type:"string"}),Ue({handle:"host",userControlled:!0}),i.__metadata("design:type",String)],e.RedisNode.prototype,"host",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.port.label",type:"number"}),Ue({handle:"port",userControlled:!0}),i.__metadata("design:type",Number)],e.RedisNode.prototype,"port",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.username.label",type:"string"}),Ue({handle:"username",userControlled:!0}),i.__metadata("design:type",String)],e.RedisNode.prototype,"username",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.database.label",type:"number"}),Ue({handle:"database",userControlled:!0}),i.__metadata("design:type",Number)],e.RedisNode.prototype,"database",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.tls.label",type:"boolean"}),Ue({handle:"tls",userControlled:!0}),i.__metadata("design:type",Boolean)],e.RedisNode.prototype,"tls",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.prefix.label",type:"string"}),Ue({handle:"prefix",userControlled:!0}),i.__metadata("design:type",String)],e.RedisNode.prototype,"prefix",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.key.label",type:"string"}),Ue({handle:"key",userControlled:!0}),i.__metadata("design:type",String)],e.RedisNode.prototype,"key",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.value.label",type:"textarea"}),Ue({handle:"value",userControlled:!0}),i.__metadata("design:type",Object)],e.RedisNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.ttlSeconds.label",type:"number"}),Ue({handle:"ttlSeconds",userControlled:!0}),i.__metadata("design:type",Number)],e.RedisNode.prototype,"ttlSeconds",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.pattern.label",type:"string"}),Ue({handle:"pattern",userControlled:!0}),i.__metadata("design:type",String)],e.RedisNode.prototype,"pattern",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.channel.label",type:"string"}),Ue({handle:"channel",userControlled:!0}),i.__metadata("design:type",String)],e.RedisNode.prototype,"channel",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.section.label",type:"string"}),Ue({handle:"section",userControlled:!0}),i.__metadata("design:type",String)],e.RedisNode.prototype,"section",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.RedisNode.prototype,"result",void 0),i.__decorate([Be({handle:"value"}),i.__metadata("design:type",Object)],e.RedisNode.prototype,"valueOutput",void 0),i.__decorate([Be({handle:"count",type:"number"}),i.__metadata("design:type",Number)],e.RedisNode.prototype,"count",void 0),e.RedisNode=i.__decorate([qe("core.storage.redis",{kind:"core.storage.redis",category:"Storage",color:"#dc382d",icon:"ti-brand-redis",width:96,height:96,labels:["storage","redis","cache","keyvalue"],metadata:{title:"graph.node.storage.redis.name",description:"graph.node.storage.redis.description"}}),r.model()],e.RedisNode);const $n=["queue","exchange"];e.RabbitMqNode=class extends Er{constructor(){super(...arguments),this.mode="queue",this.ssl=!1}async execute(e,t){const o=$n.includes(this.mode)?this.mode:"queue",a=Cn(this.queue),r=Cn(this.exchange),n=Cn(this.routingKey)??"";if("queue"===o&&!a)throw new Ao("RabbitMQ node requires a queue when publishing to a queue","GRAPH_RABBITMQ_QUEUE_REQUIRED");if("exchange"===o&&!r)throw new Ao("RabbitMQ node requires an exchange when publishing to an exchange","GRAPH_RABBITMQ_EXCHANGE_REQUIRED");const i=Ln(await Xo(t,e.credentials,"rabbitmq",!1,"RabbitMQ"),["password","secret","token"],"RabbitMQ"),d=On(this.ssl,!1),s="string"==typeof(l=this.value??e.inputs.value??e.inputs.payload??e.inputs.message)?l:null==l?"":JSON.stringify(l);var l;let c,p;try{let e;if(c=await b.connect({protocol:d?"amqps":"amqp",hostname:Cn(this.host)??"localhost",port:kn(this.port)??(d?5671:5672),username:Cn(this.username)??"guest",password:i,vhost:Cn(this.vhost)??"/",heartbeat:10}),p=await c.createConfirmChannel(),"exchange"===o){const t=Cn(this.exchangeType)??"topic";await p.assertExchange(r,t,{durable:!0}),p.publish(r,n,Buffer.from(s,"utf8"),{contentType:"application/json",contentEncoding:"utf8"}),e=r}else await p.assertQueue(a,{durable:!0}),p.sendToQueue(a,Buffer.from(s,"utf8"),{contentType:"application/json",contentEncoding:"utf8"}),e=a;return await p.waitForConfirms(),{result:!0,target:e}}catch(e){if(e instanceof Ao)throw e;throw new Ao("RabbitMQ node publish failed: "+(e instanceof Error?e.message:e+""),"GRAPH_RABBITMQ_PUBLISH_FAILED",{mode:o})}finally{await(p?.close().catch(()=>{})),await(c?.close().catch(()=>{}))}}},i.__decorate([Ue({handle:"mode",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.mode.label",type:"select"}),i.__metadata("design:type",String)],e.RabbitMqNode.prototype,"mode",void 0),i.__decorate([Ue({handle:"queue",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.queue.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqNode.prototype,"queue",void 0),i.__decorate([Ue({handle:"exchange",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.exchange.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqNode.prototype,"exchange",void 0),i.__decorate([Ue({handle:"exchangeType",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.exchangeType.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqNode.prototype,"exchangeType",void 0),i.__decorate([Ue({handle:"routingKey",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.routingKey.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqNode.prototype,"routingKey",void 0),i.__decorate([Ue({handle:"host",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.host.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqNode.prototype,"host",void 0),i.__decorate([Ue({handle:"port",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.port.label",type:"number"}),i.__metadata("design:type",Number)],e.RabbitMqNode.prototype,"port",void 0),i.__decorate([Ue({handle:"username",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.username.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqNode.prototype,"username",void 0),i.__decorate([Ue({handle:"vhost",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.vhost.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqNode.prototype,"vhost",void 0),i.__decorate([Ue({handle:"ssl",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.ssl.label",type:"boolean"}),i.__metadata("design:type",Boolean)],e.RabbitMqNode.prototype,"ssl",void 0),i.__decorate([Ue({handle:"value",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.value.label",type:"textarea"}),i.__metadata("design:type",Object)],e.RabbitMqNode.prototype,"value",void 0),i.__decorate([r.required(),Be({handle:"result",type:"boolean"}),i.__metadata("design:type",Boolean)],e.RabbitMqNode.prototype,"result",void 0),i.__decorate([Be({handle:"target"}),i.__metadata("design:type",String)],e.RabbitMqNode.prototype,"target",void 0),e.RabbitMqNode=i.__decorate([qe("core.storage.rabbitmq",{kind:"core.storage.rabbitmq",category:"Storage",color:"#ff6600",icon:"ti-inbox",width:96,height:96,labels:["storage","rabbitmq","amqp","queue","publish"],metadata:{title:"graph.node.storage.rabbitmq.name",description:"graph.node.storage.rabbitmq.description"}}),r.model()],e.RabbitMqNode);const Wn=["put","get","delete","list","stat","has","url","copy"];class Vn extends Er{constructor(){super(...arguments),this.operation="get",this.encoding="utf8",this.urlOperation="get"}async execute(e,t){const o=this.constructor.name,a=Wn.includes(this.operation)?this.operation:"get",r=Cn(this.key);if("list"!==a&&!r)throw new Ao(`${o} node operation '${a}' requires a key`,"GRAPH_BLOB_KEY_REQUIRED",{operation:a});const n=await Xo(t,e.credentials,this.credentialType,!1,o),i=await this.createService(n);try{switch(a){case"put":{const t=this.content??e.inputs.value,a=Tn(this.metadataValues),n=await i.put(r,((e,t,o)=>{if("string"==typeof e)return"base64"===t?Buffer.from(e,"base64"):Buffer.from(e,"utf8");if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(null==e)return Buffer.alloc(0);try{return Buffer.from(JSON.stringify(e),"utf8")}catch{throw new Ao(o+" node cannot encode the blob payload","GRAPH_BLOB_INVALID_PAYLOAD")}})(t,this.encoding,o),{contentType:Cn(this.contentType),metadata:a?Object.fromEntries(Object.entries(a).map(([e,t])=>[e,t+""])):void 0});return{result:n}}case"get":{const e=await i.get(r),t=await w.collectToBuffer(e.value),o="base64"===this.encoding?t.toString("base64"):t.toString("utf8");return{result:{key:e.key,uri:e.uri,provider:e.provider,sourceId:e.sourceId,metadata:e.metadata},value:o,contentLength:t.length,contentType:e.metadata.contentType}}case"delete":return await i.delete(r),{result:{key:r,deleted:!0}};case"list":{const e=kn(this.limit);return{result:await i.list({prefix:Cn(this.prefix),limit:void 0===e?void 0:Math.max(0,Math.floor(e)),cursor:Cn(this.cursor)})}}case"stat":return{result:await i.stat(r)};case"has":return{result:await i.has(r)};case"url":{const e=kn(this.expiresInSeconds);return{result:await i.url(r,{operation:this.urlOperation,expiresInSeconds:void 0===e?void 0:Math.max(0,Math.floor(e)),contentType:Cn(this.contentType)})}}case"copy":{const e=Cn(this.targetKey);if(!e)throw new Ao(o+" node copy operation requires a targetKey","GRAPH_BLOB_TARGET_KEY_REQUIRED");return{result:await i.copy(r,e,{contentType:Cn(this.contentType)})}}default:throw new Ao(`${o} node operation '${a}' is not supported`,"GRAPH_BLOB_OPERATION_NOT_SUPPORTED",{operation:a})}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`${o} node operation '${a}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_BLOB_OPERATION_FAILED",{operation:a})}finally{await i.shutdown().catch(()=>{})}}}i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],Vn.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.key.label",type:"string"}),Ue({handle:"key",userControlled:!0}),i.__metadata("design:type",String)],Vn.prototype,"key",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.targetKey.label",type:"string"}),Ue({handle:"targetKey",userControlled:!0}),i.__metadata("design:type",String)],Vn.prototype,"targetKey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.content.label",type:"textarea"}),Ue({handle:"content",userControlled:!0}),i.__metadata("design:type",Object)],Vn.prototype,"content",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.contentType.label",type:"string"}),Ue({handle:"contentType",userControlled:!0}),i.__metadata("design:type",String)],Vn.prototype,"contentType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.encoding.label",type:"select"}),Ue({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],Vn.prototype,"encoding",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.metadataValues.label",type:"object"}),Ue({handle:"metadataValues",userControlled:!0}),i.__metadata("design:type",Object)],Vn.prototype,"metadataValues",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.prefix.label",type:"string"}),Ue({handle:"prefix",userControlled:!0}),i.__metadata("design:type",String)],Vn.prototype,"prefix",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.cursor.label",type:"string"}),Ue({handle:"cursor",userControlled:!0}),i.__metadata("design:type",String)],Vn.prototype,"cursor",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],Vn.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.urlOperation.label",type:"select"}),Ue({handle:"urlOperation",userControlled:!0}),i.__metadata("design:type",String)],Vn.prototype,"urlOperation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.expiresInSeconds.label",type:"number"}),Ue({handle:"expiresInSeconds",userControlled:!0}),i.__metadata("design:type",Number)],Vn.prototype,"expiresInSeconds",void 0),i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],Vn.prototype,"value",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],Vn.prototype,"result",void 0),i.__decorate([Be({handle:"value"}),i.__metadata("design:type",String)],Vn.prototype,"valueOutput",void 0),i.__decorate([Be({handle:"contentLength",type:"number"}),i.__metadata("design:type",Number)],Vn.prototype,"contentLength",void 0),i.__decorate([Be({handle:"contentType"}),i.__metadata("design:type",String)],Vn.prototype,"contentTypeOutput",void 0);class Kn extends Vn{constructor(){super(...arguments),this.credentialType="s3",this.forcePathStyle=!1}async createService(e){const t=Cn(this.bucket);if(!t)throw new Ao("S3 node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o=new N.S3BlobStoreService;return await v.bootWithoutEnvironment(o,((e,t)=>{const o=e?Pn(e,"S3"):void 0;return{provider:"s3",bucket:t.bucket,sourceId:t.sourceId,region:t.region,endpoint:t.endpoint,prefix:t.prefix,forcePathStyle:t.forcePathStyle,credentials:o&&"string"==typeof o.accessKeyId?{accessKeyId:o.accessKeyId,secretAccessKey:(o.secretAccessKey??"")+"",sessionToken:Cn(o.sessionToken)}:void 0}})(e,{bucket:t,sourceId:Cn(this.sourceId)??"graph",region:Cn(this.region),endpoint:Cn(this.endpoint),prefix:Cn(this.prefix),forcePathStyle:this.forcePathStyle})),o}}function zn(e){if(!e)return;if("string"!=typeof e)return Cn(e.connectionString);const t=e.trim();return t.startsWith("{")?Cn(Pn(t,"Azure Storage").connectionString):t}i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),Ue({handle:"bucket",userControlled:!0}),i.__metadata("design:type",String)],Kn.prototype,"bucket",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),Ue({handle:"sourceId",userControlled:!0}),i.__metadata("design:type",String)],Kn.prototype,"sourceId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.region.label",type:"string"}),Ue({handle:"region",userControlled:!0}),i.__metadata("design:type",String)],Kn.prototype,"region",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.endpoint.label",type:"string"}),Ue({handle:"endpoint",userControlled:!0}),i.__metadata("design:type",String)],Kn.prototype,"endpoint",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.forcePathStyle.label",type:"boolean"}),Ue({handle:"forcePathStyle",userControlled:!0}),i.__metadata("design:type",Boolean)],Kn.prototype,"forcePathStyle",void 0),e.S3StorageNode=class extends Kn{},e.S3StorageNode=i.__decorate([qe("core.storage.s3",{kind:"core.storage.s3",category:"Storage",color:"#e25444",icon:"ti-bucket",width:96,height:96,labels:["storage","s3","blob","aws"],metadata:{title:"graph.node.storage.s3.name",description:"graph.node.storage.s3.description"}}),r.model()],e.S3StorageNode),e.AwsS3StorageNode=class extends Kn{},e.AwsS3StorageNode=i.__decorate([qe("core.storage.awsS3",{kind:"core.storage.awsS3",category:"Storage",color:"#ff9900",icon:"ti-brand-aws",width:96,height:96,labels:["storage","s3","blob","aws"],metadata:{title:"graph.node.storage.aws_s3.name",description:"graph.node.storage.aws_s3.description"}}),r.model()],e.AwsS3StorageNode),e.GoogleCloudStorageNode=class extends Vn{constructor(){super(...arguments),this.credentialType="gcs"}async createService(e){const t=Cn(this.bucket);if(!t)throw new Ao("Google Cloud Storage node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o={provider:"gcs",bucket:t,sourceId:Cn(this.sourceId)??"graph",projectId:Cn(this.projectId),apiEndpoint:Cn(this.apiEndpoint),prefix:Cn(this.prefix),credentials:e?Pn(e,"Google Cloud Storage"):void 0},a=new A.GcsBlobStoreService;return await v.bootWithoutEnvironment(a,o),a}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),Ue({handle:"bucket",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCloudStorageNode.prototype,"bucket",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),Ue({handle:"sourceId",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCloudStorageNode.prototype,"sourceId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.projectId.label",type:"string"}),Ue({handle:"projectId",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCloudStorageNode.prototype,"projectId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.apiEndpoint.label",type:"string"}),Ue({handle:"apiEndpoint",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCloudStorageNode.prototype,"apiEndpoint",void 0),e.GoogleCloudStorageNode=i.__decorate([qe("core.storage.googleCloudStorage",{kind:"core.storage.googleCloudStorage",category:"Storage",color:"#4285f4",icon:"ti-brand-google-cloud",width:96,height:96,labels:["storage","gcs","blob","google"],metadata:{title:"graph.node.storage.google_cloud_storage.name",description:"graph.node.storage.google_cloud_storage.description"}}),r.model()],e.GoogleCloudStorageNode),e.AzureStorageNode=class extends Vn{constructor(){super(...arguments),this.credentialType="azure-blob"}async createService(e){const t=Cn(this.container);if(!t)throw new Ao("Azure Storage node requires a container","GRAPH_BLOB_CONTAINER_REQUIRED");const o={provider:"azure-blob",container:t,sourceId:Cn(this.sourceId)??"graph",accountName:Cn(this.accountName),endpoint:Cn(this.endpoint),prefix:Cn(this.prefix),connectionString:zn(e)},a=new x.AzureBlobStoreService;return await v.bootWithoutEnvironment(a,o),a}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.container.label",type:"string"}),Ue({handle:"container",userControlled:!0}),i.__metadata("design:type",String)],e.AzureStorageNode.prototype,"container",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),Ue({handle:"sourceId",userControlled:!0}),i.__metadata("design:type",String)],e.AzureStorageNode.prototype,"sourceId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.accountName.label",type:"string"}),Ue({handle:"accountName",userControlled:!0}),i.__metadata("design:type",String)],e.AzureStorageNode.prototype,"accountName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.endpoint.label",type:"string"}),Ue({handle:"endpoint",userControlled:!0}),i.__metadata("design:type",String)],e.AzureStorageNode.prototype,"endpoint",void 0),e.AzureStorageNode=i.__decorate([qe("core.storage.azureStorage",{kind:"core.storage.azureStorage",category:"Storage",color:"#0078d4",icon:"ti-brand-azure",width:96,height:96,labels:["storage","azure","blob"],metadata:{title:"graph.node.storage.azure_storage.name",description:"graph.node.storage.azure_storage.description"}}),r.model()],e.AzureStorageNode);const Qn=["postMessage","listConversations","getConversation","getUser"];e.SlackNode=class extends Er{constructor(){super(...arguments),this.operation="postMessage"}async execute(e,t){const o=Qn.includes(this.operation)?this.operation:"postMessage";if(!this.operation)throw new Ao("Slack node requires an operation","GRAPH_SLACK_OPERATION_REQUIRED");const a=Fn(await Xo(t,e.credentials,"slack",!1,"Slack"),"Slack"),r=new I.SlackService;try{switch(await v.bootWithoutEnvironment(r,{token:a,baseUrl:this.baseUrl}),o){case"postMessage":{const t=this.channel,o=this.text??(e.inputs.value??"")+"";if(!t||!o)throw new Ao("Slack postMessage requires a channel and text","GRAPH_SLACK_MESSAGE_REQUIRED");const a=await r.postMessage({channel:t,text:o,blocks:Dn(this.blocks),threadTs:this.threadTs,replyBroadcast:this.replyBroadcast,unfurlLinks:this.unfurlLinks,unfurlMedia:this.unfurlMedia});return{result:a,channel:a.channel,ts:a.ts}}case"listConversations":return{result:await r.listConversations({limit:kn(this.limit),cursor:this.cursor,types:this.types,excludeArchived:this.excludeArchived})};case"getConversation":{if(!this.channel)throw new Ao("Slack getConversation requires a channel","GRAPH_SLACK_CHANNEL_REQUIRED");const e=await r.getConversation(this.channel);return{result:e,channel:e.id}}default:if(!this.userId)throw new Ao("Slack getUser requires a user ID","GRAPH_SLACK_USER_REQUIRED");return{result:await r.getUser(this.userId)}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Slack node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SLACK_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.SlackNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.channel.label",type:"string"}),Ue({handle:"channel",userControlled:!0}),i.__metadata("design:type",String)],e.SlackNode.prototype,"channel",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.text.label",type:"textarea"}),Ue({handle:"text",userControlled:!0}),i.__metadata("design:type",String)],e.SlackNode.prototype,"text",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.blocks.label",type:"json"}),Ue({handle:"blocks",userControlled:!0}),i.__metadata("design:type",Array)],e.SlackNode.prototype,"blocks",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.threadTs.label",type:"string"}),Ue({handle:"threadTs",userControlled:!0}),i.__metadata("design:type",String)],e.SlackNode.prototype,"threadTs",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.SlackNode.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.cursor.label",type:"string"}),Ue({handle:"cursor",userControlled:!0}),i.__metadata("design:type",String)],e.SlackNode.prototype,"cursor",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.types.label",type:"string"}),Ue({handle:"types",userControlled:!0}),i.__metadata("design:type",String)],e.SlackNode.prototype,"types",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.userId.label",type:"string"}),Ue({handle:"userId",userControlled:!0}),i.__metadata("design:type",String)],e.SlackNode.prototype,"userId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.SlackNode.prototype,"baseUrl",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.excludeArchived.label",type:"boolean"}),Ue({handle:"excludeArchived",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SlackNode.prototype,"excludeArchived",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.replyBroadcast.label",type:"boolean"}),Ue({handle:"replyBroadcast",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SlackNode.prototype,"replyBroadcast",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.unfurlLinks.label",type:"boolean"}),Ue({handle:"unfurlLinks",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SlackNode.prototype,"unfurlLinks",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.unfurlMedia.label",type:"boolean"}),Ue({handle:"unfurlMedia",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SlackNode.prototype,"unfurlMedia",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.SlackNode.prototype,"result",void 0),i.__decorate([Be({handle:"channel",type:"string"}),i.__metadata("design:type",String)],e.SlackNode.prototype,"resultChannel",void 0),i.__decorate([Be({handle:"ts",type:"string"}),i.__metadata("design:type",String)],e.SlackNode.prototype,"resultTs",void 0),e.SlackNode=i.__decorate([qe("core.comms.slack",{kind:"core.comms.slack",category:"Comms",color:"#4a154b",icon:"ti-brand-slack",width:96,height:96,labels:["comms","slack","messaging","chat"],metadata:{title:"graph.node.comms.slack.name",description:"graph.node.comms.slack.description"}}),r.model()],e.SlackNode);const Jn=["sendMessage","getMe","getUpdates","sendChatAction"];e.TelegramNode=class extends Er{constructor(){super(...arguments),this.operation="sendMessage"}async execute(e,t){if(!this.operation)throw new Ao("Telegram node requires an operation","GRAPH_TELEGRAM_OPERATION_REQUIRED");const o=Jn.includes(this.operation)?this.operation:"sendMessage",a=Fn(await Xo(t,e.credentials,"telegram",!1,"Telegram"),"Telegram"),r=new E.TelegramService;try{switch(await v.bootWithoutEnvironment(r,{token:a,baseUrl:this.baseUrl}),o){case"sendMessage":{const t=this.chatId,o=this.text??(e.inputs.value??"")+"";if(null==t||!o)throw new Ao("Telegram sendMessage requires a chat ID and text","GRAPH_TELEGRAM_MESSAGE_REQUIRED");const a=await r.sendMessage({chatId:t,text:o,parseMode:this.parseMode,disableNotification:this.disableNotification,disablePreview:this.disablePreview,replyToMessageId:kn(this.replyToMessageId),messageThreadId:kn(this.messageThreadId)});return{result:a,messageId:kn(a?.message_id)}}case"getMe":return{result:await r.getMe()};case"getUpdates":return{result:await r.getUpdates({offset:kn(this.offset),limit:kn(this.limit),timeoutSeconds:kn(this.timeoutSeconds)})};default:if(void 0===this.chatId||null===this.chatId)throw new Ao("Telegram sendChatAction requires a chat ID","GRAPH_TELEGRAM_CHAT_REQUIRED");return{result:await r.sendChatAction(this.chatId,this.action??"typing")}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Telegram node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TELEGRAM_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.TelegramNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.chatId.label",type:"string"}),Ue({handle:"chatId",userControlled:!0}),i.__metadata("design:type",Object)],e.TelegramNode.prototype,"chatId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.text.label",type:"textarea"}),Ue({handle:"text",userControlled:!0}),i.__metadata("design:type",String)],e.TelegramNode.prototype,"text",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.parseMode.label",type:"select"}),Ue({handle:"parseMode",userControlled:!0}),i.__metadata("design:type",String)],e.TelegramNode.prototype,"parseMode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.disableNotification.label",type:"boolean"}),Ue({handle:"disableNotification",userControlled:!0}),i.__metadata("design:type",Boolean)],e.TelegramNode.prototype,"disableNotification",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.disablePreview.label",type:"boolean"}),Ue({handle:"disablePreview",userControlled:!0}),i.__metadata("design:type",Boolean)],e.TelegramNode.prototype,"disablePreview",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.replyToMessageId.label",type:"number"}),Ue({handle:"replyToMessageId",userControlled:!0}),i.__metadata("design:type",Number)],e.TelegramNode.prototype,"replyToMessageId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.messageThreadId.label",type:"number"}),Ue({handle:"messageThreadId",userControlled:!0}),i.__metadata("design:type",Number)],e.TelegramNode.prototype,"messageThreadId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.offset.label",type:"number"}),Ue({handle:"offset",userControlled:!0}),i.__metadata("design:type",Number)],e.TelegramNode.prototype,"offset",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.TelegramNode.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.timeoutSeconds.label",type:"number"}),Ue({handle:"timeoutSeconds",userControlled:!0}),i.__metadata("design:type",Number)],e.TelegramNode.prototype,"timeoutSeconds",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.action.label",type:"string"}),Ue({handle:"action",userControlled:!0}),i.__metadata("design:type",String)],e.TelegramNode.prototype,"action",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.TelegramNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.TelegramNode.prototype,"result",void 0),i.__decorate([Be({handle:"messageId",type:"number"}),i.__metadata("design:type",Number)],e.TelegramNode.prototype,"messageId",void 0),e.TelegramNode=i.__decorate([qe("core.comms.telegram",{kind:"core.comms.telegram",category:"Comms",color:"#229ed9",icon:"ti-brand-telegram",width:96,height:96,labels:["comms","telegram","messaging","bot"],metadata:{title:"graph.node.comms.telegram.name",description:"graph.node.comms.telegram.description"}}),r.model()],e.TelegramNode);const Xn=["sendWebhook","sendChannelMessage","listTeams","listChannels"];e.TeamsNode=class extends Er{constructor(){super(...arguments),this.operation="sendWebhook"}async execute(e,t){if(!this.operation)throw new Ao("Microsoft Teams node requires an operation","GRAPH_TEAMS_OPERATION_REQUIRED");const o=Xn.includes(this.operation)?this.operation:"sendWebhook",a=await Xo(t,e.credentials,"teams",!1,"Microsoft Teams"),r=new S.TeamsService;try{switch(await v.bootWithoutEnvironment(r,{token:Mn(a,"token","Microsoft Teams"),webhookUrl:Mn(a,"webhookUrl","Microsoft Teams"),baseUrl:this.baseUrl}),o){case"sendWebhook":{const t=this.text??(e.inputs.value??"")+"";if(!t)throw new Ao("Microsoft Teams sendWebhook requires text","GRAPH_TEAMS_TEXT_REQUIRED");return{result:await r.sendWebhook({text:t,title:this.title,markdown:this.markdown})}}case"sendChannelMessage":if(!this.teamId||!this.channelId||!this.content)throw new Ao("Microsoft Teams sendChannelMessage requires teamId, channelId, and content","GRAPH_TEAMS_CHANNEL_MESSAGE_REQUIRED");return{result:await r.sendChannelMessage({teamId:this.teamId,channelId:this.channelId,content:this.content,contentType:this.contentType})};case"listTeams":return{result:await r.listTeams(kn(this.limit))};default:if(!this.teamId)throw new Ao("Microsoft Teams listChannels requires a teamId","GRAPH_TEAMS_TEAM_REQUIRED");return{result:await r.listChannels(this.teamId)}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Microsoft Teams node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TEAMS_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.text.label",type:"textarea"}),Ue({handle:"text",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsNode.prototype,"text",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.title.label",type:"string"}),Ue({handle:"title",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsNode.prototype,"title",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.markdown.label",type:"boolean"}),Ue({handle:"markdown",userControlled:!0}),i.__metadata("design:type",Boolean)],e.TeamsNode.prototype,"markdown",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.teamId.label",type:"string"}),Ue({handle:"teamId",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsNode.prototype,"teamId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.channelId.label",type:"string"}),Ue({handle:"channelId",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsNode.prototype,"channelId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.content.label",type:"textarea"}),Ue({handle:"content",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsNode.prototype,"content",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.contentType.label",type:"select"}),Ue({handle:"contentType",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsNode.prototype,"contentType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.TeamsNode.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.TeamsNode.prototype,"result",void 0),e.TeamsNode=i.__decorate([qe("core.comms.teams",{kind:"core.comms.teams",category:"Comms",color:"#6264a7",icon:"ti-brand-teams",width:96,height:96,labels:["comms","teams","microsoft","messaging"],metadata:{title:"graph.node.comms.teams.name",description:"graph.node.comms.teams.description"}}),r.model()],e.TeamsNode);const Yn=["send","list","get","labels"];e.GmailNode=class extends Er{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new Ao("Gmail node requires an operation","GRAPH_GMAIL_OPERATION_REQUIRED");const o=Yn.includes(this.operation)?this.operation:"send",a=await Xo(t,e.credentials,"gmail",!1,"Gmail"),r=new R.GmailService;try{switch(await v.bootWithoutEnvironment(r,{token:Fn(a,"Gmail"),userId:this.userId??Mn(a,"userId","Gmail"),baseUrl:this.baseUrl}),o){case"send":{const t=this.from??Mn(a,"from","Gmail");if(!t||!this.to||!this.subject)throw new Ao("Gmail send requires from, to, and subject","GRAPH_GMAIL_MESSAGE_REQUIRED");const o=await r.send({from:t,to:this.to,cc:this.cc,bcc:this.bcc,subject:this.subject,text:this.text??(e.inputs.value??"")+"",html:this.html,replyTo:this.replyTo});return{result:o,id:o.id}}case"list":return{result:await r.listMessages({query:this.query,maxResults:kn(this.maxResults),pageToken:this.pageToken,labelIds:Dn(this.labelIds)?.map(String)})};case"get":if(!this.messageId)throw new Ao("Gmail get requires a message ID","GRAPH_GMAIL_MESSAGE_ID_REQUIRED");return{result:await r.getMessage(this.messageId,this.format??"full")};default:return{result:await r.listLabels()}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Gmail node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GMAIL_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.userId.label",type:"string"}),Ue({handle:"userId",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"userId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.from.label",type:"string"}),Ue({handle:"from",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"from",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.to.label",type:"string"}),Ue({handle:"to",userControlled:!0}),i.__metadata("design:type",Object)],e.GmailNode.prototype,"to",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.cc.label",type:"string"}),Ue({handle:"cc",userControlled:!0}),i.__metadata("design:type",Object)],e.GmailNode.prototype,"cc",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.bcc.label",type:"string"}),Ue({handle:"bcc",userControlled:!0}),i.__metadata("design:type",Object)],e.GmailNode.prototype,"bcc",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.subject.label",type:"string"}),Ue({handle:"subject",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"subject",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.text.label",type:"textarea"}),Ue({handle:"text",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"text",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.html.label",type:"textarea"}),Ue({handle:"html",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"html",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.replyTo.label",type:"string"}),Ue({handle:"replyTo",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"replyTo",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.query.label",type:"string"}),Ue({handle:"query",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"query",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.maxResults.label",type:"number"}),Ue({handle:"maxResults",userControlled:!0}),i.__metadata("design:type",Number)],e.GmailNode.prototype,"maxResults",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.pageToken.label",type:"string"}),Ue({handle:"pageToken",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"pageToken",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.labelIds.label",type:"json"}),Ue({handle:"labelIds",userControlled:!0}),i.__metadata("design:type",Array)],e.GmailNode.prototype,"labelIds",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.messageId.label",type:"string"}),Ue({handle:"messageId",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"messageId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.format.label",type:"select"}),Ue({handle:"format",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"format",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.GmailNode.prototype,"result",void 0),i.__decorate([Be({handle:"id",type:"string"}),i.__metadata("design:type",String)],e.GmailNode.prototype,"id",void 0),e.GmailNode=i.__decorate([qe("core.comms.gmail",{kind:"core.comms.gmail",category:"Comms",color:"#ea4335",icon:"ti-brand-google",width:96,height:96,labels:["comms","gmail","email","google"],metadata:{title:"graph.node.comms.gmail.name",description:"graph.node.comms.gmail.description"}}),r.model()],e.GmailNode);const Zn=["send","listInbox","listImap"];e.EmailSendNode=class extends Er{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new Ao("Email Send node requires an operation","GRAPH_EMAIL_OPERATION_REQUIRED");const o=Zn.includes(this.operation)?this.operation:"send",a=await Xo(t,e.credentials,"email",!1,"Email"),r=Gn(a,"Email"),n=a&&!r?a:void 0,i=new T.EmailService;try{switch(await v.bootWithoutEnvironment(i,{provider:this.provider??r?.provider,host:this.host??this.asCredentialString(r,"host"),port:kn(this.port)??kn(r?.port),secure:this.secure??On(r?.secure,!1),username:this.username??this.asCredentialString(r,"username"),password:this.asCredentialString(r,"password"),from:this.from??this.asCredentialString(r,"from"),token:n??this.asCredentialString(r,"token"),graphBaseUrl:this.graphBaseUrl??this.asCredentialString(r,"graphBaseUrl"),baseUrl:this.baseUrl}),o){case"send":{if(!this.to||!this.subject)throw new Ao("Email Send send requires to and subject","GRAPH_EMAIL_MESSAGE_REQUIRED");const t=await i.send({from:this.from??this.asCredentialString(r,"from")??"",to:this.to,cc:this.cc,bcc:this.bcc,subject:this.subject,text:this.text??(e.inputs.value??"")+"",html:this.html,replyTo:this.replyTo});return{result:t,messageId:t.messageId}}case"listInbox":return{result:await i.listInbox({mailbox:this.mailbox,limit:kn(this.limit),since:this.since,subject:this.subjectFilter})};default:return{result:await i.listImapMessages({mailbox:this.mailbox,limit:kn(this.limit),since:this.since,subject:this.subjectFilter})}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Email node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_EMAIL_OPERATION_FAILED",{operation:o})}finally{await i.shutdown().catch(()=>{})}}asCredentialString(e,t){const o=e?.[t];return"string"==typeof o&&o.trim().length>0?o.trim():void 0}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.provider.label",type:"select"}),Ue({handle:"provider",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"provider",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.host.label",type:"string"}),Ue({handle:"host",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"host",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.port.label",type:"number"}),Ue({handle:"port",userControlled:!0}),i.__metadata("design:type",Number)],e.EmailSendNode.prototype,"port",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.secure.label",type:"boolean"}),Ue({handle:"secure",userControlled:!0}),i.__metadata("design:type",Boolean)],e.EmailSendNode.prototype,"secure",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.username.label",type:"string"}),Ue({handle:"username",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"username",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.from.label",type:"string"}),Ue({handle:"from",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"from",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.to.label",type:"string"}),Ue({handle:"to",userControlled:!0}),i.__metadata("design:type",Object)],e.EmailSendNode.prototype,"to",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.cc.label",type:"string"}),Ue({handle:"cc",userControlled:!0}),i.__metadata("design:type",Object)],e.EmailSendNode.prototype,"cc",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.bcc.label",type:"string"}),Ue({handle:"bcc",userControlled:!0}),i.__metadata("design:type",Object)],e.EmailSendNode.prototype,"bcc",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.subject.label",type:"string"}),Ue({handle:"subject",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"subject",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.text.label",type:"textarea"}),Ue({handle:"text",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"text",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.html.label",type:"textarea"}),Ue({handle:"html",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"html",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.replyTo.label",type:"string"}),Ue({handle:"replyTo",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"replyTo",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.mailbox.label",type:"string"}),Ue({handle:"mailbox",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"mailbox",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.EmailSendNode.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.since.label",type:"string"}),Ue({handle:"since",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"since",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.subjectFilter.label",type:"string"}),Ue({handle:"subjectFilter",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"subjectFilter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.graphBaseUrl.label",type:"string"}),Ue({handle:"graphBaseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"graphBaseUrl",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.EmailSendNode.prototype,"result",void 0),i.__decorate([Be({handle:"messageId",type:"string"}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"messageId",void 0),e.EmailSendNode=i.__decorate([qe("core.comms.emailSend",{kind:"core.comms.emailSend",category:"Comms",color:"#0f766e",icon:"ti-mail",width:96,height:96,labels:["comms","email","smtp","imap"],metadata:{title:"graph.node.comms.email_send.name",description:"graph.node.comms.email_send.description"}}),r.model()],e.EmailSendNode);const ei=["sendMessage","getMessage","listMessages","getChannel","listChannels","createChannel","deleteChannel","addReaction"];function ti(e){if(null==e||""===e)return;if(Array.isArray(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);return Array.isArray(t)?t:[t]}catch{throw new Ao("Discord embeds must be a JSON array","GRAPH_DISCORD_EMBEDS_INVALID")}const t=Tn(e);return t?[t]:void 0}e.DiscordNode=class extends Er{constructor(){super(...arguments),this.operation="sendMessage"}async execute(e,t){if(!this.operation)throw new Ao("Discord node requires an operation","GRAPH_DISCORD_OPERATION_REQUIRED");const o=ei.includes(this.operation)?this.operation:"sendMessage",a=await Xo(t,e.credentials,"discord",!1,"Discord"),r=new C.DiscordService;try{switch(await v.bootWithoutEnvironment(r,{token:Fn(a,"Discord"),baseUrl:this.baseUrl}),o){case"sendMessage":{if(!this.channelId)throw new Ao("Discord sendMessage requires a channelId","GRAPH_DISCORD_CHANNEL_REQUIRED");const t=this.content??(e.inputs.value??"")+"";if(!t)throw new Ao("Discord sendMessage requires content","GRAPH_DISCORD_CONTENT_REQUIRED");const o=await r.sendMessage({channelId:this.channelId,content:t,tts:this.tts,embeds:ti(this.embeds)}),a=Tn(o);return{result:o,channelId:this.channelId,..."string"==typeof a?.id?{messageId:a.id}:{}}}case"getMessage":if(!this.channelId||!this.messageId)throw new Ao("Discord getMessage requires channelId and messageId","GRAPH_DISCORD_MESSAGE_REQUIRED");return{result:await r.getMessage(this.channelId,this.messageId),channelId:this.channelId,messageId:this.messageId};case"listMessages":if(!this.channelId)throw new Ao("Discord listMessages requires a channelId","GRAPH_DISCORD_CHANNEL_REQUIRED");return{result:await r.listMessages({channelId:this.channelId,limit:kn(this.limit),before:this.before}),channelId:this.channelId};case"getChannel":if(!this.channelId)throw new Ao("Discord getChannel requires a channelId","GRAPH_DISCORD_CHANNEL_REQUIRED");return{result:await r.getChannel(this.channelId),channelId:this.channelId};case"listChannels":if(!this.guildId)throw new Ao("Discord listChannels requires a guildId","GRAPH_DISCORD_GUILD_REQUIRED");return{result:await r.listChannels(this.guildId)};case"createChannel":{if(!this.guildId||!this.name)throw new Ao("Discord createChannel requires guildId and name","GRAPH_DISCORD_CHANNEL_CREATE_REQUIRED");const e=await r.createChannel({guildId:this.guildId,name:this.name,type:kn(this.channelType),topic:this.topic,parentId:this.parentId}),t=Tn(e);return{result:e,..."string"==typeof t?.id?{channelId:t.id}:{}}}case"deleteChannel":if(!this.channelId)throw new Ao("Discord deleteChannel requires a channelId","GRAPH_DISCORD_CHANNEL_REQUIRED");return{result:await r.deleteChannel(this.channelId),channelId:this.channelId};default:if(!this.channelId||!this.messageId||!this.emoji)throw new Ao("Discord addReaction requires channelId, messageId, and emoji","GRAPH_DISCORD_REACTION_REQUIRED");return{result:await r.addReaction({channelId:this.channelId,messageId:this.messageId,emoji:this.emoji}),channelId:this.channelId,messageId:this.messageId}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Discord node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_DISCORD_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.channelId.label",type:"string"}),Ue({handle:"channelId",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"channelId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.guildId.label",type:"string"}),Ue({handle:"guildId",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"guildId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.messageId.label",type:"string"}),Ue({handle:"messageId",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"messageId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.content.label",type:"textarea"}),Ue({handle:"content",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"content",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.embeds.label",type:"textarea"}),Ue({handle:"embeds",userControlled:!0}),i.__metadata("design:type",Object)],e.DiscordNode.prototype,"embeds",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.tts.label",type:"boolean"}),Ue({handle:"tts",userControlled:!0}),i.__metadata("design:type",Boolean)],e.DiscordNode.prototype,"tts",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.name.label",type:"string"}),Ue({handle:"name",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"name",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.channelType.label",type:"number"}),Ue({handle:"channelType",userControlled:!0}),i.__metadata("design:type",Number)],e.DiscordNode.prototype,"channelType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.topic.label",type:"string"}),Ue({handle:"topic",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"topic",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.parentId.label",type:"string"}),Ue({handle:"parentId",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"parentId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.emoji.label",type:"string"}),Ue({handle:"emoji",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"emoji",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.DiscordNode.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.before.label",type:"string"}),Ue({handle:"before",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"before",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.DiscordNode.prototype,"result",void 0),i.__decorate([Be({handle:"channelId",type:"string"}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"resultChannelId",void 0),i.__decorate([Be({handle:"messageId",type:"string"}),i.__metadata("design:type",String)],e.DiscordNode.prototype,"resultMessageId",void 0),e.DiscordNode=i.__decorate([qe("core.comms.discord",{kind:"core.comms.discord",category:"Comms",color:"#5865f2",icon:"ti-brand-discord",width:96,height:96,labels:["comms","discord","messaging","chat"],metadata:{title:"graph.node.comms.discord.name",description:"graph.node.comms.discord.description"}}),r.model()],e.DiscordNode);const oi=["sendText","sendTemplate","sendMedia","markAsRead","getMedia"];function ai(e){if(null==e||""===e)return;if(Array.isArray(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);return Array.isArray(t)?t:[t]}catch{throw new Ao("WhatsApp template components must be a JSON array","GRAPH_WHATSAPP_COMPONENTS_INVALID")}const t=Tn(e);return t?[t]:void 0}e.WhatsAppNode=class extends Er{constructor(){super(...arguments),this.operation="sendText"}async execute(e,t){if(!this.operation)throw new Ao("WhatsApp node requires an operation","GRAPH_WHATSAPP_OPERATION_REQUIRED");const o=oi.includes(this.operation)?this.operation:"sendText",a=await Xo(t,e.credentials,"whatsapp",!1,"WhatsApp"),r=new O.WhatsAppService;try{switch(await v.bootWithoutEnvironment(r,{token:Fn(a,"WhatsApp"),phoneNumberId:this.phoneNumberId??Mn(a,"phoneNumberId","WhatsApp"),baseUrl:this.baseUrl}),o){case"sendText":{const t=this.text??(e.inputs.value??"")+"";if(!this.to||!t)throw new Ao("WhatsApp sendText requires to and text","GRAPH_WHATSAPP_TEXT_REQUIRED");const o=await r.sendText({to:this.to,text:t,previewUrl:this.previewUrl});return{result:o,...this.messageIdOf(o)}}case"sendTemplate":{if(!this.to||!this.templateName||!this.languageCode)throw new Ao("WhatsApp sendTemplate requires to, templateName, and languageCode","GRAPH_WHATSAPP_TEMPLATE_REQUIRED");const e=await r.sendTemplate({to:this.to,templateName:this.templateName,languageCode:this.languageCode,components:ai(this.components)});return{result:e,...this.messageIdOf(e)}}case"sendMedia":{if(!this.to||!this.mediaId&&!this.mediaUrl)throw new Ao("WhatsApp sendMedia requires to and a mediaId or mediaUrl","GRAPH_WHATSAPP_MEDIA_REQUIRED");const e=await r.sendMedia({to:this.to,type:this.mediaType??"image",mediaId:this.mediaId,link:this.mediaUrl,caption:this.caption,filename:this.filename});return{result:e,...this.messageIdOf(e)}}case"markAsRead":if(!this.messageId)throw new Ao("WhatsApp markAsRead requires a messageId","GRAPH_WHATSAPP_MESSAGE_REQUIRED");return{result:await r.markAsRead({messageId:this.messageId}),messageId:this.messageId};default:if(!this.mediaId)throw new Ao("WhatsApp getMedia requires a mediaId","GRAPH_WHATSAPP_MEDIA_REQUIRED");return{result:await r.getMedia(this.mediaId)}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`WhatsApp node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_WHATSAPP_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}messageIdOf(e){const t=Tn(e),o=t?.messages;if(Array.isArray(o)){const e=Tn(o[0]);if("string"==typeof e?.id)return{messageId:e.id}}return{}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.phoneNumberId.label",type:"string"}),Ue({handle:"phoneNumberId",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"phoneNumberId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.to.label",type:"string"}),Ue({handle:"to",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"to",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.text.label",type:"textarea"}),Ue({handle:"text",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"text",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.previewUrl.label",type:"boolean"}),Ue({handle:"previewUrl",userControlled:!0}),i.__metadata("design:type",Boolean)],e.WhatsAppNode.prototype,"previewUrl",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.templateName.label",type:"string"}),Ue({handle:"templateName",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"templateName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.languageCode.label",type:"string"}),Ue({handle:"languageCode",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"languageCode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.components.label",type:"textarea"}),Ue({handle:"components",userControlled:!0}),i.__metadata("design:type",Object)],e.WhatsAppNode.prototype,"components",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.mediaType.label",type:"select"}),Ue({handle:"mediaType",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"mediaType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.mediaId.label",type:"string"}),Ue({handle:"mediaId",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"mediaId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.mediaUrl.label",type:"string"}),Ue({handle:"mediaUrl",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"mediaUrl",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.caption.label",type:"string"}),Ue({handle:"caption",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"caption",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.filename.label",type:"string"}),Ue({handle:"filename",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"filename",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.messageId.label",type:"string"}),Ue({handle:"messageId",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"messageId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.WhatsAppNode.prototype,"result",void 0),i.__decorate([Be({handle:"messageId",type:"string"}),i.__metadata("design:type",String)],e.WhatsAppNode.prototype,"resultMessageId",void 0),e.WhatsAppNode=i.__decorate([qe("core.comms.whatsApp",{kind:"core.comms.whatsApp",category:"Comms",color:"#25d366",icon:"ti-brand-whatsapp",width:96,height:96,labels:["comms","whatsapp","messaging","meta"],metadata:{title:"graph.node.comms.whatsapp.name",description:"graph.node.comms.whatsapp.description"}}),r.model()],e.WhatsAppNode);const ri=["sendMail","listMessages","getMessage","listEvents","createEvent","deleteEvent"];function ni(e){if(null!=e&&""!==e){if(Array.isArray(e))return e.map(e=>(e+"").trim()).filter(e=>e.length>0);if("string"==typeof e){if(e.trim().startsWith("["))try{const t=JSON.parse(e);return Array.isArray(t)?t.map(e=>(e+"").trim()):void 0}catch{throw new Ao("Microsoft Outlook attendees must be a JSON array or a comma-separated list","GRAPH_OUTLOOK_ATTENDEES_INVALID")}return e.split(/[,;]/).map(e=>e.trim()).filter(e=>e.length>0)}}}e.MicrosoftOutlookNode=class extends Er{constructor(){super(...arguments),this.operation="sendMail"}async execute(e,t){if(!this.operation)throw new Ao("Microsoft Outlook node requires an operation","GRAPH_OUTLOOK_OPERATION_REQUIRED");const o=ri.includes(this.operation)?this.operation:"sendMail",a=await Xo(t,e.credentials,"microsoft-outlook",!1,"Microsoft Outlook"),r=new k.MicrosoftOutlookService;try{switch(await v.bootWithoutEnvironment(r,{token:Fn(a,"Microsoft Outlook"),baseUrl:this.baseUrl}),o){case"sendMail":{if(!this.to||!this.subject)throw new Ao("Microsoft Outlook sendMail requires to and subject","GRAPH_OUTLOOK_MAIL_REQUIRED");const t=this.body??(e.inputs.value??"")+"";return{result:await r.sendMail({to:this.to,cc:this.cc,bcc:this.bcc,subject:this.subject,body:t,contentType:this.contentType,saveToSentItems:this.saveToSentItems})}}case"listMessages":return{result:await r.listMessages({folderId:this.folderId,top:kn(this.top),filter:this.filter,search:this.search})};case"getMessage":if(!this.messageId)throw new Ao("Microsoft Outlook getMessage requires a messageId","GRAPH_OUTLOOK_MESSAGE_REQUIRED");return{result:await r.getMessage(this.messageId),messageId:this.messageId};case"listEvents":return{result:await r.listEvents({top:kn(this.top),filter:this.filter,search:this.search})};case"createEvent":{if(!this.subject||!this.start||!this.end)throw new Ao("Microsoft Outlook createEvent requires subject, start, and end","GRAPH_OUTLOOK_EVENT_REQUIRED");const e=await r.createEvent({subject:this.subject,start:this.start,end:this.end,timeZone:this.timeZone,body:this.body,location:this.location,attendees:ni(this.attendees)}),t=Tn(e);return{result:e,..."string"==typeof t?.id?{eventId:t.id}:{}}}default:if(!this.eventId)throw new Ao("Microsoft Outlook deleteEvent requires an eventId","GRAPH_OUTLOOK_EVENT_REQUIRED");return{result:await r.deleteEvent(this.eventId),eventId:this.eventId}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Microsoft Outlook node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_OUTLOOK_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.to.label",type:"string"}),Ue({handle:"to",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"to",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.cc.label",type:"string"}),Ue({handle:"cc",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"cc",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.bcc.label",type:"string"}),Ue({handle:"bcc",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"bcc",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.subject.label",type:"string"}),Ue({handle:"subject",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"subject",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.body.label",type:"textarea"}),Ue({handle:"body",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"body",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.contentType.label",type:"select"}),Ue({handle:"contentType",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"contentType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.saveToSentItems.label",type:"boolean"}),Ue({handle:"saveToSentItems",userControlled:!0}),i.__metadata("design:type",Boolean)],e.MicrosoftOutlookNode.prototype,"saveToSentItems",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.folderId.label",type:"string"}),Ue({handle:"folderId",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"folderId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.messageId.label",type:"string"}),Ue({handle:"messageId",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"messageId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.eventId.label",type:"string"}),Ue({handle:"eventId",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"eventId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.start.label",type:"string"}),Ue({handle:"start",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"start",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.end.label",type:"string"}),Ue({handle:"end",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"end",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.timeZone.label",type:"string"}),Ue({handle:"timeZone",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"timeZone",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.location.label",type:"string"}),Ue({handle:"location",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"location",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.attendees.label",type:"textarea"}),Ue({handle:"attendees",userControlled:!0}),i.__metadata("design:type",Object)],e.MicrosoftOutlookNode.prototype,"attendees",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.top.label",type:"number"}),Ue({handle:"top",userControlled:!0}),i.__metadata("design:type",Number)],e.MicrosoftOutlookNode.prototype,"top",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.filter.label",type:"string"}),Ue({handle:"filter",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"filter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.search.label",type:"string"}),Ue({handle:"search",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"search",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.MicrosoftOutlookNode.prototype,"result",void 0),i.__decorate([Be({handle:"messageId",type:"string"}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"resultMessageId",void 0),i.__decorate([Be({handle:"eventId",type:"string"}),i.__metadata("design:type",String)],e.MicrosoftOutlookNode.prototype,"resultEventId",void 0),e.MicrosoftOutlookNode=i.__decorate([qe("core.comms.microsoftOutlook",{kind:"core.comms.microsoftOutlook",category:"Comms",color:"#0078d4",icon:"ti-brand-office",width:96,height:96,labels:["comms","outlook","microsoft","email","calendar"],metadata:{title:"graph.node.comms.microsoft_outlook.name",description:"graph.node.comms.microsoft_outlook.description"}}),r.model()],e.MicrosoftOutlookNode);const ii=["get","update","append","clear","create"];e.GoogleSheetsNode=class extends Er{constructor(){super(...arguments),this.operation="get"}async execute(e,t){if(!this.operation)throw new Ao("Google Sheets node requires an operation","GRAPH_GOOGLE_SHEETS_OPERATION_REQUIRED");const o=ii.includes(this.operation)?this.operation:"get",a=await Xo(t,e.credentials,"google-sheets",!1,"Google Sheets"),r=new D.GoogleSheetsService;try{switch(await v.bootWithoutEnvironment(r,{token:Mn(a,"token","Google Sheets"),apiKey:Mn(a,"apiKey","Google Sheets"),baseUrl:this.baseUrl}),o){case"get":{const e=await r.getValues(this.requireSpreadsheet(),this.requireRange());return{result:e,values:e.values,spreadsheetId:e.spreadsheetId,range:e.range}}case"update":case"append":{const e=this.requireValues(),t={spreadsheetId:this.requireSpreadsheet(),range:this.requireRange(),values:e,valueInputOption:this.valueInputOption??"USER_ENTERED"},a="update"===o?await r.updateValues(t):await r.appendValues(t);return{result:a,values:a.values,spreadsheetId:a.spreadsheetId,range:a.range}}case"clear":{const e=await r.clearValues(this.requireSpreadsheet(),this.requireRange());return{result:e,spreadsheetId:e.spreadsheetId,range:e.clearedRange}}default:{if(!this.title)throw new Ao("Google Sheets create requires a title","GRAPH_GOOGLE_SHEETS_TITLE_REQUIRED");const e=await r.createSpreadsheet(this.title);return{result:e,spreadsheetId:e.spreadsheetId}}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Google Sheets node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GOOGLE_SHEETS_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}requireSpreadsheet(){if(!this.spreadsheetId)throw new Ao("Google Sheets node requires a spreadsheet ID","GRAPH_GOOGLE_SHEETS_SPREADSHEET_REQUIRED");return this.spreadsheetId}requireRange(){if(!this.range)throw new Ao("Google Sheets node requires a range","GRAPH_GOOGLE_SHEETS_RANGE_REQUIRED");return this.range}requireValues(){if(!Array.isArray(this.values)||!this.values.every(e=>Array.isArray(e)))throw new Ao("Google Sheets node requires values as an array of rows","GRAPH_GOOGLE_SHEETS_VALUES_REQUIRED");return this.values}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.spreadsheetId.label",type:"string"}),Ue({handle:"spreadsheetId",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"spreadsheetId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.range.label",type:"string"}),Ue({handle:"range",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"range",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.values.label",type:"json"}),Ue({handle:"values",userControlled:!0}),i.__metadata("design:type",Array)],e.GoogleSheetsNode.prototype,"values",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.valueInputOption.label",type:"select"}),Ue({handle:"valueInputOption",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"valueInputOption",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.title.label",type:"string"}),Ue({handle:"title",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"title",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.GoogleSheetsNode.prototype,"result",void 0),i.__decorate([Be({handle:"values",type:"array"}),i.__metadata("design:type",Array)],e.GoogleSheetsNode.prototype,"outputValues",void 0),i.__decorate([Be({handle:"spreadsheetId",type:"string"}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"outputSpreadsheetId",void 0),i.__decorate([Be({handle:"range",type:"string"}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"outputRange",void 0),e.GoogleSheetsNode=i.__decorate([qe("core.io.googleSheets",{kind:"core.io.googleSheets",category:"IO",color:"#0f9d58",icon:"ti-brand-google",width:96,height:96,labels:["io","google","sheets","spreadsheet"],metadata:{title:"graph.node.io.google_sheets.name",description:"graph.node.io.google_sheets.description"}}),r.model()],e.GoogleSheetsNode);const di=["list","get","create","update","delete"];e.AirtableNode=class extends Er{constructor(){super(...arguments),this.operation="list"}async execute(e,t){if(!this.operation)throw new Ao("Airtable node requires an operation","GRAPH_AIRTABLE_OPERATION_REQUIRED");const o=di.includes(this.operation)?this.operation:"list",a=await Xo(t,e.credentials,"airtable",!1,"Airtable"),r=new P.AirtableService;try{switch(await v.bootWithoutEnvironment(r,{token:Mn(a,"token","Airtable"),baseId:this.baseId??Mn(a,"baseId","Airtable"),baseUrl:this.baseUrl}),o){case"list":{const e=await r.listRecords({table:this.requireTable(),view:this.view,filterByFormula:this.filterByFormula,maxRecords:kn(this.maxRecords),pageSize:kn(this.pageSize),offset:this.offset,fields:Array.isArray(this.fields)?this.fields.map(String):void 0,sort:this.sortField?[{field:this.sortField,direction:this.sortDirection}]:void 0});return{result:e,records:e.records,offset:e.offset}}case"get":{const e=await r.getRecord(this.requireTable(),this.requireRecordId());return{result:e,records:[e]}}case"create":{const e=await r.createRecord({table:this.requireTable(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}case"update":{const e=await r.updateRecord({table:this.requireTable(),recordId:this.requireRecordId(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}default:return{result:await r.deleteRecord(this.requireTable(),this.requireRecordId())}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Airtable node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_AIRTABLE_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}requireTable(){if(!this.table)throw new Ao("Airtable node requires a table","GRAPH_AIRTABLE_TABLE_REQUIRED");return this.table}requireRecordId(){if(!this.recordId)throw new Ao("Airtable node requires a record ID","GRAPH_AIRTABLE_RECORD_REQUIRED");return this.recordId}requireRecordFields(){const e=Tn(this.recordFields);if(!e)throw new Ao("Airtable node requires recordFields as an object","GRAPH_AIRTABLE_FIELDS_REQUIRED");return e}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.baseId.label",type:"string"}),Ue({handle:"baseId",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"baseId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.table.label",type:"string"}),Ue({handle:"table",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"table",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.recordId.label",type:"string"}),Ue({handle:"recordId",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"recordId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.recordFields.label",type:"json"}),Ue({handle:"recordFields",userControlled:!0}),i.__metadata("design:type",Object)],e.AirtableNode.prototype,"recordFields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.typecast.label",type:"boolean"}),Ue({handle:"typecast",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AirtableNode.prototype,"typecast",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.view.label",type:"string"}),Ue({handle:"view",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"view",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.filterByFormula.label",type:"string"}),Ue({handle:"filterByFormula",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"filterByFormula",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.fields.label",type:"json"}),Ue({handle:"fields",userControlled:!0}),i.__metadata("design:type",Array)],e.AirtableNode.prototype,"fields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.sortField.label",type:"string"}),Ue({handle:"sortField",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"sortField",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.sortDirection.label",type:"select"}),Ue({handle:"sortDirection",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"sortDirection",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.maxRecords.label",type:"number"}),Ue({handle:"maxRecords",userControlled:!0}),i.__metadata("design:type",Number)],e.AirtableNode.prototype,"maxRecords",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.pageSize.label",type:"number"}),Ue({handle:"pageSize",userControlled:!0}),i.__metadata("design:type",Number)],e.AirtableNode.prototype,"pageSize",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.offset.label",type:"string"}),Ue({handle:"offset",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"offset",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.AirtableNode.prototype,"result",void 0),i.__decorate([Be({handle:"records",type:"array"}),i.__metadata("design:type",Array)],e.AirtableNode.prototype,"records",void 0),i.__decorate([Be({handle:"offset",type:"string"}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"nextOffset",void 0),e.AirtableNode=i.__decorate([qe("core.io.airtable",{kind:"core.io.airtable",category:"IO",color:"#fcb400",icon:"ti-table",width:96,height:96,labels:["io","airtable","database","records"],metadata:{title:"graph.node.io.airtable.name",description:"graph.node.io.airtable.description"}}),r.model()],e.AirtableNode);const si=["parse","write"];e.SpreadsheetFileNode=class extends Er{constructor(){super(...arguments),this.spreadsheets=new G.SpreadsheetService,this.operation="parse"}async execute(e){const t=si.includes(this.operation)?this.operation:"parse";try{if("parse"===t){const t=this.content??e.inputs.value;if("string"!=typeof t)throw new Ao("Spreadsheet File parse requires text content","GRAPH_SPREADSHEET_CONTENT_REQUIRED");const o=this.spreadsheets.parse(t,{format:this.format,delimiter:this.delimiter,header:this.hasHeader});return{result:o,content:t,rows:o.rows,header:o.header}}const o=Array.isArray(this.rows)?this.rows:Array.isArray(e.inputs.value)?e.inputs.value:void 0;if(!o)throw new Ao("Spreadsheet File write requires rows as an array of arrays","GRAPH_SPREADSHEET_ROWS_REQUIRED");const a=this.spreadsheets.serialize(o,{format:this.format,delimiter:this.delimiter,header:Dn(this.header)?.map(String)});return{result:a,content:a}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Spreadsheet File node operation '${t}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SPREADSHEET_OPERATION_FAILED",{operation:t})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.SpreadsheetFileNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.format.label",type:"select"}),Ue({handle:"format",userControlled:!0}),i.__metadata("design:type",String)],e.SpreadsheetFileNode.prototype,"format",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.delimiter.label",type:"string"}),Ue({handle:"delimiter",userControlled:!0}),i.__metadata("design:type",String)],e.SpreadsheetFileNode.prototype,"delimiter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.content.label",type:"textarea"}),Ue({handle:"content",userControlled:!0}),i.__metadata("design:type",String)],e.SpreadsheetFileNode.prototype,"content",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.rows.label",type:"json"}),Ue({handle:"rows",userControlled:!0}),i.__metadata("design:type",Array)],e.SpreadsheetFileNode.prototype,"rows",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.header.label",type:"json"}),Ue({handle:"header",userControlled:!0}),i.__metadata("design:type",Array)],e.SpreadsheetFileNode.prototype,"header",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.hasHeader.label",type:"boolean"}),Ue({handle:"hasHeader",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SpreadsheetFileNode.prototype,"hasHeader",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.SpreadsheetFileNode.prototype,"result",void 0),i.__decorate([Be({handle:"content",type:"string"}),i.__metadata("design:type",String)],e.SpreadsheetFileNode.prototype,"outputContent",void 0),i.__decorate([Be({handle:"rows",type:"array"}),i.__metadata("design:type",Array)],e.SpreadsheetFileNode.prototype,"outputRows",void 0),i.__decorate([Be({handle:"header",type:"array"}),i.__metadata("design:type",Array)],e.SpreadsheetFileNode.prototype,"outputHeader",void 0),e.SpreadsheetFileNode=i.__decorate([qe("core.io.spreadsheetFile",{kind:"core.io.spreadsheetFile",category:"IO",color:"#217346",icon:"ti-file-spreadsheet",width:96,height:96,labels:["io","spreadsheet","csv","tsv","json"],metadata:{title:"graph.node.io.spreadsheet_file.name",description:"graph.node.io.spreadsheet_file.description"}}),r.model()],e.SpreadsheetFileNode);const li=["query","mutation"];e.GraphqlNode=class extends Er{constructor(){super(...arguments),this.operation="query"}async execute(e,t){if(!this.operation)throw new Ao("GraphQL node requires an operation","GRAPH_GRAPHQL_OPERATION_REQUIRED");const o=li.includes(this.operation)?this.operation:"query",a=this.query??(e.inputs.value??"")+"";if(!a)throw new Ao("GraphQL node requires a query document","GRAPH_GRAPHQL_QUERY_REQUIRED");const r=await Xo(t,e.credentials,"graphql",!1,"GraphQL"),n=new M.GraphqlService;try{await v.bootWithoutEnvironment(n,{endpoint:this.endpoint??Mn(r,"endpoint","GraphQL"),token:Mn(r,"token","GraphQL")});const e=await n.request({query:a,variables:Tn(this.variables),operationName:this.operationName});return e.errors&&e.errors.length>0?{result:e.data,errors:e.errors}:{result:e.data}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`GraphQL node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GRAPHQL_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.GraphqlNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.endpoint.label",type:"string"}),Ue({handle:"endpoint",userControlled:!0}),i.__metadata("design:type",String)],e.GraphqlNode.prototype,"endpoint",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.query.label",type:"textarea"}),Ue({handle:"query",userControlled:!0}),i.__metadata("design:type",String)],e.GraphqlNode.prototype,"query",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.variables.label",type:"json"}),Ue({handle:"variables",userControlled:!0}),i.__metadata("design:type",Object)],e.GraphqlNode.prototype,"variables",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.operationName.label",type:"string"}),Ue({handle:"operationName",userControlled:!0}),i.__metadata("design:type",String)],e.GraphqlNode.prototype,"operationName",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.GraphqlNode.prototype,"result",void 0),i.__decorate([Be({handle:"errors",type:"array"}),i.__metadata("design:type",Array)],e.GraphqlNode.prototype,"errors",void 0),e.GraphqlNode=i.__decorate([qe("core.io.graphql",{kind:"core.io.graphql",category:"IO",color:"#e10098",icon:"ti-api",width:96,height:96,labels:["io","graphql","api","query"],metadata:{title:"graph.node.io.graphql.name",description:"graph.node.io.graphql.description"}}),r.model()],e.GraphqlNode);const ci=["listWorksheets","getRange","updateRange","listTables","addTableRow"];function pi(e){const t=(e=>{if(null==e||""===e)throw new Ao("Microsoft Excel operation requires values","GRAPH_EXCEL_VALUES_REQUIRED");if(Array.isArray(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{throw new Ao("Microsoft Excel values must be a JSON array","GRAPH_EXCEL_VALUES_INVALID")}throw new Ao("Microsoft Excel values must be a JSON array","GRAPH_EXCEL_VALUES_INVALID")})(e);return 0===t.length?[]:Array.isArray(t[0])?t:[t]}e.MicrosoftExcelNode=class extends Er{constructor(){super(...arguments),this.operation="getRange"}async execute(e,t){if(!this.operation)throw new Ao("Microsoft Excel node requires an operation","GRAPH_EXCEL_OPERATION_REQUIRED");const o=ci.includes(this.operation)?this.operation:"getRange",a=await Xo(t,e.credentials,"microsoft-excel",!1,"Microsoft Excel"),r=new F.MicrosoftExcelService;try{await v.bootWithoutEnvironment(r,{token:Fn(a,"Microsoft Excel"),baseUrl:this.baseUrl});const e={itemId:this.itemId??"",driveId:this.driveId};switch(o){case"listWorksheets":return{result:await r.listWorksheets(e)};case"getRange":return{result:await r.getRange({...e,worksheet:this.worksheet??"",range:this.range??""})};case"updateRange":return{result:await r.updateRange({...e,worksheet:this.worksheet??"",range:this.range??"",values:pi(this.values)})};case"listTables":return{result:await r.listTables(e)};default:{const t=pi(this.values);return{result:await r.addTableRow({...e,tableId:this.tableId??"",values:t[0]??[]})}}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Microsoft Excel node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_EXCEL_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftExcelNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.itemId.label",type:"string"}),Ue({handle:"itemId",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftExcelNode.prototype,"itemId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.driveId.label",type:"string"}),Ue({handle:"driveId",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftExcelNode.prototype,"driveId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.worksheet.label",type:"string"}),Ue({handle:"worksheet",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftExcelNode.prototype,"worksheet",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.range.label",type:"string"}),Ue({handle:"range",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftExcelNode.prototype,"range",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.values.label",type:"textarea"}),Ue({handle:"values",userControlled:!0}),i.__metadata("design:type",Object)],e.MicrosoftExcelNode.prototype,"values",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.tableId.label",type:"string"}),Ue({handle:"tableId",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftExcelNode.prototype,"tableId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftExcelNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.MicrosoftExcelNode.prototype,"result",void 0),e.MicrosoftExcelNode=i.__decorate([qe("core.io.microsoftExcel",{kind:"core.io.microsoftExcel",category:"IO",color:"#217346",icon:"ti-file-spreadsheet",width:96,height:96,labels:["io","microsoft","excel","spreadsheet","onedrive"],metadata:{title:"graph.node.io.microsoft_excel.name",description:"graph.node.io.microsoft_excel.description"}}),r.model()],e.MicrosoftExcelNode);const ui=["getPage","listSpaces","createPage","updatePage","deletePage","search"];e.ConfluenceNode=class extends Er{constructor(){super(...arguments),this.operation="getPage"}async execute(e,t){if(!this.operation)throw new Ao("Confluence node requires an operation","GRAPH_CONFLUENCE_OPERATION_REQUIRED");const o=ui.includes(this.operation)?this.operation:"getPage",a=await Xo(t,e.credentials,"confluence",!1,"Confluence"),r=new L.ConfluenceService;try{switch(await v.bootWithoutEnvironment(r,{token:Mn(a,"token","Confluence"),username:Mn(a,"username","Confluence"),baseUrl:this.baseUrl??Mn(a,"baseUrl","Confluence")}),o){case"getPage":if(!this.pageId)throw new Ao("Confluence getPage requires a pageId","GRAPH_CONFLUENCE_PAGE_REQUIRED");return{result:await r.getPage(this.pageId)};case"listSpaces":return{result:await r.listSpaces(kn(this.limit)??25)};case"createPage":if(!this.spaceKey||!this.title)throw new Ao("Confluence createPage requires spaceKey and title","GRAPH_CONFLUENCE_CREATE_REQUIRED");return{result:await r.createPage({spaceKey:this.spaceKey,title:this.title,body:this.body??"",parentId:this.parentId})};case"updatePage":if(!this.pageId||!this.title)throw new Ao("Confluence updatePage requires pageId and title","GRAPH_CONFLUENCE_UPDATE_REQUIRED");return{result:await r.updatePage({pageId:this.pageId,title:this.title,body:this.body??"",version:kn(this.version)})};case"deletePage":if(!this.pageId)throw new Ao("Confluence deletePage requires a pageId","GRAPH_CONFLUENCE_PAGE_REQUIRED");return{result:await r.deletePage(this.pageId)};default:if(!this.cql)throw new Ao("Confluence search requires a cql query","GRAPH_CONFLUENCE_SEARCH_REQUIRED");return{result:await r.search({cql:this.cql,limit:kn(this.limit)})}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Confluence node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_CONFLUENCE_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.ConfluenceNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.pageId.label",type:"string"}),Ue({handle:"pageId",userControlled:!0}),i.__metadata("design:type",String)],e.ConfluenceNode.prototype,"pageId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.spaceKey.label",type:"string"}),Ue({handle:"spaceKey",userControlled:!0}),i.__metadata("design:type",String)],e.ConfluenceNode.prototype,"spaceKey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.title.label",type:"string"}),Ue({handle:"title",userControlled:!0}),i.__metadata("design:type",String)],e.ConfluenceNode.prototype,"title",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.body.label",type:"textarea"}),Ue({handle:"body",userControlled:!0}),i.__metadata("design:type",String)],e.ConfluenceNode.prototype,"body",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.parentId.label",type:"string"}),Ue({handle:"parentId",userControlled:!0}),i.__metadata("design:type",String)],e.ConfluenceNode.prototype,"parentId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.version.label",type:"number"}),Ue({handle:"version",userControlled:!0}),i.__metadata("design:type",Number)],e.ConfluenceNode.prototype,"version",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.cql.label",type:"string"}),Ue({handle:"cql",userControlled:!0}),i.__metadata("design:type",String)],e.ConfluenceNode.prototype,"cql",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.ConfluenceNode.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.ConfluenceNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.ConfluenceNode.prototype,"result",void 0),e.ConfluenceNode=i.__decorate([qe("core.io.confluence",{kind:"core.io.confluence",category:"IO",color:"#0052cc",icon:"ti-file-text",width:96,height:96,labels:["io","confluence","wiki","atlassian","documentation"],metadata:{title:"graph.node.io.confluence.name",description:"graph.node.io.confluence.description"}}),r.model()],e.ConfluenceNode);const gi=["createIssue","getIssue","updateIssue","deleteIssue","addComment","getTransitions","transitionIssue","search"];function hi(e,t,o){if(null==e||""===e)return;if("string"==typeof e){try{const t=Tn(JSON.parse(e));if(t)return t}catch{}throw new Ao(`Jira ${o} must be a JSON object`,t)}const a=Tn(e);if(a)return a;throw new Ao(`Jira ${o} must be a JSON object`,t)}e.JiraNode=class extends Er{constructor(){super(...arguments),this.operation="createIssue"}async execute(e,t){if(!this.operation)throw new Ao("Jira node requires an operation","GRAPH_JIRA_OPERATION_REQUIRED");const o=gi.includes(this.operation)?this.operation:"createIssue",a=await Xo(t,e.credentials,"jira",!1,"Jira"),r=new j.JiraService;try{switch(await v.bootWithoutEnvironment(r,{token:Mn(a,"token","Jira"),username:Mn(a,"username","Jira"),baseUrl:this.baseUrl??Mn(a,"baseUrl","Jira")}),o){case"createIssue":{if(!this.projectKey||!this.summary)throw new Ao("Jira createIssue requires projectKey and summary","GRAPH_JIRA_CREATE_REQUIRED");const e=await r.createIssue({projectKey:this.projectKey,summary:this.summary,issueType:this.issueType,description:this.description,fields:hi(this.fields,"GRAPH_JIRA_FIELDS_INVALID","fields")}),t=Tn(e);return{result:e,..."string"==typeof t?.key?{issueKey:t.key}:{}}}case"getIssue":if(!this.issueKey)throw new Ao("Jira getIssue requires an issueKey","GRAPH_JIRA_ISSUE_REQUIRED");return{result:await r.getIssue(this.issueKey),issueKey:this.issueKey};case"updateIssue":{if(!this.issueKey)throw new Ao("Jira updateIssue requires an issueKey","GRAPH_JIRA_ISSUE_REQUIRED");const e=hi(this.fields,"GRAPH_JIRA_FIELDS_REQUIRED","fields");if(!e)throw new Ao("Jira updateIssue requires fields","GRAPH_JIRA_FIELDS_REQUIRED");return{result:await r.updateIssue({issueKey:this.issueKey,fields:e}),issueKey:this.issueKey}}case"deleteIssue":if(!this.issueKey)throw new Ao("Jira deleteIssue requires an issueKey","GRAPH_JIRA_ISSUE_REQUIRED");return{result:await r.deleteIssue(this.issueKey),issueKey:this.issueKey};case"addComment":if(!this.issueKey||!this.comment)throw new Ao("Jira addComment requires issueKey and comment","GRAPH_JIRA_COMMENT_REQUIRED");return{result:await r.addComment({issueKey:this.issueKey,body:this.comment}),issueKey:this.issueKey};case"getTransitions":if(!this.issueKey)throw new Ao("Jira getTransitions requires an issueKey","GRAPH_JIRA_ISSUE_REQUIRED");return{result:await r.getTransitions(this.issueKey),issueKey:this.issueKey};case"transitionIssue":if(!this.issueKey||!this.transitionId)throw new Ao("Jira transitionIssue requires issueKey and transitionId","GRAPH_JIRA_TRANSITION_REQUIRED");return{result:await r.transitionIssue({issueKey:this.issueKey,transitionId:this.transitionId}),issueKey:this.issueKey};default:if(!this.jql)throw new Ao("Jira search requires a jql query","GRAPH_JIRA_SEARCH_REQUIRED");return{result:await r.search({jql:this.jql,maxResults:kn(this.maxResults)})}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Jira node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_JIRA_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.projectKey.label",type:"string"}),Ue({handle:"projectKey",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"projectKey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.issueType.label",type:"string"}),Ue({handle:"issueType",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"issueType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.summary.label",type:"string"}),Ue({handle:"summary",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"summary",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.description.label",type:"textarea"}),Ue({handle:"description",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"description",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.issueKey.label",type:"string"}),Ue({handle:"issueKey",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"issueKey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.fields.label",type:"textarea"}),Ue({handle:"fields",userControlled:!0}),i.__metadata("design:type",Object)],e.JiraNode.prototype,"fields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.comment.label",type:"textarea"}),Ue({handle:"comment",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"comment",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.transitionId.label",type:"string"}),Ue({handle:"transitionId",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"transitionId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.jql.label",type:"string"}),Ue({handle:"jql",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"jql",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.maxResults.label",type:"number"}),Ue({handle:"maxResults",userControlled:!0}),i.__metadata("design:type",Number)],e.JiraNode.prototype,"maxResults",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.JiraNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.JiraNode.prototype,"result",void 0),i.__decorate([Be({handle:"issueKey",type:"string"}),i.__metadata("design:type",String)],e.JiraNode.prototype,"resultIssueKey",void 0),e.JiraNode=i.__decorate([qe("core.io.jira",{kind:"core.io.jira",category:"IO",color:"#0052cc",icon:"ti-brand-jira",width:96,height:96,labels:["io","jira","issues","atlassian","project"],metadata:{title:"graph.node.io.jira.name",description:"graph.node.io.jira.description"}}),r.model()],e.JiraNode);const mi=["createDocument","getDocument","appendText","replaceAllText","batchUpdate"];function fi(e){if(Array.isArray(e))return e;if("string"==typeof e&&e.trim().length>0)try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{}throw new Ao("Google Docs requests must be a JSON array","GRAPH_GOOGLE_DOCS_REQUESTS_INVALID")}e.GoogleDocsNode=class extends Er{constructor(){super(...arguments),this.operation="getDocument"}async execute(e,t){if(!this.operation)throw new Ao("Google Docs node requires an operation","GRAPH_GOOGLE_DOCS_OPERATION_REQUIRED");const o=mi.includes(this.operation)?this.operation:"getDocument",a=await Xo(t,e.credentials,"google-docs",!1,"Google Docs"),r=new q.GoogleDocsService;try{switch(await v.bootWithoutEnvironment(r,{token:Mn(a,"token","Google Docs"),apiKey:Mn(a,"apiKey","Google Docs"),baseUrl:this.baseUrl}),o){case"createDocument":{if(!this.title)throw new Ao("Google Docs createDocument requires a title","GRAPH_GOOGLE_DOCS_TITLE_REQUIRED");const e=await r.createDocument(this.title),t=Tn(e);return{result:e,..."string"==typeof t?.documentId?{documentId:t.documentId}:{}}}case"getDocument":if(!this.documentId)throw new Ao("Google Docs getDocument requires a documentId","GRAPH_GOOGLE_DOCS_DOCUMENT_REQUIRED");return{result:await r.getDocument(this.documentId),documentId:this.documentId};case"appendText":if(!this.documentId||!this.text)throw new Ao("Google Docs appendText requires documentId and text","GRAPH_GOOGLE_DOCS_TEXT_REQUIRED");return{result:await r.appendText(this.documentId,this.text),documentId:this.documentId};case"replaceAllText":if(!this.documentId||!this.findText)throw new Ao("Google Docs replaceAllText requires documentId and findText","GRAPH_GOOGLE_DOCS_REPLACE_REQUIRED");return{result:await r.replaceAllText({documentId:this.documentId,find:this.findText,replace:this.replaceText??"",matchCase:this.matchCase}),documentId:this.documentId};default:if(!this.documentId)throw new Ao("Google Docs batchUpdate requires a documentId","GRAPH_GOOGLE_DOCS_DOCUMENT_REQUIRED");return{result:await r.batchUpdate(this.documentId,fi(this.requests)),documentId:this.documentId}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Google Docs node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GOOGLE_DOCS_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleDocsNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.documentId.label",type:"string"}),Ue({handle:"documentId",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleDocsNode.prototype,"documentId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.title.label",type:"string"}),Ue({handle:"title",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleDocsNode.prototype,"title",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.text.label",type:"textarea"}),Ue({handle:"text",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleDocsNode.prototype,"text",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.findText.label",type:"string"}),Ue({handle:"findText",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleDocsNode.prototype,"findText",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.replaceText.label",type:"string"}),Ue({handle:"replaceText",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleDocsNode.prototype,"replaceText",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.matchCase.label",type:"boolean"}),Ue({handle:"matchCase",userControlled:!0}),i.__metadata("design:type",Boolean)],e.GoogleDocsNode.prototype,"matchCase",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.requests.label",type:"textarea"}),Ue({handle:"requests",userControlled:!0}),i.__metadata("design:type",Object)],e.GoogleDocsNode.prototype,"requests",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleDocsNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.GoogleDocsNode.prototype,"result",void 0),i.__decorate([Be({handle:"documentId",type:"string"}),i.__metadata("design:type",String)],e.GoogleDocsNode.prototype,"resultDocumentId",void 0),e.GoogleDocsNode=i.__decorate([qe("core.io.googleDocs",{kind:"core.io.googleDocs",category:"IO",color:"#4285f4",icon:"ti-brand-google",width:96,height:96,labels:["io","google","docs","document"],metadata:{title:"graph.node.io.google_docs.name",description:"graph.node.io.google_docs.description"}}),r.model()],e.GoogleDocsNode);const _i=["listSites","getSite","listLists","listItems","createListItem","listDriveItems"];e.MicrosoftSharePointNode=class extends Er{constructor(){super(...arguments),this.operation="listSites"}async execute(e,t){if(!this.operation)throw new Ao("Microsoft SharePoint node requires an operation","GRAPH_SHAREPOINT_OPERATION_REQUIRED");const o=_i.includes(this.operation)?this.operation:"listSites",a=await Xo(t,e.credentials,"microsoft-sharepoint",!1,"Microsoft SharePoint"),r=new H.MicrosoftSharePointService;try{switch(await v.bootWithoutEnvironment(r,{token:Fn(a,"Microsoft SharePoint"),baseUrl:this.baseUrl}),o){case"listSites":return{result:await r.listSites(this.search??"*")};case"getSite":if(!this.siteId)throw new Ao("Microsoft SharePoint getSite requires a siteId","GRAPH_SHAREPOINT_SITE_REQUIRED");return{result:await r.getSite(this.siteId)};case"listLists":if(!this.siteId)throw new Ao("Microsoft SharePoint listLists requires a siteId","GRAPH_SHAREPOINT_SITE_REQUIRED");return{result:await r.listLists(this.siteId)};case"listItems":if(!this.siteId||!this.listId)throw new Ao("Microsoft SharePoint listItems requires siteId and listId","GRAPH_SHAREPOINT_LIST_REQUIRED");return{result:await r.listItems({siteId:this.siteId,listId:this.listId,top:kn(this.top),filter:this.filter})};case"createListItem":{if(!this.siteId||!this.listId||!this.fields)throw new Ao("Microsoft SharePoint createListItem requires siteId, listId, and fields","GRAPH_SHAREPOINT_ITEM_REQUIRED");const e=(e=>{if(null==e||""===e)return;if("string"==typeof e){try{const t=Tn(JSON.parse(e));if(t)return t}catch{}throw new Ao("Microsoft SharePoint fields must be a JSON object","GRAPH_SHAREPOINT_FIELDS_INVALID")}const t=Tn(e);if(t)return t;throw new Ao("Microsoft SharePoint fields must be a JSON object","GRAPH_SHAREPOINT_FIELDS_INVALID")})(this.fields);if(!e)throw new Ao("Microsoft SharePoint createListItem requires fields","GRAPH_SHAREPOINT_ITEM_REQUIRED");return{result:await r.createListItem({siteId:this.siteId,listId:this.listId,fields:e})}}default:if(!this.siteId)throw new Ao("Microsoft SharePoint listDriveItems requires a siteId","GRAPH_SHAREPOINT_SITE_REQUIRED");return{result:await r.listDriveItems({siteId:this.siteId,itemId:this.itemId,top:kn(this.top)})}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Microsoft SharePoint node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SHAREPOINT_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftSharePointNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.siteId.label",type:"string"}),Ue({handle:"siteId",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftSharePointNode.prototype,"siteId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.listId.label",type:"string"}),Ue({handle:"listId",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftSharePointNode.prototype,"listId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.itemId.label",type:"string"}),Ue({handle:"itemId",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftSharePointNode.prototype,"itemId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.search.label",type:"string"}),Ue({handle:"search",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftSharePointNode.prototype,"search",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.top.label",type:"number"}),Ue({handle:"top",userControlled:!0}),i.__metadata("design:type",Number)],e.MicrosoftSharePointNode.prototype,"top",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.filter.label",type:"string"}),Ue({handle:"filter",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftSharePointNode.prototype,"filter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.fields.label",type:"textarea"}),Ue({handle:"fields",userControlled:!0}),i.__metadata("design:type",Object)],e.MicrosoftSharePointNode.prototype,"fields",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.MicrosoftSharePointNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.MicrosoftSharePointNode.prototype,"result",void 0),e.MicrosoftSharePointNode=i.__decorate([qe("core.io.microsoftSharePoint",{kind:"core.io.microsoftSharePoint",category:"IO",color:"#036c70",icon:"ti-brand-office",width:96,height:96,labels:["io","microsoft","sharepoint","files","lists"],metadata:{title:"graph.node.io.microsoft_sharepoint.name",description:"graph.node.io.microsoft_sharepoint.description"}}),r.model()],e.MicrosoftSharePointNode);const yi=["listCalendars","listEvents","createEvent","getEvent","updateEvent","deleteEvent"];function bi(e){if(null!=e&&""!==e){if(Array.isArray(e))return e.map(e=>(e+"").trim()).filter(e=>e.length>0);if("string"==typeof e){if(e.trim().startsWith("["))try{const t=JSON.parse(e);return Array.isArray(t)?t.map(e=>(e+"").trim()):void 0}catch{throw new Ao("Google Calendar attendees must be a JSON array or a comma-separated list","GRAPH_GOOGLE_CALENDAR_ATTENDEES_INVALID")}return e.split(/[,;]/).map(e=>e.trim()).filter(e=>e.length>0)}}}e.GoogleCalendarNode=class extends Er{constructor(){super(...arguments),this.operation="listEvents"}async execute(e,t){if(!this.operation)throw new Ao("Google Calendar node requires an operation","GRAPH_GOOGLE_CALENDAR_OPERATION_REQUIRED");const o=yi.includes(this.operation)?this.operation:"listEvents",a=await Xo(t,e.credentials,"google-calendar",!1,"Google Calendar"),r=new U.GoogleCalendarService;try{switch(await v.bootWithoutEnvironment(r,{token:Mn(a,"token","Google Calendar"),apiKey:Mn(a,"apiKey","Google Calendar"),calendarId:Mn(a,"calendarId","Google Calendar"),baseUrl:this.baseUrl}),o){case"listCalendars":return{result:await r.listCalendars()};case"listEvents":return{result:await r.listEvents({calendarId:this.calendarId,timeMin:this.timeMin,timeMax:this.timeMax,maxResults:kn(this.maxResults),q:this.q,singleEvents:this.singleEvents})};case"createEvent":{if(!this.summary||!this.start||!this.end)throw new Ao("Google Calendar createEvent requires summary, start, and end","GRAPH_GOOGLE_CALENDAR_EVENT_REQUIRED");const e=await r.createEvent({calendarId:this.calendarId,summary:this.summary,description:this.description,location:this.location,start:this.start,end:this.end,timeZone:this.timeZone,attendees:bi(this.attendees)}),t=Tn(e);return{result:e,..."string"==typeof t?.id?{eventId:t.id}:{}}}case"getEvent":if(!this.eventId)throw new Ao("Google Calendar getEvent requires an eventId","GRAPH_GOOGLE_CALENDAR_EVENT_REQUIRED");return{result:await r.getEvent(this.calendarId??"primary",this.eventId),eventId:this.eventId};case"updateEvent":if(!this.eventId)throw new Ao("Google Calendar updateEvent requires an eventId","GRAPH_GOOGLE_CALENDAR_EVENT_REQUIRED");return{result:await r.updateEvent(this.eventId,{calendarId:this.calendarId,summary:this.summary,description:this.description,location:this.location,start:this.start,end:this.end,timeZone:this.timeZone,attendees:bi(this.attendees)}),eventId:this.eventId};default:if(!this.eventId)throw new Ao("Google Calendar deleteEvent requires an eventId","GRAPH_GOOGLE_CALENDAR_EVENT_REQUIRED");return{result:await r.deleteEvent(this.calendarId??"primary",this.eventId),eventId:this.eventId}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Google Calendar node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GOOGLE_CALENDAR_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.calendarId.label",type:"string"}),Ue({handle:"calendarId",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"calendarId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.eventId.label",type:"string"}),Ue({handle:"eventId",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"eventId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.summary.label",type:"string"}),Ue({handle:"summary",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"summary",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.description.label",type:"textarea"}),Ue({handle:"description",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"description",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.location.label",type:"string"}),Ue({handle:"location",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"location",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.start.label",type:"string"}),Ue({handle:"start",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"start",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.end.label",type:"string"}),Ue({handle:"end",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"end",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.timeZone.label",type:"string"}),Ue({handle:"timeZone",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"timeZone",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.attendees.label",type:"textarea"}),Ue({handle:"attendees",userControlled:!0}),i.__metadata("design:type",Object)],e.GoogleCalendarNode.prototype,"attendees",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.timeMin.label",type:"string"}),Ue({handle:"timeMin",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"timeMin",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.timeMax.label",type:"string"}),Ue({handle:"timeMax",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"timeMax",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.maxResults.label",type:"number"}),Ue({handle:"maxResults",userControlled:!0}),i.__metadata("design:type",Number)],e.GoogleCalendarNode.prototype,"maxResults",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.q.label",type:"string"}),Ue({handle:"q",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"q",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.singleEvents.label",type:"boolean"}),Ue({handle:"singleEvents",userControlled:!0}),i.__metadata("design:type",Boolean)],e.GoogleCalendarNode.prototype,"singleEvents",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.GoogleCalendarNode.prototype,"result",void 0),i.__decorate([Be({handle:"eventId",type:"string"}),i.__metadata("design:type",String)],e.GoogleCalendarNode.prototype,"resultEventId",void 0),e.GoogleCalendarNode=i.__decorate([qe("core.io.googleCalendar",{kind:"core.io.googleCalendar",category:"IO",color:"#4285f4",icon:"ti-calendar-event",width:96,height:96,labels:["io","google","calendar","events","scheduling"],metadata:{title:"graph.node.io.google_calendar.name",description:"graph.node.io.google_calendar.description"}}),r.model()],e.GoogleCalendarNode);const wi=new Set(["workdocs"]);function Ni(){return["/etc","/proc","/root",g.resolve(h.homedir(),".ssh")]}function vi(){const e=process.env.GRAPH_FILE_IO_BASE?.trim(),t=g.resolve(e&&e.length>0?e:process.cwd());try{return m.realpathSync(t)}catch{return t}}function Ai(e,t){const o=g.relative(e,t);return""===o||!o.startsWith("..")&&!g.isAbsolute(o)}function xi(e,t,o){if(!Ai(e,t))throw new Ao(`File node path '${o}' resolves outside the configured file IO base`,"GRAPH_FILE_PATH_FORBIDDEN",{path:o,base:e});for(const e of Ni())if(Ai(e,t))throw new Ao(`File node path '${o}' targets a forbidden directory`,"GRAPH_FILE_PATH_FORBIDDEN",{path:o});const a=g.relative(e,t).split(g.sep).filter(Boolean);for(const e of a)if(wi.has(e.toLowerCase()))throw new Ao(`File node path '${o}' targets a forbidden directory`,"GRAPH_FILE_PATH_FORBIDDEN",{path:o,segment:e})}function Ii(e){if(e.includes("\0"))throw new Ao("File node path contains a NUL byte","GRAPH_FILE_INVALID_PATH",{path:e});const t=vi();(e=>{if(!g.isAbsolute(e))return;const t=g.resolve(e);for(const o of Ni())if(Ai(o,t))throw new Ao(`File node path '${e}' targets a forbidden directory`,"GRAPH_FILE_PATH_FORBIDDEN",{path:e})})(e);const o=e.replace(/^[/\\]+/,""),a=g.resolve(t,o);return xi(t,a,e),{base:t,candidate:a}}async function Ei(e){let t=e;for(;;)try{return await f.realpath(t)}catch{const e=g.dirname(t);if(e===t)return;t=e}}const Si={".csv":"text/csv",".gif":"image/gif",".htm":"text/html",".html":"text/html",".ics":"text/calendar",".jpeg":"image/jpeg",".jpg":"image/jpeg",".json":"application/json",".md":"text/markdown",".ods":"application/vnd.oasis.opendocument.spreadsheet",".pdf":"application/pdf",".png":"image/png",".rtf":"application/rtf",".svg":"image/svg+xml",".txt":"text/plain",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".xml":"application/xml",".zip":"application/zip"};function Ri(e){return Si[g.extname(e).toLowerCase()]??"application/octet-stream"}function Ti(e,t,o,a){const r={fileName:t,mimeType:a||Ri(t),byteLength:e.byteLength,data:e.toString("base64")};return void 0!==o&&(r.path=o),r}function Ci(e,t="utf8",o="data"){if("string"==typeof e){if(e.startsWith("data:")){const t=e.indexOf(",");if(t>=0)return Buffer.from(e.slice(t+1),"base64")}return"base64"===t?Buffer.from(e,"base64"):Buffer.from(e,"utf8")}if(Vr(e))return Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e);if(Pr(e)){const a="auto"===t?"number"==typeof e.byteLength||"string"==typeof e.mimeType?"base64":"utf8":t;for(const t of[o,"data","content","value"])if(t&&void 0!==e[t]&&e[t]!==e)return Ci(e[t],a,o)}throw new Ao("File node requires a binary payload","GRAPH_BINARY_INPUT_REQUIRED",{valueType:typeof e})}async function Oi(e){const{base:t,candidate:o}=Ii(e);let a;try{a=await f.realpath(o)}catch{throw new Ao(`File node path '${e}' does not exist`,"GRAPH_FILE_INVALID_PATH",{path:e})}xi(t,a,e);const r=await f.readFile(a);return{payload:Ti(r,g.basename(o),e,Ri(o)),bytes:r.byteLength}}function ki(e,t,o){const a=e;let r;switch(t.returnValue??"text"){case"attribute":r=t.attribute?a.attr(t.attribute):void 0;break;case"html":r=a.html()??void 0;break;case"value":{const e=a.val();r=void 0===e?void 0:Array.isArray(e)?e.join(","):e;break}default:r=((e,t)=>{const o=e;if(!t.skipSelectors)return o.text()||void 0;const a=t.skipSelectors.split(",").map(e=>e.trim()).filter(e=>e.length>0).map(e=>({selector:e,format:"skip"}));return $.convert(o.html()??"",{selectors:a})||void 0})(e,t)}if(void 0!==r)return((e,t)=>{if(void 0===e)return e;let o=e;return!1!==t.trimValues&&(o=o.trim()),t.cleanUpText&&(o=o.replace(/^\s+|\s+$/g,"").replace(/(\r\n|\n|\r)/gm,"").replace(/\s+/g," ")),o})(r,o)}function Di(e,t,o={}){const a=se.load(e),r={};for(const e of t){if(!e||"string"!=typeof e.cssSelector)continue;const t=e.key||e.cssSelector,n=a(e.cssSelector);if(e.returnArray){const i=[];n.each((t,r)=>{i.push(ki(a(r),e,o))}),r[t]=i}else r[t]=ki(n,e,o)}return r}function Pi(e){if("string"==typeof e)return[e];if(Array.isArray(e))return e.flatMap(e=>Pi(e));if(Buffer.isBuffer(e)||e instanceof Uint8Array)return[Buffer.from(e).toString("utf8")];if(e instanceof ArrayBuffer)return[Buffer.from(new Uint8Array(e)).toString("utf8")];if(Pr(e))for(const t of["data","content","html","value"])if(void 0!==e[t]&&e[t]!==e)return Pi(e[t]);return[]}function Gi(e,t){return e.replace(/\{\{\s*([^}]+?)\s*\}\}/g,(e,o)=>{const a=(o+"").replace(/^\$json\.?/,"").trim(),r=Lr(t,a,!0);return null==r?"":"object"==typeof r?JSON.stringify(r):r+""})}function Mi(e,t={}){const o=e.map(e=>Pr(e)?e:{value:e}),a=Array.from(new Set(o.flatMap(e=>Object.keys(e)))),r=t.customStyling?"":"style='border-spacing:0; font-family:helvetica,arial,sans-serif'",n=t.customStyling?"":"style='margin:0; padding:7px 20px 7px 0px; border-bottom:1px solid #eee; text-align:left; color:#888; font-weight:normal'",i=t.customStyling?"":"style='margin:0; padding:7px 20px 7px 0px; border-bottom:1px solid #eee'";let d=`<table ${r} ${t.tableAttributes??""}>`;t.caption&&(d+=`<caption>${t.caption}</caption>`),d+=`<thead ${n} ${t.headerAttributes??""}>`,d+="<tr>",d+=a.map(e=>`<th>${((e,t)=>t?e.split("_").filter(e=>e).map(e=>e[0].toUpperCase()+e.slice(1)).join(" "):e)(e,t.capitalize)}</th>`).join(""),d+="</tr></thead><tbody>";for(const e of o)d+=`<tr ${t.rowAttributes??""}>`,d+=a.map(o=>{const a=e[o];let r=`<td ${i} ${t.cellAttributes??""}>`;return r+="boolean"==typeof a?`<input type="checkbox" ${a?'checked="checked"':""}/>`:null==a?"":a+"",r+="</td>",r}).join(""),d+="</tr>";return d+="</tbody></table>",d}const Fi=["csv","html","toJson","toText","toBinary"];function Li(e,t){if(null==e)return"";const o="object"==typeof e?JSON.stringify(e):e+"";return o.includes('"')||o.includes("\n")||o.includes("\r")||o.includes(t)?`"${o.replace(/"/g,'""')}"`:o}function ji(e,t){return Buffer.from(`${t?"\ufeff":""}${e}`,"utf8")}e.ConvertToFileNode=class extends Er{constructor(){super(...arguments),this.operation="csv",this.binaryPropertyName="data",this.mode="once",this.delimiter=",",this.headerRow=!0,this.addBOM=!1,this.format=!1,this.dataIsBase64=!0,this.customStyling=!1,this.capitalize=!1}execute(e){if(!Fi.includes(this.operation))throw new Ao(`Convert to File operation '${this.operation}' is not supported`,"GRAPH_CONVERT_TO_FILE_UNSUPPORTED_OPERATION",{operation:this.operation});const t=Gr(e.inputs.value).map(e=>Pr(e)?e:{value:e});switch(this.operation){case"csv":{const e=((e,t,o)=>{const a=Array.from(new Set(e.flatMap(e=>Object.keys(e)))),r=[];o&&r.push(a.map(e=>Li(e,t)).join(t));for(const o of e)r.push(a.map(e=>Li(o[e],t)).join(t));return r.join("\n")})(t,this.delimiter||",",!1!==this.headerRow),o=Ti(ji(e,this.addBOM),this.fileName||"file.csv",void 0,"text/csv");return{result:o,content:e,bytes:o.byteLength}}case"html":{const e=`<!DOCTYPE html><html><body>${Mi(t,{caption:this.caption,customStyling:!0===this.customStyling,capitalize:!0===this.capitalize})}</body></html>`,o=Ti(ji(e,this.addBOM),this.fileName||"file.html",void 0,"text/html");return{result:o,content:e,bytes:o.byteLength}}case"toText":{const e=this.textPayloads(t);return this.returnPayloads(e)}case"toBinary":{const e=this.binaryPayloads(t);return this.returnPayloads(e)}default:{if("each"===this.mode){const e=t.map(e=>Ti(ji(JSON.stringify(e,null,this.format?2:0),this.addBOM),this.fileName||"file.json",void 0,"application/json"));return this.returnPayloads(e)}const e=JSON.stringify(t,null,this.format?2:0),o=Ti(ji(e,this.addBOM),this.fileName||"file.json",void 0,"application/json");return{result:o,content:e,bytes:o.byteLength}}}}textPayloads(e){return e.map(e=>{const t=this.sourceProperty?Lr(e,this.sourceProperty,!0):e.value??e;if(null==t)throw new Ao(`Convert to File node could not find '${this.sourceProperty}' in the input`,"GRAPH_CONVERT_TO_FILE_SOURCE_REQUIRED",{sourceProperty:this.sourceProperty});return Ti(ji("string"==typeof t?t:t+"",this.addBOM),this.fileName||"file.txt",void 0,"text/plain")})}binaryPayloads(e){return e.map(e=>{const t=this.sourceProperty?Lr(e,this.sourceProperty,!0):e.data??e.value;if("string"!=typeof t)throw new Ao(`Convert to File node requires a base64 string in '${this.sourceProperty??"data"}'`,"GRAPH_CONVERT_TO_FILE_SOURCE_REQUIRED",{sourceProperty:this.sourceProperty});const o=t.startsWith("data:")?t.slice(t.indexOf(",")+1):t;return!1===this.dataIsBase64?Ti(Buffer.from(o,"utf8"),this.fileName||"file.bin",void 0,this.mimeType||"application/octet-stream"):Ti(Buffer.from(o,"base64"),this.fileName||"file.bin",void 0,this.mimeType||"application/octet-stream")})}returnPayloads(e){return 1===e.length?{result:e[0],bytes:e[0].byteLength}:{result:e,bytes:e.reduce((e,t)=>e+t.byteLength,0)}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.ConvertToFileNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.binaryPropertyName.label",type:"text"}),Ue({handle:"binaryPropertyName",userControlled:!0}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"binaryPropertyName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.sourceProperty.label",placeholder:"graph.node.io.convert_to_file.fields.sourceProperty.placeholder",type:"text"}),Ue({handle:"sourceProperty",userControlled:!0}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"sourceProperty",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.mode.label",type:"select"}),Ue({handle:"mode",userControlled:!0}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"mode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.fileName.label",placeholder:"graph.node.io.convert_to_file.fields.fileName.placeholder",type:"text"}),Ue({handle:"fileName",userControlled:!0}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"fileName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.mimeType.label",type:"text"}),Ue({handle:"mimeType",userControlled:!0}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"mimeType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.delimiter.label",type:"text"}),Ue({handle:"delimiter",userControlled:!0}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"delimiter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.headerRow.label",type:"checkbox"}),Ue({handle:"headerRow",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ConvertToFileNode.prototype,"headerRow",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.sheetName.label",type:"text"}),Ue({handle:"sheetName",userControlled:!0}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"sheetName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.addBOM.label",type:"checkbox"}),Ue({handle:"addBOM",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ConvertToFileNode.prototype,"addBOM",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.format.label",type:"checkbox"}),Ue({handle:"format",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ConvertToFileNode.prototype,"format",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.dataIsBase64.label",type:"checkbox"}),Ue({handle:"dataIsBase64",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ConvertToFileNode.prototype,"dataIsBase64",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.caption.label",type:"text"}),Ue({handle:"caption",userControlled:!0}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"caption",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.customStyling.label",type:"checkbox"}),Ue({handle:"customStyling",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ConvertToFileNode.prototype,"customStyling",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.capitalize.label",type:"checkbox"}),Ue({handle:"capitalize",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ConvertToFileNode.prototype,"capitalize",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.ConvertToFileNode.prototype,"result",void 0),i.__decorate([Be({handle:"content"}),i.__metadata("design:type",String)],e.ConvertToFileNode.prototype,"content",void 0),i.__decorate([Be({handle:"bytes"}),i.__metadata("design:type",Number)],e.ConvertToFileNode.prototype,"bytes",void 0),e.ConvertToFileNode=i.__decorate([qe("core.io.convertToFile",{kind:"core.io.convertToFile",category:"IO",color:"#0ea5e9",icon:"ti-file-arrow-right",width:96,height:96,labels:["io","file","convert","binary","csv","json"],metadata:{title:"graph.node.io.convert_to_file.name",description:"graph.node.io.convert_to_file.description"}}),r.model()],e.ConvertToFileNode),e.HtmlNode=class extends Er{constructor(){super(...arguments),this.operation="generateHtmlTemplate",this.sourceData="json",this.dataPropertyName="data",this.extractionValues=[],this.trimValues=!0,this.cleanUpText=!1,this.customStyling=!1,this.capitalize=!1}execute(e){const t=e.inputs.value;switch(this.operation){case"extractHtmlContent":{const e=this.dataPropertyName||"data";let o;if(o="binary"===this.sourceData?[Ci(t,"base64",e).toString("utf8")]:Pr(t)?Pi(Lr(t,e,!0)??t):Pi(t),0===o.length)throw new Ao("HTML node requires HTML content to extract","GRAPH_HTML_INVALID_INPUT");const a=(this.extractionValues??[]).filter(e=>e&&"string"==typeof e.cssSelector);if(0===a.length)throw new Ao("HTML node requires at least one extraction value","GRAPH_HTML_EXTRACT_VALUES_REQUIRED");return{result:o.map(e=>Di(e,a,{trimValues:!1!==this.trimValues,cleanUpText:!0===this.cleanUpText}))}}case"convertToHtmlTable":{const e=Mi(Gr(t),{caption:this.caption,tableAttributes:this.tableAttributes,headerAttributes:this.headerAttributes,rowAttributes:this.rowAttributes,cellAttributes:this.cellAttributes,customStyling:!0===this.customStyling,capitalize:!0===this.capitalize});return{result:e,table:e}}default:if(!this.html)throw new Ao("HTML node requires a template to render","GRAPH_HTML_TEMPLATE_REQUIRED");return Array.isArray(t)?{result:t.filter(e=>null!=e).map(e=>Gi(this.html,e))}:{result:Gi(this.html,t)}}}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.HtmlNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.html.label",type:"textarea"}),Ue({handle:"html",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"html",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.sourceData.label",type:"select"}),Ue({handle:"sourceData",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"sourceData",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.dataPropertyName.label",placeholder:"graph.node.io.html.fields.dataPropertyName.placeholder",type:"text"}),Ue({handle:"dataPropertyName",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"dataPropertyName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.extractionValues.label",placeholder:"graph.node.io.html.fields.extractionValues.placeholder",type:"collection"}),Ue({handle:"extractionValues",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.HtmlNode.prototype,"extractionValues",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.trimValues.label",type:"checkbox"}),Ue({handle:"trimValues",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HtmlNode.prototype,"trimValues",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.cleanUpText.label",type:"checkbox"}),Ue({handle:"cleanUpText",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HtmlNode.prototype,"cleanUpText",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.caption.label",type:"text"}),Ue({handle:"caption",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"caption",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.tableAttributes.label",type:"text"}),Ue({handle:"tableAttributes",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"tableAttributes",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.headerAttributes.label",type:"text"}),Ue({handle:"headerAttributes",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"headerAttributes",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.rowAttributes.label",type:"text"}),Ue({handle:"rowAttributes",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"rowAttributes",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.cellAttributes.label",type:"text"}),Ue({handle:"cellAttributes",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"cellAttributes",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.customStyling.label",type:"checkbox"}),Ue({handle:"customStyling",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HtmlNode.prototype,"customStyling",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.capitalize.label",type:"checkbox"}),Ue({handle:"capitalize",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HtmlNode.prototype,"capitalize",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.HtmlNode.prototype,"result",void 0),i.__decorate([Be({handle:"table"}),i.__metadata("design:type",String)],e.HtmlNode.prototype,"table",void 0),e.HtmlNode=i.__decorate([qe("core.io.html",{kind:"core.io.html",category:"IO",color:"#0ea5e9",icon:"ti-brand-html5",width:96,height:96,labels:["io","html","template","table"],metadata:{title:"graph.node.io.html.name",description:"graph.node.io.html.description"}}),r.model()],e.HtmlNode),e.HtmlExtractNode=class extends Er{constructor(){super(...arguments),this.sourceData="json",this.dataPropertyName="data",this.extractionValues=[],this.trimValues=!0,this.cleanUpText=!1}execute(e){const t=e.inputs.value,o=this.dataPropertyName||"data";let a;if(a="binary"===this.sourceData?[Ci(t,"base64",o).toString("utf8")]:Pr(t)?Pi(Lr(t,o,!0)??t):Pi(t),0===a.length)throw new Ao("HTML Extract node requires HTML content","GRAPH_HTML_EXTRACT_INVALID_INPUT");const r=(this.extractionValues??[]).filter(e=>e&&"string"==typeof e.cssSelector);if(0===r.length)throw new Ao("HTML Extract node requires at least one extraction value","GRAPH_HTML_EXTRACT_VALUES_REQUIRED");return{result:a.map(e=>Di(e,r,{trimValues:!1!==this.trimValues,cleanUpText:!0===this.cleanUpText}))}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.HtmlExtractNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.sourceData.label",type:"select"}),Ue({handle:"sourceData",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlExtractNode.prototype,"sourceData",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.dataPropertyName.label",placeholder:"graph.node.io.html_extract.fields.dataPropertyName.placeholder",type:"text"}),Ue({handle:"dataPropertyName",userControlled:!0}),i.__metadata("design:type",String)],e.HtmlExtractNode.prototype,"dataPropertyName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.extractionValues.label",placeholder:"graph.node.io.html_extract.fields.extractionValues.placeholder",type:"collection"}),Ue({handle:"extractionValues",userControlled:!0,type:"array"}),i.__metadata("design:type",Array)],e.HtmlExtractNode.prototype,"extractionValues",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.trimValues.label",type:"checkbox"}),Ue({handle:"trimValues",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HtmlExtractNode.prototype,"trimValues",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.cleanUpText.label",type:"checkbox"}),Ue({handle:"cleanUpText",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HtmlExtractNode.prototype,"cleanUpText",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Array)],e.HtmlExtractNode.prototype,"result",void 0),e.HtmlExtractNode=i.__decorate([qe("core.io.htmlExtract",{kind:"core.io.htmlExtract",category:"IO",color:"#0ea5e9",icon:"ti-cut",width:96,height:96,labels:["io","html","extract","css"],metadata:{title:"graph.node.io.html_extract.name",description:"graph.node.io.html_extract.description"}}),r.model()],e.HtmlExtractNode),e.MarkdownNode=class extends Er{constructor(){super(...arguments),this.mode="htmlToMarkdown"}execute(e){const t=e.inputs.value,o="markdownToHtml"===this.mode?this.markdown??t:this.html??t;if("string"!=typeof o||0===o.length)throw new Ao(`Markdown node requires ${"markdownToHtml"===this.mode?"markdown":"HTML"} content`,"GRAPH_MARKDOWN_CONTENT_REQUIRED");let a;try{a="markdownToHtml"===this.mode?W.marked.parse(o):this.turndown().turndown(o)}catch(e){throw new Ao("Markdown node conversion failed: "+(e instanceof Error?e.message:e+""),"GRAPH_MARKDOWN_CONVERSION_FAILED")}if(!this.destinationKey)return{result:a,content:a};const r={};return jr(r,this.destinationKey,a,!0),{result:r,content:a}}turndown(){const e=new V({headingStyle:this.headingStyle??"atx",hr:this.hr??"---",bulletListMarker:this.bulletMarker??"*",codeBlockStyle:"fenced",fence:this.codeBlockFence??"```",emDelimiter:this.emDelimiter??"_",strongDelimiter:this.strongDelimiter??"**",linkStyle:this.linkStyle??"inlined"});for(const t of Jr(this.ignore,"Ignored Elements"))e.remove(t);return e}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.MarkdownNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.mode.label",type:"select"}),Ue({handle:"mode",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"mode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.markdown.label",type:"textarea"}),Ue({handle:"markdown",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"markdown",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.html.label",type:"textarea"}),Ue({handle:"html",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"html",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.destinationKey.label",placeholder:"graph.node.io.markdown.fields.destinationKey.placeholder",type:"text"}),Ue({handle:"destinationKey",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"destinationKey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.headingStyle.label",type:"select"}),Ue({handle:"headingStyle",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"headingStyle",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.hr.label",type:"text"}),Ue({handle:"hr",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"hr",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.bulletMarker.label",type:"text"}),Ue({handle:"bulletMarker",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"bulletMarker",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.codeBlockFence.label",type:"text"}),Ue({handle:"codeBlockFence",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"codeBlockFence",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.emDelimiter.label",type:"text"}),Ue({handle:"emDelimiter",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"emDelimiter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.strongDelimiter.label",type:"text"}),Ue({handle:"strongDelimiter",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"strongDelimiter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.linkStyle.label",type:"select"}),Ue({handle:"linkStyle",userControlled:!0}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"linkStyle",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.ignore.label",placeholder:"graph.node.io.markdown.fields.ignore.placeholder",type:"text"}),Ue({handle:"ignore",userControlled:!0}),i.__metadata("design:type",Object)],e.MarkdownNode.prototype,"ignore",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.MarkdownNode.prototype,"result",void 0),i.__decorate([Be({handle:"content"}),i.__metadata("design:type",String)],e.MarkdownNode.prototype,"content",void 0),e.MarkdownNode=i.__decorate([qe("core.io.markdown",{kind:"core.io.markdown",category:"IO",color:"#0ea5e9",icon:"ti-markdown",width:96,height:96,labels:["io","markdown","html","convert"],metadata:{title:"graph.node.io.markdown.name",description:"graph.node.io.markdown.description"}}),r.model()],e.MarkdownNode);const qi=10485760,Hi=/<!ENTITY/i;e.XmlNode=class extends Er{constructor(){super(...arguments),this.mode="xmlToJson",this.dataPropertyName="data",this.attrkey="$",this.charkey="_",this.explicitArray=!1,this.explicitRoot=!0,this.ignoreAttrs=!1,this.mergeAttrs=!0,this.normalize=!1,this.normalizeTags=!1,this.trim=!1,this.cdata=!1,this.headless=!1,this.rootName="root",this.allowSurrogateChars=!1}async execute(e){const t=e.inputs.value;if("xmlToJson"===this.mode){const e=this.xmlTextOf(t),o=Buffer.byteLength(e,"utf8");if(o>qi)throw new Ao(`XML input of ${o} bytes exceeds the 10485760-byte limit`,"GRAPH_XML_INPUT_TOO_LARGE",{byteLength:o,maxBytes:qi});if(Hi.test(e))throw new Ao("XML input entity declarations are not allowed","GRAPH_XML_ENTITY_FORBIDDEN");const a=new K.Parser({attrkey:this.attrkey||"$",charkey:this.charkey||"_",explicitArray:!0===this.explicitArray,explicitRoot:!1!==this.explicitRoot,ignoreAttrs:!0===this.ignoreAttrs,mergeAttrs:!1!==this.mergeAttrs,normalize:!0===this.normalize,normalizeTags:!0===this.normalizeTags,trim:!0===this.trim});try{const t=await a.parseStringPromise(e);return{result:this.wrap(t)}}catch(e){throw new Ao("XML node could not parse XML: "+(e instanceof Error?e.message:e+""),"GRAPH_XML_PARSE_FAILED")}}const o=t;if(null==o)throw new Ao("XML node requires JSON data to convert","GRAPH_XML_INVALID_INPUT");const a=new K.Builder({attrkey:this.attrkey||"$",charkey:this.charkey||"_",headless:!0===this.headless,rootName:this.rootName||"root",cdata:!0===this.cdata,allowSurrogateChars:!0===this.allowSurrogateChars});try{return{result:this.wrap(a.buildObject(o))}}catch(e){throw new Ao("XML node could not build XML: "+(e instanceof Error?e.message:e+""),"GRAPH_XML_BUILD_FAILED")}}wrap(e){if(!this.destinationField)return e;const t={};return jr(t,this.destinationField,e,!0),t}xmlTextOf(e){if("string"==typeof e)return e;if(Pr(e)){const t=this.dataPropertyName?Lr(e,this.dataPropertyName,!0):void 0;if("string"==typeof t)return t}try{return Ci(e,"utf8",this.dataPropertyName||"data").toString("utf8")}catch{throw new Ao("XML node requires XML text to parse","GRAPH_XML_INVALID_INPUT")}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.XmlNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.mode.label",type:"select"}),Ue({handle:"mode",userControlled:!0}),i.__metadata("design:type",String)],e.XmlNode.prototype,"mode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.dataPropertyName.label",placeholder:"graph.node.io.xml.fields.dataPropertyName.placeholder",type:"text"}),Ue({handle:"dataPropertyName",userControlled:!0}),i.__metadata("design:type",String)],e.XmlNode.prototype,"dataPropertyName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.destinationField.label",placeholder:"graph.node.io.xml.fields.destinationField.placeholder",type:"text"}),Ue({handle:"destinationField",userControlled:!0}),i.__metadata("design:type",String)],e.XmlNode.prototype,"destinationField",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.attrkey.label",type:"text"}),Ue({handle:"attrkey",userControlled:!0}),i.__metadata("design:type",String)],e.XmlNode.prototype,"attrkey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.charkey.label",type:"text"}),Ue({handle:"charkey",userControlled:!0}),i.__metadata("design:type",String)],e.XmlNode.prototype,"charkey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.explicitArray.label",type:"checkbox"}),Ue({handle:"explicitArray",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"explicitArray",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.explicitRoot.label",type:"checkbox"}),Ue({handle:"explicitRoot",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"explicitRoot",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.ignoreAttrs.label",type:"checkbox"}),Ue({handle:"ignoreAttrs",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"ignoreAttrs",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.mergeAttrs.label",type:"checkbox"}),Ue({handle:"mergeAttrs",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"mergeAttrs",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.normalize.label",type:"checkbox"}),Ue({handle:"normalize",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"normalize",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.normalizeTags.label",type:"checkbox"}),Ue({handle:"normalizeTags",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"normalizeTags",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.trim.label",type:"checkbox"}),Ue({handle:"trim",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"trim",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.cdata.label",type:"checkbox"}),Ue({handle:"cdata",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"cdata",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.headless.label",type:"checkbox"}),Ue({handle:"headless",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"headless",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.rootName.label",type:"text"}),Ue({handle:"rootName",userControlled:!0}),i.__metadata("design:type",String)],e.XmlNode.prototype,"rootName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.allowSurrogateChars.label",type:"checkbox"}),Ue({handle:"allowSurrogateChars",userControlled:!0}),i.__metadata("design:type",Boolean)],e.XmlNode.prototype,"allowSurrogateChars",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.XmlNode.prototype,"result",void 0),e.XmlNode=i.__decorate([qe("core.io.xml",{kind:"core.io.xml",category:"IO",color:"#0ea5e9",icon:"ti-code",width:96,height:96,labels:["io","xml","json","convert"],metadata:{title:"graph.node.io.xml.name",description:"graph.node.io.xml.description"}}),r.model()],e.XmlNode),e.ReadBinaryFileNode=class extends Er{async execute(){const e=this.filePath||this.path;if(!e)throw new Ao("Read Binary File node requires a file path","GRAPH_READ_BINARY_FILE_PATH_REQUIRED");const{payload:t,bytes:o}=await Oi(e);return{result:t,fileName:t.fileName,mimeType:t.mimeType,bytes:o}}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.ReadBinaryFileNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_binary_file.fields.filePath.label",placeholder:"graph.node.io.read_binary_file.fields.filePath.placeholder",type:"text"}),Ue({handle:"filePath",userControlled:!0}),i.__metadata("design:type",String)],e.ReadBinaryFileNode.prototype,"filePath",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_binary_file.fields.path.label",placeholder:"graph.node.io.read_binary_file.fields.path.placeholder",type:"text"}),Ue({handle:"path",userControlled:!0}),i.__metadata("design:type",String)],e.ReadBinaryFileNode.prototype,"path",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.ReadBinaryFileNode.prototype,"result",void 0),i.__decorate([Be({handle:"fileName"}),i.__metadata("design:type",String)],e.ReadBinaryFileNode.prototype,"fileName",void 0),i.__decorate([Be({handle:"mimeType"}),i.__metadata("design:type",String)],e.ReadBinaryFileNode.prototype,"mimeType",void 0),i.__decorate([Be({handle:"bytes"}),i.__metadata("design:type",Number)],e.ReadBinaryFileNode.prototype,"bytes",void 0),e.ReadBinaryFileNode=i.__decorate([qe("core.io.readBinaryFile",{kind:"core.io.readBinaryFile",category:"IO",color:"#0ea5e9",icon:"ti-file-download",width:96,height:96,labels:["io","file","binary","read"],metadata:{title:"graph.node.io.read_binary_file.name",description:"graph.node.io.read_binary_file.description"}}),r.model()],e.ReadBinaryFileNode),e.ReadBinaryFilesNode=class extends Er{async execute(){const e=this.fileSelector||this.pattern;if(!e)throw new Ao("Read Binary Files node requires a file selector pattern","GRAPH_READ_BINARY_FILES_SELECTOR_REQUIRED");const t=await(async e=>{const t=vi(),o=e.replace(/^[/\\]+/,""),a=[];for await(const e of f.glob(o,{cwd:t}))a.push(e);a.sort();const r=[];for(const e of a){const{candidate:o}=Ii(e),a=await Ei(o);a&&(xi(t,a,e),r.push(e))}return r})(e),o=[];let a=0;for(const e of t){const{payload:t,bytes:r}=await Oi(e);o.push(t),a+=r}return{result:o,files:o.length,bytes:a}}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.ReadBinaryFilesNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_binary_files.fields.fileSelector.label",placeholder:"graph.node.io.read_binary_files.fields.fileSelector.placeholder",type:"text"}),Ue({handle:"fileSelector",userControlled:!0}),i.__metadata("design:type",String)],e.ReadBinaryFilesNode.prototype,"fileSelector",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.read_binary_files.fields.pattern.label",placeholder:"graph.node.io.read_binary_files.fields.pattern.placeholder",type:"text"}),Ue({handle:"pattern",userControlled:!0}),i.__metadata("design:type",String)],e.ReadBinaryFilesNode.prototype,"pattern",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Array)],e.ReadBinaryFilesNode.prototype,"result",void 0),i.__decorate([Be({handle:"files"}),i.__metadata("design:type",Number)],e.ReadBinaryFilesNode.prototype,"files",void 0),i.__decorate([Be({handle:"bytes"}),i.__metadata("design:type",Number)],e.ReadBinaryFilesNode.prototype,"bytes",void 0),e.ReadBinaryFilesNode=i.__decorate([qe("core.io.readBinaryFiles",{kind:"core.io.readBinaryFiles",category:"IO",color:"#0ea5e9",icon:"ti-files",width:96,height:96,labels:["io","file","binary","glob"],metadata:{title:"graph.node.io.read_binary_files.name",description:"graph.node.io.read_binary_files.description"}}),r.model()],e.ReadBinaryFilesNode),e.WriteBinaryFileNode=class extends Er{constructor(){super(...arguments),this.dataPropertyName="data",this.encoding="auto",this.append=!1,this.createDirectories=!0}async execute(e){const t=this.fileName||this.path;if(!t)throw new Ao("Write Binary File node requires a file path","GRAPH_WRITE_BINARY_FILE_PATH_REQUIRED");const o=e.inputs.value;if(null==o)throw new Ao("Write Binary File node requires a binary payload","GRAPH_WRITE_BINARY_FILE_CONTENT_REQUIRED");const a=Ci(o,this.encoding??"utf8",this.dataPropertyName||"data"),r=await(async(e,t,o={})=>{const{base:a,candidate:r}=Ii(e),n=await Ei(r);n&&xi(a,n,e),o.createDirectories&&await f.mkdir(g.dirname(r),{recursive:!0}),xi(a,await f.realpath(g.dirname(r)),e);const i=await Ei(r);return i&&xi(a,i,e),o.append?await f.appendFile(r,t):await f.writeFile(r,t),{path:e,bytes:t.byteLength}})(t,a,{append:!0===this.append,createDirectories:!1!==this.createDirectories});return{result:{fileName:t,path:r.path,bytes:r.bytes},bytes:r.bytes}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.WriteBinaryFileNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.fileName.label",placeholder:"graph.node.io.write_binary_file.fields.fileName.placeholder",type:"text"}),Ue({handle:"fileName",userControlled:!0}),i.__metadata("design:type",String)],e.WriteBinaryFileNode.prototype,"fileName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.path.label",placeholder:"graph.node.io.write_binary_file.fields.path.placeholder",type:"text"}),Ue({handle:"path",userControlled:!0}),i.__metadata("design:type",String)],e.WriteBinaryFileNode.prototype,"path",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.dataPropertyName.label",type:"text"}),Ue({handle:"dataPropertyName",userControlled:!0}),i.__metadata("design:type",String)],e.WriteBinaryFileNode.prototype,"dataPropertyName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.encoding.label",type:"select"}),Ue({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],e.WriteBinaryFileNode.prototype,"encoding",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.append.label",type:"checkbox"}),Ue({handle:"append",userControlled:!0}),i.__metadata("design:type",Boolean)],e.WriteBinaryFileNode.prototype,"append",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.createDirectories.label",type:"checkbox"}),Ue({handle:"createDirectories",userControlled:!0}),i.__metadata("design:type",Boolean)],e.WriteBinaryFileNode.prototype,"createDirectories",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.WriteBinaryFileNode.prototype,"result",void 0),i.__decorate([Be({handle:"bytes"}),i.__metadata("design:type",Number)],e.WriteBinaryFileNode.prototype,"bytes",void 0),e.WriteBinaryFileNode=i.__decorate([qe("core.io.writeBinaryFile",{kind:"core.io.writeBinaryFile",category:"IO",color:"#0ea5e9",icon:"ti-file-upload",width:96,height:96,labels:["io","file","binary","write"],metadata:{title:"graph.node.io.write_binary_file.name",description:"graph.node.io.write_binary_file.description"}}),r.model()],e.WriteBinaryFileNode);const Ui=["getRepo","listIssues","createIssue","commentIssue","listPullRequests"];e.GithubNode=class extends Er{constructor(){super(...arguments),this.operation="getRepo"}async execute(e,t){if(!this.operation)throw new Ao("GitHub node requires an operation","GRAPH_GITHUB_OPERATION_REQUIRED");const o=Ui.includes(this.operation)?this.operation:"getRepo",a=await Xo(t,e.credentials,"github",!1,"GitHub"),r=new z.GithubService;try{switch(await v.bootWithoutEnvironment(r,{token:Fn(a,"GitHub"),owner:this.owner,repo:this.repo,baseUrl:this.baseUrl}),o){case"getRepo":return{result:await r.getRepository({owner:this.owner,repo:this.repo})};case"listIssues":return{result:await r.listIssues({owner:this.owner,repo:this.repo,state:this.state,limit:kn(this.limit),page:kn(this.page),labels:this.labels?.join(",")})};case"createIssue":{if(!this.title)throw new Ao("GitHub createIssue requires a title","GRAPH_GITHUB_TITLE_REQUIRED");const t=await r.createIssue({owner:this.owner,repo:this.repo,title:this.title,body:this.body??(e.inputs.value??"")+"",labels:Dn(this.labels)?.map(String),assignees:Dn(this.assignees)?.map(String)});return{result:t,number:t.number,url:t.htmlUrl}}case"commentIssue":{const e=kn(this.number);if(!e||!this.body)throw new Ao("GitHub commentIssue requires an issue number and body","GRAPH_GITHUB_COMMENT_REQUIRED");const t=await r.commentOnIssue({owner:this.owner,repo:this.repo,number:e,body:this.body});return{result:t,number:e,url:t.htmlUrl}}default:return{result:await r.listPullRequests({owner:this.owner,repo:this.repo,state:this.state,limit:kn(this.limit),page:kn(this.page)})}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`GitHub node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITHUB_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.GithubNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.owner.label",type:"string"}),Ue({handle:"owner",userControlled:!0}),i.__metadata("design:type",String)],e.GithubNode.prototype,"owner",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.repo.label",type:"string"}),Ue({handle:"repo",userControlled:!0}),i.__metadata("design:type",String)],e.GithubNode.prototype,"repo",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.number.label",type:"number"}),Ue({handle:"number",userControlled:!0}),i.__metadata("design:type",Number)],e.GithubNode.prototype,"number",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.title.label",type:"string"}),Ue({handle:"title",userControlled:!0}),i.__metadata("design:type",String)],e.GithubNode.prototype,"title",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.body.label",type:"textarea"}),Ue({handle:"body",userControlled:!0}),i.__metadata("design:type",String)],e.GithubNode.prototype,"body",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.labels.label",type:"json"}),Ue({handle:"labels",userControlled:!0}),i.__metadata("design:type",Array)],e.GithubNode.prototype,"labels",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.assignees.label",type:"json"}),Ue({handle:"assignees",userControlled:!0}),i.__metadata("design:type",Array)],e.GithubNode.prototype,"assignees",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.state.label",type:"select"}),Ue({handle:"state",userControlled:!0}),i.__metadata("design:type",String)],e.GithubNode.prototype,"state",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.GithubNode.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.page.label",type:"number"}),Ue({handle:"page",userControlled:!0}),i.__metadata("design:type",Number)],e.GithubNode.prototype,"page",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GithubNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.GithubNode.prototype,"result",void 0),i.__decorate([Be({handle:"number",type:"number"}),i.__metadata("design:type",Number)],e.GithubNode.prototype,"issueNumber",void 0),i.__decorate([Be({handle:"url",type:"string"}),i.__metadata("design:type",String)],e.GithubNode.prototype,"url",void 0),e.GithubNode=i.__decorate([qe("core.devops.github",{kind:"core.devops.github",category:"DevOps",color:"#24292f",icon:"ti-brand-github",width:96,height:96,labels:["devops","github","git","issues"],metadata:{title:"graph.node.devops.github.name",description:"graph.node.devops.github.description"}}),r.model()],e.GithubNode);const Bi=["getProject","listIssues","createIssue","commentIssue","listMergeRequests"];e.GitlabNode=class extends Er{constructor(){super(...arguments),this.operation="getProject"}async execute(e,t){if(!this.operation)throw new Ao("GitLab node requires an operation","GRAPH_GITLAB_OPERATION_REQUIRED");const o=Bi.includes(this.operation)?this.operation:"getProject",a=await Xo(t,e.credentials,"gitlab",!1,"GitLab"),r=new Q.GitlabService;try{switch(await v.bootWithoutEnvironment(r,{token:Fn(a,"GitLab"),projectId:this.projectId,baseUrl:this.baseUrl}),o){case"getProject":return{result:await r.getProject(this.projectId)};case"listIssues":return{result:await r.listIssues({projectId:this.projectId,state:this.state,limit:kn(this.limit),page:kn(this.page),labels:Dn(this.labels)?.map(String).join(","),search:this.search})};case"createIssue":{if(!this.title)throw new Ao("GitLab createIssue requires a title","GRAPH_GITLAB_TITLE_REQUIRED");const t=await r.createIssue({projectId:this.projectId,title:this.title,description:this.body??(e.inputs.value??"")+"",labels:Dn(this.labels)?.map(String).join(","),assigneeIds:Dn(this.assigneeIds)?.map(Number)});return{result:t,iid:t.iid,url:t.webUrl}}case"commentIssue":{const e=kn(this.iid);if(!e||!this.body)throw new Ao("GitLab commentIssue requires an issue IID and body","GRAPH_GITLAB_COMMENT_REQUIRED");const t=await r.commentOnIssue({projectId:this.projectId,iid:e,body:this.body});return{result:t,iid:e,url:t.webUrl}}default:return{result:await r.listMergeRequests({projectId:this.projectId,state:this.state,limit:kn(this.limit),page:kn(this.page),search:this.search})}}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`GitLab node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITLAB_OPERATION_FAILED",{operation:o})}finally{await r.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.projectId.label",type:"string"}),Ue({handle:"projectId",userControlled:!0}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"projectId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.iid.label",type:"number"}),Ue({handle:"iid",userControlled:!0}),i.__metadata("design:type",Number)],e.GitlabNode.prototype,"iid",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.title.label",type:"string"}),Ue({handle:"title",userControlled:!0}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"title",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.body.label",type:"textarea"}),Ue({handle:"body",userControlled:!0}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"body",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.labels.label",type:"json"}),Ue({handle:"labels",userControlled:!0}),i.__metadata("design:type",Array)],e.GitlabNode.prototype,"labels",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.assigneeIds.label",type:"json"}),Ue({handle:"assigneeIds",userControlled:!0}),i.__metadata("design:type",Array)],e.GitlabNode.prototype,"assigneeIds",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.state.label",type:"select"}),Ue({handle:"state",userControlled:!0}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"state",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.search.label",type:"string"}),Ue({handle:"search",userControlled:!0}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"search",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.limit.label",type:"number"}),Ue({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.GitlabNode.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.page.label",type:"number"}),Ue({handle:"page",userControlled:!0}),i.__metadata("design:type",Number)],e.GitlabNode.prototype,"page",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.baseUrl.label",type:"string"}),Ue({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"baseUrl",void 0),i.__decorate([Be({handle:"result"}),i.__metadata("design:type",Object)],e.GitlabNode.prototype,"result",void 0),i.__decorate([Be({handle:"iid",type:"number"}),i.__metadata("design:type",Number)],e.GitlabNode.prototype,"issueIid",void 0),i.__decorate([Be({handle:"url",type:"string"}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"url",void 0),e.GitlabNode=i.__decorate([qe("core.devops.gitlab",{kind:"core.devops.gitlab",category:"DevOps",color:"#fc6d26",icon:"ti-brand-gitlab",width:96,height:96,labels:["devops","gitlab","git","issues"],metadata:{title:"graph.node.devops.gitlab.name",description:"graph.node.devops.gitlab.description"}}),r.model()],e.GitlabNode);const $i={MD5:"md5",SHA1:"sha1",SHA256:"sha256",SHA384:"sha384",SHA512:"sha512","SHA3-256":"sha3-256","SHA3-384":"sha3-384","SHA3-512":"sha3-512"},Wi=["hash","hmac","encrypt","decrypt","sign","verify","generate"];e.CryptoNode=class extends Er{constructor(){super(...arguments),this.operation="hash",this.algorithm="SHA256",this.encoding="hex",this.keyType="rsa"}async execute(e,t){const o="Crypto",a=async a=>{const r=Ln(await Xo(t,e.credentials,"crypto",!0,o),a,o);if(!r)throw new Ao(o+" node credential must contain the required key material","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:o});return r},r=Wi.includes(this.operation)?this.operation:"hash",n=$i[this.algorithm]??$i.SHA256,i="base64"===this.encoding?"base64":"hex",d=()=>((e,t)=>{if("string"==typeof e)return e;if(null==e)throw new Ao(t+" node requires a payload","GRAPH_CRYPTO_PAYLOAD_REQUIRED");try{return JSON.stringify(e)}catch{throw new Ao(t+" node cannot serialize the payload","GRAPH_CRYPTO_INVALID_PAYLOAD")}})(this.payload??e.inputs.value,o),s=new J.CryptoService;await s.boot();const l=s.client;try{switch(r){case"hash":return{result:l.createHash(n).update(d()).digest(i)};case"hmac":{const e=await a(["secret","key","password","token"]);return{result:l.createHmac(n,e).update(d()).digest(i)}}case"encrypt":{const e=await a(["secret","key","password","token"]);return{result:await s.encrypt(d(),e),encodings:["base64"]}}case"decrypt":{const e=await a(["secret","key","password","token"]),t=Cn(this.encryptedData);if(!t)throw new Ao("Crypto node decrypt requires encryptedData","GRAPH_CRYPTO_ENCRYPTED_DATA_REQUIRED");const o=Cn(this.salt);if(!o)throw new Ao("Crypto node decrypt requires the encryption salt","GRAPH_CRYPTO_SALT_REQUIRED");return{result:await s.decrypt(t,e,o)}}case"sign":{const e=await a(["privateKey","key","secret","token"]);return{result:l.createSign(n).update(d()).sign(e,i)}}case"verify":{const e=Cn(this.publicKey)??await a(["publicKey","key","secret","token"]),t=Cn(this.signature);if(!t)throw new Ao("Crypto node verify requires a signature","GRAPH_CRYPTO_SIGNATURE_REQUIRED");return{result:l.createVerify(n).update(d()).verify(e,t,i)}}case"generate":{const e=this.keyType??"rsa";return"ed25519"===e?{result:l.generateKeyPairSync("ed25519",{publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}})}:"ec"===e?{result:l.generateKeyPairSync("ec",{namedCurve:Cn(this.namedCurve)??"prime256v1",publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}})}:{result:l.generateKeyPairSync("rsa",{modulusLength:Math.max(2048,Math.floor(this.modulusLength??2048)),publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}})}}default:throw new Ao(`Crypto node operation '${r}' is not supported`,"GRAPH_CRYPTO_OPERATION_NOT_SUPPORTED",{operation:r})}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`Crypto node operation '${r}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_CRYPTO_OPERATION_FAILED",{operation:r})}finally{await s.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.algorithm.label",type:"select"}),Ue({handle:"algorithm",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"algorithm",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.encoding.label",type:"select"}),Ue({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"encoding",void 0),i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.CryptoNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.payload.label",type:"textarea"}),Ue({handle:"payload",userControlled:!0}),i.__metadata("design:type",Object)],e.CryptoNode.prototype,"payload",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.encryptedData.label",type:"textarea"}),Ue({handle:"encryptedData",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"encryptedData",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.salt.label",type:"string"}),Ue({handle:"salt",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"salt",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.publicKey.label",type:"textarea"}),Ue({handle:"publicKey",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"publicKey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.signature.label",type:"textarea"}),Ue({handle:"signature",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"signature",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.keyType.label",type:"select"}),Ue({handle:"keyType",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"keyType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.modulusLength.label",type:"number"}),Ue({handle:"modulusLength",userControlled:!0}),i.__metadata("design:type",Number)],e.CryptoNode.prototype,"modulusLength",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.namedCurve.label",type:"string"}),Ue({handle:"namedCurve",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"namedCurve",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.CryptoNode.prototype,"result",void 0),i.__decorate([Be({handle:"encodings",type:"array"}),i.__metadata("design:type",Array)],e.CryptoNode.prototype,"encodings",void 0),e.CryptoNode=i.__decorate([qe("core.devops.crypto",{kind:"core.devops.crypto",category:"DevOps",color:"#7c3aed",icon:"ti-lock",width:96,height:96,labels:["devops","crypto","hash","encrypt","sign"],metadata:{title:"graph.node.devops.crypto.name",description:"graph.node.devops.crypto.description"}}),r.model()],e.CryptoNode);const Vi=["sign","verify","decode"];function Ki(e,t="utf8"){const o=Buffer.isBuffer(e)?e:Buffer.from(e??"",t);return o.length>_o?{value:o.subarray(0,_o).toString(t),truncated:!0}:{value:o.toString(t),truncated:!1}}e.JwtNode=class extends Er{constructor(){super(...arguments),this.operation="decode"}async execute(e,t){const o=Vi.includes(this.operation)?this.operation:"decode",a=Cn(this.token)??Cn(e.inputs.value);if("sign"!==o&&!a)throw new Ao(`JWT node operation '${o}' requires a token`,"GRAPH_JWT_TOKEN_REQUIRED",{operation:o});try{if("sign"===o){const o=await Xo(t,e.credentials,"jwt",!0,"JWT"),a=(e=>{if("string"==typeof e&&e.trim().startsWith("{"))try{return Tn(JSON.parse(e))??{}}catch{throw new Ao("JWT node claims must be a JSON object","GRAPH_JWT_INVALID_CLAIMS")}const t=Tn(e);if(!t)throw new Ao("JWT node sign operation requires claims","GRAPH_JWT_CLAIMS_REQUIRED");return t})(this.claims??e.inputs.value),r={secret:o,expiry:Cn(this.expiry)??"1h"},n=await X.sign(a,r);return{result:n,token:n}}if("verify"===o){const o=await Xo(t,e.credentials,"jwt",!1,"JWT"),r=Cn(this.verifyUrl);if(!o&&!r)throw new Ao("JWT node verify requires a secret credential or verifyUrl","GRAPH_JWT_VERIFICATION_NOT_CONFIGURED");const n=await X.verify(a,{secret:"string"==typeof o?o:Cn(o?.secret),verifyUrl:r,clockToleranceSeconds:kn(this.clockToleranceSeconds)});return{result:n,payload:n}}const r=X.decodeJwtPayload(a);return{result:r??null,payload:r??null}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`JWT node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_JWT_OPERATION_FAILED",{operation:o})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.JwtNode.prototype,"operation",void 0),i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.JwtNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.token.label",type:"textarea"}),Ue({handle:"token",userControlled:!0}),i.__metadata("design:type",String)],e.JwtNode.prototype,"token",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.claims.label",type:"object"}),Ue({handle:"claims",userControlled:!0}),i.__metadata("design:type",Object)],e.JwtNode.prototype,"claims",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.expiry.label",type:"string"}),Ue({handle:"expiry",userControlled:!0}),i.__metadata("design:type",String)],e.JwtNode.prototype,"expiry",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.verifyUrl.label",type:"string"}),Ue({handle:"verifyUrl",userControlled:!0}),i.__metadata("design:type",String)],e.JwtNode.prototype,"verifyUrl",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.clockToleranceSeconds.label",type:"number"}),Ue({handle:"clockToleranceSeconds",userControlled:!0}),i.__metadata("design:type",Number)],e.JwtNode.prototype,"clockToleranceSeconds",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.JwtNode.prototype,"result",void 0),i.__decorate([Be({handle:"token"}),i.__metadata("design:type",String)],e.JwtNode.prototype,"tokenOutput",void 0),i.__decorate([Be({handle:"payload"}),i.__metadata("design:type",Object)],e.JwtNode.prototype,"payload",void 0),e.JwtNode=i.__decorate([qe("core.devops.jwt",{kind:"core.devops.jwt",category:"DevOps",color:"#0f766e",icon:"ti-key",width:96,height:96,labels:["devops","jwt","token","auth"],metadata:{title:"graph.node.devops.jwt.name",description:"graph.node.devops.jwt.description"}}),r.model()],e.JwtNode),e.ExecuteCommandNode=class extends Er{constructor(){super(...arguments),this.failOnError=!1}async execute(e,t){const o=Cn(this.command);if(!o)throw new Ao("Execute Command node requires a command","GRAPH_EXECUTE_COMMAND_REQUIRED");const a=Math.min(6e4,Math.max(1,Math.floor(kn(this.timeoutMs)??3e4))),r=await new Promise(e=>{Y.exec(o,{timeout:a,maxBuffer:_o,cwd:Cn(this.cwd),shell:Cn(this.shell),signal:t.abortSignal,windowsHide:!0},(t,o,a)=>{const r=Ki(o),n=Ki(a),i=t?.code;e({stdout:r.value,stderr:n.value,exitCode:"number"==typeof i?i:t?null:0,error:t??void 0,truncated:r.truncated||n.truncated})})});if(r.error&&this.failOnError)throw new Ao("Execute Command node command failed: "+r.error.message,"GRAPH_EXECUTE_COMMAND_FAILED",{exitCode:r.exitCode});return{result:{stdout:r.stdout,stderr:r.stderr,exitCode:r.exitCode,truncated:r.truncated},stdout:r.stdout,stderr:r.stderr,exitCode:r.exitCode}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.command.label",type:"textarea"}),Ue({handle:"command",userControlled:!0}),i.__metadata("design:type",String)],e.ExecuteCommandNode.prototype,"command",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.cwd.label",type:"string"}),Ue({handle:"cwd",userControlled:!0}),i.__metadata("design:type",String)],e.ExecuteCommandNode.prototype,"cwd",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.shell.label",type:"string"}),Ue({handle:"shell",userControlled:!0}),i.__metadata("design:type",String)],e.ExecuteCommandNode.prototype,"shell",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.timeoutMs.label",type:"number"}),Ue({handle:"timeoutMs",userControlled:!0}),i.__metadata("design:type",Number)],e.ExecuteCommandNode.prototype,"timeoutMs",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.failOnError.label",type:"boolean"}),Ue({handle:"failOnError",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ExecuteCommandNode.prototype,"failOnError",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.ExecuteCommandNode.prototype,"result",void 0),i.__decorate([Be({handle:"stdout"}),i.__metadata("design:type",String)],e.ExecuteCommandNode.prototype,"stdout",void 0),i.__decorate([Be({handle:"stderr"}),i.__metadata("design:type",String)],e.ExecuteCommandNode.prototype,"stderr",void 0),i.__decorate([Be({handle:"exitCode",type:"number"}),i.__metadata("design:type",Object)],e.ExecuteCommandNode.prototype,"exitCode",void 0),e.ExecuteCommandNode=i.__decorate([qe("core.devops.executeCommand",{kind:"core.devops.executeCommand",category:"DevOps",color:"#334155",icon:"ti-terminal-2",width:96,height:96,labels:["devops","shell","command","process"],metadata:{title:"graph.node.devops.execute_command.name",description:"graph.node.devops.execute_command.description"}}),r.model()],e.ExecuteCommandNode);const zi=["list","download","delete"];function Qi(e){if(!e)return{};if("string"!=typeof e)return{password:Cn(e.password),privateKey:Cn(e.privateKey),passphrase:Cn(e.passphrase)};if(!e.trim().startsWith("{"))return{password:e};const t=Pn(e,"FTP");return{password:Cn(t.password),privateKey:Cn(t.privateKey),passphrase:Cn(t.passphrase)}}e.FtpNode=class extends Er{constructor(){super(...arguments),this.operation="list",this.encoding="utf8"}async execute(e,t){const o=Cn(this.host),a=Cn(this.username);if(!o||!a)throw new Ao("FTP node requires host and username","GRAPH_FTP_CONNECTION_REQUIRED");const r=zi.includes(this.operation)?this.operation:"list",n=Cn(this.path);if("list"!==r&&!n)throw new Ao(`FTP node operation '${r}' requires a path`,"GRAPH_FTP_PATH_REQUIRED",{operation:r});const i=await Xo(t,e.credentials,"sftp",!1,"FTP"),d={provider:"ssh2",sourceId:Cn(this.sourceId)??"graph",host:o,port:kn(this.port)??22,username:a,remotePath:Cn(this.remotePath),...Qi(i)},s=new Z.Ssh2SftpService;try{if(await s.initialize(d),"list"===r)return{result:await s.list(n)};if("delete"===r)return await s.delete(n),{result:{path:n,deleted:!0}};const e=await s.fetch(n);return{result:{path:e.path,name:e.name,size:e.size},content:"base64"===this.encoding?e.content.toString("base64"):e.content.toString("utf8"),size:e.size}}catch(e){if(e instanceof Ao)throw e;throw new Ao(`FTP node operation '${r}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_FTP_OPERATION_FAILED",{operation:r})}finally{await s.close().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.operation.label",type:"select"}),Ue({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.FtpNode.prototype,"operation",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.host.label",type:"string"}),Ue({handle:"host",userControlled:!0}),i.__metadata("design:type",String)],e.FtpNode.prototype,"host",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.port.label",type:"number"}),Ue({handle:"port",userControlled:!0}),i.__metadata("design:type",Number)],e.FtpNode.prototype,"port",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.username.label",type:"string"}),Ue({handle:"username",userControlled:!0}),i.__metadata("design:type",String)],e.FtpNode.prototype,"username",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.sourceId.label",type:"string"}),Ue({handle:"sourceId",userControlled:!0}),i.__metadata("design:type",String)],e.FtpNode.prototype,"sourceId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.remotePath.label",type:"string"}),Ue({handle:"remotePath",userControlled:!0}),i.__metadata("design:type",String)],e.FtpNode.prototype,"remotePath",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.path.label",type:"string"}),Ue({handle:"path",userControlled:!0}),i.__metadata("design:type",String)],e.FtpNode.prototype,"path",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.encoding.label",type:"select"}),Ue({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],e.FtpNode.prototype,"encoding",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.FtpNode.prototype,"result",void 0),i.__decorate([Be({handle:"content"}),i.__metadata("design:type",String)],e.FtpNode.prototype,"content",void 0),i.__decorate([Be({handle:"size",type:"number"}),i.__metadata("design:type",Number)],e.FtpNode.prototype,"size",void 0),e.FtpNode=i.__decorate([qe("core.devops.ftp",{kind:"core.devops.ftp",category:"DevOps",color:"#0ea5e9",icon:"ti-folder-symlink",width:96,height:96,labels:["devops","ftp","sftp","files"],metadata:{title:"graph.node.devops.ftp.name",description:"graph.node.devops.ftp.description"}}),r.model()],e.FtpNode),e.ExecuteSubWorkflowNode=class extends Er{constructor(){super(...arguments),this.mode="once",this.inputPort="value"}async execute(e,t){const o=t.engine;if(!o)throw new Ao("Execute Sub-workflow node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const a=await this.documentOf(o,t),r=this.inputPort||"value",n=e.inputs.value??e.inputs.input;if("perItem"===this.mode){const e=[];let i,d;for(const s of Gr(n)){const n=await o.execute(a,{[r]:s},{parentRunId:t.runId,path:[...t.path,"subworkflow"],auth:t.auth,metadata:{...t.metadata,item:s}},t);e.push(n.outputs.result??n.outputs),i=n.outputs,d=n.runId}return{result:e,outputs:i,childRunId:d}}const i=await o.execute(a,{[r]:n},{parentRunId:t.runId,path:[...t.path,"subworkflow"],auth:t.auth,metadata:t.metadata},t);return{result:i.outputs.result??i.outputs,outputs:i.outputs,childRunId:i.runId}}async documentOf(e,t){if(Pr(o=this.workflow)&&"string"==typeof o.id&&Array.isArray(o.nodes)&&Array.isArray(o.edges))return this.workflow;var o;const a=this.workflowId;if(!a)throw new Ao("Execute Sub-workflow node requires a workflow id or an inline workflow document","GRAPH_SUB_WORKFLOW_REQUIRED");try{return await e.getWorkflow(a,t)}catch(e){throw new Ao(`Execute Sub-workflow node could not resolve workflow '${a}': ${e instanceof Error?e.message:e+""}`,"GRAPH_SUB_WORKFLOW_NOT_FOUND",{workflowId:a})}}},i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.ExecuteSubWorkflowNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.workflowId.label",placeholder:"graph.node.flow_control.execute_sub_workflow.fields.workflowId.placeholder",type:"text"}),Ue({handle:"workflowId",userControlled:!0}),i.__metadata("design:type",String)],e.ExecuteSubWorkflowNode.prototype,"workflowId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.workflow.label",type:"json"}),Ue({handle:"workflow",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.ExecuteSubWorkflowNode.prototype,"workflow",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.mode.label",type:"select"}),Ue({handle:"mode",userControlled:!0}),i.__metadata("design:type",String)],e.ExecuteSubWorkflowNode.prototype,"mode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.inputPort.label",placeholder:"graph.node.flow_control.execute_sub_workflow.fields.inputPort.placeholder",type:"text"}),Ue({handle:"inputPort",userControlled:!0}),i.__metadata("design:type",String)],e.ExecuteSubWorkflowNode.prototype,"inputPort",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.ExecuteSubWorkflowNode.prototype,"result",void 0),i.__decorate([Be({handle:"outputs"}),i.__metadata("design:type",Object)],e.ExecuteSubWorkflowNode.prototype,"outputs",void 0),i.__decorate([Be({handle:"childRunId"}),i.__metadata("design:type",String)],e.ExecuteSubWorkflowNode.prototype,"childRunId",void 0),e.ExecuteSubWorkflowNode=i.__decorate([qe("core.flow.executeSubWorkflow",{kind:"core.flow.executeSubWorkflow",category:"Flow Control",color:"#f59e0b",icon:"ti-subtask",width:96,height:96,labels:["flow","workflow","subworkflow"],metadata:{title:"graph.node.flow_control.execute_sub_workflow.name",description:"graph.node.flow_control.execute_sub_workflow.description"}}),r.model()],e.ExecuteSubWorkflowNode),e.ExecuteWorkflowTriggerNode=class extends Er{execute(e){const t=e.inputs.payload;return{result:void 0!==t?t:e.inputs.value??e.inputs}}},i.__decorate([Ue({handle:"payload"}),i.__metadata("design:type",Object)],e.ExecuteWorkflowTriggerNode.prototype,"payload",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.execute_workflow.fields.schema.label",placeholder:"graph.node.trigger.execute_workflow.fields.schema.placeholder",type:"json"}),Ue({handle:"schema",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.ExecuteWorkflowTriggerNode.prototype,"schema",void 0),i.__decorate([r.required(),Be({handle:"result"}),i.__metadata("design:type",Object)],e.ExecuteWorkflowTriggerNode.prototype,"result",void 0),e.ExecuteWorkflowTriggerNode=i.__decorate([qe("core.trigger.executeWorkflow",{kind:"core.trigger.executeWorkflow",category:"Trigger",color:"#3b82f6",icon:"ti-player-play",width:96,height:96,labels:["trigger","workflow","subworkflow"],metadata:{title:"graph.node.trigger.execute_workflow.name",description:"graph.node.trigger.execute_workflow.description",trigger:{type:"executeWorkflow"}}}),r.model()],e.ExecuteWorkflowTriggerNode),e.ChatTriggerNode=class extends Er{execute(e){return{message:e.inputs.message??null,sessionId:e.inputs.sessionId??null,userId:e.inputs.userId??null}}},i.__decorate([r.required(),Be({handle:"message"}),i.__metadata("design:type",String)],e.ChatTriggerNode.prototype,"message",void 0),i.__decorate([r.required(),Be({handle:"sessionId"}),i.__metadata("design:type",String)],e.ChatTriggerNode.prototype,"sessionId",void 0),i.__decorate([r.required(),Be({handle:"userId"}),i.__metadata("design:type",String)],e.ChatTriggerNode.prototype,"userId",void 0),e.ChatTriggerNode=i.__decorate([qe("core.trigger.chat",{kind:"core.trigger.chat",category:"Trigger",color:"#3b82f6",icon:"ti-message-circle",width:96,height:96,labels:["trigger","chat","entrypoint"],metadata:{title:"graph.node.trigger.chat.name",description:"graph.node.trigger.chat.description",trigger:{type:"chat"}}}),r.model()],e.ChatTriggerNode),e.EventTriggerNode=class extends Er{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Be({handle:"payload"}),i.__metadata("design:type",Object)],e.EventTriggerNode.prototype,"payload",void 0),e.EventTriggerNode=i.__decorate([qe("core.trigger.event",{kind:"core.trigger.event",category:"Trigger",color:"#3b82f6",icon:"ti-broadcast",width:96,height:96,labels:["trigger","event","bus"],metadata:{title:"graph.node.trigger.event.name",description:"graph.node.trigger.event.description",trigger:{type:"event",topic:"default"}}}),r.model()],e.EventTriggerNode),e.FormTriggerNode=class extends Er{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Ue({handle:"schema"}),o.uielement("ngx-decaf-model-builder",{label:"graph.node.trigger.form.fields.schema.label",placeholder:"graph.node.trigger.form.fields.schema.placeholder"}),i.__metadata("design:type",Object)],e.FormTriggerNode.prototype,"schema",void 0),i.__decorate([r.required(),Be({handle:"payload"}),i.__metadata("design:type",Object)],e.FormTriggerNode.prototype,"payload",void 0),e.FormTriggerNode=i.__decorate([qe("core.trigger.form",{kind:"core.trigger.form",category:"Trigger",color:"#3b82f6",icon:"ti-forms",width:96,height:96,labels:["trigger","form","public"],metadata:{title:"graph.node.trigger.form.name",description:"graph.node.trigger.form.description",trigger:{type:"form",fields:[]}}}),r.model()],e.FormTriggerNode),e.ManualTriggerNode=class extends Er{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Be({handle:"payload"}),i.__metadata("design:type",Object)],e.ManualTriggerNode.prototype,"payload",void 0),e.ManualTriggerNode=i.__decorate([qe("core.trigger.manual",{kind:"core.trigger.manual",category:"Trigger",color:"#3b82f6",icon:"ti-hand-click",width:96,height:96,labels:["trigger","manual","entrypoint"],metadata:{title:"graph.node.trigger.manual.name",description:"graph.node.trigger.manual.description",trigger:{type:"manual",inputSchema:{}}}}),r.model()],e.ManualTriggerNode),e.ScheduleTriggerNode=class extends Er{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Ue({handle:"cron"}),o.uielement("app-cron-selector-field",{label:"graph.node.trigger.schedule.fields.cron.label",placeholder:"graph.node.trigger.schedule.fields.cron.placeholder"}),i.__metadata("design:type",String)],e.ScheduleTriggerNode.prototype,"cron",void 0),i.__decorate([r.required(),Be({handle:"payload"}),i.__metadata("design:type",Object)],e.ScheduleTriggerNode.prototype,"payload",void 0),e.ScheduleTriggerNode=i.__decorate([qe("core.trigger.schedule",{kind:"core.trigger.schedule",category:"Trigger",color:"#3b82f6",icon:"ti-calendar-time",width:96,height:96,labels:["trigger","schedule","cron"],metadata:{title:"graph.node.trigger.schedule.name",description:"graph.node.trigger.schedule.description",trigger:{type:"schedule",schedule:"0 * * * *",timezone:"UTC"}}}),r.model()],e.ScheduleTriggerNode),e.WebhookTriggerNode=class extends Er{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([r.required(),Ue({handle:"schema"}),o.uielement("ngx-decaf-model-builder",{label:"graph.node.trigger.webhook.fields.schema.label",placeholder:"graph.node.trigger.webhook.fields.schema.placeholder"}),i.__metadata("design:type",Object)],e.WebhookTriggerNode.prototype,"schema",void 0),i.__decorate([r.required(),Be({handle:"payload"}),i.__metadata("design:type",Object)],e.WebhookTriggerNode.prototype,"payload",void 0),e.WebhookTriggerNode=i.__decorate([qe("core.trigger.webhook",{kind:"core.trigger.webhook",category:"Trigger",color:"#3b82f6",icon:"ti-webhook",width:96,height:96,labels:["trigger","webhook","http"],metadata:{title:"graph.node.trigger.webhook.name",description:"graph.node.trigger.webhook.description",trigger:{type:"webhook",path:"/webhook",method:"POST",auth:"none",responseMode:"onReceived"}}}),r.model()],e.WebhookTriggerNode),e.ErrorTriggerNode=class extends Er{execute(e){const t=this.payload??e.inputs.payload??e.inputs.value??e.inputs,o=Tn(t)??{value:t},a=Tn(o.execution)??Tn(e.inputs.execution),r=Tn(o.workflow)??Tn(e.inputs.workflow),n=Tn(a?.error)??Tn(o.error)??Tn(e.inputs.error);return{payload:o,...a?{execution:a}:{},...r?{workflow:r}:{},...n?{error:n}:{}}}},i.__decorate([Ue({handle:"payload",type:"object"}),i.__metadata("design:type",Object)],e.ErrorTriggerNode.prototype,"payload",void 0),i.__decorate([r.required(),Be({handle:"payload",type:"object"}),i.__metadata("design:type",Object)],e.ErrorTriggerNode.prototype,"payloadOut",void 0),i.__decorate([Be({handle:"execution",type:"object"}),i.__metadata("design:type",Object)],e.ErrorTriggerNode.prototype,"execution",void 0),i.__decorate([Be({handle:"workflow",type:"object"}),i.__metadata("design:type",Object)],e.ErrorTriggerNode.prototype,"workflow",void 0),i.__decorate([Be({handle:"error",type:"object"}),i.__metadata("design:type",Object)],e.ErrorTriggerNode.prototype,"error",void 0),e.ErrorTriggerNode=i.__decorate([qe("core.trigger.error",{kind:"core.trigger.error",category:"Trigger",color:"#3b82f6",icon:"ti-alert-triangle",width:96,height:96,labels:["trigger","error","failure","workflow"],metadata:{title:"graph.node.trigger.error.name",description:"graph.node.trigger.error.description",trigger:{type:"error"}}}),r.model()],e.ErrorTriggerNode);const Ji={activate:"Workflow activated",update:"Workflow updated"};function Xi(e){if("string"!=typeof e)return;const t=e.trim().toLowerCase();return"activate"===t||"workflow activated"===t?"activate":"update"===t||"workflow updated"===t?"update":void 0}function Yi(e){const t=kn(e);return t&&t>0?Math.floor(t):3e4}function Zi(e,t){if(!t)return e;try{return JSON.parse(e)}catch{return e}}function ed(e,t,o){return o instanceof Ao?o:new Ao(`${e} trigger failed: ${o instanceof Error?o.message:o+""}`,t,{cause:o instanceof Error?o.name:typeof o})}function td(e){if(e)try{Promise.resolve(e()).catch(()=>{})}catch{}}async function od(e,t,o,a,r){let n,i;const d=e.abortSignal;let s;try{return await new Promise((e,l)=>{let c=!1;const p=e=>{c||(c=!0,e())};if(i=setTimeout(()=>p(()=>l(new Ao(r,a,{timeoutMs:t}))),t),d){if(s=()=>p(()=>l(new Ao("The trigger wait was aborted because the run was cancelled or timed out","GRAPH_TRIGGER_ABORTED"))),d.aborted)return void s();d.addEventListener("abort",s,{once:!0})}Promise.resolve(o(t=>p(()=>e(t)),e=>p(()=>l(e)))).then(e=>{n=e,c&&td(e)}).catch(e=>p(()=>l(e)))})}finally{i&&clearTimeout(i),s&&d&&d.removeEventListener("abort",s),td(n)}}function ad(e){const t=e?.timestamp,o={contentType:e?.contentType,contentEncoding:e?.contentEncoding,correlationId:e?.correlationId,replyTo:e?.replyTo,messageId:e?.messageId,type:e?.type,appId:e?.appId,timestamp:t instanceof Date?t.toISOString():void 0===t?void 0:t+""};for(const[e,t]of Object.entries(o))void 0===t&&delete o[e];return o}e.WorkflowTriggerNode=class extends Er{constructor(){super(...arguments),this.events=["activate"]}execute(e){const t=Tn(this.payload??e.inputs.payload),o=this.event??e.inputs.event??t?.event??t?.workflow_event,a=(e=>{const t=(Array.isArray(e)?e:"string"==typeof e?e.split(","):[]).map(e=>Xi(e)).filter(e=>void 0!==e);return t.length?t:["activate"]})(this.events),r=void 0===o?a[0]:Xi(o);if(!r)throw new Ao(`Workflow trigger received an unsupported event '${o+""}'`,"GRAPH_WORKFLOW_TRIGGER_EVENT_INVALID",{event:o});if(!a.includes(r))throw new Ao(`Workflow trigger is not configured for the '${r}' event`,"GRAPH_WORKFLOW_TRIGGER_EVENT_NOT_CONFIGURED",{event:r,events:a});const n=this.timestamp??e.inputs.timestamp??("string"==typeof t?.timestamp?t.timestamp:void 0)??(new Date).toISOString(),i=this.workflowId??e.inputs.workflowId??("string"==typeof t?.workflow_id?t.workflow_id:void 0);return{payload:t??{event:Ji[r],timestamp:n,...i?{workflow_id:i}:{}},event:r,timestamp:n,...i?{workflowId:i}:{}}}},i.__decorate([r.required(),Ue({handle:"events",userControlled:!0,type:"array"}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.workflow.fields.events.label",type:"select"}),i.__metadata("design:type",Array)],e.WorkflowTriggerNode.prototype,"events",void 0),i.__decorate([Ue({handle:"event"}),i.__metadata("design:type",Object)],e.WorkflowTriggerNode.prototype,"event",void 0),i.__decorate([Ue({handle:"payload",type:"object"}),i.__metadata("design:type",Object)],e.WorkflowTriggerNode.prototype,"payload",void 0),i.__decorate([Ue({handle:"timestamp"}),i.__metadata("design:type",Object)],e.WorkflowTriggerNode.prototype,"timestamp",void 0),i.__decorate([Ue({handle:"workflowId"}),i.__metadata("design:type",Object)],e.WorkflowTriggerNode.prototype,"workflowId",void 0),i.__decorate([r.required(),Be({handle:"payload",type:"object"}),i.__metadata("design:type",Object)],e.WorkflowTriggerNode.prototype,"payloadOut",void 0),i.__decorate([Be({handle:"event"}),i.__metadata("design:type",String)],e.WorkflowTriggerNode.prototype,"eventOut",void 0),i.__decorate([Be({handle:"timestamp"}),i.__metadata("design:type",String)],e.WorkflowTriggerNode.prototype,"timestampOut",void 0),i.__decorate([Be({handle:"workflowId"}),i.__metadata("design:type",String)],e.WorkflowTriggerNode.prototype,"workflowIdOut",void 0),e.WorkflowTriggerNode=i.__decorate([qe("core.trigger.workflow",{kind:"core.trigger.workflow",category:"Trigger",color:"#3b82f6",icon:"ti-git-branch",width:96,height:96,labels:["trigger","workflow","lifecycle","activate","update"],metadata:{title:"graph.node.trigger.workflow.name",description:"graph.node.trigger.workflow.description",trigger:{type:"workflow",events:["activate"]}}}),r.model()],e.WorkflowTriggerNode),e.RabbitMqTriggerNode=class extends Er{constructor(){super(...arguments),this.ssl=!1,this.jsonParseBody=!1}async execute(e,t){const o=Cn(this.queue);if(!o)throw new Ao("RabbitMQ trigger requires a queue","GRAPH_RABBITMQ_TRIGGER_QUEUE_REQUIRED");const a=Cn(this.exchange),r=Cn(this.routingKey)??"",n=Ln(await Xo(t,e.credentials,"rabbitmq",!1,"RabbitMQ trigger"),["password","secret","token"],"RabbitMQ trigger"),i=On(this.ssl,!1),d=Yi(this.timeoutMs);let s,l;try{s=await b.connect({protocol:i?"amqps":"amqp",hostname:Cn(this.host)??"localhost",port:kn(this.port)??(i?5671:5672),username:Cn(this.username)??"guest",password:n,vhost:Cn(this.vhost)??"/",heartbeat:10}),l=await s.createChannel(),await l.assertQueue(o,{durable:!0}),a&&(await l.assertExchange(a,Cn(this.exchangeType)??"topic",{durable:!0}),await l.bindQueue(o,a,r)),await l.prefetch(1);const e=await od(t,d,async e=>{const a=await l.consume(o,t=>{if(!t)return;const o=t.content.toString("utf8");try{l.ack(t)}catch{}e({message:o,properties:ad(t.properties)})},{noAck:!1});return await t.log("RabbitMQ trigger subscribed",{queue:o}),async()=>{await l.cancel(a.consumerTag).catch(()=>{})}},"GRAPH_TRIGGER_TIMEOUT",`RabbitMQ trigger received no message within ${d}ms`);return{payload:Zi(e.message,!0===this.jsonParseBody),message:e.message,queue:o,properties:e.properties}}catch(e){throw ed("RabbitMQ","GRAPH_RABBITMQ_TRIGGER_FAILED",e)}finally{await(l?.close().catch(()=>{})),await(s?.close().catch(()=>{}))}}},i.__decorate([r.required(),Ue({handle:"queue"}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.queue.label",placeholder:"queue-name",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqTriggerNode.prototype,"queue",void 0),i.__decorate([Ue({handle:"exchange",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.exchange.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqTriggerNode.prototype,"exchange",void 0),i.__decorate([Ue({handle:"exchangeType",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.exchangeType.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqTriggerNode.prototype,"exchangeType",void 0),i.__decorate([Ue({handle:"routingKey",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.routingKey.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqTriggerNode.prototype,"routingKey",void 0),i.__decorate([Ue({handle:"host",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.host.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqTriggerNode.prototype,"host",void 0),i.__decorate([Ue({handle:"port",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.port.label",type:"number"}),i.__metadata("design:type",Number)],e.RabbitMqTriggerNode.prototype,"port",void 0),i.__decorate([Ue({handle:"username",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.username.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqTriggerNode.prototype,"username",void 0),i.__decorate([Ue({handle:"vhost",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.vhost.label",type:"string"}),i.__metadata("design:type",String)],e.RabbitMqTriggerNode.prototype,"vhost",void 0),i.__decorate([Ue({handle:"ssl",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.ssl.label",type:"boolean"}),i.__metadata("design:type",Boolean)],e.RabbitMqTriggerNode.prototype,"ssl",void 0),i.__decorate([Ue({handle:"jsonParseBody",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.jsonParseBody.label",type:"boolean"}),i.__metadata("design:type",Boolean)],e.RabbitMqTriggerNode.prototype,"jsonParseBody",void 0),i.__decorate([Ue({handle:"timeoutMs",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.timeoutMs.label",type:"number"}),i.__metadata("design:type",Number)],e.RabbitMqTriggerNode.prototype,"timeoutMs",void 0),i.__decorate([r.required(),Be({handle:"payload"}),i.__metadata("design:type",Object)],e.RabbitMqTriggerNode.prototype,"payload",void 0),i.__decorate([Be({handle:"message"}),i.__metadata("design:type",String)],e.RabbitMqTriggerNode.prototype,"message",void 0),i.__decorate([Be({handle:"queue"}),i.__metadata("design:type",String)],e.RabbitMqTriggerNode.prototype,"queueOutput",void 0),i.__decorate([Be({handle:"properties",type:"object"}),i.__metadata("design:type",Object)],e.RabbitMqTriggerNode.prototype,"properties",void 0),e.RabbitMqTriggerNode=i.__decorate([qe("core.trigger.rabbitmq",{kind:"core.trigger.rabbitmq",category:"Trigger",color:"#3b82f6",icon:"ti-inbox",width:96,height:96,labels:["trigger","rabbitmq","amqp","queue"],metadata:{title:"graph.node.trigger.rabbitmq.name",description:"graph.node.trigger.rabbitmq.description",trigger:{type:"rabbitmq",queue:"",jsonParseBody:!1}}}),r.model()],e.RabbitMqTriggerNode),e.RedisTriggerNode=class extends Er{constructor(){super(...arguments),this.tls=!1,this.jsonParseBody=!1}async execute(e,t){const o=Cn(this.channels);if(!o)throw new Ao("Redis trigger requires at least one channel","GRAPH_REDIS_TRIGGER_CHANNELS_REQUIRED");const a=Cn(this.prefix),r=o.split(",").map(e=>e.trim()).filter(e=>e.length>0).map(e=>a?`${a}:${e}`:e);if(!r.length)throw new Ao("Redis trigger requires at least one channel","GRAPH_REDIS_TRIGGER_CHANNELS_REQUIRED");const n=Ln(await Xo(t,e.credentials,"redis",!1,"Redis trigger"),["password","secret","token"],"Redis trigger"),i=Yi(this.timeoutMs),s=`as-graph-redis-trigger-${Date.now()}-${Math.random().toString(36).slice(2)}`,l=new y.RedisAdapter({host:Cn(this.host)??"localhost",port:kn(this.port)??6379,username:Cn(this.username),password:n,database:kn(this.database),tls:!!this.tls||void 0},s);try{await l.initialize();const e=l.client,o=await od(t,i,async o=>{for(const t of r)await e.pSubscribe(t,(e,t)=>o({channel:t,message:e}));return await t.log("Redis trigger subscribed",{channels:r}),async()=>{await e.pUnsubscribe().catch(()=>{})}},"GRAPH_TRIGGER_TIMEOUT",`Redis trigger received no message within ${i}ms`);return{payload:Zi(o.message,!0===this.jsonParseBody),message:o.message,channel:o.channel}}catch(e){throw ed("Redis","GRAPH_REDIS_TRIGGER_FAILED",e)}finally{await l.shutdown().catch(()=>{}),d.Adapter.unregister(s)}}},i.__decorate([r.required(),Ue({handle:"channels"}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.channels.label",placeholder:"graph.node.trigger.redis.fields.channels.placeholder",type:"string"}),i.__metadata("design:type",String)],e.RedisTriggerNode.prototype,"channels",void 0),i.__decorate([Ue({handle:"host",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.host.label",type:"string"}),i.__metadata("design:type",String)],e.RedisTriggerNode.prototype,"host",void 0),i.__decorate([Ue({handle:"port",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.port.label",type:"number"}),i.__metadata("design:type",Number)],e.RedisTriggerNode.prototype,"port",void 0),i.__decorate([Ue({handle:"username",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.username.label",type:"string"}),i.__metadata("design:type",String)],e.RedisTriggerNode.prototype,"username",void 0),i.__decorate([Ue({handle:"database",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.database.label",type:"number"}),i.__metadata("design:type",Number)],e.RedisTriggerNode.prototype,"database",void 0),i.__decorate([Ue({handle:"tls",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.tls.label",type:"boolean"}),i.__metadata("design:type",Boolean)],e.RedisTriggerNode.prototype,"tls",void 0),i.__decorate([Ue({handle:"prefix",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.prefix.label",type:"string"}),i.__metadata("design:type",String)],e.RedisTriggerNode.prototype,"prefix",void 0),i.__decorate([Ue({handle:"jsonParseBody",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.jsonParseBody.label",type:"boolean"}),i.__metadata("design:type",Boolean)],e.RedisTriggerNode.prototype,"jsonParseBody",void 0),i.__decorate([Ue({handle:"timeoutMs",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.timeoutMs.label",type:"number"}),i.__metadata("design:type",Number)],e.RedisTriggerNode.prototype,"timeoutMs",void 0),i.__decorate([r.required(),Be({handle:"payload"}),i.__metadata("design:type",Object)],e.RedisTriggerNode.prototype,"payload",void 0),i.__decorate([Be({handle:"message"}),i.__metadata("design:type",String)],e.RedisTriggerNode.prototype,"message",void 0),i.__decorate([Be({handle:"channel"}),i.__metadata("design:type",String)],e.RedisTriggerNode.prototype,"channel",void 0),e.RedisTriggerNode=i.__decorate([qe("core.trigger.redis",{kind:"core.trigger.redis",category:"Trigger",color:"#3b82f6",icon:"ti-brand-redis",width:96,height:96,labels:["trigger","redis","pubsub","channel"],metadata:{title:"graph.node.trigger.redis.name",description:"graph.node.trigger.redis.description",trigger:{type:"redis",channels:"",jsonParseBody:!1}}}),r.model()],e.RedisTriggerNode),e.SseTriggerNode=class extends Er{constructor(){super(...arguments),this.jsonParseBody=!0}async execute(e,t){const o=Cn(this.url);if(!o)throw new Ao("SSE trigger requires a URL","GRAPH_SSE_TRIGGER_URL_REQUIRED");let a;try{a=new URL(o)}catch{throw new Ao("SSE trigger URL is not a valid URL","GRAPH_SSE_TRIGGER_URL_INVALID")}const r=Ln(await Xo(t,e.credentials,"token",!1,"SSE trigger"),["token","secret","apiKey"],"SSE trigger"),{url:n,authorization:i}=(e=>{if(!e.username&&!e.password)return{url:e};const t=`${decodeURIComponent(e.username)}:${decodeURIComponent(e.password)}`,o=new URL(e.toString());return o.username="",o.password="",{url:o,authorization:"Basic "+Buffer.from(t,"utf8").toString("base64")}})(a),d=r?"Bearer "+r:i,s=Yi(this.timeoutMs);let l;try{const e=await od(t,s,(e,o)=>(l=new ee.EventSource(n,{fetch:(e,t)=>fetch(e,{...t,headers:d?{...t.headers,Authorization:d}:t.headers})}),l.onopen=()=>{t.log("SSE trigger connected",{url:n.toString()}).catch(()=>{})},l.onmessage=t=>e({data:t.data,event:t.type||"message",id:t.lastEventId??""}),l.onerror=e=>{const t=void 0===e.code?"":` (HTTP ${e.code})`;o(new Ao(`SSE trigger connection failed${t}: ${e.message??"unknown error"}`,"GRAPH_SSE_TRIGGER_FAILED"))},()=>l?.close()),"GRAPH_TRIGGER_TIMEOUT",`SSE trigger received no event within ${s}ms`);return{payload:Zi(e.data,!1!==this.jsonParseBody),message:e.data,event:e.event,id:e.id}}catch(e){throw ed("SSE","GRAPH_SSE_TRIGGER_FAILED",e)}finally{l?.close()}}},i.__decorate([r.required(),Ue({handle:"url"}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.sse.fields.url.label",placeholder:"graph.node.trigger.sse.fields.url.placeholder",type:"string"}),i.__metadata("design:type",String)],e.SseTriggerNode.prototype,"url",void 0),i.__decorate([Ue({handle:"jsonParseBody",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.sse.fields.jsonParseBody.label",type:"boolean"}),i.__metadata("design:type",Boolean)],e.SseTriggerNode.prototype,"jsonParseBody",void 0),i.__decorate([Ue({handle:"timeoutMs",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.sse.fields.timeoutMs.label",type:"number"}),i.__metadata("design:type",Number)],e.SseTriggerNode.prototype,"timeoutMs",void 0),i.__decorate([r.required(),Be({handle:"payload"}),i.__metadata("design:type",Object)],e.SseTriggerNode.prototype,"payload",void 0),i.__decorate([Be({handle:"message"}),i.__metadata("design:type",String)],e.SseTriggerNode.prototype,"message",void 0),i.__decorate([Be({handle:"event"}),i.__metadata("design:type",String)],e.SseTriggerNode.prototype,"event",void 0),i.__decorate([Be({handle:"id"}),i.__metadata("design:type",String)],e.SseTriggerNode.prototype,"id",void 0),e.SseTriggerNode=i.__decorate([qe("core.trigger.sse",{kind:"core.trigger.sse",category:"Trigger",color:"#3b82f6",icon:"ti-rss",width:96,height:96,labels:["trigger","sse","events","stream"],metadata:{title:"graph.node.trigger.sse.name",description:"graph.node.trigger.sse.description",trigger:{type:"sse",url:""}}}),r.model()],e.SseTriggerNode);const rd=/^[A-Za-z_][A-Za-z0-9_]*$/;e.PostgresTriggerNode=class extends Er{constructor(){super(...arguments),this.ssl=!1,this.acceptSelfSigned=!1,this.jsonParseBody=!1}async execute(e,t){const o=Cn(this.channel);if(!o)throw new Ao("Postgres trigger requires a channel","GRAPH_POSTGRES_TRIGGER_CHANNEL_REQUIRED");if(!rd.test(o))throw new Ao(`Postgres trigger channel '${o}' is not a valid identifier`,"GRAPH_POSTGRES_TRIGGER_CHANNEL_INVALID",{channel:o});const a=Cn(this.database),r=Cn(this.username);if(!a||!r)throw new Ao("Postgres trigger requires a database and username","GRAPH_POSTGRES_TRIGGER_CONNECTION_REQUIRED");const n=Ln(await Xo(t,e.credentials,"postgres",!1,"Postgres trigger"),["password","secret","token"],"Postgres trigger"),i=On(this.ssl,!1),d=On(this.acceptSelfSigned,!1),s=Yi(this.timeoutMs),l=new te.Client({host:Cn(this.host)??"localhost",port:kn(this.port)??5432,database:a,user:r,password:n,ssl:!!i&&{rejectUnauthorized:!d}});try{await l.connect();const e=await od(t,s,async e=>(l.on("notification",t=>{t.channel===o&&e({channel:t.channel,message:t.payload??""})}),await l.query(`LISTEN "${o}"`),await t.log("Postgres trigger listening",{channel:o}),async()=>{await l.query(`UNLISTEN "${o}"`).catch(()=>{})}),"GRAPH_TRIGGER_TIMEOUT",`Postgres trigger received no notification within ${s}ms`);return{payload:Zi(e.message,!0===this.jsonParseBody),message:e.message,channel:e.channel}}catch(e){throw ed("Postgres","GRAPH_POSTGRES_TRIGGER_FAILED",e)}finally{await l.end().catch(()=>{})}}},i.__decorate([Ue({handle:"host",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.host.label",type:"string"}),i.__metadata("design:type",String)],e.PostgresTriggerNode.prototype,"host",void 0),i.__decorate([Ue({handle:"port",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.port.label",type:"number"}),i.__metadata("design:type",Number)],e.PostgresTriggerNode.prototype,"port",void 0),i.__decorate([r.required(),Ue({handle:"database",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.database.label",type:"string"}),i.__metadata("design:type",String)],e.PostgresTriggerNode.prototype,"database",void 0),i.__decorate([r.required(),Ue({handle:"username",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.username.label",type:"string"}),i.__metadata("design:type",String)],e.PostgresTriggerNode.prototype,"username",void 0),i.__decorate([r.required(),Ue({handle:"channel"}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.channel.label",placeholder:"graph.node.trigger.postgres.fields.channel.placeholder",type:"string"}),i.__metadata("design:type",String)],e.PostgresTriggerNode.prototype,"channel",void 0),i.__decorate([Ue({handle:"ssl",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.ssl.label",type:"boolean"}),i.__metadata("design:type",Boolean)],e.PostgresTriggerNode.prototype,"ssl",void 0),i.__decorate([Ue({handle:"acceptSelfSigned",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.acceptSelfSigned.label",type:"boolean"}),i.__metadata("design:type",Boolean)],e.PostgresTriggerNode.prototype,"acceptSelfSigned",void 0),i.__decorate([Ue({handle:"jsonParseBody",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.jsonParseBody.label",type:"boolean"}),i.__metadata("design:type",Boolean)],e.PostgresTriggerNode.prototype,"jsonParseBody",void 0),i.__decorate([Ue({handle:"timeoutMs",userControlled:!0}),o.uielement("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.timeoutMs.label",type:"number"}),i.__metadata("design:type",Number)],e.PostgresTriggerNode.prototype,"timeoutMs",void 0),i.__decorate([r.required(),Be({handle:"payload"}),i.__metadata("design:type",Object)],e.PostgresTriggerNode.prototype,"payload",void 0),i.__decorate([Be({handle:"message"}),i.__metadata("design:type",String)],e.PostgresTriggerNode.prototype,"message",void 0),i.__decorate([Be({handle:"channel"}),i.__metadata("design:type",String)],e.PostgresTriggerNode.prototype,"channelOutput",void 0),e.PostgresTriggerNode=i.__decorate([qe("core.trigger.postgres",{kind:"core.trigger.postgres",category:"Trigger",color:"#3b82f6",icon:"ti-database",width:96,height:96,labels:["trigger","postgres","sql","listen","notify"],metadata:{title:"graph.node.trigger.postgres.name",description:"graph.node.trigger.postgres.description",trigger:{type:"postgres",channel:"",jsonParseBody:!1}}}),r.model()],e.PostgresTriggerNode);const nd={memory:"memory",scorers:"scorers",embedding:"embedding",hooks:"hooks",sandbox:"sandbox",tools:"tools",skill:"skill",inputProcessors:"inputProcessors",outputProcessors:"outputProcessors"},id=[nd.memory,nd.scorers,nd.embedding,nd.hooks,nd.sandbox,nd.tools,nd.skill,nd.inputProcessors,nd.outputProcessors];e.AgentNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent",backend:"local"})}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.prompt.label",placeholder:"graph.node.agent.agent.fields.prompt.placeholder",type:"textarea"}),Ue({handle:"prompt"}),i.__metadata("design:type",String)],e.AgentNode.prototype,"prompt",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.name.label",placeholder:"graph.node.agent.agent.fields.name.placeholder",type:"text"}),Ue({handle:"name",userControlled:!0}),i.__metadata("design:type",String)],e.AgentNode.prototype,"name",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.description.label",type:"textarea"}),Ue({handle:"description",userControlled:!0}),i.__metadata("design:type",String)],e.AgentNode.prototype,"description",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.instructions.label",placeholder:"graph.node.agent.agent.fields.instructions.placeholder",type:"textarea"}),Ue({handle:"instructions",userControlled:!0}),i.__metadata("design:type",String)],e.AgentNode.prototype,"instructions",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.skillsFormat.label",type:"select"}),Ue({handle:"skillsFormat",userControlled:!0}),i.__metadata("design:type",String)],e.AgentNode.prototype,"skillsFormat",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.maxRetries.label",type:"number"}),Ue({handle:"maxRetries",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentNode.prototype,"maxRetries",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.modelAdapter.label",type:"object"}),Ue({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"modelAdapter",void 0),i.__decorate([o.uielement("ngx-decaf-model-builder",{label:"graph.node.agent.agent.fields.structuredOutput.label"}),Ue({handle:"structuredOutput",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"structuredOutput",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.agentOptions.label",type:"object"}),Ue({handle:"agentOptions",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"agentOptions",void 0),i.__decorate([r.required(),Be({handle:"response"}),i.__metadata("design:type",String)],e.AgentNode.prototype,"response",void 0),i.__decorate([r.required(),Be({handle:"actions"}),i.__metadata("design:type",Array)],e.AgentNode.prototype,"actions",void 0),i.__decorate([$e({category:nd.memory,handle:"memory",zone:{side:"bottom",align:"start",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"memory",void 0),i.__decorate([$e({category:nd.scorers,handle:"scorers",zone:{side:"top",align:"end",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"scorers",void 0),i.__decorate([$e({category:nd.embedding,handle:"embedding",zone:{side:"bottom",align:"end",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"embedding",void 0),i.__decorate([$e({category:nd.hooks,handle:"hooks",zone:{side:"top",align:"center",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"hooks",void 0),i.__decorate([$e({category:nd.sandbox,handle:"sandbox",zone:{side:"top",align:"center",order:1}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"sandbox",void 0),i.__decorate([$e({category:nd.tools,handle:"tools",zone:{side:"bottom",align:"center",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"tools",void 0),i.__decorate([$e({category:nd.skill,handle:"skill",zone:{side:"bottom",align:"center",order:1}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"skill",void 0),i.__decorate([$e({category:nd.inputProcessors,handle:"inputProcessors",zone:{side:"top",align:"center",order:2}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"inputProcessors",void 0),i.__decorate([$e({category:nd.outputProcessors,handle:"outputProcessors",zone:{side:"bottom",align:"center",order:2}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"outputProcessors",void 0),i.__decorate([$e({category:"model",handle:"model",zone:{side:"bottom",align:"start",order:1}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"model",void 0),i.__decorate([$e({category:"workspace",handle:"workspace",zone:{side:"bottom",align:"start",order:2}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"workspace",void 0),e.AgentNode=i.__decorate([qe("core.agent",{kind:"core.agent",category:"Agent",width:168,height:132,labels:["agent","ai","orchestrator"],metadata:{title:"graph.node.agent.agent.name",description:"graph.node.agent.agent.description",shape:"rectangle"}}),r.model()],e.AgentNode);const dd=[e.AgentNode];e.AgentToolNode=class extends Er{execute(e){return{resource:{type:"mastra.tool",toolId:this.toolId,description:this.description,input:e.inputs}}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.tool.fields.toolId.label",placeholder:"graph.node.agent.tool.fields.toolId.placeholder",type:"text"}),Ue({handle:"toolId",userControlled:!0}),i.__metadata("design:type",String)],e.AgentToolNode.prototype,"toolId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.tool.fields.description.label",type:"textarea"}),Ue({handle:"description",userControlled:!0}),i.__metadata("design:type",String)],e.AgentToolNode.prototype,"description",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentToolNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.tools,handle:"tool"}),i.__metadata("design:type",Object)],e.AgentToolNode.prototype,"tool",void 0),e.AgentToolNode=i.__decorate([qe("core.agent.tool",{kind:"core.agent.tool",category:"Agent",width:128,height:112,labels:["agent","ai","tool"],metadata:{title:"graph.node.agent.tool.name",description:"graph.node.agent.tool.description",shape:"rectangle"}}),r.model()],e.AgentToolNode);const sd=[e.AgentToolNode];e.AgentToolSelectorNode=class extends Er{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.tools??[],a="string"==typeof t?t:o.length?o[0]:void 0;return{selected:a,resource:a?{type:"mastra.tool",toolId:a}:null}}},i.__decorate([Ue({handle:"decision"}),i.__metadata("design:type",Object)],e.AgentToolSelectorNode.prototype,"decision",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.tool_selector.fields.tools.label",type:"text"}),Ue({handle:"tools",userControlled:!0}),i.__metadata("design:type",Array)],e.AgentToolSelectorNode.prototype,"tools",void 0),i.__decorate([Be({handle:"selected"}),i.__metadata("design:type",Object)],e.AgentToolSelectorNode.prototype,"selectedOut",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentToolSelectorNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.tools,handle:"tool"}),i.__metadata("design:type",Object)],e.AgentToolSelectorNode.prototype,"tool",void 0),e.AgentToolSelectorNode=i.__decorate([qe("core.agent.toolSelector",{kind:"core.agent.toolSelector",category:"Agent",width:128,height:112,labels:["agent","ai","tool","selector"],metadata:{title:"graph.node.agent.tool_selector.name",description:"graph.node.agent.tool_selector.description",shape:"rectangle"}}),r.model()],e.AgentToolSelectorNode);const ld=[e.AgentToolSelectorNode];e.AgentHookNode=class extends Er{execute(e){const t=e.inputs??{};return{toolName:t.toolName??this.toolName,input:t.input,output:t.output,error:t.error,value:t.value??t}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.hook.fields.phase.label",type:"select"}),Ue({handle:"phase",userControlled:!0}),i.__metadata("design:type",String)],e.AgentHookNode.prototype,"phase",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.hook.fields.toolName.label",type:"text"}),Ue({handle:"toolName",userControlled:!0}),i.__metadata("design:type",String)],e.AgentHookNode.prototype,"toolName",void 0),i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"value",void 0),i.__decorate([r.required(),Be({handle:"toolName"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"toolNameOut",void 0),i.__decorate([Be({handle:"input"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"inputOut",void 0),i.__decorate([Be({handle:"output"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"outputOut",void 0),i.__decorate([Be({handle:"error"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"errorOut",void 0),i.__decorate([Be({handle:"value"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"valueOut",void 0),i.__decorate([$e({category:nd.hooks,handle:"hook"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"hook",void 0),e.AgentHookNode=i.__decorate([qe("core.agent.hook",{kind:"core.agent.hook",category:"Agent",width:128,height:112,labels:["agent","ai","hook"],metadata:{title:"graph.node.agent.hook.name",description:"graph.node.agent.hook.description",shape:"rectangle"}}),r.model()],e.AgentHookNode);const cd=[e.AgentHookNode];e.AgentToolDenyNode=class extends Er{execute(e){const t=e.inputs.value;return{proceed:!1,denied:!0,reason:this.reason,value:this.replacement??t}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.tool_deny.fields.replacement.label",type:"textarea"}),Ue({handle:"replacement",userControlled:!0}),i.__metadata("design:type",Object)],e.AgentToolDenyNode.prototype,"replacement",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.tool_deny.fields.reason.label",type:"text"}),Ue({handle:"reason",userControlled:!0}),i.__metadata("design:type",String)],e.AgentToolDenyNode.prototype,"reason",void 0),i.__decorate([Ue({handle:"value"}),i.__metadata("design:type",Object)],e.AgentToolDenyNode.prototype,"value",void 0),i.__decorate([Be({handle:"proceed"}),i.__metadata("design:type",Boolean)],e.AgentToolDenyNode.prototype,"proceedOut",void 0),i.__decorate([Be({handle:"value"}),i.__metadata("design:type",Object)],e.AgentToolDenyNode.prototype,"valueOut",void 0),i.__decorate([Be({handle:"denied"}),i.__metadata("design:type",Boolean)],e.AgentToolDenyNode.prototype,"deniedOut",void 0),i.__decorate([Be({handle:"reason"}),i.__metadata("design:type",Object)],e.AgentToolDenyNode.prototype,"reasonOut",void 0),e.AgentToolDenyNode=i.__decorate([qe("core.agent.toolDeny",{kind:"core.agent.toolDeny",category:"Agent",width:112,height:96,labels:["agent","ai","hook","deny"],metadata:{title:"graph.node.agent.tool_deny.name",description:"graph.node.agent.tool_deny.description",shape:"rectangle"}}),r.model()],e.AgentToolDenyNode);const pd=[e.AgentToolDenyNode];e.AgentDelegationHookNode=class extends Er{execute(e){const t=e.inputs??{};return{fromAgentId:t.fromAgentId,toAgentId:t.toAgentId??this.subAgentId,input:t.input,output:t.output,error:t.error,value:t.value??t}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.delegation_hook.fields.phase.label",type:"select"}),Ue({handle:"phase",userControlled:!0}),i.__metadata("design:type",String)],e.AgentDelegationHookNode.prototype,"phase",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.delegation_hook.fields.subAgentId.label",type:"text"}),Ue({handle:"subAgentId",userControlled:!0}),i.__metadata("design:type",String)],e.AgentDelegationHookNode.prototype,"subAgentId",void 0),i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"value",void 0),i.__decorate([Be({handle:"fromAgentId"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"fromAgentIdOut",void 0),i.__decorate([Be({handle:"toAgentId"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"toAgentIdOut",void 0),i.__decorate([Be({handle:"input"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"inputOut",void 0),i.__decorate([Be({handle:"output"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"outputOut",void 0),i.__decorate([Be({handle:"error"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"errorOut",void 0),i.__decorate([Be({handle:"value"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"valueOut",void 0),i.__decorate([$e({category:nd.hooks,handle:"hook"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"hook",void 0),e.AgentDelegationHookNode=i.__decorate([qe("core.agent.delegationHook",{kind:"core.agent.delegationHook",category:"Agent",width:128,height:112,labels:["agent","ai","hook","delegation"],metadata:{title:"graph.node.agent.delegation_hook.name",description:"graph.node.agent.delegation_hook.description",shape:"rectangle"}}),r.model()],e.AgentDelegationHookNode);const ud=[e.AgentDelegationHookNode];e.AgentSkillNode=class extends Er{execute(e){return{resource:{type:"mastra.skill",name:this.name,description:this.description,input:e.inputs}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.name.label",type:"text"}),Ue({handle:"name",userControlled:!0}),i.__metadata("design:type",String)],e.AgentSkillNode.prototype,"name",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.description.label",type:"textarea"}),Ue({handle:"description",userControlled:!0}),i.__metadata("design:type",String)],e.AgentSkillNode.prototype,"description",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.instructions.label",type:"textarea"}),Ue({handle:"instructions",userControlled:!0}),i.__metadata("design:type",String)],e.AgentSkillNode.prototype,"instructions",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentSkillNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.skill,handle:"skill"}),i.__metadata("design:type",Object)],e.AgentSkillNode.prototype,"skill",void 0),e.AgentSkillNode=i.__decorate([qe("core.agent.skill",{kind:"core.agent.skill",category:"Agent",width:128,height:112,labels:["agent","ai","skill"],metadata:{title:"graph.node.agent.skill.name",description:"graph.node.agent.skill.description",shape:"rectangle"}}),r.model()],e.AgentSkillNode);const gd=[e.AgentSkillNode];e.AgentSkillSelectorNode=class extends Er{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.skills??[],a="string"==typeof t?t:o.length?o[0]:void 0;return{selected:a,resource:a?{type:"mastra.skill",name:a}:null}}},i.__decorate([Ue({handle:"decision"}),i.__metadata("design:type",Object)],e.AgentSkillSelectorNode.prototype,"decision",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.skill_selector.fields.skills.label",type:"text"}),Ue({handle:"skills",userControlled:!0}),i.__metadata("design:type",Array)],e.AgentSkillSelectorNode.prototype,"skills",void 0),i.__decorate([Be({handle:"selected"}),i.__metadata("design:type",Object)],e.AgentSkillSelectorNode.prototype,"selectedOut",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentSkillSelectorNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.skill,handle:"skill"}),i.__metadata("design:type",Object)],e.AgentSkillSelectorNode.prototype,"skill",void 0),e.AgentSkillSelectorNode=i.__decorate([qe("core.agent.skillSelector",{kind:"core.agent.skillSelector",category:"Agent",width:128,height:112,labels:["agent","ai","skill","selector"],metadata:{title:"graph.node.agent.skill_selector.name",description:"graph.node.agent.skill_selector.description",shape:"rectangle"}}),r.model()],e.AgentSkillSelectorNode);const hd=[e.AgentSkillSelectorNode];function md(e){const t=Tr.graph.execution?.maxCodeTimeoutMs;return Cr(e,"number"==typeof t&&Number.isFinite(t)&&t>0?t:ho)}e.AgentSandboxNode=class extends Er{execute(e){return{resource:{type:"mastra.sandbox",workingDirectory:this.workingDirectory,isolation:this.isolation,timeoutMs:md(this.timeoutMs),input:e.inputs}}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.workingDirectory.label",type:"text"}),Ue({handle:"workingDirectory",userControlled:!0}),i.__metadata("design:type",String)],e.AgentSandboxNode.prototype,"workingDirectory",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.isolation.label",type:"select"}),Ue({handle:"isolation",userControlled:!0}),i.__metadata("design:type",String)],e.AgentSandboxNode.prototype,"isolation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.timeoutMs.label",type:"number"}),Ue({handle:"timeoutMs",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentSandboxNode.prototype,"timeoutMs",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentSandboxNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.sandbox,handle:"sandbox"}),i.__metadata("design:type",Object)],e.AgentSandboxNode.prototype,"sandbox",void 0),e.AgentSandboxNode=i.__decorate([qe("core.agent.sandbox",{kind:"core.agent.sandbox",category:"Agent",width:128,height:112,labels:["agent","ai","sandbox","filesystem"],metadata:{title:"graph.node.agent.sandbox.name",description:"graph.node.agent.sandbox.description",shape:"rectangle"}}),r.model()],e.AgentSandboxNode);const fd=[e.AgentSandboxNode];e.AgentScorerNode=class extends Er{execute(e){return{resource:{type:"mastra.scorer",id:this.scorerId,description:this.description,scorerType:this.scorerType,input:e.inputs}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.scorerId.label",type:"text"}),Ue({handle:"scorerId",userControlled:!0}),i.__metadata("design:type",String)],e.AgentScorerNode.prototype,"scorerId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.description.label",type:"textarea"}),Ue({handle:"description",userControlled:!0}),i.__metadata("design:type",String)],e.AgentScorerNode.prototype,"description",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.scorerType.label",type:"select"}),Ue({handle:"scorerType",userControlled:!0}),i.__metadata("design:type",String)],e.AgentScorerNode.prototype,"scorerType",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentScorerNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.scorers,handle:"scorer"}),i.__metadata("design:type",Object)],e.AgentScorerNode.prototype,"scorer",void 0),e.AgentScorerNode=i.__decorate([qe("core.agent.scorer",{kind:"core.agent.scorer",category:"Agent",width:128,height:112,labels:["agent","ai","scorer","eval"],metadata:{title:"graph.node.agent.scorer.name",description:"graph.node.agent.scorer.description",shape:"rectangle"}}),r.model()],e.AgentScorerNode);const _d=[e.AgentScorerNode];e.AgentScorerSelectorNode=class extends Er{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.scorers??[],a="string"==typeof t?t:o.length?o[0]:void 0;return{selected:a,resource:a?{type:"mastra.scorer",id:a}:null}}},i.__decorate([Ue({handle:"decision"}),i.__metadata("design:type",Object)],e.AgentScorerSelectorNode.prototype,"decision",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.scorer_selector.fields.scorers.label",type:"text"}),Ue({handle:"scorers",userControlled:!0}),i.__metadata("design:type",Array)],e.AgentScorerSelectorNode.prototype,"scorers",void 0),i.__decorate([Be({handle:"selected"}),i.__metadata("design:type",Object)],e.AgentScorerSelectorNode.prototype,"selectedOut",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentScorerSelectorNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.scorers,handle:"scorer"}),i.__metadata("design:type",Object)],e.AgentScorerSelectorNode.prototype,"scorer",void 0),e.AgentScorerSelectorNode=i.__decorate([qe("core.agent.scorerSelector",{kind:"core.agent.scorerSelector",category:"Agent",width:128,height:112,labels:["agent","ai","scorer","selector"],metadata:{title:"graph.node.agent.scorer_selector.name",description:"graph.node.agent.scorer_selector.description",shape:"rectangle"}}),r.model()],e.AgentScorerSelectorNode);const yd=[e.AgentScorerSelectorNode];t.LoggedEnvironment.accumulate({mastra:{engine:{enabled:!0,terminalTimeoutMs:3e5},provider:{endpoint:"",model:""},credentials:{apiKeyEnv:"MASTRA_PROVIDER_API_KEY"},observability:{enabled:!0,serviceName:"as-graph-mastra",environment:"",langfuse:{endpoint:"https://cloud.langfuse.com",publicKeyEnv:"LANGFUSE_PUBLIC_KEY",secretKeyEnv:"LANGFUSE_SECRET_KEY"}},persistence:{replaysAdapter:"fs",cacheAdapter:"ram",pinsAdapter:"fs",fsRoot:"var/as-graph-mastra"}}});const bd=[...Aa,"connectionString","dsn","pwd","passphrase","authToken"];function wd(e,t,o,a=0){if(8>=a&&null!==e)if(Array.isArray(e))for(const r of e)wd(r,t,o,a+1);else if("object"==typeof e)for(const[r,n]of Object.entries(e)){const e=[...t,r];if(bd.includes(r))throw new Ao(`The '${o.provider}' ${o.surface} connection options carry plaintext credential material in '${e.join(".")}'; configs may only reference credentials by name through 'credentialRef', resolved by the host from the git-ignored .env.secret (gate C, SAA-911 F4)`,"GRAPH_MASTRA_PLAIN_CREDENTIAL_REFUSED",{provider:o.provider,id:o.id,key:r,path:e.join(".")});wd(n,e,o,a+1)}}function Nd(e,t){wd(e,[],t)}const vd=["memory","libsql","pg","mongodb","upstash","cloud","d1","dynamodb","convex","astra","redis"];function Ad(e){const t={type:"mastra.memory",provider:e.provider,id:e.id??e.provider};return void 0!==e.threadId&&(t.threadId=e.threadId),void 0!==e.resourceId&&(t.resourceId=e.resourceId),void 0!==e.lastMessages&&(t.lastMessages=e.lastMessages),void 0!==e.semanticRecall&&(t.semanticRecall=e.semanticRecall),void 0!==e.workingMemoryTemplate&&(t.workingMemory={enabled:!0,template:e.workingMemoryTemplate}),void 0!==e.generateTitle&&(t.generateTitle=e.generateTitle),void 0!==e.credentialRef&&(t.credentialRef=e.credentialRef),t}e.AgentMemoryNode=class extends Er{execute(e){return{resource:Ad(this.configOf(e))}}configOf(e){const t=this.provider??"memory";if(!vd.includes(t))throw new Ao(`Memory provider node '${e.nodeId}' declares unknown provider '${t+""}'`,"GRAPH_MASTRA_MEMORY_PROVIDER_UNKNOWN",{nodeId:e.nodeId,provider:t+""});const o=e.inputs.workingMemoryTemplate,a={provider:t};void 0!==this.memoryId&&(a.id=this.memoryId),void 0!==this.threadId&&(a.threadId=this.threadId),void 0!==this.resourceId&&(a.resourceId=this.resourceId),void 0!==this.lastMessages&&(a.lastMessages=this.lastMessages),void 0!==this.semanticRecall&&(a.semanticRecall=this.semanticRecall),void 0!==this.generateTitle&&(a.generateTitle=this.generateTitle),void 0!==this.memoryOptions&&(a.memoryOptions=this.memoryOptions),void 0!==this.connection&&(a.connection=this.connection),void 0!==this.credentialKey&&(a.credentialKey=this.credentialKey),void 0!==this.credentialRef&&(a.credentialRef=this.credentialRef);const r="string"==typeof o&&o.trim().length>0?o:this.workingMemoryTemplate;return"string"==typeof r&&r.trim().length>0&&(a.workingMemoryTemplate=r),a}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.provider.label",type:"select"}),Ue({handle:"provider",userControlled:!0}),i.__metadata("design:type",String)],e.AgentMemoryNode.prototype,"provider",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.memoryId.label",type:"text"}),Ue({handle:"memoryId",userControlled:!0}),i.__metadata("design:type",String)],e.AgentMemoryNode.prototype,"memoryId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.threadId.label",placeholder:"graph.node.agent.memory.fields.threadId.placeholder",type:"text"}),Ue({handle:"threadId",userControlled:!0}),i.__metadata("design:type",String)],e.AgentMemoryNode.prototype,"threadId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.resourceId.label",type:"text"}),Ue({handle:"resourceId",userControlled:!0}),i.__metadata("design:type",String)],e.AgentMemoryNode.prototype,"resourceId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.lastMessages.label",type:"number"}),Ue({handle:"lastMessages",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentMemoryNode.prototype,"lastMessages",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.semanticRecall.label",type:"select"}),Ue({handle:"semanticRecall",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AgentMemoryNode.prototype,"semanticRecall",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.workingMemoryTemplate.label",placeholder:"graph.node.agent.memory.fields.workingMemoryTemplate.placeholder",type:"textarea"}),Ue({handle:"workingMemoryTemplate",userControlled:!0}),i.__metadata("design:type",String)],e.AgentMemoryNode.prototype,"workingMemoryTemplate",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.generateTitle.label",type:"select"}),Ue({handle:"generateTitle",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AgentMemoryNode.prototype,"generateTitle",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.memoryOptions.label",type:"object"}),Ue({handle:"memoryOptions",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentMemoryNode.prototype,"memoryOptions",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.connection.label",type:"object"}),Ue({handle:"connection",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentMemoryNode.prototype,"connection",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.credentialRef.label",type:"text"}),Ue({handle:"credentialKey",userControlled:!0}),i.__metadata("design:type",String)],e.AgentMemoryNode.prototype,"credentialKey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.credentialRef.label",type:"object"}),Ue({handle:"credentialRef",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentMemoryNode.prototype,"credentialRef",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentMemoryNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.memory,handle:"memory"}),i.__metadata("design:type",Object)],e.AgentMemoryNode.prototype,"memory",void 0),e.AgentMemoryNode=i.__decorate([qe("core.agent.memory",{kind:"core.agent.memory",category:"Agent",width:140,height:120,labels:["agent","ai","memory"],metadata:{title:"graph.node.agent.memory.name",description:"graph.node.agent.memory.description",shape:"rectangle"}}),r.model()],e.AgentMemoryNode),e.AgentMemorySelectorNode=class extends Er{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.memories??[],a="string"==typeof t?t:o.length?o[0]:void 0;return{selected:a,resource:a?{type:"mastra.memory",id:a}:null}}},i.__decorate([Ue({handle:"decision"}),i.__metadata("design:type",Object)],e.AgentMemorySelectorNode.prototype,"decision",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory_selector.fields.memories.label",type:"text"}),Ue({handle:"memories",userControlled:!0}),i.__metadata("design:type",Array)],e.AgentMemorySelectorNode.prototype,"memories",void 0),i.__decorate([Be({handle:"selected"}),i.__metadata("design:type",Object)],e.AgentMemorySelectorNode.prototype,"selectedOut",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentMemorySelectorNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.memory,handle:"memory"}),i.__metadata("design:type",Object)],e.AgentMemorySelectorNode.prototype,"memory",void 0),e.AgentMemorySelectorNode=i.__decorate([qe("core.agent.memorySelector",{kind:"core.agent.memorySelector",category:"Agent",width:128,height:112,labels:["agent","ai","memory","selector"],metadata:{title:"graph.node.agent.memory_selector.name",description:"graph.node.agent.memory_selector.description",shape:"rectangle"}}),r.model()],e.AgentMemorySelectorNode);const xd=[e.AgentMemorySelectorNode];e.AgentEmbeddingNode=class extends Er{execute(e){const t=this.modelAdapter??{};return{resource:{type:"mastra.embedding",provider:t.provider,modelId:t.modelId,dimension:this.dimension,batchSize:this.batchSize,input:e.inputs}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.modelAdapter.label",type:"object"}),Ue({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentEmbeddingNode.prototype,"modelAdapter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.dimension.label",type:"number"}),Ue({handle:"dimension",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentEmbeddingNode.prototype,"dimension",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.batchSize.label",type:"number"}),Ue({handle:"batchSize",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentEmbeddingNode.prototype,"batchSize",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentEmbeddingNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.embedding,handle:"embedding"}),i.__metadata("design:type",Object)],e.AgentEmbeddingNode.prototype,"embedding",void 0),e.AgentEmbeddingNode=i.__decorate([qe("core.agent.embedding",{kind:"core.agent.embedding",category:"Agent",width:128,height:112,labels:["agent","ai","embedding","vector"],metadata:{title:"graph.node.agent.embedding.name",description:"graph.node.agent.embedding.description",shape:"rectangle"}}),r.model()],e.AgentEmbeddingNode);const Id=[e.AgentEmbeddingNode];e.AgentVectorStoreNode=class extends Er{execute(e){const t=this.provider??"memory",o={type:"mastra.vectorStore",provider:t,id:this.storeId??this.indexName??t};void 0!==this.indexName&&(o.indexName=this.indexName),void 0!==this.dimension&&(o.dimension=this.dimension),void 0!==this.metric&&(o.metric=this.metric),void 0!==this.embedding&&(Nd(this.embedding,{provider:t,id:this.storeId??this.indexName??t,surface:"vector store embedding"}),o.embedding=this.embedding),void 0!==this.credentialRef&&(o.credentialRef=this.credentialRef);const a=e.inputs.ids;return{resource:o,inserted:Array.isArray(a)?a:[],documents:e.inputs.documents??[]}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.provider.label",type:"select"}),Ue({handle:"provider",userControlled:!0}),i.__metadata("design:type",String)],e.AgentVectorStoreNode.prototype,"provider",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.storeId.label",type:"text"}),Ue({handle:"storeId",userControlled:!0}),i.__metadata("design:type",String)],e.AgentVectorStoreNode.prototype,"storeId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.indexName.label",type:"text"}),Ue({handle:"indexName",userControlled:!0}),i.__metadata("design:type",String)],e.AgentVectorStoreNode.prototype,"indexName",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.dimension.label",type:"number"}),Ue({handle:"dimension",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentVectorStoreNode.prototype,"dimension",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.metric.label",type:"select"}),Ue({handle:"metric",userControlled:!0}),i.__metadata("design:type",String)],e.AgentVectorStoreNode.prototype,"metric",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.modelAdapter.label",type:"object"}),Ue({handle:"embedding",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"embedding",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.connection.label",type:"object"}),Ue({handle:"connection",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"connection",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.credentialRef.label",type:"text"}),Ue({handle:"credentialKey",userControlled:!0}),i.__metadata("design:type",String)],e.AgentVectorStoreNode.prototype,"credentialKey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.credentialRef.label",type:"object"}),Ue({handle:"credentialRef",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"credentialRef",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"resource",void 0),i.__decorate([Be({handle:"inserted"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"insertedOut",void 0),i.__decorate([Be({handle:"documents"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"documentsOut",void 0),e.AgentVectorStoreNode=i.__decorate([qe("core.agent.vectorStore",{kind:"core.agent.vectorStore",category:"Agent",width:140,height:120,labels:["agent","ai","vector-store","rag"],metadata:{title:"graph.node.agent.vector_store.name",description:"graph.node.agent.vector_store.description",shape:"rectangle"}}),r.model()],e.AgentVectorStoreNode);const Ed=[e.AgentVectorStoreNode];e.AgentRetrieverNode=class extends Er{execute(e){const t=e.inputs.documents;return{documents:Array.isArray(t)?t:[],resource:{type:"mastra.retriever",topK:this.topK,indexName:this.indexName,store:e.inputs.store,input:e.inputs}}}},i.__decorate([r.required(),Ue({handle:"store"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"store",void 0),i.__decorate([r.required(),Ue({handle:"query"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"query",void 0),i.__decorate([Ue({handle:"queryVector"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"queryVector",void 0),i.__decorate([Ue({handle:"filter",type:"object"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"filter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.retriever.fields.topK.label",type:"number"}),Ue({handle:"topK",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentRetrieverNode.prototype,"topK",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.retriever.fields.indexName.label",type:"text"}),Ue({handle:"indexName",userControlled:!0}),i.__metadata("design:type",String)],e.AgentRetrieverNode.prototype,"indexName",void 0),i.__decorate([r.required(),Be({handle:"documents"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"documents",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"resource",void 0),e.AgentRetrieverNode=i.__decorate([qe("core.agent.retriever",{kind:"core.agent.retriever",category:"Agent",width:128,height:112,labels:["agent","ai","retriever","rag"],metadata:{title:"graph.node.agent.retriever.name",description:"graph.node.agent.retriever.description",shape:"rectangle"}}),r.model()],e.AgentRetrieverNode);const Sd=[e.AgentRetrieverNode];function Rd(e,t,o){if("number"!=typeof e||!Number.isFinite(e))return t;const a=Math.floor(e);return o>a?t:a}function Td(e,t,o){if(e.length<=t)return e.length?[e]:[];const a=Math.max(1,t-o),r=[];for(let o=0;o<e.length;o+=a){const a=Math.min(o+t,e.length);if(r.push(e.slice(o,a)),a>=e.length)break}return r}function Cd(e,t={}){if("string"!=typeof e||0===e.length)return[];const o=t.strategy??"recursive",a=Rd(t.chunkSize,1e3,1),r=Rd(t.chunkOverlap,200,0),n=Math.min(r,Math.max(0,a-1));if("character"===o)return Td(e,a,n);if("token"===o){const t=e.split(/\s+/).filter(e=>e.length>0);if(0===t.length)return[];const o=Math.max(1,a-n),r=[];for(let e=0;e<t.length&&(r.push(t.slice(e,e+a).join(" ")),e+a<t.length);e+=o);return r}const i="markdown"===o?"\n#":t.separator??"\n\n",d=e.split(i),s=[];return d.forEach(e=>{const t=e.trim();t&&(t.length>a?s.push(...Td(t,a,n)):s.push(t))}),s.length?s:Td(e,a,n)}function Od(e){const t=e.documents,o=[];if("string"==typeof e.text&&o.push(e.text),Array.isArray(t))for(const e of t)"string"==typeof e?o.push(e):e&&"object"==typeof e&&"string"==typeof e.text&&o.push(e.text);return o}e.AgentChunkingNode=class extends Er{execute(e){const t=Od(e.inputs),o={strategy:this.strategy,chunkSize:this.chunkSize,chunkOverlap:this.chunkOverlap,separator:this.separator},a=t.flatMap(e=>Cd(e,o));return{chunks:a,count:a.length}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.strategy.label",type:"select"}),Ue({handle:"strategy",userControlled:!0}),i.__metadata("design:type",String)],e.AgentChunkingNode.prototype,"strategy",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.chunkSize.label",type:"number"}),Ue({handle:"chunkSize",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentChunkingNode.prototype,"chunkSize",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.chunkOverlap.label",type:"number"}),Ue({handle:"chunkOverlap",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentChunkingNode.prototype,"chunkOverlap",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.separator.label",type:"text"}),Ue({handle:"separator",userControlled:!0}),i.__metadata("design:type",String)],e.AgentChunkingNode.prototype,"separator",void 0),i.__decorate([r.required(),Be({handle:"chunks"}),i.__metadata("design:type",Object)],e.AgentChunkingNode.prototype,"chunks",void 0),i.__decorate([Be({handle:"count"}),i.__metadata("design:type",Object)],e.AgentChunkingNode.prototype,"countOut",void 0),e.AgentChunkingNode=i.__decorate([qe("core.agent.chunking",{kind:"core.agent.chunking",category:"Agent",width:128,height:112,labels:["agent","ai","chunking","rag"],metadata:{title:"graph.node.agent.chunking.name",description:"graph.node.agent.chunking.description",shape:"rectangle"}}),r.model()],e.AgentChunkingNode);const kd=[e.AgentChunkingNode];e.AgentRerankNode=class extends Er{execute(e){const t=e.inputs.documents,o=Array.isArray(t)?t:[],a="number"==typeof this.topN&&this.topN>0?this.topN:void 0,r=this.modelAdapter??{};return{documents:void 0!==a?o.slice(0,a):o,resource:{type:"mastra.rerank",provider:r.provider,modelId:r.modelId,topN:a}}}},i.__decorate([r.required(),Ue({handle:"documents"}),i.__metadata("design:type",Object)],e.AgentRerankNode.prototype,"documents",void 0),i.__decorate([Ue({handle:"query"}),i.__metadata("design:type",Object)],e.AgentRerankNode.prototype,"query",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.rerank.fields.modelAdapter.label",type:"object"}),Ue({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentRerankNode.prototype,"modelAdapter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.rerank.fields.topN.label",type:"number"}),Ue({handle:"topN",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentRerankNode.prototype,"topN",void 0),i.__decorate([r.required(),Be({handle:"documents"}),i.__metadata("design:type",Object)],e.AgentRerankNode.prototype,"documentsOut",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentRerankNode.prototype,"resource",void 0),e.AgentRerankNode=i.__decorate([qe("core.agent.rerank",{kind:"core.agent.rerank",category:"Agent",width:128,height:112,labels:["agent","ai","rerank","rag"],metadata:{title:"graph.node.agent.rerank.name",description:"graph.node.agent.rerank.description",shape:"rectangle"}}),r.model()],e.AgentRerankNode);const Dd=[e.AgentRerankNode];e.AgentQaChainNode=class extends Er{execute(e){const t=this.modelAdapter??{},o=e.inputs.context??e.inputs.documents,a=Array.isArray(o)?o:[];return{text:"string"==typeof e.inputs.text?e.inputs.text:"",sourceDocuments:this.returnSourceDocuments?a:[],resource:{type:"mastra.chain.qa",provider:t.provider,modelId:t.modelId,returnSourceDocuments:this.returnSourceDocuments??!1}}}},i.__decorate([r.required(),Ue({handle:"query"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"query",void 0),i.__decorate([Ue({handle:"context"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"context",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.modelAdapter.label",type:"object"}),Ue({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"modelAdapter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.promptTemplate.label",type:"textarea"}),Ue({handle:"promptTemplate",userControlled:!0}),i.__metadata("design:type",String)],e.AgentQaChainNode.prototype,"promptTemplate",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.returnSourceDocuments.label",type:"boolean"}),Ue({handle:"returnSourceDocuments",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AgentQaChainNode.prototype,"returnSourceDocuments",void 0),i.__decorate([r.required(),Be({handle:"text"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"text",void 0),i.__decorate([Be({handle:"sourceDocuments"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"sourceDocumentsOut",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"resource",void 0),e.AgentQaChainNode=i.__decorate([qe("core.agent.chain.qa",{kind:"core.agent.chain.qa",category:"Agent",width:128,height:112,labels:["agent","ai","chain","qa"],metadata:{title:"graph.node.agent.chain.qa.name",description:"graph.node.agent.chain.qa.description",shape:"rectangle"}}),r.model()],e.AgentQaChainNode);const Pd=[e.AgentQaChainNode];e.AgentBasicChainNode=class extends Er{execute(e){const t=this.modelAdapter??{};return{text:"string"==typeof e.inputs.text?e.inputs.text:"",resource:{type:"mastra.chain.basic",provider:t.provider,modelId:t.modelId,promptTemplate:this.promptTemplate}}}},i.__decorate([r.required(),Ue({handle:"input"}),i.__metadata("design:type",Object)],e.AgentBasicChainNode.prototype,"input",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chain.basic.fields.modelAdapter.label",type:"object"}),Ue({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentBasicChainNode.prototype,"modelAdapter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chain.basic.fields.promptTemplate.label",type:"textarea"}),Ue({handle:"promptTemplate",userControlled:!0}),i.__metadata("design:type",String)],e.AgentBasicChainNode.prototype,"promptTemplate",void 0),i.__decorate([r.required(),Be({handle:"text"}),i.__metadata("design:type",Object)],e.AgentBasicChainNode.prototype,"text",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentBasicChainNode.prototype,"resource",void 0),e.AgentBasicChainNode=i.__decorate([qe("core.agent.chain.basic",{kind:"core.agent.chain.basic",category:"Agent",width:128,height:112,labels:["agent","ai","chain","llm"],metadata:{title:"graph.node.agent.chain.basic.name",description:"graph.node.agent.chain.basic.description",shape:"rectangle"}}),r.model()],e.AgentBasicChainNode);const Gd=[e.AgentBasicChainNode];e.AgentSummarizationChainNode=class extends Er{execute(e){const t=this.modelAdapter??{},o=e.inputs.documents;return{text:"string"==typeof e.inputs.text?e.inputs.text:"",resource:{type:"mastra.chain.summarization",provider:t.provider,modelId:t.modelId,strategy:this.strategy??"stuff",documentCount:Array.isArray(o)?o.length:0}}}},i.__decorate([r.required(),Ue({handle:"documents"}),i.__metadata("design:type",Object)],e.AgentSummarizationChainNode.prototype,"documents",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.modelAdapter.label",type:"object"}),Ue({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentSummarizationChainNode.prototype,"modelAdapter",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.strategy.label",type:"select"}),Ue({handle:"strategy",userControlled:!0}),i.__metadata("design:type",String)],e.AgentSummarizationChainNode.prototype,"strategy",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.instructions.label",type:"textarea"}),Ue({handle:"instructions",userControlled:!0}),i.__metadata("design:type",String)],e.AgentSummarizationChainNode.prototype,"instructions",void 0),i.__decorate([r.required(),Be({handle:"text"}),i.__metadata("design:type",Object)],e.AgentSummarizationChainNode.prototype,"text",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentSummarizationChainNode.prototype,"resource",void 0),e.AgentSummarizationChainNode=i.__decorate([qe("core.agent.chain.summarization",{kind:"core.agent.chain.summarization",category:"Agent",width:128,height:112,labels:["agent","ai","chain","summarization"],metadata:{title:"graph.node.agent.chain.summarization.name",description:"graph.node.agent.chain.summarization.description",shape:"rectangle"}}),r.model()],e.AgentSummarizationChainNode);const Md=[e.AgentSummarizationChainNode];function Fd(e){if("string"!=typeof e||0===e.trim().length)return null;try{return JSON.parse(e)}catch{return null}}e.AgentStructuredOutputParserNode=class extends Er{execute(e){return{object:Fd(e.inputs.text??e.inputs.input),resource:{type:"mastra.structuredOutputParser",strict:this.strict??!1,hasSchema:void 0!==this.structuredOutput}}}},i.__decorate([r.required(),Ue({handle:"text"}),i.__metadata("design:type",Object)],e.AgentStructuredOutputParserNode.prototype,"text",void 0),i.__decorate([o.uielement("ngx-decaf-model-builder",{label:"graph.node.agent.structured_output_parser.fields.structuredOutput.label"}),Ue({handle:"structuredOutput",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentStructuredOutputParserNode.prototype,"structuredOutput",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.structured_output_parser.fields.strict.label",type:"boolean"}),Ue({handle:"strict",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AgentStructuredOutputParserNode.prototype,"strict",void 0),i.__decorate([r.required(),Be({handle:"object"}),i.__metadata("design:type",Object)],e.AgentStructuredOutputParserNode.prototype,"object",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentStructuredOutputParserNode.prototype,"resource",void 0),e.AgentStructuredOutputParserNode=i.__decorate([qe("core.agent.structuredOutputParser",{kind:"core.agent.structuredOutputParser",category:"Agent",width:128,height:112,labels:["agent","ai","parser","structured-output"],metadata:{title:"graph.node.agent.structured_output_parser.name",description:"graph.node.agent.structured_output_parser.description",shape:"rectangle"}}),r.model()],e.AgentStructuredOutputParserNode);const Ld=[e.AgentStructuredOutputParserNode];e.AgentInformationExtractorNode=class extends Er{execute(e){const t=this.modelAdapter??{};return{data:e.inputs.data??null,resource:{type:"mastra.informationExtractor",provider:t.provider,modelId:t.modelId,instructions:this.instructions,hasSchema:void 0!==this.structuredOutput}}}},i.__decorate([r.required(),Ue({handle:"text"}),i.__metadata("design:type",Object)],e.AgentInformationExtractorNode.prototype,"text",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.information_extractor.fields.modelAdapter.label",type:"object"}),Ue({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentInformationExtractorNode.prototype,"modelAdapter",void 0),i.__decorate([o.uielement("ngx-decaf-model-builder",{label:"graph.node.agent.information_extractor.fields.structuredOutput.label"}),Ue({handle:"structuredOutput",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentInformationExtractorNode.prototype,"structuredOutput",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.information_extractor.fields.instructions.label",type:"textarea"}),Ue({handle:"instructions",userControlled:!0}),i.__metadata("design:type",String)],e.AgentInformationExtractorNode.prototype,"instructions",void 0),i.__decorate([r.required(),Be({handle:"data"}),i.__metadata("design:type",Object)],e.AgentInformationExtractorNode.prototype,"data",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentInformationExtractorNode.prototype,"resource",void 0),e.AgentInformationExtractorNode=i.__decorate([qe("core.agent.informationExtractor",{kind:"core.agent.informationExtractor",category:"Agent",width:128,height:112,labels:["agent","ai","extractor","structured-output"],metadata:{title:"graph.node.agent.information_extractor.name",description:"graph.node.agent.information_extractor.description",shape:"rectangle"}}),r.model()],e.AgentInformationExtractorNode);const jd=[e.AgentInformationExtractorNode];e.AgentLangChainCodeNode=class extends Er{execute(e){return{output:e.inputs.input??null,resource:{type:"mastra.langchainCode",language:this.language??"javascript",mode:this.mode??"runOnce",hasCode:"string"==typeof this.code&&this.code.length>0}}}},i.__decorate([r.required(),Ue({handle:"input"}),i.__metadata("design:type",Object)],e.AgentLangChainCodeNode.prototype,"input",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.code.label",type:"textarea"}),Ue({handle:"code",userControlled:!0}),i.__metadata("design:type",String)],e.AgentLangChainCodeNode.prototype,"code",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.language.label",type:"select"}),Ue({handle:"language",userControlled:!0}),i.__metadata("design:type",String)],e.AgentLangChainCodeNode.prototype,"language",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.mode.label",type:"select"}),Ue({handle:"mode",userControlled:!0}),i.__metadata("design:type",String)],e.AgentLangChainCodeNode.prototype,"mode",void 0),i.__decorate([Be({handle:"output"}),i.__metadata("design:type",Object)],e.AgentLangChainCodeNode.prototype,"outputOut",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentLangChainCodeNode.prototype,"resource",void 0),e.AgentLangChainCodeNode=i.__decorate([qe("core.agent.langchainCode",{kind:"core.agent.langchainCode",category:"Agent",width:128,height:112,labels:["agent","ai","code","glue"],metadata:{title:"graph.node.agent.langchain_code.name",description:"graph.node.agent.langchain_code.description",shape:"rectangle"}}),r.model()],e.AgentLangChainCodeNode);const qd=[e.AgentLangChainCodeNode];e.AgentInputProcessorNode=class extends Er{execute(e){return{resource:{type:"mastra.inputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.processorType.label",type:"select"}),Ue({handle:"processorType",userControlled:!0}),i.__metadata("design:type",Object)],e.AgentInputProcessorNode.prototype,"processorType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.options.label",type:"object"}),Ue({handle:"options",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentInputProcessorNode.prototype,"options",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.modelAdapter.label",type:"object"}),Ue({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentInputProcessorNode.prototype,"modelAdapter",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentInputProcessorNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.inputProcessors,handle:"processors"}),i.__metadata("design:type",Object)],e.AgentInputProcessorNode.prototype,"processors",void 0),e.AgentInputProcessorNode=i.__decorate([qe("core.agent.inputProcessor",{kind:"core.agent.inputProcessor",category:"Agent",width:128,height:112,labels:["agent","ai","processor","input"],metadata:{title:"graph.node.agent.input_processor.name",description:"graph.node.agent.input_processor.description",shape:"rectangle"}}),r.model()],e.AgentInputProcessorNode);const Hd=[e.AgentInputProcessorNode];e.AgentOutputProcessorNode=class extends Er{execute(e){return{resource:{type:"mastra.outputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.output_processor.fields.processorType.label",type:"select"}),Ue({handle:"processorType",userControlled:!0}),i.__metadata("design:type",Object)],e.AgentOutputProcessorNode.prototype,"processorType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.output_processor.fields.options.label",type:"object"}),Ue({handle:"options",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentOutputProcessorNode.prototype,"options",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentOutputProcessorNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.outputProcessors,handle:"processors"}),i.__metadata("design:type",Object)],e.AgentOutputProcessorNode.prototype,"processors",void 0),e.AgentOutputProcessorNode=i.__decorate([qe("core.agent.outputProcessor",{kind:"core.agent.outputProcessor",category:"Agent",width:128,height:112,labels:["agent","ai","processor","output"],metadata:{title:"graph.node.agent.output_processor.name",description:"graph.node.agent.output_processor.description",shape:"rectangle"}}),r.model()],e.AgentOutputProcessorNode);const Ud=[e.AgentOutputProcessorNode];e.AgentGuardrailNode=class extends Er{execute(e){return{resource:{type:"mastra.guardrail",guardrailType:this.guardrailType,strategy:this.strategy,options:this.options,input:e.inputs}}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.guardrailType.label",type:"select"}),Ue({handle:"guardrailType",userControlled:!0}),i.__metadata("design:type",Object)],e.AgentGuardrailNode.prototype,"guardrailType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.strategy.label",type:"select"}),Ue({handle:"strategy",userControlled:!0}),i.__metadata("design:type",String)],e.AgentGuardrailNode.prototype,"strategy",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.options.label",type:"object"}),Ue({handle:"options",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentGuardrailNode.prototype,"options",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.modelAdapter.label",type:"object"}),Ue({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentGuardrailNode.prototype,"modelAdapter",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentGuardrailNode.prototype,"resource",void 0),i.__decorate([$e({category:nd.outputProcessors,handle:"guardrail"}),i.__metadata("design:type",Object)],e.AgentGuardrailNode.prototype,"guardrail",void 0),e.AgentGuardrailNode=i.__decorate([qe("core.agent.guardrail",{kind:"core.agent.guardrail",category:"Agent",width:128,height:112,labels:["agent","ai","guardrail","safety"],metadata:{title:"graph.node.agent.guardrail.name",description:"graph.node.agent.guardrail.description",shape:"rectangle"}}),r.model()],e.AgentGuardrailNode);const Bd=[e.AgentGuardrailNode];e.AgentHitlNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.hitl' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.hitl",backend:"local"})}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.AgentHitlNode.prototype,"value",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.hitl.fields.message.label",placeholder:"graph.node.agent.hitl.fields.message.placeholder",type:"textarea"}),Ue({handle:"message",userControlled:!0}),i.__metadata("design:type",String)],e.AgentHitlNode.prototype,"message",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.hitl.fields.prompt.label",type:"textarea"}),Ue({handle:"prompt",userControlled:!0}),i.__metadata("design:type",String)],e.AgentHitlNode.prototype,"prompt",void 0),i.__decorate([r.required(),Ue({handle:"resumeSchema"}),o.uielement("ngx-decaf-model-builder",{label:"graph.node.agent.hitl.fields.resumeSchema.label",placeholder:"graph.node.agent.hitl.fields.resumeSchema.placeholder"}),i.__metadata("design:type",Object)],e.AgentHitlNode.prototype,"resumeSchema",void 0),i.__decorate([Be({handle:"approved"}),i.__metadata("design:type",Object)],e.AgentHitlNode.prototype,"approvedOut",void 0),i.__decorate([Be({handle:"rejected"}),i.__metadata("design:type",Object)],e.AgentHitlNode.prototype,"rejectedOut",void 0),e.AgentHitlNode=i.__decorate([qe("core.agent.hitl",{kind:"core.agent.hitl",category:"Agent",width:128,height:112,labels:["agent","ai","hitl","suspend"],metadata:{title:"graph.node.agent.hitl.name",description:"graph.node.agent.hitl.description",shape:"rectangle"}}),r.model()],e.AgentHitlNode);const $d=[e.AgentHitlNode];e.McpServerTriggerNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.trigger.mcp' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.trigger.mcp",backend:"local"})}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.serverId.label",placeholder:"graph.node.agent.mcp_trigger.fields.serverId.placeholder",type:"text"}),Ue({handle:"serverId",userControlled:!0}),i.__metadata("design:type",String)],e.McpServerTriggerNode.prototype,"serverId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.title.label",type:"text"}),Ue({handle:"title",userControlled:!0}),i.__metadata("design:type",String)],e.McpServerTriggerNode.prototype,"title",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.instructions.label",type:"textarea"}),Ue({handle:"instructions",userControlled:!0}),i.__metadata("design:type",String)],e.McpServerTriggerNode.prototype,"instructions",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.transport.label",type:"select"}),Ue({handle:"transport",userControlled:!0}),i.__metadata("design:type",String)],e.McpServerTriggerNode.prototype,"transport",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.authMode.label",type:"select"}),Ue({handle:"authMode",userControlled:!0}),i.__metadata("design:type",String)],e.McpServerTriggerNode.prototype,"authMode",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.authCredentialRef.label",type:"object"}),Ue({handle:"authCredentialRef",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.McpServerTriggerNode.prototype,"authCredentialRef",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.pendingCap.label",type:"number"}),Ue({handle:"pendingCap",userControlled:!0}),i.__metadata("design:type",Number)],e.McpServerTriggerNode.prototype,"pendingCap",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.pendingTimeoutMs.label",type:"number"}),Ue({handle:"pendingTimeoutMs",userControlled:!0}),i.__metadata("design:type",Number)],e.McpServerTriggerNode.prototype,"pendingTimeoutMs",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.McpServerTriggerNode.prototype,"resource",void 0),e.McpServerTriggerNode=i.__decorate([qe("core.agent.trigger.mcp",{kind:"core.agent.trigger.mcp",category:"Agent",width:128,height:112,labels:["agent","ai","trigger","mcp","server"],metadata:{title:"graph.node.agent.mcp_trigger.name",description:"graph.node.agent.mcp_trigger.description",shape:"rectangle"}}),r.model()],e.McpServerTriggerNode);const Wd=[e.McpServerTriggerNode];e.SlackChannelTriggerNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.trigger.slack' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.trigger.slack",backend:"local"})}},i.__decorate([r.required(),Be({handle:"message"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"message",void 0),i.__decorate([r.required(),Be({handle:"sessionId"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"sessionId",void 0),i.__decorate([r.required(),Be({handle:"userId"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"userId",void 0),i.__decorate([r.required(),Be({handle:"threadId"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"threadId",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"resource",void 0),e.SlackChannelTriggerNode=i.__decorate([qe("core.agent.trigger.slack",{kind:"core.agent.trigger.slack",category:"Agent",icon:"ti-brand-slack",width:96,height:96,labels:["agent","ai","trigger","channel","slack"],metadata:{title:"graph.node.agent.slack_trigger.name",description:"graph.node.agent.slack_trigger.description"}}),r.model()],e.SlackChannelTriggerNode);const Vd=[e.SlackChannelTriggerNode];e.DiscordChannelTriggerNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.trigger.discord' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.trigger.discord",backend:"local"})}},i.__decorate([r.required(),Be({handle:"message"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"message",void 0),i.__decorate([r.required(),Be({handle:"sessionId"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"sessionId",void 0),i.__decorate([r.required(),Be({handle:"userId"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"userId",void 0),i.__decorate([r.required(),Be({handle:"threadId"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"threadId",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"resource",void 0),e.DiscordChannelTriggerNode=i.__decorate([qe("core.agent.trigger.discord",{kind:"core.agent.trigger.discord",category:"Agent",icon:"ti-brand-discord",width:96,height:96,labels:["agent","ai","trigger","channel","discord"],metadata:{title:"graph.node.agent.discord_trigger.name",description:"graph.node.agent.discord_trigger.description"}}),r.model()],e.DiscordChannelTriggerNode);const Kd=[e.DiscordChannelTriggerNode];e.TelegramChannelTriggerNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.trigger.telegram' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.trigger.telegram",backend:"local"})}},i.__decorate([r.required(),Be({handle:"message"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"message",void 0),i.__decorate([r.required(),Be({handle:"sessionId"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"sessionId",void 0),i.__decorate([r.required(),Be({handle:"userId"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"userId",void 0),i.__decorate([r.required(),Be({handle:"threadId"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"threadId",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"resource",void 0),e.TelegramChannelTriggerNode=i.__decorate([qe("core.agent.trigger.telegram",{kind:"core.agent.trigger.telegram",category:"Agent",icon:"ti-brand-telegram",width:96,height:96,labels:["agent","ai","trigger","channel","telegram"],metadata:{title:"graph.node.agent.telegram_trigger.name",description:"graph.node.agent.telegram_trigger.description"}}),r.model()],e.TelegramChannelTriggerNode);const zd=[e.TelegramChannelTriggerNode];e.TeamsChannelTriggerNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.trigger.teams' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.trigger.teams",backend:"local"})}},i.__decorate([r.required(),Be({handle:"message"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"message",void 0),i.__decorate([r.required(),Be({handle:"sessionId"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"sessionId",void 0),i.__decorate([r.required(),Be({handle:"userId"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"userId",void 0),i.__decorate([r.required(),Be({handle:"threadId"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"threadId",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"resource",void 0),e.TeamsChannelTriggerNode=i.__decorate([qe("core.agent.trigger.teams",{kind:"core.agent.trigger.teams",category:"Agent",icon:"ti-brand-teams",width:96,height:96,labels:["agent","ai","trigger","channel","teams"],metadata:{title:"graph.node.agent.teams_trigger.name",description:"graph.node.agent.teams_trigger.description"}}),r.model()],e.TeamsChannelTriggerNode);const Qd=[e.TeamsChannelTriggerNode];e.SlackChannelResponseNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.response.slack' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.response.slack",backend:"local"})}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.slack_response.fields.response.label",type:"textarea"}),Ue({handle:"response"}),i.__metadata("design:type",Object)],e.SlackChannelResponseNode.prototype,"response",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.slack_response.fields.threadId.label",type:"text"}),Ue({handle:"threadId",userControlled:!0}),i.__metadata("design:type",String)],e.SlackChannelResponseNode.prototype,"threadId",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.SlackChannelResponseNode.prototype,"resource",void 0),e.SlackChannelResponseNode=i.__decorate([qe("core.agent.response.slack",{kind:"core.agent.response.slack",category:"Agent",icon:"ti-brand-slack",width:96,height:96,labels:["agent","ai","response","channel","slack"],metadata:{title:"graph.node.agent.slack_response.name",description:"graph.node.agent.slack_response.description"}}),r.model()],e.SlackChannelResponseNode);const Jd=[e.SlackChannelResponseNode];e.DiscordChannelResponseNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.response.discord' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.response.discord",backend:"local"})}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.discord_response.fields.response.label",type:"textarea"}),Ue({handle:"response"}),i.__metadata("design:type",Object)],e.DiscordChannelResponseNode.prototype,"response",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.discord_response.fields.threadId.label",type:"text"}),Ue({handle:"threadId",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordChannelResponseNode.prototype,"threadId",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.DiscordChannelResponseNode.prototype,"resource",void 0),e.DiscordChannelResponseNode=i.__decorate([qe("core.agent.response.discord",{kind:"core.agent.response.discord",category:"Agent",icon:"ti-brand-discord",width:96,height:96,labels:["agent","ai","response","channel","discord"],metadata:{title:"graph.node.agent.discord_response.name",description:"graph.node.agent.discord_response.description"}}),r.model()],e.DiscordChannelResponseNode);const Xd=[e.DiscordChannelResponseNode];e.TelegramChannelResponseNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.response.telegram' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.response.telegram",backend:"local"})}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.telegram_response.fields.response.label",type:"textarea"}),Ue({handle:"response"}),i.__metadata("design:type",Object)],e.TelegramChannelResponseNode.prototype,"response",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.telegram_response.fields.threadId.label",type:"text"}),Ue({handle:"threadId",userControlled:!0}),i.__metadata("design:type",String)],e.TelegramChannelResponseNode.prototype,"threadId",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.TelegramChannelResponseNode.prototype,"resource",void 0),e.TelegramChannelResponseNode=i.__decorate([qe("core.agent.response.telegram",{kind:"core.agent.response.telegram",category:"Agent",icon:"ti-brand-telegram",width:96,height:96,labels:["agent","ai","response","channel","telegram"],metadata:{title:"graph.node.agent.telegram_response.name",description:"graph.node.agent.telegram_response.description"}}),r.model()],e.TelegramChannelResponseNode);const Yd=[e.TelegramChannelResponseNode];e.TeamsChannelResponseNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.response.teams' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.response.teams",backend:"local"})}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.teams_response.fields.response.label",type:"textarea"}),Ue({handle:"response"}),i.__metadata("design:type",Object)],e.TeamsChannelResponseNode.prototype,"response",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.teams_response.fields.threadId.label",type:"text"}),Ue({handle:"threadId",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsChannelResponseNode.prototype,"threadId",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.TeamsChannelResponseNode.prototype,"resource",void 0),e.TeamsChannelResponseNode=i.__decorate([qe("core.agent.response.teams",{kind:"core.agent.response.teams",category:"Agent",icon:"ti-brand-teams",width:96,height:96,labels:["agent","ai","response","channel","teams"],metadata:{title:"graph.node.agent.teams_response.name",description:"graph.node.agent.teams_response.description"}}),r.model()],e.TeamsChannelResponseNode);const Zd=[e.TeamsChannelResponseNode];e.AgentVoiceNode=class extends Er{execute(e){throw new Ao("Node kind 'core.agent.voice' requires the mastra engine, which the local backend does not provide",po,{kind:"core.agent.voice",backend:"local"})}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.speaker.label",type:"text"}),Ue({handle:"speaker",userControlled:!0}),i.__metadata("design:type",String)],e.AgentVoiceNode.prototype,"speaker",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.speechModel.label",type:"object"}),Ue({handle:"speechModel",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentVoiceNode.prototype,"speechModel",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.listeningModel.label",type:"object"}),Ue({handle:"listeningModel",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentVoiceNode.prototype,"listeningModel",void 0),i.__decorate([r.required(),Be({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentVoiceNode.prototype,"resource",void 0),e.AgentVoiceNode=i.__decorate([qe("core.agent.voice",{kind:"core.agent.voice",category:"Agent",icon:"ti-volume-2",shape:"rounded",width:96,height:96,labels:["agent","ai","voice","speech"],metadata:{title:"graph.node.agent.voice.name",description:"graph.node.agent.voice.description"}}),r.model()],e.AgentVoiceNode);const es=[e.AgentVoiceNode];function ts(e,t,o,a){const r=t??o;if(null==e)return Math.min(o,r);const n=Number(e);if(!Number.isFinite(n)||0>=n)throw new Io(a+" loop maxIterations must be a positive finite number");return Math.min(Math.floor(n),r)}function os(e,t,o){const a=t.node.loop,r=t.metadata?.loop;if(!a?.body&&!r?.body)throw new Io(o+" node is missing loop configuration (instance.loop.body)");const n=t=>{const o=e[t]??a?.[t]??r?.[t],n=Number(o);return void 0!==o&&Number.isFinite(n)?n:void 0},i=t=>{const o=e[t]??r?.[t];return"string"==typeof o?o:void 0};return{body:a?.body??r?.body,maxIterations:n("maxIterations"),timeoutMs:n("timeoutMs"),concurrency:n("concurrency"),condition:e.condition??r?.condition,inputPort:i("inputPort"),outputPort:i("outputPort"),itemPort:i("itemPort"),resultPort:i("resultPort"),statePort:i("statePort"),slice:n("slice")}}e.GraphForeachLoopNode=class extends Er{async execute(e,t){const o=os(this,t,"foreach"),a=e.inputs,r=a.items,n=ts(o.maxIterations,t.limits?.maxForeachIterations,1e3,"foreach");if(!Array.isArray(r))throw new Io("foreach input 'items' must be an array");const i=t.engine;if(!i)throw new Ao("foreach node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const d=Number(a.slice??o.slice??1),s=Number.isFinite(d)&&d>0?Math.floor(d):1,l=s>1?Math.ceil(r.length/s):r.length;if(l>n)throw new Eo(`foreach exceeded max iterations (${l} > ${n})`);const c=o.itemPort??"item",p=o.resultPort??"result",u=o.statePort??"state",g=o.body,h=[];let m=a.state,f=!1;await t.emit({type:be.LOOP_STARTED});for(let e=0;l>e;e++){await t.emit({type:be.LOOP_ITERATION_STARTED,iteration:e});const o=s>1?r.slice(e*s,e*s+s):r[e],a={[c]:o,index:e};s>1&&(a.slice=o),void 0!==m&&(a[u]=m);try{const r=await i.execute(g,a,{parentRunId:t.runId,path:[...t.path,"iteration:"+e],metadata:{item:o,index:e,slice:s},auth:t.auth},t);h.push(r.outputs[p]),void 0!==r.outputs[u]&&(m=r.outputs[u])}catch(o){if(o instanceof Co){const a=o.details?.value;void 0!==a&&h.push(a),f=!0,await t.emit({type:be.LOOP_ITERATION_COMPLETED,iteration:e,metadata:{broken:!0}});break}throw o}await t.emit({type:be.LOOP_ITERATION_COMPLETED,iteration:e})}await t.emit({type:be.LOOP_COMPLETED,metadata:{broken:f}});const _={results:h,completed:h,iterations:h.length,broken:f};return void 0!==m&&(_[u]=m),_}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.items.label",placeholder:"graph.node.loop.foreach.fields.items.placeholder",type:"textarea"}),Ue({handle:"items"}),i.__metadata("design:type",Array)],e.GraphForeachLoopNode.prototype,"items",void 0),i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.slice.label",placeholder:"graph.node.loop.foreach.fields.slice.placeholder",type:"number"}),Ue({handle:"slice"}),i.__metadata("design:type",Number)],e.GraphForeachLoopNode.prototype,"slice",void 0),i.__decorate([r.required(),Be({handle:"item"}),i.__metadata("design:type",Object)],e.GraphForeachLoopNode.prototype,"item",void 0),i.__decorate([r.required(),$e({handle:"loop",connectionRules:{allowSelf:!0,maxConnections:1}}),i.__metadata("design:type",Object)],e.GraphForeachLoopNode.prototype,"loop",void 0),i.__decorate([r.required(),Be({handle:"completed"}),i.__metadata("design:type",Array)],e.GraphForeachLoopNode.prototype,"completed",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.maxIterations.label",type:"number"}),Ue({handle:"maxIterations",userControlled:!0}),i.__metadata("design:type",Number)],e.GraphForeachLoopNode.prototype,"maxIterations",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.condition.label",type:"code"}),Ue({handle:"condition",userControlled:!0}),i.__metadata("design:type",Object)],e.GraphForeachLoopNode.prototype,"condition",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.itemPort.label",type:"text"}),Ue({handle:"itemPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphForeachLoopNode.prototype,"itemPort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.resultPort.label",type:"text"}),Ue({handle:"resultPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphForeachLoopNode.prototype,"resultPort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.statePort.label",type:"text"}),Ue({handle:"statePort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphForeachLoopNode.prototype,"statePort",void 0),e.GraphForeachLoopNode=i.__decorate([qe("graph-foreach-loop-node",{kind:"core.loop.foreach",category:"Loop",color:"#eab308",icon:"ti-repeat",width:120,height:140,labels:["loop","iteration","foreach"],metadata:{title:"graph.node.loop.foreach.name",description:"graph.node.loop.foreach.description",loop:{maxIterations:100,itemPort:"item",resultPort:"result",slice:1}}}),r.model()],e.GraphForeachLoopNode);class as{constructor(){this.expressionEvaluator=new ia}evaluate(t,o){if(this.isConditionExpression(t))return this.expressionEvaluator.evaluate(t,o);const a=this.resolveValue(t.left,o),r=t.right;switch(t.type){case e.GraphConditionType.TRUTHY:return!!a;case e.GraphConditionType.FALSY:return!a;case e.GraphConditionType.EQUALS:return a===r;case e.GraphConditionType.NOT_EQUALS:return a!==r;case e.GraphConditionType.GREATER_THAN:return Number(a)>Number(r);case e.GraphConditionType.GREATER_THAN_OR_EQUAL:return Number(a)>=Number(r);case e.GraphConditionType.LESS_THAN:return Number(r)>Number(a);case e.GraphConditionType.LESS_THAN_OR_EQUAL:return Number(r)>=Number(a);case e.GraphConditionType.EXISTS:return null!=a;case e.GraphConditionType.CUSTOM:throw new Ao("Custom condition evaluators are not supported in v1","GRAPH_CUSTOM_CONDITION_UNSUPPORTED");default:throw new Ao(`Unknown condition type '${t.type}'`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:t})}}async evaluateAsync(e,t,o,a){return da(e)?la(e,a,o):this.evaluate(e,t)}resolveValue(e,t){if(!e)return t;const o=e.split(".");let a=t;for(const e of o){if(null==a)return;a=a[e]}return a}isConditionExpression(e){return"string"==typeof e.op}}function rs(e,t,o,a={}){return{id:e,label:t,direction:o,...a}}function ns(e){const t=e,o=Ce(t),a=o?.metadata?.title;return Zt(t,a?{name:a}:{})}function is(e,t){const o=e,a=Ce(o),r=a?.metadata?.title;return Zt(o,{...r?{name:r}:{},icon:{type:"catalogue",name:t}})}function ds(e,t,o){const a={type:"credential",id:"credentialRef",label:o,required:!1,credentialType:t};return{...e,parameters:[...e.parameters,a],credentials:[...(e.credentials??[]).filter(e=>e.type!==t),{type:t,required:!1}]}}e.GraphUntilLoopNode=class extends Er{async execute(e,t){const o=os(this,t,"until"),a=e.inputs,r=ts(o.maxIterations,t.limits?.maxLoopIterations,100,"until"),n=o.condition;if(!n)throw new Io("until node is missing a condition");const i=o.statePort??"state",d=o.inputPort??i,s=o.outputPort??i,l=o.body,c=t.engine;if(!c)throw new Ao("until node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=a.state,u=0;await t.emit({type:be.LOOP_STARTED});let g=!1;do{if(u>=r)throw await t.emit({type:be.LOOP_LIMIT_REACHED,iteration:u}),new Eo(`until loop exceeded max iterations (${r})`);await t.emit({type:be.LOOP_ITERATION_STARTED,iteration:u}),p=(await c.execute(l,{[d]:p,iteration:u},{parentRunId:t.runId,path:[...t.path,"iteration:"+u],auth:t.auth},t)).outputs[s],await t.emit({type:be.LOOP_ITERATION_COMPLETED,iteration:u});const e=await(new as).evaluateAsync(n,p,t,{...a,state:p});await t.emit({type:be.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:e}}),u++,g=e}while(!g);return await t.emit({type:be.LOOP_COMPLETED}),{state:p,iterations:u}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.state.label",placeholder:"graph.node.loop.until.fields.state.placeholder",type:"textarea"}),Ue({handle:"state"}),i.__metadata("design:type",Object)],e.GraphUntilLoopNode.prototype,"state",void 0),i.__decorate([r.required(),Be({handle:"state"}),i.__metadata("design:type",Object)],e.GraphUntilLoopNode.prototype,"stateOut",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.maxIterations.label",type:"number"}),Ue({handle:"maxIterations",userControlled:!0}),i.__metadata("design:type",Number)],e.GraphUntilLoopNode.prototype,"maxIterations",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.condition.label",type:"code"}),Ue({handle:"condition",userControlled:!0}),i.__metadata("design:type",Object)],e.GraphUntilLoopNode.prototype,"condition",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.statePort.label",type:"text"}),Ue({handle:"statePort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphUntilLoopNode.prototype,"statePort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.inputPort.label",type:"text"}),Ue({handle:"inputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphUntilLoopNode.prototype,"inputPort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.outputPort.label",type:"text"}),Ue({handle:"outputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphUntilLoopNode.prototype,"outputPort",void 0),e.GraphUntilLoopNode=i.__decorate([qe("graph-until-loop-node",{kind:"core.loop.until",category:"Loop",color:"#eab308",icon:"ti-player-stop",width:96,height:96,labels:["loop","conditional","until"],metadata:{title:"graph.node.loop.until.name",description:"graph.node.loop.until.description",loop:{maxIterations:50,statePort:"state",condition:{type:"greaterThanOrEqual",left:"iteration",right:2}}}}),r.model()],e.GraphUntilLoopNode),e.GraphWhileLoopNode=class extends Er{async execute(e,t){const o=os(this,t,"while"),a=e.inputs,r=ts(o.maxIterations,t.limits?.maxLoopIterations,100,"while"),n=o.condition;if(!n)throw new Io("while node is missing a condition");const i=o.statePort??"state",d=o.inputPort??i,s=o.outputPort??i,l=o.body,c=t.engine;if(!c)throw new Ao("while node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=a.state,u=0;for(await t.emit({type:be.LOOP_STARTED});await(new as).evaluateAsync(n,p,t,{...a,state:p});){if(u>=r)throw await t.emit({type:be.LOOP_LIMIT_REACHED,iteration:u}),new Eo(`while loop exceeded max iterations (${r})`);await t.emit({type:be.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:!0}}),await t.emit({type:be.LOOP_ITERATION_STARTED,iteration:u}),p=(await c.execute(l,{[d]:p,iteration:u},{parentRunId:t.runId,path:[...t.path,"iteration:"+u],auth:t.auth},t)).outputs[s],await t.emit({type:be.LOOP_ITERATION_COMPLETED,iteration:u}),u++}return await t.emit({type:be.LOOP_COMPLETED}),{state:p,iterations:u}}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.state.label",placeholder:"graph.node.loop.while.fields.state.placeholder",type:"textarea"}),Ue({handle:"state"}),i.__metadata("design:type",Object)],e.GraphWhileLoopNode.prototype,"state",void 0),i.__decorate([r.required(),Be({handle:"state"}),i.__metadata("design:type",Object)],e.GraphWhileLoopNode.prototype,"stateOut",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.maxIterations.label",type:"number"}),Ue({handle:"maxIterations",userControlled:!0}),i.__metadata("design:type",Number)],e.GraphWhileLoopNode.prototype,"maxIterations",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.condition.label",type:"code"}),Ue({handle:"condition",userControlled:!0}),i.__metadata("design:type",Object)],e.GraphWhileLoopNode.prototype,"condition",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.statePort.label",type:"text"}),Ue({handle:"statePort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphWhileLoopNode.prototype,"statePort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.inputPort.label",type:"text"}),Ue({handle:"inputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphWhileLoopNode.prototype,"inputPort",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.outputPort.label",type:"text"}),Ue({handle:"outputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphWhileLoopNode.prototype,"outputPort",void 0),e.GraphWhileLoopNode=i.__decorate([qe("graph-while-loop-node",{kind:"core.loop.while",category:"Loop",color:"#eab308",icon:"ti-arrows-loop",width:96,height:96,labels:["loop","conditional","while"],metadata:{title:"graph.node.loop.while.name",description:"graph.node.loop.while.description",loop:{maxIterations:50,statePort:"state",condition:{type:"lessThan",left:"iteration",right:3}}}}),r.model()],e.GraphWhileLoopNode),e.GraphInputValueNode=class extends Er{execute(e){const t=e.inputs;return{value:t?.value??null}}},i.__decorate([Be({handle:"value",connectionRules:{allowMultiple:!0}}),i.__metadata("design:type",Object)],e.GraphInputValueNode.prototype,"value",void 0),e.GraphInputValueNode=i.__decorate([qe("graph-input-value-node",{kind:"value",category:"Boundary",color:"#0f766e",icon:"ti-circle-plus",labels:["workflow","input","value"],metadata:{title:"graph.node.boundary.input.name",description:"graph.node.boundary.input.description"}}),r.model()],e.GraphInputValueNode),e.GraphOutputValueNode=class extends Er{execute(e){return{}}},i.__decorate([r.required(),Ue({handle:"value"}),i.__metadata("design:type",Object)],e.GraphOutputValueNode.prototype,"value",void 0),e.GraphOutputValueNode=i.__decorate([qe("graph-output-value-node",{kind:"result",category:"Boundary",color:"#0f766e",icon:"ti-circle-minus",width:96,height:96,labels:["workflow","output","value"],metadata:{title:"graph.node.boundary.output.name",description:"graph.node.boundary.output.description"}}),r.model()],e.GraphOutputValueNode);const ss={kind:"core.loop.foreach",capabilities:["loop"],display:{name:"graph.node.loop.foreach.name",description:"graph.node.loop.foreach.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-repeat"},width:120,height:140,labels:["loop","iteration","foreach"]},inputs:[rs("items","graph.node.loop.foreach.ports.input.items.label","input",{required:!0,schema:{type:"array",items:{type:"any"}}}),rs("slice","graph.node.loop.foreach.ports.input.slice.label","input",{schema:{type:"number",integer:!0,min:1}}),rs("state","graph.node.loop.foreach.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[rs("results","graph.node.loop.foreach.ports.output.results.label","output",{schema:{type:"array",items:{type:"any"}}}),rs("completed","graph.node.loop.foreach.ports.output.completed.label","output",{schema:{type:"array",items:{type:"any"}}}),rs("iterations","graph.node.loop.foreach.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}}),rs("broken","graph.node.loop.foreach.ports.output.broken.label","output",{schema:{type:"boolean"}}),rs("state","graph.node.loop.foreach.ports.output.state.label","output",{schema:{type:"any"}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.foreach.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.foreach.fields.condition.label"},{type:"string",id:"itemPort",label:"graph.node.loop.foreach.fields.itemPort.label"},{type:"string",id:"resultPort",label:"graph.node.loop.foreach.fields.resultPort.label"},{type:"string",id:"statePort",label:"graph.node.loop.foreach.fields.statePort.label"},{type:"number",id:"slice",label:"graph.node.loop.foreach.fields.slice.label",integer:!0,min:1}]},ls={kind:"core.loop.while",capabilities:["loop"],display:{name:"graph.node.loop.while.name",description:"graph.node.loop.while.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-arrows-loop"},width:120,height:140,labels:["loop","conditional","while"]},inputs:[rs("state","graph.node.loop.while.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[rs("state","graph.node.loop.while.ports.output.state.label","output",{schema:{type:"any"}}),rs("iterations","graph.node.loop.while.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.while.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.while.fields.condition.label",required:!0},{type:"string",id:"statePort",label:"graph.node.loop.while.fields.statePort.label"},{type:"string",id:"inputPort",label:"graph.node.loop.while.fields.inputPort.label"},{type:"string",id:"outputPort",label:"graph.node.loop.while.fields.outputPort.label"}]},cs={kind:"core.loop.until",capabilities:["loop"],display:{name:"graph.node.loop.until.name",description:"graph.node.loop.until.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-player-stop"},width:120,height:140,labels:["loop","conditional","until"]},inputs:[rs("state","graph.node.loop.until.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[rs("state","graph.node.loop.until.ports.output.state.label","output",{schema:{type:"any"}}),rs("iterations","graph.node.loop.until.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.until.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.until.fields.condition.label",required:!0},{type:"string",id:"statePort",label:"graph.node.loop.until.fields.statePort.label"},{type:"string",id:"inputPort",label:"graph.node.loop.until.fields.inputPort.label"},{type:"string",id:"outputPort",label:"graph.node.loop.until.fields.outputPort.label"}]},ps=[ns(e.GraphInputValueNode),ns(e.GraphOutputValueNode),ns(e.DateTimeNode),ns(e.DataTableNode),ns(e.FilterNode),ns(e.LimitNode),ns(e.MergeNode),ns(e.RenameKeysNode),ns(e.SetNode),ns(e.SortNode),ns(e.SplitOutNode),ns(e.AggregateNode),ns(e.ItemListsNode),ns(e.CompareDatasetsNode),ns(e.SummarizeNode),ns(e.RemoveDuplicatesNode),ns(e.ExtractFromFileNode),ns(e.HttpRequestNode),ns(e.ReadPDFNode),ns(e.ReadWriteFileNode),ds(ns(e.PostgresNode),"postgres","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.MySqlNode),"mysql","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.MicrosoftSqlNode),"mssql","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.RedisNode),"redis","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.RabbitMqNode),"rabbitmq","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.S3StorageNode),"s3","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.AwsS3StorageNode),"s3","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.GoogleCloudStorageNode),"gcs","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.AzureStorageNode),"azure-blob","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.CryptoNode),"crypto","graph.node.devops.common.fields.credentialRef.label"),ds(ns(e.JwtNode),"jwt","graph.node.devops.common.fields.credentialRef.label"),(e=>{const t=ns(e);return{...t,metadata:{...t.metadata??{},danger:!0,requiresOptIn:!0,dangerReason:"Executes arbitrary shell commands with the host process privileges; expose only behind an explicit operator opt-in."}}})(e.ExecuteCommandNode),ds(ns(e.FtpNode),"sftp","graph.node.devops.common.fields.credentialRef.label"),ds(ns(e.GithubNode),"github","graph.node.devops.common.fields.credentialRef.label"),ds(ns(e.GitlabNode),"gitlab","graph.node.devops.common.fields.credentialRef.label"),ds(ns(e.SlackNode),"slack","graph.node.comms.common.fields.credentialRef.label"),ds(ns(e.TelegramNode),"telegram","graph.node.comms.common.fields.credentialRef.label"),ds(ns(e.TeamsNode),"teams","graph.node.comms.common.fields.credentialRef.label"),ds(ns(e.GmailNode),"gmail","graph.node.comms.common.fields.credentialRef.label"),ds(ns(e.EmailSendNode),"email","graph.node.comms.common.fields.credentialRef.label"),ds(ns(e.DiscordNode),"discord","graph.node.comms.common.fields.credentialRef.label"),ds(ns(e.WhatsAppNode),"whatsapp","graph.node.comms.common.fields.credentialRef.label"),ds(ns(e.MicrosoftOutlookNode),"microsoft-outlook","graph.node.comms.common.fields.credentialRef.label"),ds(ns(e.GoogleSheetsNode),"google-sheets","graph.node.io.common.fields.credentialRef.label"),ds(ns(e.AirtableNode),"airtable","graph.node.io.common.fields.credentialRef.label"),ds(ns(e.GraphqlNode),"graphql","graph.node.io.common.fields.credentialRef.label"),ds(ns(e.MicrosoftExcelNode),"microsoft-excel","graph.node.io.common.fields.credentialRef.label"),ds(ns(e.ConfluenceNode),"confluence","graph.node.io.common.fields.credentialRef.label"),ds(ns(e.JiraNode),"jira","graph.node.io.common.fields.credentialRef.label"),ds(ns(e.GoogleDocsNode),"google-docs","graph.node.io.common.fields.credentialRef.label"),ds(ns(e.MicrosoftSharePointNode),"microsoft-sharepoint","graph.node.io.common.fields.credentialRef.label"),ds(ns(e.GoogleCalendarNode),"google-calendar","graph.node.io.common.fields.credentialRef.label"),ns(e.SpreadsheetFileNode),ns(e.ConvertToFileNode),ns(e.HtmlNode),ns(e.HtmlExtractNode),ns(e.MarkdownNode),ns(e.XmlNode),ns(e.ReadBinaryFileNode),ns(e.ReadBinaryFilesNode),ns(e.WriteBinaryFileNode),ns(e.RespondToWebhookNode),ns(e.ExecuteSubWorkflowNode),ns(e.ExecuteWorkflowTriggerNode),ns(e.ErrorTriggerNode),ns(e.WorkflowTriggerNode),ds(ns(e.RabbitMqTriggerNode),"rabbitmq","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.RedisTriggerNode),"redis","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.SseTriggerNode),"token","graph.node.storage.common.fields.credentialRef.label"),ds(ns(e.PostgresTriggerNode),"postgres","graph.node.storage.common.fields.credentialRef.label"),ns(e.ManualTriggerNode),ns(e.WebhookTriggerNode),ns(e.ScheduleTriggerNode),ns(e.EventTriggerNode),ns(e.FormTriggerNode),ns(e.ChatTriggerNode),(us=ns(e.IfFlowNode),{...us,dynamicPorts:[{type:"togglePort",parameter:"else",equals:!0,port:{id:"else",label:"graph.node.flow_control.if.ports.output.else.label",direction:"output",schema:{type:"any"}}}]}),(e=>({...e,outputs:[],parameters:[...e.parameters,{type:"collection",id:"cases",label:"graph.node.flow_control.switch.fields.cases.label",required:!0,itemIdPath:"outputPort",itemLabelPath:"label"},{type:"boolean",id:"hasDefault",label:"graph.node.flow_control.switch.fields.hasDefault.label",defaultValue:!1},{type:"object",id:"switch",label:"graph.node.flow_control.switch.fields.switch.label",required:!1}],dynamicPorts:[{type:"repeatFromParameter",parameter:"cases",itemIdPath:"outputPort",itemLabelPath:"label",direction:"output",portIdTemplate:"${id}",defaultPort:{id:"case",label:"graph.node.flow_control.switch.ports.output.case.label",direction:"output",schema:{type:"any"}}},{type:"togglePort",parameter:"hasDefault",equals:!0,port:{id:"default",label:"graph.node.flow_control.switch.ports.output.default.label",direction:"output",schema:{type:"any"}}}]}))(ns(e.SwitchFlowNode)),ns(e.MapNode),ns(e.DelayFlowNode),ns(e.ErrorBoundaryFlowNode),ns(e.HumanApprovalFlowNode),ns(e.CodeNode),ns(e.LogFlowNode),ns(e.UtilityLogNode),ns(e.BreakFlowNode),ns(e.AgentNode),ns(e.AgentToolNode),ns(e.AgentToolSelectorNode),ns(e.AgentHookNode),ns(e.AgentToolDenyNode),ns(e.AgentDelegationHookNode),ns(e.AgentSkillNode),ns(e.AgentSkillSelectorNode),ns(e.AgentSandboxNode),ns(e.AgentScorerNode),ns(e.AgentScorerSelectorNode),ns(e.AgentMemoryNode),ns(e.AgentMemorySelectorNode),ns(e.AgentEmbeddingNode),ns(e.AgentVectorStoreNode),ns(e.AgentRetrieverNode),ns(e.AgentChunkingNode),ns(e.AgentRerankNode),ns(e.AgentQaChainNode),ns(e.AgentBasicChainNode),ns(e.AgentSummarizationChainNode),ns(e.AgentStructuredOutputParserNode),ns(e.AgentInformationExtractorNode),ns(e.AgentLangChainCodeNode),ns(e.AgentInputProcessorNode),ns(e.AgentOutputProcessorNode),ns(e.AgentGuardrailNode),ns(e.AgentHitlNode),ns(e.McpServerTriggerNode),is(e.SlackChannelTriggerNode,"ti-brand-slack"),is(e.DiscordChannelTriggerNode,"ti-brand-discord"),is(e.TelegramChannelTriggerNode,"ti-brand-telegram"),is(e.TeamsChannelTriggerNode,"ti-brand-teams"),is(e.SlackChannelResponseNode,"ti-brand-slack"),is(e.DiscordChannelResponseNode,"ti-brand-discord"),is(e.TelegramChannelResponseNode,"ti-brand-telegram"),is(e.TeamsChannelResponseNode,"ti-brand-teams"),is(e.AgentVoiceNode,"ti-volume-2"),ss,ls,cs];var us;const gs=Object.fromEntries(ps.map(e=>[e.kind,e])),hs=[e.ManualTriggerNode,e.WebhookTriggerNode,e.ScheduleTriggerNode,e.EventTriggerNode,e.FormTriggerNode,e.ChatTriggerNode],ms=[e.IfFlowNode,e.SwitchFlowNode,e.DelayFlowNode,e.ErrorBoundaryFlowNode,e.HumanApprovalFlowNode,e.LogFlowNode,e.BreakFlowNode],fs=[e.CodeNode,e.MapNode,e.UtilityLogNode],_s=[e.GraphForeachLoopNode,e.GraphWhileLoopNode,e.GraphUntilLoopNode],ys=[e.GraphInputValueNode,e.GraphOutputValueNode],bs=[e.AgentToolNode,e.AgentToolSelectorNode,e.AgentHookNode,e.AgentToolDenyNode,e.AgentDelegationHookNode,e.AgentSkillNode,e.AgentSkillSelectorNode,e.AgentSandboxNode,e.AgentScorerNode,e.AgentScorerSelectorNode],ws=[e.AgentMemoryNode,e.AgentMemorySelectorNode],Ns=[e.AgentEmbeddingNode,e.AgentVectorStoreNode,e.AgentRetrieverNode,e.AgentChunkingNode,e.AgentRerankNode,e.AgentQaChainNode,e.AgentBasicChainNode,e.AgentSummarizationChainNode,e.AgentStructuredOutputParserNode,e.AgentInformationExtractorNode,e.AgentLangChainCodeNode],vs=[e.AgentInputProcessorNode,e.AgentOutputProcessorNode,e.AgentGuardrailNode],As=[e.AgentHitlNode,e.McpServerTriggerNode],xs=[e.SlackChannelTriggerNode,e.DiscordChannelTriggerNode,e.TelegramChannelTriggerNode,e.TeamsChannelTriggerNode,e.SlackChannelResponseNode,e.DiscordChannelResponseNode,e.TelegramChannelResponseNode,e.TeamsChannelResponseNode,e.AgentVoiceNode],Is=[e.SetNode,e.MergeNode,e.FilterNode,e.SplitOutNode,e.DateTimeNode,e.DataTableNode,e.LimitNode,e.SortNode,e.RenameKeysNode,e.AggregateNode,e.ItemListsNode,e.CompareDatasetsNode,e.SummarizeNode,e.RemoveDuplicatesNode],Es=[e.HttpRequestNode,e.RespondToWebhookNode,e.ExtractFromFileNode,e.ReadPDFNode,e.ReadWriteFileNode,e.ConvertToFileNode,e.HtmlNode,e.HtmlExtractNode,e.MarkdownNode,e.XmlNode,e.ReadBinaryFileNode,e.ReadBinaryFilesNode,e.WriteBinaryFileNode],Ss={value:e.GraphInputValueNode,result:e.GraphOutputValueNode,"core.trigger.manual":e.ManualTriggerNode,"core.trigger.webhook":e.WebhookTriggerNode,"core.trigger.schedule":e.ScheduleTriggerNode,"core.trigger.event":e.EventTriggerNode,"core.trigger.form":e.FormTriggerNode,"core.trigger.chat":e.ChatTriggerNode,"core.flow.if":e.IfFlowNode,"core.flow.switch":e.SwitchFlowNode,"core.utility.map":e.MapNode,"core.flow.delay":e.DelayFlowNode,"core.flow.errorBoundary":e.ErrorBoundaryFlowNode,"core.flow.humanApproval":e.HumanApprovalFlowNode,"core.utility.code":e.CodeNode,"core.flow.log":e.LogFlowNode,"core.utility.log":e.UtilityLogNode,"core.flow.break":e.BreakFlowNode,"core.agent":e.AgentNode,"core.agent.tool":e.AgentToolNode,"core.agent.toolSelector":e.AgentToolSelectorNode,"core.agent.hook":e.AgentHookNode,"core.agent.toolDeny":e.AgentToolDenyNode,"core.agent.delegationHook":e.AgentDelegationHookNode,"core.agent.skill":e.AgentSkillNode,"core.agent.skillSelector":e.AgentSkillSelectorNode,"core.agent.sandbox":e.AgentSandboxNode,"core.agent.scorer":e.AgentScorerNode,"core.agent.scorerSelector":e.AgentScorerSelectorNode,"core.agent.memory":e.AgentMemoryNode,"core.agent.memorySelector":e.AgentMemorySelectorNode,"core.agent.embedding":e.AgentEmbeddingNode,"core.agent.vectorStore":e.AgentVectorStoreNode,"core.agent.retriever":e.AgentRetrieverNode,"core.agent.chunking":e.AgentChunkingNode,"core.agent.rerank":e.AgentRerankNode,"core.agent.chain.qa":e.AgentQaChainNode,"core.agent.chain.basic":e.AgentBasicChainNode,"core.agent.chain.summarization":e.AgentSummarizationChainNode,"core.agent.structuredOutputParser":e.AgentStructuredOutputParserNode,"core.agent.informationExtractor":e.AgentInformationExtractorNode,"core.agent.langchainCode":e.AgentLangChainCodeNode,"core.agent.inputProcessor":e.AgentInputProcessorNode,"core.agent.outputProcessor":e.AgentOutputProcessorNode,"core.agent.guardrail":e.AgentGuardrailNode,"core.agent.hitl":e.AgentHitlNode,"core.agent.trigger.mcp":e.McpServerTriggerNode,"core.agent.trigger.slack":e.SlackChannelTriggerNode,"core.agent.trigger.discord":e.DiscordChannelTriggerNode,"core.agent.trigger.telegram":e.TelegramChannelTriggerNode,"core.agent.trigger.teams":e.TeamsChannelTriggerNode,"core.agent.response.slack":e.SlackChannelResponseNode,"core.agent.response.discord":e.DiscordChannelResponseNode,"core.agent.response.telegram":e.TelegramChannelResponseNode,"core.agent.response.teams":e.TeamsChannelResponseNode,"core.agent.voice":e.AgentVoiceNode,"core.data.set":e.SetNode,"core.data.merge":e.MergeNode,"core.data.filter":e.FilterNode,"core.data.splitOut":e.SplitOutNode,"core.data.aggregate":e.AggregateNode,"core.data.itemLists":e.ItemListsNode,"core.data.compareDatasets":e.CompareDatasetsNode,"core.data.summarize":e.SummarizeNode,"core.data.removeDuplicates":e.RemoveDuplicatesNode,"core.data.dateTime":e.DateTimeNode,"core.data.dataTable":e.DataTableNode,"core.data.limit":e.LimitNode,"core.data.sort":e.SortNode,"core.data.renameKeys":e.RenameKeysNode,"core.io.httpRequest":e.HttpRequestNode,"core.io.respondToWebhook":e.RespondToWebhookNode,"core.io.extractFromFile":e.ExtractFromFileNode,"core.io.readPDF":e.ReadPDFNode,"core.io.readWriteFile":e.ReadWriteFileNode,"core.storage.postgres":e.PostgresNode,"core.storage.mySql":e.MySqlNode,"core.storage.microsoftSql":e.MicrosoftSqlNode,"core.storage.redis":e.RedisNode,"core.storage.rabbitmq":e.RabbitMqNode,"core.storage.s3":e.S3StorageNode,"core.storage.awsS3":e.AwsS3StorageNode,"core.storage.googleCloudStorage":e.GoogleCloudStorageNode,"core.storage.azureStorage":e.AzureStorageNode,"core.devops.crypto":e.CryptoNode,"core.devops.jwt":e.JwtNode,"core.devops.executeCommand":e.ExecuteCommandNode,"core.devops.ftp":e.FtpNode,"core.devops.github":e.GithubNode,"core.devops.gitlab":e.GitlabNode,"core.comms.slack":e.SlackNode,"core.comms.telegram":e.TelegramNode,"core.comms.teams":e.TeamsNode,"core.comms.gmail":e.GmailNode,"core.comms.emailSend":e.EmailSendNode,"core.comms.discord":e.DiscordNode,"core.comms.whatsApp":e.WhatsAppNode,"core.comms.microsoftOutlook":e.MicrosoftOutlookNode,"core.io.googleSheets":e.GoogleSheetsNode,"core.io.airtable":e.AirtableNode,"core.io.spreadsheetFile":e.SpreadsheetFileNode,"core.io.graphql":e.GraphqlNode,"core.io.microsoftExcel":e.MicrosoftExcelNode,"core.io.confluence":e.ConfluenceNode,"core.io.jira":e.JiraNode,"core.io.googleDocs":e.GoogleDocsNode,"core.io.microsoftSharePoint":e.MicrosoftSharePointNode,"core.io.googleCalendar":e.GoogleCalendarNode,"core.io.convertToFile":e.ConvertToFileNode,"core.io.html":e.HtmlNode,"core.io.htmlExtract":e.HtmlExtractNode,"core.io.markdown":e.MarkdownNode,"core.io.xml":e.XmlNode,"core.io.readBinaryFile":e.ReadBinaryFileNode,"core.io.readBinaryFiles":e.ReadBinaryFilesNode,"core.io.writeBinaryFile":e.WriteBinaryFileNode,"core.flow.executeSubWorkflow":e.ExecuteSubWorkflowNode,"core.trigger.executeWorkflow":e.ExecuteWorkflowTriggerNode,"core.trigger.error":e.ErrorTriggerNode,"core.trigger.workflow":e.WorkflowTriggerNode,"core.trigger.rabbitmq":e.RabbitMqTriggerNode,"core.trigger.redis":e.RedisTriggerNode,"core.trigger.sse":e.SseTriggerNode,"core.trigger.postgres":e.PostgresTriggerNode,"core.loop.foreach":e.GraphForeachLoopNode,"core.loop.while":e.GraphWhileLoopNode,"core.loop.until":e.GraphUntilLoopNode};function Rs(e){return{execute:(t,o)=>e.instantiate({...Ir(o.node),...t.parameters,...o.node.state??{}}).execute(t,o)}}function Ts(){const e=[];for(const[t,o]of Object.entries(gs)){const a=Ss[t];a&&e.push(xr({manifest:o,executor:Rs(a)}))}return e}const Cs=["node","definition","executor","execute","ports","component"];function Os(e,t,o,a){return{code:e,path:t,message:o,...void 0!==a?.nodeId?{nodeId:a.nodeId}:{},...void 0!==a?.edgeId?{edgeId:a.edgeId}:{},...a?.details?{details:a.details}:{}}}function ks(e,t){const o=[];for(const a of Object.keys(e))Cs.includes(a)&&o.push(Os("document.forbidden-field",`${t}.${a}`,`Field '${a}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected at the boundary`,{details:{field:a}}));return o}function Ds(e,t){t.push(...ks(e,"$")),e.inputs.forEach((e,o)=>t.push(...ks(e,`inputs[${o}]`))),e.outputs.forEach((e,o)=>t.push(...ks(e,`outputs[${o}]`)));for(const o of e.nodes)t.push(...ks(o,`nodes[${o.id}]`)),o.loop&&(t.push(...ks(o.loop,`nodes[${o.id}].loop`)),Ds(o.loop.body,t));for(const o of e.edges)t.push(...ks(o,`edges[${o.id}]`))}function Ps(e,t){const o=[];e.nodes.length>t.maxNodes&&o.push(Os("document.limit.nodes","$.nodes",`Document declares ${e.nodes.length} nodes; at most ${t.maxNodes} are allowed`,{details:{count:e.nodes.length,limit:t.maxNodes}})),e.edges.length>t.maxEdges&&o.push(Os("document.limit.edges","$.edges",`Document declares ${e.edges.length} edges; at most ${t.maxEdges} are allowed`,{details:{count:e.edges.length,limit:t.maxEdges}}));const a=Gs(e);a>t.maxNestingDepth&&o.push(Os("document.limit.depth","$.nodes",`Document nests loop bodies ${a} levels deep; at most ${t.maxNestingDepth} levels are allowed`,{details:{depth:a,limit:t.maxNestingDepth}}));const r=Buffer.byteLength(JSON.stringify(e),"utf8");return r>t.maxDocumentBytes&&o.push(Os("document.limit.size","$",`Document serializes to ${r} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,{details:{bytes:r,limit:t.maxDocumentBytes}})),o}function Gs(e,t=0){let o=t;for(const a of e.nodes)a.loop?.body&&(o=Math.max(o,Gs(a.loop.body,t+1)));return o}async function Ms(e,t,...o){const a=[];for(const r of e.nodes)t.has(r.kind,...o)||a.push(Os("node.unknown-kind",`nodes[${r.id}].kind`,`Node '${r.id}' references kind '${r.kind}' which is not registered in the backend catalogue`,{nodeId:r.id,details:{kind:r.kind}})),r.loop?.body&&a.push(...await Ms(r.loop.body,t,...o));return a}async function Fs(e,t={},...o){const a={...Rr,...t.limits},r=[];if(!It(e))return r.push(Os("document.shape","$","Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays")),{valid:!1,issues:r};if(!Je(e))return r.push(Os("document.json-unsafe","$","Document contains JSON-unsafe values: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected")),{valid:!1,issues:r};Ds(e,r),r.push(...(e=>{const t=[],o=new Set;for(const a of[...e.inputs,...e.outputs])o.has(a.id)?t.push(Os("document.duplicate-port-id",`ports[${a.id}]`,`Workflow port '${a.id}' is declared more than once; workflow port ids must be unique`)):o.add(a.id);const a=new Set;for(const o of e.nodes)a.has(o.id)?t.push(Os("document.duplicate-node-id",`nodes[${o.id}]`,`Node '${o.id}' is declared more than once; node ids must be unique`,{nodeId:o.id})):a.add(o.id);const r=new Set;for(const o of e.edges)r.has(o.id)?t.push(Os("document.duplicate-edge-id",`edges[${o.id}]`,`Edge '${o.id}' is declared more than once; edge ids must be unique`,{edgeId:o.id})):r.add(o.id);return t})(e)),r.push(...Ps(e,a)),ja(e,r);try{mt(e)}catch(e){const t=e instanceof n.ValidationError?e.message:e+"";r.push(Os("document.structure","$",t))}return t.catalogue&&r.push(...await Ms(e,t.catalogue,...o)),{valid:0===r.length,issues:r}}function Ls(e,t,o={}){const a=e?.owner??null;return!a||a===t||(null==t||""===t)&&!0===o.allowAnonymousAccess}function js(e,t){return(e?.owner??null)===(t??null)}function qs(e,t,o){if(!js(e,t))throw new d.ForbiddenError(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function Hs(e,t,o){if(!Ls(e,t,o))throw new d.ForbiddenError(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function Us(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Us(e)).join(",")}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${Us(t[e])}`).join(",")}}`}function Bs(e){return u.createHash("sha256").update(Us(e)).digest("hex")}function $s(e){return new oo({runId:e.runId,workflowId:e.workflowId,...e.ownerUser?{owner:e.ownerUser}:{},status:e.status,...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{},...void 0!==e.result?{result:Ws(e.result)}:{},...e.error?{error:Ws(e.error)}:{},createdAt:new Date(e.createdAt),...e.startedAt?{startedAt:new Date(e.startedAt)}:{},...e.finishedAt?{finishedAt:new Date(e.finishedAt)}:{}})}function Ws(e){if(null!=e)return JSON.parse(JSON.stringify(e))}class Vs{constructor(e,t={}){this.sequences=new Map,this.chains=new Map,this.store=e,this.limits={...we,...t}}async publish(e){const t=e.runId,o=(this.sequences.get(t)??0)+1;this.sequences.set(t,o);const a={...e,payload:this.limitPayload(e.payload),sequence:o,timestamp:(new Date).toISOString()},r=(this.chains.get(t)??Promise.resolve()).then(()=>this.store.append(a));return this.chains.set(t,r.catch(()=>{})),await r,a}lastSequence(e){return this.sequences.get(e)??0}release(e){this.sequences.delete(e),this.chains.delete(e)}limitPayload(e){if(void 0===e)return;let t;try{t=JSON.stringify(e)}catch{return{nonSerializable:!0}}return t.length>this.limits.maxEventPayloadBytes?{truncated:!0,reason:"event payload exceeds the configured byte limit",bytes:t.length}:e}}class Ks{constructor(e,t,o,a={},r={}){this.controllers=new Map,this.completions=new Map,this.timeouts=new Map,this.engine=e,this.runStore=t,this.publisher=o,this.hooks=a,this.limits={...we,...r}}begin(e){const t=this.controllers.get(e);if(t)return t;const o=new AbortController;return this.controllers.set(e,o),o}abort(e,t){const o=this.controllers.get(e);return!!o&&(o.signal.aborted||o.abort(t),!0)}isAborted(e){return!0===this.controllers.get(e)?.signal.aborted}abortReason(e){const t=this.controllers.get(e)?.signal;if(t?.aborted)return"timeout"===t.reason?"timeout":"user"}waitFor(e){return this.completions.get(e)}schedule(e,t,o,...a){const r=this.completions.get(e.runId);if(r)return r;const n=this.runExecution({...e},t,o,...a).catch(async t=>{const o=zs(t);try{await this.emitTerminal({...e},be.WORKFLOW_FAILED,o)}catch{}return await this.finalize({...e},"failed",void 0,o,...a)});return this.completions.set(e.runId,n),n}release(e){this.controllers.delete(e),this.completions.delete(e);const t=this.timeouts.get(e);t&&(clearTimeout(t),this.timeouts.delete(e)),this.publisher.release(e)}armTimeout(e){const t=setTimeout(()=>{this.timeouts.delete(e),this.abort(e,"timeout")},this.limits.executionTimeoutMs);this.timeouts.set(e,t)}async runExecution(e,t,o,...a){const r=e.runId;let n,i,d=!1;const s=this.engine.observe({refresh:async t=>{t.runId===r&&(t.error&&(n=t.error),ve((await this.publisher.publish(this.envelopeOf(e,t))).type)?d=!0:t.type===be.WORKFLOW_STARTED&&"validating"===e.status&&(e.status="running",await this.persist(e,...a)))}});this.armTimeout(r);try{if(this.isAborted(r)){const t={name:"GraphRunCancelledError",message:`Graph run '${r}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return n=t,await this.emitTerminal(e,be.WORKFLOW_CANCELLED,t),d=!0,await this.finalize(e,"cancelled",void 0,t,...a)}let s,l;e.status="validating",e.startedAt=(new Date).toISOString(),await this.persist(e,...a);try{({document:s,fingerprint:l}=await t(...a)),e.documentFingerprint=l,await this.persist(e,...a)}catch(t){const o=zs(t);return n=o,d||(await this.emitTerminal(e,be.WORKFLOW_FAILED,o),d=!0),await this.finalize(e,"failed",void 0,o,...a)}if(this.isAborted(r)){const t={name:"GraphRunCancelledError",message:`Graph run '${r}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return n=t,d||(await this.emitTerminal(e,be.WORKFLOW_CANCELLED,t),d=!0),await this.finalize(e,"cancelled",void 0,t,...a)}try{i=await this.engine.execute(s,o,{runId:r,abortSignal:this.controllers.get(r)?.signal,metadata:{documentFingerprint:l}},...a)}catch(e){n=zs(e)}const c=this.abortReason(r);let p,u;return"timeout"===c?(p="failed",u=n??{name:"GraphRunTimeoutError",message:`Graph run '${r}' exceeded the configured execution timeout of ${this.limits.executionTimeoutMs}ms`,code:"GRAPH_RUN_TIMEOUT"}):"user"===c?(p="cancelled",u=n):i?.status===fe.SUCCEEDED?p="succeeded":i?.status===fe.CANCELLED?(p="cancelled",u=n):(p="failed",u=n??zs(new Ao(i?`Graph run '${r}' failed`:`Graph run '${r}' failed without a result`,"GRAPH_RUN_FAILED",{runId:r}))),d||await this.emitTerminal(e,"succeeded"===p?be.WORKFLOW_COMPLETED:"cancelled"===p?be.WORKFLOW_CANCELLED:be.WORKFLOW_FAILED,u),await this.finalize(e,p,i,u,...a)}finally{s();const e=this.timeouts.get(r);e&&(clearTimeout(e),this.timeouts.delete(r))}}async emitTerminal(e,t,o){await this.publisher.publish({runId:e.runId,workflowId:e.workflowId,type:t,error:o})}async finalize(e,t,o,a,...r){e.status=t,o&&(e.result=o),a&&(e.error=a),e.startedAt||(e.startedAt=(new Date).toISOString()),e.finishedAt=(new Date).toISOString(),await this.persist(e,...r);try{await(this.hooks.onRunCompleted?.(e,o))}catch{}return e}async persist(e,...t){await this.runStore.saveRun({...e},...t)}envelopeOf(e,t){return{runId:e.runId,workflowId:t.workflowId??e.workflowId,type:t.type,nodeId:t.nodeId,edgeId:t.edgeId,payload:void 0===t.payload?void 0:Qe(t.payload)?t.payload:{nonSerializable:!0},error:t.error,parentRunId:t.parentRunId,path:t.path}}}function zs(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}function Qs(e){if(!e)return;let t;try{t=e.cache?.user}catch{t=void 0}if(null==t)try{t=e.get("user")}catch{t=void 0}return"string"==typeof t&&t.length>0?t:void 0}function Js(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&It(e.document)&&!It(e)}function Xs(e){return JSON.parse(JSON.stringify(e))}function Ys(e){if(null==e)return 0;let t;try{t=e.getTime()}catch{return 0}return Number.isFinite(t)?t:0}e.GraphWorkflowService=class extends d.ModelService{constructor(e){super(ao),this.catalogue=e}get limits(){return{...Rr,...Tr.graph.workflows.limits??{}}}get allowAnonymousAccess(){return!0===Tr.graph.workflows.allowAnonymousAccess}async saveDocument(e,t,...o){const{ctx:a,ctxArgs:r}=(await this.logCtx(o,"saveDocument",!0)).for(this.saveDocument);if(!It(t))throw new n.ValidationError("Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays");if(t.id!==e)throw new n.ValidationError(`Document id '${t.id}' does not match the workflow id '${e}' from the request path`);const i=await this.validateDocument(t,a);if(!i.valid)throw new ko(i.issues);const d=Qs(a),s=await this.readExistingForWrite(e,r);s&&this.assertWriteOwnership(e,s,d);const l=new Date;if(s)return s.name=t.name,s.document=Xs(t),s.updatedAt=l,this.update(s,...r);const c=new ao({workflowId:e,name:t.name,document:Xs(t),...d?{owner:d}:{},updatedAt:l});return this.create(c,...r)}async seedDocument(e,t,...o){const{log:a,ctxArgs:r}=(await this.logCtx(o,"seedDocument",!0)).for(this.seedDocument);try{return await this.saveDocument(e,t,...r)}catch(t){if(t instanceof d.ForbiddenError)return a.warn(`Skipping boot seed of graph workflow '${e}': an existing row is owned by another user`),null;throw t}}async getDocument(e,...t){const{ctx:o,ctxArgs:a}=(await this.logCtx(t,"getDocument",!0)).for(this.getDocument);let r;try{r=await this.read(e,...a)}catch{r=null}if(!r)throw new n.NotFoundError(`No graph workflow found for workflowId '${e}'`);if(this.assertOwnership(e,r,Qs(o)),r.document)return Xs(r.document);throw new n.NotFoundError(`Graph workflow '${e}' has no canonical document; legacy definition/state snapshots are no longer supported (DECAF-50 \xa74.26 R2-2)`)}async listWorkflows(...e){const{ctx:t,ctxArgs:o}=(await this.logCtx(e,"listWorkflows",!0)).for(this.listWorkflows),a=await this.listBy("workflowId",d.OrderDirection.ASC,...o),r=Qs(t);return a.filter(e=>Ls(e,r,{allowAnonymousAccess:this.allowAnonymousAccess})).sort((e,t)=>Ys(t.updatedAt)-Ys(e.updatedAt))}async assertAccess(e,...t){const{ctx:o,ctxArgs:a}=(await this.logCtx(t,"assertAccess",!0)).for(this.assertAccess);let r;try{r=await this.read(e,...a)}catch{r=null}if(!r)throw new n.NotFoundError(`No graph workflow found for workflowId '${e}'`);return this.assertOwnership(e,r,Qs(o)),r}async validateDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateDocument",!0)).for(this.validateDocument);return await Fs(e,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o)}async saveSnapshot(e,t,...o){const{ctx:a,ctxArgs:r}=(await this.logCtx(o,"saveSnapshot",!0)).for(this.saveSnapshot);if(!Je(t))throw new n.ValidationError("Workflow snapshot payload must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected");if(!Js(t))throw new n.ValidationError("Workflow snapshots must wrap a canonical GraphWorkflowDocument ({ document, editor?, metadata? }): legacy definition/state snapshots are no longer accepted; save canonical documents via PUT /graph/workflows/{workflowId}");const i=Qs(a),d=await this.readExistingForWrite(e,r);d&&this.assertWriteOwnership(e,d,i);const s=new Date;if(d)return d.snapshot=t,await this.applyCanonicalWrapper(d,t,a),d.updatedAt=s,this.update(d,...r);const l=new ao({workflowId:e,snapshot:t,...i?{owner:i}:{},updatedAt:s});return await this.applyCanonicalWrapper(l,t,a),this.create(l,...r)}async loadSnapshot(e,...t){const{ctx:o,ctxArgs:a}=(await this.logCtx(t,"loadSnapshot",!0)).for(this.loadSnapshot);try{const t=await this.read(e,...a);return this.assertOwnership(e,t,Qs(o)),t}catch{return null}}async readExistingForWrite(e,t){try{return await this.read(e,...t)}catch(e){if(e instanceof n.NotFoundError)return null;throw e}}assertOwnership(e,t,o){Hs(t??null,o??null,{allowAnonymousAccess:this.allowAnonymousAccess,resourceKind:"Graph workflow",resourceId:e})}assertWriteOwnership(e,t,o){qs(t??null,o??null,{resourceKind:"Graph workflow",resourceId:e})}async applyCanonicalWrapper(e,t,o){if(!Js(t))return;if(t.document.id!==e.workflowId)throw new n.ValidationError(`Document id '${t.document.id}' does not match the workflow id '${e.workflowId}' from the request path`);const a=await Fs(t.document,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o);if(!a.valid)throw new ko(a.issues);e.document=Xs(t.document),e.name=t.document.name}},e.GraphWorkflowService=i.__decorate([d.service(ao),i.__metadata("design:paramtypes",[Function])],e.GraphWorkflowService),e.GraphRunModelService=class extends d.ModelService{constructor(){super(oo)}async saveRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"saveRun",!0)).for(this.saveRun),a=$s(e);let r;try{r=await super.read(e.runId,...o)}catch{r=null}if(r)return r.workflowId=a.workflowId,r.owner=a.owner,r.status=a.status,r.documentFingerprint=a.documentFingerprint,r.result=a.result,r.error=a.error,r.startedAt=a.startedAt,r.finishedAt=a.finishedAt,void await this.update(r,...o);await this.create(a,...o)}async readRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"readRun",!0)).for(this.readRun);try{return(e=>{const t=e.result;return{runId:e.runId,workflowId:e.workflowId,ownerUser:e.owner??null,status:(o=e.status,"string"==typeof o&&["queued","validating","running","succeeded","failed","cancelled"].includes(o)?e.status:"failed"),createdAt:e.createdAt.toISOString(),...e.startedAt?{startedAt:e.startedAt.toISOString()}:{},...e.finishedAt?{finishedAt:e.finishedAt.toISOString()}:{},...t?{result:t}:{},...e.error?{error:e.error}:{},...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{}};var o})(await super.read(e,...o))}catch{return null}}async listRuns(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"listRuns",!0)).for(this.listRuns);return await this.findBy("workflowId",e,...o)}},e.GraphRunModelService=i.__decorate([d.service(oo),i.__metadata("design:paramtypes",[])],e.GraphRunModelService),e.GraphNodeModelService=class extends d.ModelService{constructor(){super(ro)}async upsertManifest(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"upsertManifest",!0)).for(this.upsertManifest),a=(e=>new ro({kind:e.kind,name:e.display?.name,category:e.display?.category,group:e.display?.group,description:e.display?.description,manifest:kt(Ot(e))}))(e);let r;try{r=await this.read(a.kind,...o)}catch{r=void 0}return r?(r.name=a.name,r.category=a.category,r.group=a.group,r.description=a.description,r.manifest=a.manifest,await this.update(r,...o)):await this.create(a,...o)}async syncFromCatalogue(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"syncFromCatalogue",!0)).for(this.syncFromCatalogue),a=e.listManifests(void 0,...o),r=[];for(const e of a)r.push(await this.upsertManifest(e,...o));return r}async listNodes(...e){const{ctxArgs:t}=(await this.logCtx(e,"listNodes",!0)).for(this.listNodes);return await this.listBy("kind",d.OrderDirection.ASC,...t)}async listManifests(...e){return(await this.listNodes(...e)).map(e=>(e=>{if(!e.manifest)throw new n.ValidationError(`Graph node row '${e.kind}' has no manifest to convert`);return kt(Ot(e.manifest))})(e))}async getNode(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"getNode",!0)).for(this.getNode);try{return await this.read(e,...o)}catch{throw new n.NotFoundError(`Graph node kind '${e}' is not registered`)}}},e.GraphNodeModelService=i.__decorate([d.service(ro),i.__metadata("design:paramtypes",[])],e.GraphNodeModelService),e.ConditionExpressionEvaluator=ia,e.DEFAULT_GRAPH_WORKFLOW_DOCUMENT_LIMITS=Rr,e.DEFAULT_GRAPH_WORKFLOW_VALIDATION_LIMITS=Va,e.DEFAULT_PINNING_METADATA=Oa,e.DEFAULT_RAG_CHUNK_OVERLAP=200,e.DEFAULT_RAG_CHUNK_SIZE=1e3,e.GRAPH_AGENT_BASIC_CHAIN_NODES=Gd,e.GRAPH_AGENT_CHUNKING_NODES=kd,e.GRAPH_AGENT_DELEGATION_HOOK_NODES=ud,e.GRAPH_AGENT_DISCORD_RESPONSE_NODES=Xd,e.GRAPH_AGENT_DISCORD_TRIGGER_NODES=Kd,e.GRAPH_AGENT_EMBEDDING_NODES=Id,e.GRAPH_AGENT_FAMILY_NODES=bs,e.GRAPH_AGENT_GUARDRAIL_NODES=Bd,e.GRAPH_AGENT_HITL_NODES=$d,e.GRAPH_AGENT_HOOK_NODES=cd,e.GRAPH_AGENT_INFORMATION_EXTRACTOR_NODES=jd,e.GRAPH_AGENT_INPUT_PROCESSOR_NODES=Hd,e.GRAPH_AGENT_LANGCHAIN_CODE_NODES=qd,e.GRAPH_AGENT_M5_NODES=As,e.GRAPH_AGENT_M6_NODES=xs,e.GRAPH_AGENT_MCP_TRIGGER_NODES=Wd,e.GRAPH_AGENT_MEMORY_NODES=ws,e.GRAPH_AGENT_MEMORY_SELECTOR_NODES=xd,e.GRAPH_AGENT_NODES=dd,e.GRAPH_AGENT_OUTPUT_PROCESSOR_NODES=Ud,e.GRAPH_AGENT_PROCESSOR_NODES=vs,e.GRAPH_AGENT_QA_CHAIN_NODES=Pd,e.GRAPH_AGENT_RAG_NODES=Ns,e.GRAPH_AGENT_RERANK_NODES=Dd,e.GRAPH_AGENT_RETRIEVER_NODES=Sd,e.GRAPH_AGENT_SANDBOX_NODES=fd,e.GRAPH_AGENT_SCORER_NODES=_d,e.GRAPH_AGENT_SCORER_SELECTOR_NODES=yd,e.GRAPH_AGENT_SKILL_NODES=gd,e.GRAPH_AGENT_SKILL_SELECTOR_NODES=hd,e.GRAPH_AGENT_SLACK_RESPONSE_NODES=Jd,e.GRAPH_AGENT_SLACK_TRIGGER_NODES=Vd,e.GRAPH_AGENT_STRUCTURED_OUTPUT_PARSER_NODES=Ld,e.GRAPH_AGENT_SUMMARIZATION_CHAIN_NODES=Md,e.GRAPH_AGENT_TEAMS_RESPONSE_NODES=Zd,e.GRAPH_AGENT_TEAMS_TRIGGER_NODES=Qd,e.GRAPH_AGENT_TELEGRAM_RESPONSE_NODES=Yd,e.GRAPH_AGENT_TELEGRAM_TRIGGER_NODES=zd,e.GRAPH_AGENT_TOOL_DENY_NODES=pd,e.GRAPH_AGENT_TOOL_NODES=sd,e.GRAPH_AGENT_TOOL_SELECTOR_NODES=ld,e.GRAPH_AGENT_VECTOR_STORE_NODES=Ed,e.GRAPH_AGENT_VOICE_NODES=es,e.GRAPH_BOUNDARY_NODES=ys,e.GRAPH_BUILT_IN_NODE_CLASSES_BY_KIND=Ss,e.GRAPH_BUILT_IN_NODE_MANIFESTS=ps,e.GRAPH_BUILT_IN_NODE_MANIFESTS_BY_KIND=gs,e.GRAPH_CODE_DEFAULT_LANGUAGE=kr,e.GRAPH_CODE_DEFAULT_TIMEOUT_MS=1e3,e.GRAPH_CODE_LANGUAGES=Or,e.GRAPH_CODE_MAX_TIMEOUT_MS=ho,e.GRAPH_DATA_NODES=Is,e.GRAPH_DATA_TABLE_MAX_LIST_ROWS=wo,e.GRAPH_DATA_TABLE_MAX_ROWS=yo,e.GRAPH_DATA_TABLE_MAX_ROW_BYTES=bo,e.GRAPH_DEFAULT_CONCURRENCY=4,e.GRAPH_DEFAULT_MAX_FOREACH_ITERATIONS=1e3,e.GRAPH_DEFAULT_MAX_LOOP_ITERATIONS=100,e.GRAPH_DOCUMENT_FORBIDDEN_FIELD_KEYS=Ka,e.GRAPH_EXECUTE_COMMAND_DEFAULT_TIMEOUT_MS=3e4,e.GRAPH_EXECUTE_COMMAND_MAX_OUTPUT_BYTES=_o,e.GRAPH_EXECUTE_COMMAND_MAX_TIMEOUT_MS=6e4,e.GRAPH_FLOW_CONTROL_NODES=ms,e.GRAPH_HTTP_MAX_REDIRECTS=5,e.GRAPH_HTTP_MAX_RESPONSE_BYTES=fo,e.GRAPH_HTTP_MAX_TIMEOUT_MS=mo,e.GRAPH_IO_NODES=Es,e.GRAPH_LOCAL_EXECUTION_BACKEND=co,e.GRAPH_LOCAL_UNSUPPORTED_NODE_KIND=po,e.GRAPH_LOOP_KIND={FOREACH:"core.loop.foreach",WHILE:"core.loop.while",UNTIL:"core.loop.until"},e.GRAPH_LOOP_NODES=_s,e.GRAPH_MAX_CHILD_RUNS=1e3,e.GRAPH_MAX_FOREACH_ITERATIONS=go,e.GRAPH_MAX_LOOP_ITERATIONS=uo,e.GRAPH_MAX_SUB_WORKFLOW_DEPTH=10,e.GRAPH_PINNING_METADATA_KEY="graph.pinnable",e.GRAPH_PLAIN_SECRET_KEYS=Aa,e.GRAPH_TRIGGER_NODES=hs,e.GRAPH_UTILITY_NODES=fs,e.GRAPH_WORKFLOW_BOUNDARY=lo,e.GRAPH_WORKFLOW_FORBIDDEN_FIELD_KEYS=Cs,e.GraphAuthValidator=Qo,e.GraphBreakSignal=Co,e.GraphConditionEvaluator=as,e.GraphConnectionPolicyValidator=Ha,e.GraphConnectionValidationError=$a,e.GraphCredentialAuthorizationError=Wa,e.GraphCredentialReferenceValidator=Ua,e.GraphCycleError=xo,e.GraphDocumentValidationError=Ba,e.GraphEdgeInstanceValidator=qa,e.GraphEngineEventSink=aa,e.GraphEnvironment=Tr,e.GraphExecutionBackendRegistry=na,e.GraphExecutionContext=ea,e.GraphExecutionEngine=sr,e.GraphExecutionError=Ao,e.GraphExecutionEventEmitter=Do,e.GraphExecutionEventFactory=Po,e.GraphExecutionFrame=ta,e.GraphExecutionSnapshotMapper=class{map(e){const t={};for(const[o,a]of Object.entries(e.nodeResults))t[o]={status:a.status,startedAt:a.startedAt?.toISOString(),finishedAt:a.finishedAt?.toISOString(),error:a.error,outputs:a.outputs,fromCache:a.fromCache,pinned:a.pinned};const o={};for(const t of e.events)t.edgeId&&"edge.valueRouted"===t.type&&(o[t.edgeId]={status:fe.SUCCEEDED,lastValue:t.payload?.value,updatedAt:t.timestamp.toISOString()});const a=[...e.events];return{runId:e.runId,status:e.status,nodes:t,edges:o,outputs:e.outputs,events:a}}},e.GraphInputError=Io,e.GraphLoopExecutionContext=class{constructor(e,t){this.iteration=e,this.metadata=t}},e.GraphLoopLimitError=Eo,e.GraphNode=Er,e.GraphNodeCredentialResolver=Jo,e.GraphNodeInstanceValidator=La,e.GraphNodeManifestResolver=wr,e.GraphNodeMethodNotFoundError=gr,e.GraphNodeMethodRegistry=hr,e.GraphNodeNotFoundError=ur,e.GraphNodeRegistrationError=pr,e.GraphParameterValidator=xa,e.GraphPinningDependencyResolver=Pa,e.GraphPinningError=So,e.GraphPinningPolicy=Da,e.GraphPinningService=Ca,e.GraphPortError=class extends Ao{constructor(e,t){super(e,"GRAPH_PORT_ERROR",t)}},e.GraphPortSchemaResolver=class{resolve(e){const t=this.createValidator(e);return{name:e.name,required:e.required,validate:t}}resolveAll(e){const t={};for(const o of e)t[o.name]=this.resolve(o);return t}createValidator(e){switch((e.type??e.designType??"").toLowerCase()){case"string":return e=>"string"==typeof e;case"number":return e=>"number"==typeof e;case"boolean":return e=>"boolean"==typeof e;case"date":return e=>e instanceof Date||"string"==typeof e&&!isNaN(Date.parse(e));case"array":return e=>Array.isArray(e);case"bigint":return e=>"bigint"==typeof e;default:return()=>!0}}},e.GraphRunCancelledError=Oo,e.GraphRunEventPublisher=Vs,e.GraphRunExecutor=Ks,e.GraphRunService=class{constructor(e,t,o,a={}){this.activeByCaller=new Map,this.callerKeysByRun=new Map,this.releaseTimers=new Map,this.engine=e,this.runStore=t,this.eventStore=o,this.publisher=new Vs(o,a.limits),this.executor=new Ks(e,t,this.publisher,{onRunCompleted:a.onRunCompleted},a.limits),this.options={...a,limits:{...we,...a.limits}}}get limits(){return this.options.limits}async createRun(e,t,o,...a){this.validateCreateRequest(e);const r=e.workflowId??e.workflow?.id??"";if(!r)throw new n.ValidationError("Graph run request must carry a workflow document with an id or a saved workflowId");if(e.workflowId&&!this.options.documentResolver)throw new n.ValidationError("Graph run requests by workflowId require a document resolver");const i=o??t??"anonymous",d=this.activeByCaller.get(i)??new Set;if(d.size>=this.options.limits.maxConcurrentRuns)throw new n.ValidationError(`Graph run rejected: the configured limit of ${this.options.limits.maxConcurrentRuns} concurrent runs per caller is exhausted`);const s=this.generateRunId(),l={runId:s,workflowId:r,ownerUser:t,status:"queued",createdAt:(new Date).toISOString()};this.executor.begin(s),await this.runStore.saveRun({...l},...a);const c=this.documentProviderFor(e,t);return d.add(s),this.activeByCaller.set(i,d),this.callerKeysByRun.set(s,i),this.executor.schedule(l,c,e.inputs??{},...a).catch(()=>{}).finally(()=>this.finishActiveRun(s)),l}async getRun(e,t,...o){const a=await this.runStore.readRun(e,...o);if(!a)throw new n.NotFoundError(`No graph run found for runId '${e}'`);return this.assertOwnership(a,t),a}async listRunsByWorkflow(e,t,...o){return(await this.runStore.listRuns(e,...o)).filter(e=>Ls({owner:e.owner},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess})).sort((e,t)=>{const o=e.updatedAt instanceof Date?e.updatedAt.getTime():NaN,a=t.updatedAt instanceof Date?t.updatedAt.getTime():NaN;return(Number.isFinite(a)?a:0)-(Number.isFinite(o)?o:0)})}async cancelRun(e,t,...o){const a=await this.runStore.readRun(e,...o);if(!a)throw new n.NotFoundError(`No graph run found for runId '${e}'`);return this.assertWriteOwnership(a,t),"succeeded"===(r=a.status)||"failed"===r||"cancelled"===r||(this.executor.abort(e,"user"),a.status="cancelled",a.finishedAt=(new Date).toISOString(),await this.runStore.saveRun({...a},...o)),a;var r}async resumeRun(e,t,o,...a){const r=await this.runStore.readRun(e,...a);if(!r)throw new n.NotFoundError(`No graph run found for runId '${e}'`);this.assertWriteOwnership(r,o);const i=this.engine.backend,d=i.resume;if("function"!=typeof d)throw new Ao(`Graph execution backend '${i.constructor?.name??"GraphExecutionBackend"}' does not support resume`,"GRAPH_RESUME_UNSUPPORTED_BACKEND",{runId:e});let s;try{s=await d.call(i,e,t,...a)}catch(e){throw(l=e)instanceof Ao?new Ao(l.message,l.graphCode):l}var l;const c={...s,runId:e,caller:o};return await this.publisher.publish({runId:e,workflowId:r.workflowId,type:be.WORKFLOW_RESUMED,payload:c}),c}async listEvents(e,t,o,...a){return await this.getRun(e,o,...a),this.eventStore.listAfter(e,t)}async subscribeEvents(e,t,o,...a){return await this.getRun(e,t,...a),this.eventStore.subscribe(e,o)}subscribeRunEvents(e,t){return this.eventStore.subscribe(e.runId,t)}async waitForRun(e,t,...o){const a=this.executor.waitFor(e);return a&&await a,this.getRun(e,t,...o)}async executeAndWait(e,t,o,...a){const r=await this.createRun(e,t,o,...a);return this.waitForRun(r.runId,t,...a)}release(e){this.finishActiveRun(e);const t=this.releaseTimers.get(e);t&&(clearTimeout(t),this.releaseTimers.delete(e)),this.executor.release(e),this.eventStore.release?.(e)}finishActiveRun(e){const t=this.callerKeysByRun.get(e);if(void 0!==t){this.callerKeysByRun.delete(e);const o=this.activeByCaller.get(t);o&&(o.delete(e),0===o.size&&this.activeByCaller.delete(t))}if(this.releaseTimers.has(e))return;const o=setTimeout(()=>{this.releaseTimers.delete(e),this.release(e)},this.options.limits.eventReplayWindowMs);o.unref?.(),this.releaseTimers.set(e,o)}validateCreateRequest(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new n.ValidationError("Graph run request must be an object carrying either a workflow document or a workflowId plus inputs");const t=void 0!==e.workflow,o=void 0!==e.workflowId;if(t&&o)throw new n.ValidationError("Graph run request is ambiguous: supply either an unsaved workflow document or a saved workflowId, not both");if(!t&&!o)throw new n.ValidationError("Graph run request must supply either an unsaved workflow document or a saved workflowId");if(t&&!It(e.workflow))throw new n.ValidationError("Graph run request carries a payload that is not a canonical GraphWorkflowDocument");if(void 0!==e.inputs&&!Je(e.inputs))throw new n.ValidationError("Graph run inputs must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected");const a=(e=>{try{return JSON.stringify(e)?.length??0}catch{return Number.MAX_SAFE_INTEGER}})(e);if(a>this.options.limits.maxRequestBytes)throw new n.ValidationError(`Graph run request of ${a} bytes exceeds the configured limit of ${this.options.limits.maxRequestBytes} bytes`)}documentProviderFor(e,t){if(e.workflow){const t=e.workflow;return async()=>({document:t,fingerprint:Bs(t)})}const o=e.workflowId;return async(...e)=>{const a=this.options.documentResolver;if(!a)throw new n.ValidationError("Graph run requests by workflowId require a document resolver");const r=await a.resolve(o,t,...e);return{document:r,fingerprint:Bs(r)}}}assertOwnership(e,t){Hs({owner:e.ownerUser},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess,resourceKind:"Graph run",resourceId:e.runId})}assertWriteOwnership(e,t){qs({owner:e.ownerUser},t,{resourceKind:"Graph run",resourceId:e.runId})}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new Ro("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime",{runtime:typeof globalThis.crypto});return e.randomUUID()}},e.GraphStoreError=Ro,e.GraphTopology=Ta,e.GraphTopologyError=To,e.GraphValueValidator=class{constructor(e){this.resolver=e}validateWorkflowInputs(e,t){this.validatePorts(e.inputs,t,"workflow input")}validateWorkflowOutputs(e,t){this.validatePorts(e.outputs,t,"workflow output")}validateNodeInputs(e,t){const o=(e.ports??[]).filter(e=>"input"===e.direction);this.validatePorts(o,t,`node '${e.name}' input`)}validateNodeOutputs(e,t){const o=(e.ports??[]).filter(e=>"output"===e.direction);this.validatePorts(o,t,`node '${e.name}' output`)}validatePorts(e,t,o){if(e)for(const a of e){const e=Object.prototype.hasOwnProperty.call(t,a.name);if(a.required&&!e)throw new Io(`Missing required ${o} port '${a.name}'`);if(e&&!this.resolver.resolve(a).validate(t[a.name]))throw new Io(`Invalid value for ${o} port '${a.name}'`)}}},e.GraphWebhookResponseRegistry=Xa,e.GraphWorkflowDocumentRejectedError=ko,e.GraphWorkflowDocumentValidator=Ja,e.InMemoryGraphRunEventStore=class{constructor(e={}){this.events=new Map,this.listeners=new Map,this.limits={...we,...e}}async append(e){let t=this.events.get(e.runId);t||(t=[],this.events.set(e.runId,t)),t.push(e),this.enforceRetention(t);for(const t of this.listeners.get(e.runId)??[])try{t(e)}catch{}}async listAfter(e,t){const o=this.events.get(e);return o?o.filter(e=>e.sequence>t):[]}subscribe(e,t){let o=this.listeners.get(e);return o||(o=new Set,this.listeners.set(e,o)),o.add(t),()=>{o.delete(t),0===o.size&&this.listeners.delete(e)}}release(e){this.events.delete(e),this.listeners.delete(e)}enforceRetention(e){const t=this.limits.maxEventsPerRun;for(;e.length>t;){const t=e.findIndex(e=>!ve(e.type));if(-1===t)break;e.splice(t,1)}}},e.InMemoryGraphRunStore=class{constructor(){this.runs=new Map}async saveRun(e){this.runs.set(e.runId,{...e})}async readRun(e){const t=this.runs.get(e);return t?{...t}:null}async listRuns(e){return[...this.runs.values()].filter(t=>t.workflowId===e).map(e=>$s(e))}release(e){this.runs.delete(e)}},e.IsolatedVmCodeSandboxEvaluator=cr,e.LocalGraphExecutionBackend=Ga,e.MASTRA_AGENT_ZONE=nd,e.MASTRA_AGENT_ZONES=id,e.MASTRA_GUARDRAIL_TYPES=["moderation","piiDetector","promptInjectionDetector","regexFilter"],e.MASTRA_INPUT_PROCESSOR_TYPES=["unicodeNormalizer","languageDetector","piiDetector","promptInjectionDetector","systemPromptScrubber","tokenCostControl","modelSelection"],e.MASTRA_OUTPUT_PROCESSOR_TYPES=["tokenLimiter","toolCallFilter","regexFilter","responseCache","batchParts","providerHistoryCompat","cyberRefusalHandler","prefillErrorHandler","streamErrorRetry","unsupportedFileHandler"],e.S3Node=Kn,e.assertGraphResourceOwnership=Hs,e.assertGraphResourceWriteOwnership=qs,e.buildGraphExecutionResult=oa,e.builtInGraphNodeRegistrations=Ts,e.canAccessGraphResource=Ls,e.canAccessGraphResourcePayload=js,e.checkGraphValueAgainstSchema=ba,e.chunkText=Cd,e.clampGraphCodeTimeoutMs=Cr,e.clampSandboxTimeoutMs=md,e.collectLooseNodeIssues=ja,e.composeGraphNamespace=Mo,e.createGraphDataTableRepository=rr,e.createGraphValueRepository=Ra,e.declaredGraphNodeMethods=e=>e.methods??[],e.decomposeGraphNamespace=Go,e.decomposeGraphNamespaces=Ko,e.defineGraphNode=xr,e.detectGraphCodeModeBlockingSurfaces=_a,e.detectGraphCodeModeSurfaces=ma,e.evaluateCodeCondition=la,e.evaluateCondition=pa,e.evaluateConditionSync=ca,e.extractChunkTexts=Od,e.findMalformedGraphNamespaces=Ho,e.findUngrantedGraphNamespaces=qo,e.graphAuthDataFromRecord=Wo,e.graphAuthDataOf=Vo,e.graphDocumentHasCodeMode=e=>ma(e).length>0,e.graphNamespaceCovers=jo,e.graphNamespacePartsOf=Lo,e.graphNodeConfig=Ir,e.graphRolesFromNamespaces=Uo,e.graphRunDocumentFingerprint=Bs,e.graphWorkflowOwnerOf=Qs,e.isCodeCondition=da,e.isConditionExpression=sa,e.isGraphCodeModeBlockingSurface=fa,e.isGraphCredentialReferenceLike=Na,e.isGraphNamespaceCacheEntryValid=Fo,e.isGraphResolvedWorkflow=za,e.isPinnable=ka,e.mergeGraphAuthData=zo,e.registerBuiltInGraphNodes=(e,...t)=>{for(const o of Ts())e.register(o,{},...t);return e},e.resolveGraphBackendCapabilities=ra,e.resolveGraphDynamicPorts=yr,e.resolveGraphNodeManifest=br,e.resolveNodeCredential=Xo,e.serializeGraphValueKey=Ia,e.stripFacadeOwnedBackendConfig=dr,e.validateGraphWorkflowDocumentAtBoundary=Fs},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decaf-ts/logging"),require("@decaf-ts/ui-decorators"),require("@decaf-ts/decoration"),require("@decaf-ts/decorator-validation"),require("@decaf-ts/db-decorators"),require("tslib"),require("@decaf-ts/core"),require("isolated-vm"),require("acorn"),require("acorn-walk"),require("typescript"),require("node:crypto"),require("node:path"),require("node:os"),require("node:fs"),require("node:fs/promises"),require("@decaf-ts/for-typeorm"),require("@decaf-ts/integrations/redis"),require("amqplib"),require("@decaf-ts/integrations/blob"),require("@decaf-ts/integrations/blob/s3"),require("@decaf-ts/integrations/shared/http"),require("@decaf-ts/integrations/blob/gcp"),require("@decaf-ts/integrations/blob/azure"),require("@decaf-ts/integrations/comms/slack"),require("@decaf-ts/integrations/comms/telegram"),require("@decaf-ts/integrations/comms/teams"),require("@decaf-ts/integrations/comms/gmail"),require("@decaf-ts/integrations/comms/email"),require("@decaf-ts/integrations/comms/discord"),require("@decaf-ts/integrations/comms/whatsapp"),require("@decaf-ts/integrations/comms/outlook"),require("@decaf-ts/integrations/io/google-sheets"),require("@decaf-ts/integrations/io/airtable"),require("@decaf-ts/integrations/io/spreadsheet"),require("@decaf-ts/integrations/io/graphql"),require("@decaf-ts/integrations/io/microsoft-excel"),require("@decaf-ts/integrations/io/confluence"),require("@decaf-ts/integrations/io/jira"),require("@decaf-ts/integrations/io/google-docs"),require("@decaf-ts/integrations/io/microsoft-sharepoint"),require("@decaf-ts/integrations/calendar/google-calendar"),require("cheerio"),require("html-to-text"),require("marked"),require("turndown"),require("xml2js"),require("@decaf-ts/integrations/devops/github"),require("@decaf-ts/integrations/devops/gitlab"),require("@decaf-ts/crypto/integration/services/crypto"),require("@decaf-ts/crypto/jwt"),require("node:child_process"),require("@decaf-ts/integrations/sftp"),require("eventsource"),require("pg"),require("@mastra/core/storage"),require("@mastra/memory"),require("@mastra/libsql"),require("@mastra/pg")):"function"==typeof define&&define.amd?define(["exports","@decaf-ts/logging","@decaf-ts/ui-decorators","@decaf-ts/decoration","@decaf-ts/decorator-validation","@decaf-ts/db-decorators","tslib","@decaf-ts/core","isolated-vm","acorn","acorn-walk","typescript","node:crypto","node:path","node:os","node:fs","node:fs/promises","@decaf-ts/for-typeorm","@decaf-ts/integrations/redis","amqplib","@decaf-ts/integrations/blob","@decaf-ts/integrations/blob/s3","@decaf-ts/integrations/shared/http","@decaf-ts/integrations/blob/gcp","@decaf-ts/integrations/blob/azure","@decaf-ts/integrations/comms/slack","@decaf-ts/integrations/comms/telegram","@decaf-ts/integrations/comms/teams","@decaf-ts/integrations/comms/gmail","@decaf-ts/integrations/comms/email","@decaf-ts/integrations/comms/discord","@decaf-ts/integrations/comms/whatsapp","@decaf-ts/integrations/comms/outlook","@decaf-ts/integrations/io/google-sheets","@decaf-ts/integrations/io/airtable","@decaf-ts/integrations/io/spreadsheet","@decaf-ts/integrations/io/graphql","@decaf-ts/integrations/io/microsoft-excel","@decaf-ts/integrations/io/confluence","@decaf-ts/integrations/io/jira","@decaf-ts/integrations/io/google-docs","@decaf-ts/integrations/io/microsoft-sharepoint","@decaf-ts/integrations/calendar/google-calendar","cheerio","html-to-text","marked","turndown","xml2js","@decaf-ts/integrations/devops/github","@decaf-ts/integrations/devops/gitlab","@decaf-ts/crypto/integration/services/crypto","@decaf-ts/crypto/jwt","node:child_process","@decaf-ts/integrations/sftp","eventsource","pg","@mastra/core/storage","@mastra/memory","@mastra/libsql","@mastra/pg"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["as-graph"]={},e.decafTsLogging,e.decafTsUiDecorators,e.decafTsDecoration,e.decafTsDecoratorValidation,e.decafTsDbDecorators,e.tslib,e.decafTsCore,e.isolatedVm,e.acorn,e.acornWalk,e.typescript,e.node_crypto,e.node_path,e.node_os,e.node_fs,e.promises,e.decafTsForTypeorm,e.redis,e.amqplib,e.blob,e.s3,e.http,e.gcp,e.azure,e.slack,e.telegram,e.teams,e.gmail,e.email,e.discord,e.whatsapp,e.outlook,e.googleSheets,e.airtable,e.spreadsheet,e.graphql,e.microsoftExcel,e.confluence,e.jira,e.googleDocs,e.microsoftSharepoint,e.googleCalendar,e.cheerio,e.htmlToText,e.marked,e.turndown,e.xml2js,e.github,e.gitlab,e.crypto,e.jwt,e.node_child_process,e.sftp,e.eventsource,e.pg);
2
2
  //# sourceMappingURL=as-graph.cjs.map