@decaf-ts/as-graph 0.5.0 → 0.7.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 (968) hide show
  1. package/README.md +834 -38
  2. package/assets/i18n/en.json +2527 -32
  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 +102 -11
  8. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs.map +1 -1
  9. package/lib/cjs/engine/auth/GraphAuthValidator.cjs +19 -0
  10. package/lib/cjs/engine/auth/GraphAuthValidator.cjs.map +1 -1
  11. package/lib/cjs/engine/constants.cjs +61 -1
  12. package/lib/cjs/engine/constants.cjs.map +1 -1
  13. package/lib/cjs/engine/credentials/GraphNodeCredentials.cjs +158 -0
  14. package/lib/cjs/engine/credentials/GraphNodeCredentials.cjs.map +1 -0
  15. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs +235 -67
  16. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs.map +1 -1
  17. package/lib/cjs/engine/execution/GraphNodeEngineRequirements.cjs +33 -0
  18. package/lib/cjs/engine/execution/GraphNodeEngineRequirements.cjs.map +1 -0
  19. package/lib/cjs/engine/execution/GraphWebhookResponseRegistry.cjs +108 -0
  20. package/lib/cjs/engine/execution/GraphWebhookResponseRegistry.cjs.map +1 -0
  21. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs +92 -1
  22. package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs.map +1 -1
  23. package/lib/cjs/engine/execution/index.cjs +1 -0
  24. package/lib/cjs/engine/execution/index.cjs.map +1 -1
  25. package/lib/cjs/engine/index.cjs +5 -0
  26. package/lib/cjs/engine/index.cjs.map +1 -1
  27. package/lib/cjs/engine/services/GraphNodeModelService.cjs +129 -0
  28. package/lib/cjs/engine/services/GraphNodeModelService.cjs.map +1 -0
  29. package/lib/cjs/engine/services/GraphWorkflowService.cjs +33 -0
  30. package/lib/cjs/engine/services/GraphWorkflowService.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/GraphParameterValidator.cjs +6 -0
  42. package/lib/cjs/engine/validation/GraphParameterValidator.cjs.map +1 -1
  43. package/lib/cjs/mastra/MastraAgeVectorDriver.cjs +298 -0
  44. package/lib/cjs/mastra/MastraAgeVectorDriver.cjs.map +1 -0
  45. package/lib/cjs/mastra/MastraAgentBuilder.cjs +249 -0
  46. package/lib/cjs/mastra/MastraAgentBuilder.cjs.map +1 -0
  47. package/lib/cjs/mastra/MastraAgentModelAdapter.cjs +65 -0
  48. package/lib/cjs/mastra/MastraAgentModelAdapter.cjs.map +1 -0
  49. package/lib/cjs/mastra/MastraAgentProcessors.cjs +397 -0
  50. package/lib/cjs/mastra/MastraAgentProcessors.cjs.map +1 -0
  51. package/lib/cjs/mastra/MastraAgentStepHandler.cjs +332 -0
  52. package/lib/cjs/mastra/MastraAgentStepHandler.cjs.map +1 -0
  53. package/lib/cjs/mastra/MastraCapabilities.cjs +115 -0
  54. package/lib/cjs/mastra/MastraCapabilities.cjs.map +1 -1
  55. package/lib/cjs/mastra/MastraChannelResponse.cjs +162 -0
  56. package/lib/cjs/mastra/MastraChannelResponse.cjs.map +1 -0
  57. package/lib/cjs/mastra/MastraChannelTrigger.cjs +124 -0
  58. package/lib/cjs/mastra/MastraChannelTrigger.cjs.map +1 -0
  59. package/lib/cjs/mastra/MastraDefaultStepHandlers.cjs +435 -0
  60. package/lib/cjs/mastra/MastraDefaultStepHandlers.cjs.map +1 -0
  61. package/lib/cjs/mastra/MastraEnvironment.cjs +297 -0
  62. package/lib/cjs/mastra/MastraEnvironment.cjs.map +1 -0
  63. package/lib/cjs/mastra/MastraEvalModels.cjs +546 -0
  64. package/lib/cjs/mastra/MastraEvalModels.cjs.map +1 -0
  65. package/lib/cjs/mastra/MastraEventBridge.cjs +31 -4
  66. package/lib/cjs/mastra/MastraEventBridge.cjs.map +1 -1
  67. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs +513 -20
  68. package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs.map +1 -1
  69. package/lib/cjs/mastra/MastraGraphExecutionModule.cjs +148 -0
  70. package/lib/cjs/mastra/MastraGraphExecutionModule.cjs.map +1 -0
  71. package/lib/cjs/mastra/MastraHitlStepHandler.cjs +67 -0
  72. package/lib/cjs/mastra/MastraHitlStepHandler.cjs.map +1 -0
  73. package/lib/cjs/mastra/MastraMcpTrigger.cjs +254 -0
  74. package/lib/cjs/mastra/MastraMcpTrigger.cjs.map +1 -0
  75. package/lib/cjs/mastra/MastraMemory.cjs +467 -0
  76. package/lib/cjs/mastra/MastraMemory.cjs.map +1 -0
  77. package/lib/cjs/mastra/MastraMetricsAdapter.cjs +279 -0
  78. package/lib/cjs/mastra/MastraMetricsAdapter.cjs.map +1 -0
  79. package/lib/cjs/mastra/MastraMetricsGateway.cjs +404 -0
  80. package/lib/cjs/mastra/MastraMetricsGateway.cjs.map +1 -0
  81. package/lib/cjs/mastra/MastraMetricsModels.cjs +498 -0
  82. package/lib/cjs/mastra/MastraMetricsModels.cjs.map +1 -0
  83. package/lib/cjs/mastra/MastraMetricsStatement.cjs +220 -0
  84. package/lib/cjs/mastra/MastraMetricsStatement.cjs.map +1 -0
  85. package/lib/cjs/mastra/MastraModelSchemaConverter.cjs +84 -0
  86. package/lib/cjs/mastra/MastraModelSchemaConverter.cjs.map +1 -0
  87. package/lib/cjs/mastra/MastraObservability.cjs +335 -0
  88. package/lib/cjs/mastra/MastraObservability.cjs.map +1 -0
  89. package/lib/cjs/mastra/MastraPersistence.cjs +545 -0
  90. package/lib/cjs/mastra/MastraPersistence.cjs.map +1 -0
  91. package/lib/cjs/mastra/MastraRagStepHandlers.cjs +927 -0
  92. package/lib/cjs/mastra/MastraRagStepHandlers.cjs.map +1 -0
  93. package/lib/cjs/mastra/MastraRunMetricsEndpoint.cjs +153 -0
  94. package/lib/cjs/mastra/MastraRunMetricsEndpoint.cjs.map +1 -0
  95. package/lib/cjs/mastra/MastraRunRecovery.cjs +94 -0
  96. package/lib/cjs/mastra/MastraRunRecovery.cjs.map +1 -0
  97. package/lib/cjs/mastra/MastraScheduleTrigger.cjs +115 -0
  98. package/lib/cjs/mastra/MastraScheduleTrigger.cjs.map +1 -0
  99. package/lib/cjs/mastra/MastraStorageWiring.cjs +125 -0
  100. package/lib/cjs/mastra/MastraStorageWiring.cjs.map +1 -0
  101. package/lib/cjs/mastra/MastraStructuredOutput.cjs +152 -0
  102. package/lib/cjs/mastra/MastraStructuredOutput.cjs.map +1 -0
  103. package/lib/cjs/mastra/MastraToolBuilder.cjs +73 -0
  104. package/lib/cjs/mastra/MastraToolBuilder.cjs.map +1 -0
  105. package/lib/cjs/mastra/MastraToolConfig.cjs +42 -0
  106. package/lib/cjs/mastra/MastraToolConfig.cjs.map +1 -0
  107. package/lib/cjs/mastra/MastraToolDecorator.cjs +99 -0
  108. package/lib/cjs/mastra/MastraToolDecorator.cjs.map +1 -0
  109. package/lib/cjs/mastra/MastraVectorStore.cjs +618 -0
  110. package/lib/cjs/mastra/MastraVectorStore.cjs.map +1 -0
  111. package/lib/cjs/mastra/MastraVoiceStepHandler.cjs +90 -0
  112. package/lib/cjs/mastra/MastraVoiceStepHandler.cjs.map +1 -0
  113. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs +41 -9
  114. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs.map +1 -1
  115. package/lib/cjs/mastra/MastraWorkflowManager.cjs +100 -50
  116. package/lib/cjs/mastra/MastraWorkflowManager.cjs.map +1 -1
  117. package/lib/cjs/mastra/index.cjs +41 -1
  118. package/lib/cjs/mastra/index.cjs.map +1 -1
  119. package/lib/cjs/mastra/nodes/MastraNodeRegistry.cjs +232 -0
  120. package/lib/cjs/mastra/nodes/MastraNodeRegistry.cjs.map +1 -0
  121. package/lib/cjs/mastra/nodes/index.cjs +29 -0
  122. package/lib/cjs/mastra/nodes/index.cjs.map +1 -0
  123. package/lib/cjs/mastra/nodes/types.cjs +4 -0
  124. package/lib/cjs/mastra/nodes/types.cjs.map +1 -0
  125. package/lib/cjs/mastra/types.cjs +130 -1
  126. package/lib/cjs/mastra/types.cjs.map +1 -1
  127. package/lib/cjs/nest/graph/GraphBackendHost.cjs +117 -23
  128. package/lib/cjs/nest/graph/GraphBackendHost.cjs.map +1 -1
  129. package/lib/cjs/nest/graph/GraphExecutionModule.cjs +72 -2
  130. package/lib/cjs/nest/graph/GraphExecutionModule.cjs.map +1 -1
  131. package/lib/cjs/nest/graph/GraphRunController.cjs +47 -6
  132. package/lib/cjs/nest/graph/GraphRunController.cjs.map +1 -1
  133. package/lib/cjs/nest/graph/main.cjs +99 -2
  134. package/lib/cjs/nest/graph/main.cjs.map +1 -1
  135. package/lib/cjs/node/agents/agent/node.cjs +189 -31
  136. package/lib/cjs/node/agents/agent/node.cjs.map +1 -1
  137. package/lib/cjs/node/agents/hitl/node.cjs +115 -0
  138. package/lib/cjs/node/agents/hitl/node.cjs.map +1 -0
  139. package/lib/cjs/node/agents/hooks/delegation/node.cjs +122 -0
  140. package/lib/cjs/node/agents/hooks/delegation/node.cjs.map +1 -0
  141. package/lib/cjs/node/agents/hooks/hook/node.cjs +120 -0
  142. package/lib/cjs/node/agents/hooks/hook/node.cjs.map +1 -0
  143. package/lib/cjs/node/agents/hooks/tool-deny/node.cjs +104 -0
  144. package/lib/cjs/node/agents/hooks/tool-deny/node.cjs.map +1 -0
  145. package/lib/cjs/node/agents/memory/memory/node.cjs +231 -0
  146. package/lib/cjs/node/agents/memory/memory/node.cjs.map +1 -0
  147. package/lib/cjs/node/agents/memory/memory-selector/node.cjs +101 -0
  148. package/lib/cjs/node/agents/memory/memory-selector/node.cjs.map +1 -0
  149. package/lib/cjs/node/agents/processors/guardrail/node.cjs +126 -0
  150. package/lib/cjs/node/agents/processors/guardrail/node.cjs.map +1 -0
  151. package/lib/cjs/node/agents/processors/input-processor/node.cjs +118 -0
  152. package/lib/cjs/node/agents/processors/input-processor/node.cjs.map +1 -0
  153. package/lib/cjs/node/agents/processors/output-processor/node.cjs +108 -0
  154. package/lib/cjs/node/agents/processors/output-processor/node.cjs.map +1 -0
  155. package/lib/cjs/node/agents/processors/types.cjs +68 -0
  156. package/lib/cjs/node/agents/processors/types.cjs.map +1 -0
  157. package/lib/cjs/node/agents/rag/chains/basic/node.cjs +103 -0
  158. package/lib/cjs/node/agents/rag/chains/basic/node.cjs.map +1 -0
  159. package/lib/cjs/node/agents/rag/chains/qa/node.cjs +124 -0
  160. package/lib/cjs/node/agents/rag/chains/qa/node.cjs.map +1 -0
  161. package/lib/cjs/node/agents/rag/chains/summarization/node.cjs +116 -0
  162. package/lib/cjs/node/agents/rag/chains/summarization/node.cjs.map +1 -0
  163. package/lib/cjs/node/agents/rag/chunking/node.cjs +222 -0
  164. package/lib/cjs/node/agents/rag/chunking/node.cjs.map +1 -0
  165. package/lib/cjs/node/agents/rag/embedding/node.cjs +110 -0
  166. package/lib/cjs/node/agents/rag/embedding/node.cjs.map +1 -0
  167. package/lib/cjs/node/agents/rag/information-extractor/node.cjs +115 -0
  168. package/lib/cjs/node/agents/rag/information-extractor/node.cjs.map +1 -0
  169. package/lib/cjs/node/agents/rag/langchain-code/node.cjs +113 -0
  170. package/lib/cjs/node/agents/rag/langchain-code/node.cjs.map +1 -0
  171. package/lib/cjs/node/agents/rag/rerank/node.cjs +112 -0
  172. package/lib/cjs/node/agents/rag/rerank/node.cjs.map +1 -0
  173. package/lib/cjs/node/agents/rag/retriever/node.cjs +120 -0
  174. package/lib/cjs/node/agents/rag/retriever/node.cjs.map +1 -0
  175. package/lib/cjs/node/agents/rag/structured-output-parser/node.cjs +121 -0
  176. package/lib/cjs/node/agents/rag/structured-output-parser/node.cjs.map +1 -0
  177. package/lib/cjs/node/agents/rag/vector-store/node.cjs +187 -0
  178. package/lib/cjs/node/agents/rag/vector-store/node.cjs.map +1 -0
  179. package/lib/cjs/node/agents/responses/discord/node.cjs +101 -0
  180. package/lib/cjs/node/agents/responses/discord/node.cjs.map +1 -0
  181. package/lib/cjs/node/agents/responses/slack/node.cjs +101 -0
  182. package/lib/cjs/node/agents/responses/slack/node.cjs.map +1 -0
  183. package/lib/cjs/node/agents/responses/teams/node.cjs +101 -0
  184. package/lib/cjs/node/agents/responses/teams/node.cjs.map +1 -0
  185. package/lib/cjs/node/agents/responses/telegram/node.cjs +101 -0
  186. package/lib/cjs/node/agents/responses/telegram/node.cjs.map +1 -0
  187. package/lib/cjs/node/agents/sandbox/node.cjs +135 -0
  188. package/lib/cjs/node/agents/sandbox/node.cjs.map +1 -0
  189. package/lib/cjs/node/agents/scorers/scorer/node.cjs +107 -0
  190. package/lib/cjs/node/agents/scorers/scorer/node.cjs.map +1 -0
  191. package/lib/cjs/node/agents/scorers/scorer-selector/node.cjs +100 -0
  192. package/lib/cjs/node/agents/scorers/scorer-selector/node.cjs.map +1 -0
  193. package/lib/cjs/node/agents/skills/skill/node.cjs +105 -0
  194. package/lib/cjs/node/agents/skills/skill/node.cjs.map +1 -0
  195. package/lib/cjs/node/agents/skills/skill-selector/node.cjs +98 -0
  196. package/lib/cjs/node/agents/skills/skill-selector/node.cjs.map +1 -0
  197. package/lib/cjs/node/agents/tools/tool/node.cjs +100 -0
  198. package/lib/cjs/node/agents/tools/tool/node.cjs.map +1 -0
  199. package/lib/cjs/node/agents/tools/tool-selector/node.cjs +99 -0
  200. package/lib/cjs/node/agents/tools/tool-selector/node.cjs.map +1 -0
  201. package/lib/cjs/node/agents/triggers/discord/node.cjs +101 -0
  202. package/lib/cjs/node/agents/triggers/discord/node.cjs.map +1 -0
  203. package/lib/cjs/node/agents/triggers/mcp-server/node.cjs +147 -0
  204. package/lib/cjs/node/agents/triggers/mcp-server/node.cjs.map +1 -0
  205. package/lib/cjs/node/agents/triggers/slack/node.cjs +101 -0
  206. package/lib/cjs/node/agents/triggers/slack/node.cjs.map +1 -0
  207. package/lib/cjs/node/agents/triggers/teams/node.cjs +101 -0
  208. package/lib/cjs/node/agents/triggers/teams/node.cjs.map +1 -0
  209. package/lib/cjs/node/agents/triggers/telegram/node.cjs +101 -0
  210. package/lib/cjs/node/agents/triggers/telegram/node.cjs.map +1 -0
  211. package/lib/cjs/node/agents/voice/node.cjs +107 -0
  212. package/lib/cjs/node/agents/voice/node.cjs.map +1 -0
  213. package/lib/cjs/node/agents/zones.cjs +43 -0
  214. package/lib/cjs/node/agents/zones.cjs.map +1 -0
  215. package/lib/cjs/node/comms/email-send/node.cjs +340 -0
  216. package/lib/cjs/node/comms/email-send/node.cjs.map +1 -0
  217. package/lib/cjs/node/comms/gmail/node.cjs +287 -0
  218. package/lib/cjs/node/comms/gmail/node.cjs.map +1 -0
  219. package/lib/cjs/node/comms/slack/node.cjs +276 -0
  220. package/lib/cjs/node/comms/slack/node.cjs.map +1 -0
  221. package/lib/cjs/node/comms/teams/node.cjs +231 -0
  222. package/lib/cjs/node/comms/teams/node.cjs.map +1 -0
  223. package/lib/cjs/node/comms/telegram/node.cjs +260 -0
  224. package/lib/cjs/node/comms/telegram/node.cjs.map +1 -0
  225. package/lib/cjs/node/credentials.cjs +103 -0
  226. package/lib/cjs/node/credentials.cjs.map +1 -0
  227. package/lib/cjs/node/data/data-table/node.cjs +265 -0
  228. package/lib/cjs/node/data/data-table/node.cjs.map +1 -0
  229. package/lib/cjs/node/data/date-time/node.cjs +180 -0
  230. package/lib/cjs/node/data/date-time/node.cjs.map +1 -0
  231. package/lib/cjs/node/data/filter/node.cjs +134 -0
  232. package/lib/cjs/node/data/filter/node.cjs.map +1 -0
  233. package/lib/cjs/node/data/limit/node.cjs +104 -0
  234. package/lib/cjs/node/data/limit/node.cjs.map +1 -0
  235. package/lib/cjs/node/data/merge/node.cjs +251 -0
  236. package/lib/cjs/node/data/merge/node.cjs.map +1 -0
  237. package/lib/cjs/node/data/rename-keys/node.cjs +139 -0
  238. package/lib/cjs/node/data/rename-keys/node.cjs.map +1 -0
  239. package/lib/cjs/node/data/set/node.cjs +148 -0
  240. package/lib/cjs/node/data/set/node.cjs.map +1 -0
  241. package/lib/cjs/node/data/sort/node.cjs +125 -0
  242. package/lib/cjs/node/data/sort/node.cjs.map +1 -0
  243. package/lib/cjs/node/data/split-out/node.cjs +140 -0
  244. package/lib/cjs/node/data/split-out/node.cjs.map +1 -0
  245. package/lib/cjs/node/data/support.cjs +398 -0
  246. package/lib/cjs/node/data/support.cjs.map +1 -0
  247. package/lib/cjs/node/devops/crypto/node.cjs +364 -0
  248. package/lib/cjs/node/devops/crypto/node.cjs.map +1 -0
  249. package/lib/cjs/node/devops/execute-command/node.cjs +201 -0
  250. package/lib/cjs/node/devops/execute-command/node.cjs.map +1 -0
  251. package/lib/cjs/node/devops/ftp/node.cjs +241 -0
  252. package/lib/cjs/node/devops/ftp/node.cjs.map +1 -0
  253. package/lib/cjs/node/devops/github/node.cjs +282 -0
  254. package/lib/cjs/node/devops/github/node.cjs.map +1 -0
  255. package/lib/cjs/node/devops/gitlab/node.cjs +273 -0
  256. package/lib/cjs/node/devops/gitlab/node.cjs.map +1 -0
  257. package/lib/cjs/node/devops/jwt/node.cjs +204 -0
  258. package/lib/cjs/node/devops/jwt/node.cjs.map +1 -0
  259. package/lib/cjs/node/flow/execute-sub-workflow/node.cjs +223 -0
  260. package/lib/cjs/node/flow/execute-sub-workflow/node.cjs.map +1 -0
  261. package/lib/cjs/node/index.cjs +402 -66
  262. package/lib/cjs/node/index.cjs.map +1 -1
  263. package/lib/cjs/node/io/airtable/node.cjs +318 -0
  264. package/lib/cjs/node/io/airtable/node.cjs.map +1 -0
  265. package/lib/cjs/node/io/extract-from-file/node.cjs +269 -0
  266. package/lib/cjs/node/io/extract-from-file/node.cjs.map +1 -0
  267. package/lib/cjs/node/io/google-sheets/node.cjs +267 -0
  268. package/lib/cjs/node/io/google-sheets/node.cjs.map +1 -0
  269. package/lib/cjs/node/io/graphql/node.cjs +169 -0
  270. package/lib/cjs/node/io/graphql/node.cjs.map +1 -0
  271. package/lib/cjs/node/io/http-request/node.cjs +415 -0
  272. package/lib/cjs/node/io/http-request/node.cjs.map +1 -0
  273. package/lib/cjs/node/io/read-pdf/node.cjs +206 -0
  274. package/lib/cjs/node/io/read-pdf/node.cjs.map +1 -0
  275. package/lib/cjs/node/io/read-write-file/node.cjs +314 -0
  276. package/lib/cjs/node/io/read-write-file/node.cjs.map +1 -0
  277. package/lib/cjs/node/io/respond-to-webhook/node.cjs +183 -0
  278. package/lib/cjs/node/io/respond-to-webhook/node.cjs.map +1 -0
  279. package/lib/cjs/node/io/spreadsheet-file/node.cjs +192 -0
  280. package/lib/cjs/node/io/spreadsheet-file/node.cjs.map +1 -0
  281. package/lib/cjs/node/manifests.cjs +264 -36
  282. package/lib/cjs/node/manifests.cjs.map +1 -1
  283. package/lib/cjs/node/storage/blob/azure/node.cjs +138 -0
  284. package/lib/cjs/node/storage/blob/azure/node.cjs.map +1 -0
  285. package/lib/cjs/node/storage/blob/base.cjs +321 -0
  286. package/lib/cjs/node/storage/blob/base.cjs.map +1 -0
  287. package/lib/cjs/node/storage/blob/gcs/node.cjs +126 -0
  288. package/lib/cjs/node/storage/blob/gcs/node.cjs.map +1 -0
  289. package/lib/cjs/node/storage/blob/s3/node.cjs +186 -0
  290. package/lib/cjs/node/storage/blob/s3/node.cjs.map +1 -0
  291. package/lib/cjs/node/storage/database/base.cjs +301 -0
  292. package/lib/cjs/node/storage/database/base.cjs.map +1 -0
  293. package/lib/cjs/node/storage/database/mssql/node.cjs +50 -0
  294. package/lib/cjs/node/storage/database/mssql/node.cjs.map +1 -0
  295. package/lib/cjs/node/storage/database/mysql/node.cjs +50 -0
  296. package/lib/cjs/node/storage/database/mysql/node.cjs.map +1 -0
  297. package/lib/cjs/node/storage/database/postgres/node.cjs +50 -0
  298. package/lib/cjs/node/storage/database/postgres/node.cjs.map +1 -0
  299. package/lib/cjs/node/storage/redis/node.cjs +340 -0
  300. package/lib/cjs/node/storage/redis/node.cjs.map +1 -0
  301. package/lib/cjs/node/storage/support.cjs +81 -0
  302. package/lib/cjs/node/storage/support.cjs.map +1 -0
  303. package/lib/cjs/node/triggers/execute-workflow/node.cjs +94 -0
  304. package/lib/cjs/node/triggers/execute-workflow/node.cjs.map +1 -0
  305. package/lib/cjs/ram/GraphNodeRepository.cjs +40 -0
  306. package/lib/cjs/ram/GraphNodeRepository.cjs.map +1 -0
  307. package/lib/cjs/ram/GraphRunEventModel.cjs +4 -0
  308. package/lib/cjs/ram/GraphRunEventModel.cjs.map +1 -1
  309. package/lib/cjs/ram/index.cjs +1 -0
  310. package/lib/cjs/ram/index.cjs.map +1 -1
  311. package/lib/cjs/shared/graph/GraphNodeConverters.cjs +43 -0
  312. package/lib/cjs/shared/graph/GraphNodeConverters.cjs.map +1 -0
  313. package/lib/cjs/shared/graph/GraphNodeModel.cjs +78 -0
  314. package/lib/cjs/shared/graph/GraphNodeModel.cjs.map +1 -0
  315. package/lib/cjs/shared/graph/GraphWorkflowModel.cjs +4 -0
  316. package/lib/cjs/shared/graph/GraphWorkflowModel.cjs.map +1 -1
  317. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs +40 -0
  318. package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs.map +1 -1
  319. package/lib/cjs/shared/graph/category-styles.cjs +12 -0
  320. package/lib/cjs/shared/graph/category-styles.cjs.map +1 -1
  321. package/lib/cjs/shared/graph/index.cjs +2 -0
  322. package/lib/cjs/shared/graph/index.cjs.map +1 -1
  323. package/lib/cjs/typeorm/TypeormGraphAdapter.cjs +250 -0
  324. package/lib/cjs/typeorm/TypeormGraphAdapter.cjs.map +1 -0
  325. package/lib/cjs/typeorm/index.cjs +29 -0
  326. package/lib/cjs/typeorm/index.cjs.map +1 -0
  327. package/lib/esm/dagster/DagsterGraphExecutionBackend.js +102 -11
  328. package/lib/esm/dagster/DagsterGraphExecutionBackend.js.map +1 -1
  329. package/lib/esm/engine/auth/GraphAuthValidator.js +19 -0
  330. package/lib/esm/engine/auth/GraphAuthValidator.js.map +1 -1
  331. package/lib/esm/engine/constants.js +60 -0
  332. package/lib/esm/engine/constants.js.map +1 -1
  333. package/lib/esm/engine/credentials/GraphNodeCredentials.js +152 -0
  334. package/lib/esm/engine/credentials/GraphNodeCredentials.js.map +1 -0
  335. package/lib/esm/engine/execution/GraphExecutionBackend.js.map +1 -1
  336. package/lib/esm/engine/execution/GraphExecutionEngine.js +236 -68
  337. package/lib/esm/engine/execution/GraphExecutionEngine.js.map +1 -1
  338. package/lib/esm/engine/execution/GraphNodeEngineRequirements.js +28 -0
  339. package/lib/esm/engine/execution/GraphNodeEngineRequirements.js.map +1 -0
  340. package/lib/esm/engine/execution/GraphWebhookResponseRegistry.js +103 -0
  341. package/lib/esm/engine/execution/GraphWebhookResponseRegistry.js.map +1 -0
  342. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js +93 -2
  343. package/lib/esm/engine/execution/LocalGraphExecutionBackend.js.map +1 -1
  344. package/lib/esm/engine/execution/index.js +1 -0
  345. package/lib/esm/engine/execution/index.js.map +1 -1
  346. package/lib/esm/engine/index.js +5 -0
  347. package/lib/esm/engine/index.js.map +1 -1
  348. package/lib/esm/engine/services/GraphNodeModelService.js +120 -0
  349. package/lib/esm/engine/services/GraphNodeModelService.js.map +1 -0
  350. package/lib/esm/engine/services/GraphWorkflowService.js +34 -1
  351. package/lib/esm/engine/services/GraphWorkflowService.js.map +1 -1
  352. package/lib/esm/engine/store/GraphDataTableModel.js +67 -0
  353. package/lib/esm/engine/store/GraphDataTableModel.js.map +1 -0
  354. package/lib/esm/engine/store/GraphDataTableRepository.js +314 -0
  355. package/lib/esm/engine/store/GraphDataTableRepository.js.map +1 -0
  356. package/lib/esm/engine/store/index.js +2 -0
  357. package/lib/esm/engine/store/index.js.map +1 -1
  358. package/lib/esm/engine/validation/GraphConnectionPolicyValidator.js +28 -0
  359. package/lib/esm/engine/validation/GraphConnectionPolicyValidator.js.map +1 -1
  360. package/lib/esm/engine/validation/GraphCredentialReferenceValidator.js +4 -2
  361. package/lib/esm/engine/validation/GraphCredentialReferenceValidator.js.map +1 -1
  362. package/lib/esm/engine/validation/GraphParameterValidator.js +6 -0
  363. package/lib/esm/engine/validation/GraphParameterValidator.js.map +1 -1
  364. package/lib/esm/mastra/MastraAgeVectorDriver.js +294 -0
  365. package/lib/esm/mastra/MastraAgeVectorDriver.js.map +1 -0
  366. package/lib/esm/mastra/MastraAgentBuilder.js +244 -0
  367. package/lib/esm/mastra/MastraAgentBuilder.js.map +1 -0
  368. package/lib/esm/mastra/MastraAgentModelAdapter.js +59 -0
  369. package/lib/esm/mastra/MastraAgentModelAdapter.js.map +1 -0
  370. package/lib/esm/mastra/MastraAgentProcessors.js +391 -0
  371. package/lib/esm/mastra/MastraAgentProcessors.js.map +1 -0
  372. package/lib/esm/mastra/MastraAgentStepHandler.js +327 -0
  373. package/lib/esm/mastra/MastraAgentStepHandler.js.map +1 -0
  374. package/lib/esm/mastra/MastraCapabilities.js +115 -0
  375. package/lib/esm/mastra/MastraCapabilities.js.map +1 -1
  376. package/lib/esm/mastra/MastraChannelResponse.js +154 -0
  377. package/lib/esm/mastra/MastraChannelResponse.js.map +1 -0
  378. package/lib/esm/mastra/MastraChannelTrigger.js +116 -0
  379. package/lib/esm/mastra/MastraChannelTrigger.js.map +1 -0
  380. package/lib/esm/mastra/MastraDefaultStepHandlers.js +430 -0
  381. package/lib/esm/mastra/MastraDefaultStepHandlers.js.map +1 -0
  382. package/lib/esm/mastra/MastraEnvironment.js +287 -0
  383. package/lib/esm/mastra/MastraEnvironment.js.map +1 -0
  384. package/lib/esm/mastra/MastraEvalModels.js +535 -0
  385. package/lib/esm/mastra/MastraEvalModels.js.map +1 -0
  386. package/lib/esm/mastra/MastraEventBridge.js +31 -4
  387. package/lib/esm/mastra/MastraEventBridge.js.map +1 -1
  388. package/lib/esm/mastra/MastraGraphExecutionBackend.js +514 -21
  389. package/lib/esm/mastra/MastraGraphExecutionBackend.js.map +1 -1
  390. package/lib/esm/mastra/MastraGraphExecutionModule.js +139 -0
  391. package/lib/esm/mastra/MastraGraphExecutionModule.js.map +1 -0
  392. package/lib/esm/mastra/MastraHitlStepHandler.js +62 -0
  393. package/lib/esm/mastra/MastraHitlStepHandler.js.map +1 -0
  394. package/lib/esm/mastra/MastraMcpTrigger.js +246 -0
  395. package/lib/esm/mastra/MastraMcpTrigger.js.map +1 -0
  396. package/lib/esm/mastra/MastraMemory.js +455 -0
  397. package/lib/esm/mastra/MastraMemory.js.map +1 -0
  398. package/lib/esm/mastra/MastraMetricsAdapter.js +273 -0
  399. package/lib/esm/mastra/MastraMetricsAdapter.js.map +1 -0
  400. package/lib/esm/mastra/MastraMetricsGateway.js +394 -0
  401. package/lib/esm/mastra/MastraMetricsGateway.js.map +1 -0
  402. package/lib/esm/mastra/MastraMetricsModels.js +486 -0
  403. package/lib/esm/mastra/MastraMetricsModels.js.map +1 -0
  404. package/lib/esm/mastra/MastraMetricsStatement.js +213 -0
  405. package/lib/esm/mastra/MastraMetricsStatement.js.map +1 -0
  406. package/lib/esm/mastra/MastraModelSchemaConverter.js +78 -0
  407. package/lib/esm/mastra/MastraModelSchemaConverter.js.map +1 -0
  408. package/lib/esm/mastra/MastraObservability.js +327 -0
  409. package/lib/esm/mastra/MastraObservability.js.map +1 -0
  410. package/lib/esm/mastra/MastraPersistence.js +530 -0
  411. package/lib/esm/mastra/MastraPersistence.js.map +1 -0
  412. package/lib/esm/mastra/MastraRagStepHandlers.js +920 -0
  413. package/lib/esm/mastra/MastraRagStepHandlers.js.map +1 -0
  414. package/lib/esm/mastra/MastraRunMetricsEndpoint.js +147 -0
  415. package/lib/esm/mastra/MastraRunMetricsEndpoint.js.map +1 -0
  416. package/lib/esm/mastra/MastraRunRecovery.js +89 -0
  417. package/lib/esm/mastra/MastraRunRecovery.js.map +1 -0
  418. package/lib/esm/mastra/MastraScheduleTrigger.js +110 -0
  419. package/lib/esm/mastra/MastraScheduleTrigger.js.map +1 -0
  420. package/lib/esm/mastra/MastraStorageWiring.js +119 -0
  421. package/lib/esm/mastra/MastraStorageWiring.js.map +1 -0
  422. package/lib/esm/mastra/MastraStructuredOutput.js +144 -0
  423. package/lib/esm/mastra/MastraStructuredOutput.js.map +1 -0
  424. package/lib/esm/mastra/MastraToolBuilder.js +68 -0
  425. package/lib/esm/mastra/MastraToolBuilder.js.map +1 -0
  426. package/lib/esm/mastra/MastraToolConfig.js +37 -0
  427. package/lib/esm/mastra/MastraToolConfig.js.map +1 -0
  428. package/lib/esm/mastra/MastraToolDecorator.js +92 -0
  429. package/lib/esm/mastra/MastraToolDecorator.js.map +1 -0
  430. package/lib/esm/mastra/MastraVectorStore.js +605 -0
  431. package/lib/esm/mastra/MastraVectorStore.js.map +1 -0
  432. package/lib/esm/mastra/MastraVoiceStepHandler.js +84 -0
  433. package/lib/esm/mastra/MastraVoiceStepHandler.js.map +1 -0
  434. package/lib/esm/mastra/MastraWorkflowCompiler.js +41 -9
  435. package/lib/esm/mastra/MastraWorkflowCompiler.js.map +1 -1
  436. package/lib/esm/mastra/MastraWorkflowManager.js +101 -51
  437. package/lib/esm/mastra/MastraWorkflowManager.js.map +1 -1
  438. package/lib/esm/mastra/index.js +41 -1
  439. package/lib/esm/mastra/index.js.map +1 -1
  440. package/lib/esm/mastra/nodes/MastraNodeRegistry.js +225 -0
  441. package/lib/esm/mastra/nodes/MastraNodeRegistry.js.map +1 -0
  442. package/lib/esm/mastra/nodes/index.js +12 -0
  443. package/lib/esm/mastra/nodes/index.js.map +1 -0
  444. package/lib/esm/mastra/nodes/types.js +2 -0
  445. package/lib/esm/mastra/nodes/types.js.map +1 -0
  446. package/lib/esm/mastra/types.js +129 -0
  447. package/lib/esm/mastra/types.js.map +1 -1
  448. package/lib/esm/nest/graph/GraphBackendHost.js +79 -20
  449. package/lib/esm/nest/graph/GraphBackendHost.js.map +1 -1
  450. package/lib/esm/nest/graph/GraphExecutionModule.js +73 -3
  451. package/lib/esm/nest/graph/GraphExecutionModule.js.map +1 -1
  452. package/lib/esm/nest/graph/GraphRunController.js +47 -6
  453. package/lib/esm/nest/graph/GraphRunController.js.map +1 -1
  454. package/lib/esm/nest/graph/main.js +100 -3
  455. package/lib/esm/nest/graph/main.js.map +1 -1
  456. package/lib/esm/node/agents/agent/node.js +189 -31
  457. package/lib/esm/node/agents/agent/node.js.map +1 -1
  458. package/lib/esm/node/agents/hitl/node.js +106 -0
  459. package/lib/esm/node/agents/hitl/node.js.map +1 -0
  460. package/lib/esm/node/agents/hooks/delegation/node.js +113 -0
  461. package/lib/esm/node/agents/hooks/delegation/node.js.map +1 -0
  462. package/lib/esm/node/agents/hooks/hook/node.js +111 -0
  463. package/lib/esm/node/agents/hooks/hook/node.js.map +1 -0
  464. package/lib/esm/node/agents/hooks/tool-deny/node.js +95 -0
  465. package/lib/esm/node/agents/hooks/tool-deny/node.js.map +1 -0
  466. package/lib/esm/node/agents/memory/memory/node.js +222 -0
  467. package/lib/esm/node/agents/memory/memory/node.js.map +1 -0
  468. package/lib/esm/node/agents/memory/memory-selector/node.js +92 -0
  469. package/lib/esm/node/agents/memory/memory-selector/node.js.map +1 -0
  470. package/lib/esm/node/agents/processors/guardrail/node.js +117 -0
  471. package/lib/esm/node/agents/processors/guardrail/node.js.map +1 -0
  472. package/lib/esm/node/agents/processors/input-processor/node.js +109 -0
  473. package/lib/esm/node/agents/processors/input-processor/node.js.map +1 -0
  474. package/lib/esm/node/agents/processors/output-processor/node.js +99 -0
  475. package/lib/esm/node/agents/processors/output-processor/node.js.map +1 -0
  476. package/lib/esm/node/agents/processors/types.js +64 -0
  477. package/lib/esm/node/agents/processors/types.js.map +1 -0
  478. package/lib/esm/node/agents/rag/chains/basic/node.js +94 -0
  479. package/lib/esm/node/agents/rag/chains/basic/node.js.map +1 -0
  480. package/lib/esm/node/agents/rag/chains/qa/node.js +115 -0
  481. package/lib/esm/node/agents/rag/chains/qa/node.js.map +1 -0
  482. package/lib/esm/node/agents/rag/chains/summarization/node.js +107 -0
  483. package/lib/esm/node/agents/rag/chains/summarization/node.js.map +1 -0
  484. package/lib/esm/node/agents/rag/chunking/node.js +211 -0
  485. package/lib/esm/node/agents/rag/chunking/node.js.map +1 -0
  486. package/lib/esm/node/agents/rag/embedding/node.js +101 -0
  487. package/lib/esm/node/agents/rag/embedding/node.js.map +1 -0
  488. package/lib/esm/node/agents/rag/information-extractor/node.js +106 -0
  489. package/lib/esm/node/agents/rag/information-extractor/node.js.map +1 -0
  490. package/lib/esm/node/agents/rag/langchain-code/node.js +104 -0
  491. package/lib/esm/node/agents/rag/langchain-code/node.js.map +1 -0
  492. package/lib/esm/node/agents/rag/rerank/node.js +103 -0
  493. package/lib/esm/node/agents/rag/rerank/node.js.map +1 -0
  494. package/lib/esm/node/agents/rag/retriever/node.js +111 -0
  495. package/lib/esm/node/agents/rag/retriever/node.js.map +1 -0
  496. package/lib/esm/node/agents/rag/structured-output-parser/node.js +112 -0
  497. package/lib/esm/node/agents/rag/structured-output-parser/node.js.map +1 -0
  498. package/lib/esm/node/agents/rag/vector-store/node.js +178 -0
  499. package/lib/esm/node/agents/rag/vector-store/node.js.map +1 -0
  500. package/lib/esm/node/agents/responses/discord/node.js +92 -0
  501. package/lib/esm/node/agents/responses/discord/node.js.map +1 -0
  502. package/lib/esm/node/agents/responses/slack/node.js +92 -0
  503. package/lib/esm/node/agents/responses/slack/node.js.map +1 -0
  504. package/lib/esm/node/agents/responses/teams/node.js +92 -0
  505. package/lib/esm/node/agents/responses/teams/node.js.map +1 -0
  506. package/lib/esm/node/agents/responses/telegram/node.js +92 -0
  507. package/lib/esm/node/agents/responses/telegram/node.js.map +1 -0
  508. package/lib/esm/node/agents/sandbox/node.js +125 -0
  509. package/lib/esm/node/agents/sandbox/node.js.map +1 -0
  510. package/lib/esm/node/agents/scorers/scorer/node.js +98 -0
  511. package/lib/esm/node/agents/scorers/scorer/node.js.map +1 -0
  512. package/lib/esm/node/agents/scorers/scorer-selector/node.js +91 -0
  513. package/lib/esm/node/agents/scorers/scorer-selector/node.js.map +1 -0
  514. package/lib/esm/node/agents/skills/skill/node.js +96 -0
  515. package/lib/esm/node/agents/skills/skill/node.js.map +1 -0
  516. package/lib/esm/node/agents/skills/skill-selector/node.js +89 -0
  517. package/lib/esm/node/agents/skills/skill-selector/node.js.map +1 -0
  518. package/lib/esm/node/agents/tools/tool/node.js +91 -0
  519. package/lib/esm/node/agents/tools/tool/node.js.map +1 -0
  520. package/lib/esm/node/agents/tools/tool-selector/node.js +90 -0
  521. package/lib/esm/node/agents/tools/tool-selector/node.js.map +1 -0
  522. package/lib/esm/node/agents/triggers/discord/node.js +92 -0
  523. package/lib/esm/node/agents/triggers/discord/node.js.map +1 -0
  524. package/lib/esm/node/agents/triggers/mcp-server/node.js +138 -0
  525. package/lib/esm/node/agents/triggers/mcp-server/node.js.map +1 -0
  526. package/lib/esm/node/agents/triggers/slack/node.js +92 -0
  527. package/lib/esm/node/agents/triggers/slack/node.js.map +1 -0
  528. package/lib/esm/node/agents/triggers/teams/node.js +92 -0
  529. package/lib/esm/node/agents/triggers/teams/node.js.map +1 -0
  530. package/lib/esm/node/agents/triggers/telegram/node.js +92 -0
  531. package/lib/esm/node/agents/triggers/telegram/node.js.map +1 -0
  532. package/lib/esm/node/agents/voice/node.js +98 -0
  533. package/lib/esm/node/agents/voice/node.js.map +1 -0
  534. package/lib/esm/node/agents/zones.js +39 -0
  535. package/lib/esm/node/agents/zones.js.map +1 -0
  536. package/lib/esm/node/comms/email-send/node.js +331 -0
  537. package/lib/esm/node/comms/email-send/node.js.map +1 -0
  538. package/lib/esm/node/comms/gmail/node.js +278 -0
  539. package/lib/esm/node/comms/gmail/node.js.map +1 -0
  540. package/lib/esm/node/comms/slack/node.js +267 -0
  541. package/lib/esm/node/comms/slack/node.js.map +1 -0
  542. package/lib/esm/node/comms/teams/node.js +222 -0
  543. package/lib/esm/node/comms/teams/node.js.map +1 -0
  544. package/lib/esm/node/comms/telegram/node.js +251 -0
  545. package/lib/esm/node/comms/telegram/node.js.map +1 -0
  546. package/lib/esm/node/credentials.js +96 -0
  547. package/lib/esm/node/credentials.js.map +1 -0
  548. package/lib/esm/node/data/data-table/node.js +256 -0
  549. package/lib/esm/node/data/data-table/node.js.map +1 -0
  550. package/lib/esm/node/data/date-time/node.js +171 -0
  551. package/lib/esm/node/data/date-time/node.js.map +1 -0
  552. package/lib/esm/node/data/filter/node.js +125 -0
  553. package/lib/esm/node/data/filter/node.js.map +1 -0
  554. package/lib/esm/node/data/limit/node.js +95 -0
  555. package/lib/esm/node/data/limit/node.js.map +1 -0
  556. package/lib/esm/node/data/merge/node.js +242 -0
  557. package/lib/esm/node/data/merge/node.js.map +1 -0
  558. package/lib/esm/node/data/rename-keys/node.js +130 -0
  559. package/lib/esm/node/data/rename-keys/node.js.map +1 -0
  560. package/lib/esm/node/data/set/node.js +139 -0
  561. package/lib/esm/node/data/set/node.js.map +1 -0
  562. package/lib/esm/node/data/sort/node.js +116 -0
  563. package/lib/esm/node/data/sort/node.js.map +1 -0
  564. package/lib/esm/node/data/split-out/node.js +131 -0
  565. package/lib/esm/node/data/split-out/node.js.map +1 -0
  566. package/lib/esm/node/data/support.js +382 -0
  567. package/lib/esm/node/data/support.js.map +1 -0
  568. package/lib/esm/node/devops/crypto/node.js +355 -0
  569. package/lib/esm/node/devops/crypto/node.js.map +1 -0
  570. package/lib/esm/node/devops/execute-command/node.js +192 -0
  571. package/lib/esm/node/devops/execute-command/node.js.map +1 -0
  572. package/lib/esm/node/devops/ftp/node.js +232 -0
  573. package/lib/esm/node/devops/ftp/node.js.map +1 -0
  574. package/lib/esm/node/devops/github/node.js +273 -0
  575. package/lib/esm/node/devops/github/node.js.map +1 -0
  576. package/lib/esm/node/devops/gitlab/node.js +264 -0
  577. package/lib/esm/node/devops/gitlab/node.js.map +1 -0
  578. package/lib/esm/node/devops/jwt/node.js +195 -0
  579. package/lib/esm/node/devops/jwt/node.js.map +1 -0
  580. package/lib/esm/node/flow/execute-sub-workflow/node.js +214 -0
  581. package/lib/esm/node/flow/execute-sub-workflow/node.js.map +1 -0
  582. package/lib/esm/node/index.js +338 -2
  583. package/lib/esm/node/index.js.map +1 -1
  584. package/lib/esm/node/io/airtable/node.js +309 -0
  585. package/lib/esm/node/io/airtable/node.js.map +1 -0
  586. package/lib/esm/node/io/extract-from-file/node.js +260 -0
  587. package/lib/esm/node/io/extract-from-file/node.js.map +1 -0
  588. package/lib/esm/node/io/google-sheets/node.js +258 -0
  589. package/lib/esm/node/io/google-sheets/node.js.map +1 -0
  590. package/lib/esm/node/io/graphql/node.js +160 -0
  591. package/lib/esm/node/io/graphql/node.js.map +1 -0
  592. package/lib/esm/node/io/http-request/node.js +406 -0
  593. package/lib/esm/node/io/http-request/node.js.map +1 -0
  594. package/lib/esm/node/io/read-pdf/node.js +164 -0
  595. package/lib/esm/node/io/read-pdf/node.js.map +1 -0
  596. package/lib/esm/node/io/read-write-file/node.js +305 -0
  597. package/lib/esm/node/io/read-write-file/node.js.map +1 -0
  598. package/lib/esm/node/io/respond-to-webhook/node.js +174 -0
  599. package/lib/esm/node/io/respond-to-webhook/node.js.map +1 -0
  600. package/lib/esm/node/io/spreadsheet-file/node.js +183 -0
  601. package/lib/esm/node/io/spreadsheet-file/node.js.map +1 -0
  602. package/lib/esm/node/manifests.js +228 -0
  603. package/lib/esm/node/manifests.js.map +1 -1
  604. package/lib/esm/node/storage/blob/azure/node.js +129 -0
  605. package/lib/esm/node/storage/blob/azure/node.js.map +1 -0
  606. package/lib/esm/node/storage/blob/base.js +311 -0
  607. package/lib/esm/node/storage/blob/base.js.map +1 -0
  608. package/lib/esm/node/storage/blob/gcs/node.js +117 -0
  609. package/lib/esm/node/storage/blob/gcs/node.js.map +1 -0
  610. package/lib/esm/node/storage/blob/s3/node.js +176 -0
  611. package/lib/esm/node/storage/blob/s3/node.js.map +1 -0
  612. package/lib/esm/node/storage/database/base.js +291 -0
  613. package/lib/esm/node/storage/database/base.js.map +1 -0
  614. package/lib/esm/node/storage/database/mssql/node.js +42 -0
  615. package/lib/esm/node/storage/database/mssql/node.js.map +1 -0
  616. package/lib/esm/node/storage/database/mysql/node.js +42 -0
  617. package/lib/esm/node/storage/database/mysql/node.js.map +1 -0
  618. package/lib/esm/node/storage/database/postgres/node.js +42 -0
  619. package/lib/esm/node/storage/database/postgres/node.js.map +1 -0
  620. package/lib/esm/node/storage/redis/node.js +331 -0
  621. package/lib/esm/node/storage/redis/node.js.map +1 -0
  622. package/lib/esm/node/storage/support.js +69 -0
  623. package/lib/esm/node/storage/support.js.map +1 -0
  624. package/lib/esm/node/triggers/execute-workflow/node.js +85 -0
  625. package/lib/esm/node/triggers/execute-workflow/node.js.map +1 -0
  626. package/lib/esm/ram/GraphNodeRepository.js +31 -0
  627. package/lib/esm/ram/GraphNodeRepository.js.map +1 -0
  628. package/lib/esm/ram/GraphRunEventModel.js +5 -1
  629. package/lib/esm/ram/GraphRunEventModel.js.map +1 -1
  630. package/lib/esm/ram/index.js +1 -0
  631. package/lib/esm/ram/index.js.map +1 -1
  632. package/lib/esm/shared/graph/GraphNodeConverters.js +38 -0
  633. package/lib/esm/shared/graph/GraphNodeConverters.js.map +1 -0
  634. package/lib/esm/shared/graph/GraphNodeModel.js +69 -0
  635. package/lib/esm/shared/graph/GraphNodeModel.js.map +1 -0
  636. package/lib/esm/shared/graph/GraphWorkflowModel.js +5 -1
  637. package/lib/esm/shared/graph/GraphWorkflowModel.js.map +1 -1
  638. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js +40 -0
  639. package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js.map +1 -1
  640. package/lib/esm/shared/graph/catalog/GraphPortManifest.js.map +1 -1
  641. package/lib/esm/shared/graph/category-styles.js +12 -0
  642. package/lib/esm/shared/graph/category-styles.js.map +1 -1
  643. package/lib/esm/shared/graph/constants.js.map +1 -1
  644. package/lib/esm/shared/graph/index.js +2 -0
  645. package/lib/esm/shared/graph/index.js.map +1 -1
  646. package/lib/esm/typeorm/TypeormGraphAdapter.js +213 -0
  647. package/lib/esm/typeorm/TypeormGraphAdapter.js.map +1 -0
  648. package/lib/esm/typeorm/index.js +12 -0
  649. package/lib/esm/typeorm/index.js.map +1 -0
  650. package/lib/types/dagster/DagsterGraphExecutionBackend.d.cts +40 -4
  651. package/lib/types/dagster/DagsterGraphExecutionBackend.d.mts +40 -4
  652. package/lib/types/engine/auth/GraphAuthValidator.d.cts +13 -0
  653. package/lib/types/engine/auth/GraphAuthValidator.d.mts +13 -0
  654. package/lib/types/engine/constants.d.cts +60 -0
  655. package/lib/types/engine/constants.d.mts +60 -0
  656. package/lib/types/engine/credentials/GraphNodeCredentials.d.cts +145 -0
  657. package/lib/types/engine/credentials/GraphNodeCredentials.d.mts +145 -0
  658. package/lib/types/engine/execution/GraphExecutionBackend.d.cts +27 -0
  659. package/lib/types/engine/execution/GraphExecutionBackend.d.mts +27 -0
  660. package/lib/types/engine/execution/GraphExecutionEngine.d.cts +97 -1
  661. package/lib/types/engine/execution/GraphExecutionEngine.d.mts +97 -1
  662. package/lib/types/engine/execution/GraphNodeEngineRequirements.d.cts +24 -0
  663. package/lib/types/engine/execution/GraphNodeEngineRequirements.d.mts +24 -0
  664. package/lib/types/engine/execution/GraphWebhookResponseRegistry.d.cts +67 -0
  665. package/lib/types/engine/execution/GraphWebhookResponseRegistry.d.mts +67 -0
  666. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.cts +26 -3
  667. package/lib/types/engine/execution/LocalGraphExecutionBackend.d.mts +26 -3
  668. package/lib/types/engine/execution/index.d.cts +1 -0
  669. package/lib/types/engine/execution/index.d.mts +1 -0
  670. package/lib/types/engine/index.d.cts +5 -0
  671. package/lib/types/engine/index.d.mts +5 -0
  672. package/lib/types/engine/services/GraphNodeModelService.d.cts +54 -0
  673. package/lib/types/engine/services/GraphNodeModelService.d.mts +54 -0
  674. package/lib/types/engine/services/GraphWorkflowService.d.cts +21 -0
  675. package/lib/types/engine/services/GraphWorkflowService.d.mts +21 -0
  676. package/lib/types/engine/store/GraphDataTableModel.d.cts +24 -0
  677. package/lib/types/engine/store/GraphDataTableModel.d.mts +24 -0
  678. package/lib/types/engine/store/GraphDataTableRepository.d.cts +136 -0
  679. package/lib/types/engine/store/GraphDataTableRepository.d.mts +136 -0
  680. package/lib/types/engine/store/index.d.cts +2 -0
  681. package/lib/types/engine/store/index.d.mts +2 -0
  682. package/lib/types/engine/types.d.cts +12 -0
  683. package/lib/types/engine/types.d.mts +12 -0
  684. package/lib/types/engine/validation/GraphConnectionPolicyValidator.d.cts +10 -0
  685. package/lib/types/engine/validation/GraphConnectionPolicyValidator.d.mts +10 -0
  686. package/lib/types/engine/validation/GraphParameterValidator.d.cts +1 -1
  687. package/lib/types/engine/validation/GraphParameterValidator.d.mts +1 -1
  688. package/lib/types/mastra/MastraAgeVectorDriver.d.cts +55 -0
  689. package/lib/types/mastra/MastraAgeVectorDriver.d.mts +55 -0
  690. package/lib/types/mastra/MastraAgentBuilder.d.cts +188 -0
  691. package/lib/types/mastra/MastraAgentBuilder.d.mts +188 -0
  692. package/lib/types/mastra/MastraAgentModelAdapter.d.cts +76 -0
  693. package/lib/types/mastra/MastraAgentModelAdapter.d.mts +76 -0
  694. package/lib/types/mastra/MastraAgentProcessors.d.cts +50 -0
  695. package/lib/types/mastra/MastraAgentProcessors.d.mts +50 -0
  696. package/lib/types/mastra/MastraAgentStepHandler.d.cts +128 -0
  697. package/lib/types/mastra/MastraAgentStepHandler.d.mts +128 -0
  698. package/lib/types/mastra/MastraCapabilities.d.cts +20 -0
  699. package/lib/types/mastra/MastraCapabilities.d.mts +20 -0
  700. package/lib/types/mastra/MastraChannelResponse.d.cts +64 -0
  701. package/lib/types/mastra/MastraChannelResponse.d.mts +64 -0
  702. package/lib/types/mastra/MastraChannelTrigger.d.cts +57 -0
  703. package/lib/types/mastra/MastraChannelTrigger.d.mts +57 -0
  704. package/lib/types/mastra/MastraDefaultStepHandlers.d.cts +121 -0
  705. package/lib/types/mastra/MastraDefaultStepHandlers.d.mts +121 -0
  706. package/lib/types/mastra/MastraEnvironment.d.cts +270 -0
  707. package/lib/types/mastra/MastraEnvironment.d.mts +270 -0
  708. package/lib/types/mastra/MastraEvalModels.d.cts +191 -0
  709. package/lib/types/mastra/MastraEvalModels.d.mts +191 -0
  710. package/lib/types/mastra/MastraEventBridge.d.cts +17 -0
  711. package/lib/types/mastra/MastraEventBridge.d.mts +17 -0
  712. package/lib/types/mastra/MastraGraphExecutionBackend.d.cts +137 -1
  713. package/lib/types/mastra/MastraGraphExecutionBackend.d.mts +137 -1
  714. package/lib/types/mastra/MastraGraphExecutionModule.d.cts +114 -0
  715. package/lib/types/mastra/MastraGraphExecutionModule.d.mts +114 -0
  716. package/lib/types/mastra/MastraHitlStepHandler.d.cts +18 -0
  717. package/lib/types/mastra/MastraHitlStepHandler.d.mts +18 -0
  718. package/lib/types/mastra/MastraMcpTrigger.d.cts +133 -0
  719. package/lib/types/mastra/MastraMcpTrigger.d.mts +133 -0
  720. package/lib/types/mastra/MastraMemory.d.cts +362 -0
  721. package/lib/types/mastra/MastraMemory.d.mts +362 -0
  722. package/lib/types/mastra/MastraMetricsAdapter.d.cts +216 -0
  723. package/lib/types/mastra/MastraMetricsAdapter.d.mts +216 -0
  724. package/lib/types/mastra/MastraMetricsGateway.d.cts +265 -0
  725. package/lib/types/mastra/MastraMetricsGateway.d.mts +265 -0
  726. package/lib/types/mastra/MastraMetricsModels.d.cts +175 -0
  727. package/lib/types/mastra/MastraMetricsModels.d.mts +175 -0
  728. package/lib/types/mastra/MastraMetricsStatement.d.cts +116 -0
  729. package/lib/types/mastra/MastraMetricsStatement.d.mts +116 -0
  730. package/lib/types/mastra/MastraModelSchemaConverter.d.cts +45 -0
  731. package/lib/types/mastra/MastraModelSchemaConverter.d.mts +45 -0
  732. package/lib/types/mastra/MastraObservability.d.cts +197 -0
  733. package/lib/types/mastra/MastraObservability.d.mts +197 -0
  734. package/lib/types/mastra/MastraPersistence.d.cts +241 -0
  735. package/lib/types/mastra/MastraPersistence.d.mts +241 -0
  736. package/lib/types/mastra/MastraRagStepHandlers.d.cts +137 -0
  737. package/lib/types/mastra/MastraRagStepHandlers.d.mts +137 -0
  738. package/lib/types/mastra/MastraRunMetricsEndpoint.d.cts +53 -0
  739. package/lib/types/mastra/MastraRunMetricsEndpoint.d.mts +53 -0
  740. package/lib/types/mastra/MastraRunRecovery.d.cts +26 -0
  741. package/lib/types/mastra/MastraRunRecovery.d.mts +26 -0
  742. package/lib/types/mastra/MastraScheduleTrigger.d.cts +20 -0
  743. package/lib/types/mastra/MastraScheduleTrigger.d.mts +20 -0
  744. package/lib/types/mastra/MastraStorageWiring.d.cts +71 -0
  745. package/lib/types/mastra/MastraStorageWiring.d.mts +71 -0
  746. package/lib/types/mastra/MastraStructuredOutput.d.cts +165 -0
  747. package/lib/types/mastra/MastraStructuredOutput.d.mts +165 -0
  748. package/lib/types/mastra/MastraToolBuilder.d.cts +70 -0
  749. package/lib/types/mastra/MastraToolBuilder.d.mts +70 -0
  750. package/lib/types/mastra/MastraToolConfig.d.cts +136 -0
  751. package/lib/types/mastra/MastraToolConfig.d.mts +136 -0
  752. package/lib/types/mastra/MastraToolDecorator.d.cts +47 -0
  753. package/lib/types/mastra/MastraToolDecorator.d.mts +47 -0
  754. package/lib/types/mastra/MastraVectorStore.d.cts +383 -0
  755. package/lib/types/mastra/MastraVectorStore.d.mts +383 -0
  756. package/lib/types/mastra/MastraVoiceStepHandler.d.cts +40 -0
  757. package/lib/types/mastra/MastraVoiceStepHandler.d.mts +40 -0
  758. package/lib/types/mastra/MastraWorkflowCompiler.d.cts +3 -3
  759. package/lib/types/mastra/MastraWorkflowCompiler.d.mts +3 -3
  760. package/lib/types/mastra/MastraWorkflowManager.d.cts +36 -28
  761. package/lib/types/mastra/MastraWorkflowManager.d.mts +36 -28
  762. package/lib/types/mastra/index.d.cts +41 -1
  763. package/lib/types/mastra/index.d.mts +41 -1
  764. package/lib/types/mastra/nodes/MastraNodeRegistry.d.cts +41 -0
  765. package/lib/types/mastra/nodes/MastraNodeRegistry.d.mts +41 -0
  766. package/lib/types/mastra/nodes/index.d.cts +11 -0
  767. package/lib/types/mastra/nodes/index.d.mts +11 -0
  768. package/lib/types/mastra/nodes/types.d.cts +57 -0
  769. package/lib/types/mastra/nodes/types.d.mts +57 -0
  770. package/lib/types/mastra/types.d.cts +377 -6
  771. package/lib/types/mastra/types.d.mts +377 -6
  772. package/lib/types/nest/graph/GraphBackendHost.d.cts +52 -0
  773. package/lib/types/nest/graph/GraphBackendHost.d.mts +52 -0
  774. package/lib/types/nest/graph/GraphExecutionModule.d.cts +28 -0
  775. package/lib/types/nest/graph/GraphExecutionModule.d.mts +28 -0
  776. package/lib/types/nest/graph/GraphRunController.d.cts +24 -4
  777. package/lib/types/nest/graph/GraphRunController.d.mts +24 -4
  778. package/lib/types/node/agents/agent/node.d.cts +72 -16
  779. package/lib/types/node/agents/agent/node.d.mts +72 -16
  780. package/lib/types/node/agents/hitl/node.d.cts +45 -0
  781. package/lib/types/node/agents/hitl/node.d.mts +45 -0
  782. package/lib/types/node/agents/hooks/delegation/node.d.cts +48 -0
  783. package/lib/types/node/agents/hooks/delegation/node.d.mts +48 -0
  784. package/lib/types/node/agents/hooks/hook/node.d.cts +45 -0
  785. package/lib/types/node/agents/hooks/hook/node.d.mts +45 -0
  786. package/lib/types/node/agents/hooks/tool-deny/node.d.cts +39 -0
  787. package/lib/types/node/agents/hooks/tool-deny/node.d.mts +39 -0
  788. package/lib/types/node/agents/memory/memory/node.d.cts +73 -0
  789. package/lib/types/node/agents/memory/memory/node.d.mts +73 -0
  790. package/lib/types/node/agents/memory/memory-selector/node.d.cts +34 -0
  791. package/lib/types/node/agents/memory/memory-selector/node.d.mts +34 -0
  792. package/lib/types/node/agents/processors/guardrail/node.d.cts +47 -0
  793. package/lib/types/node/agents/processors/guardrail/node.d.mts +47 -0
  794. package/lib/types/node/agents/processors/input-processor/node.d.cts +40 -0
  795. package/lib/types/node/agents/processors/input-processor/node.d.mts +40 -0
  796. package/lib/types/node/agents/processors/output-processor/node.d.cts +34 -0
  797. package/lib/types/node/agents/processors/output-processor/node.d.mts +34 -0
  798. package/lib/types/node/agents/processors/types.d.cts +45 -0
  799. package/lib/types/node/agents/processors/types.d.mts +45 -0
  800. package/lib/types/node/agents/rag/chains/basic/node.d.cts +36 -0
  801. package/lib/types/node/agents/rag/chains/basic/node.d.mts +36 -0
  802. package/lib/types/node/agents/rag/chains/qa/node.d.cts +44 -0
  803. package/lib/types/node/agents/rag/chains/qa/node.d.mts +44 -0
  804. package/lib/types/node/agents/rag/chains/summarization/node.d.cts +39 -0
  805. package/lib/types/node/agents/rag/chains/summarization/node.d.mts +39 -0
  806. package/lib/types/node/agents/rag/chunking/node.d.cts +73 -0
  807. package/lib/types/node/agents/rag/chunking/node.d.mts +73 -0
  808. package/lib/types/node/agents/rag/embedding/node.d.cts +37 -0
  809. package/lib/types/node/agents/rag/embedding/node.d.mts +37 -0
  810. package/lib/types/node/agents/rag/information-extractor/node.d.cts +39 -0
  811. package/lib/types/node/agents/rag/information-extractor/node.d.mts +39 -0
  812. package/lib/types/node/agents/rag/langchain-code/node.d.cts +36 -0
  813. package/lib/types/node/agents/rag/langchain-code/node.d.mts +36 -0
  814. package/lib/types/node/agents/rag/rerank/node.d.cts +39 -0
  815. package/lib/types/node/agents/rag/rerank/node.d.mts +39 -0
  816. package/lib/types/node/agents/rag/retriever/node.d.cts +42 -0
  817. package/lib/types/node/agents/rag/retriever/node.d.mts +42 -0
  818. package/lib/types/node/agents/rag/structured-output-parser/node.d.cts +35 -0
  819. package/lib/types/node/agents/rag/structured-output-parser/node.d.mts +35 -0
  820. package/lib/types/node/agents/rag/vector-store/node.d.cts +59 -0
  821. package/lib/types/node/agents/rag/vector-store/node.d.mts +59 -0
  822. package/lib/types/node/agents/responses/discord/node.d.cts +34 -0
  823. package/lib/types/node/agents/responses/discord/node.d.mts +34 -0
  824. package/lib/types/node/agents/responses/slack/node.d.cts +34 -0
  825. package/lib/types/node/agents/responses/slack/node.d.mts +34 -0
  826. package/lib/types/node/agents/responses/teams/node.d.cts +34 -0
  827. package/lib/types/node/agents/responses/teams/node.d.mts +34 -0
  828. package/lib/types/node/agents/responses/telegram/node.d.cts +34 -0
  829. package/lib/types/node/agents/responses/telegram/node.d.mts +34 -0
  830. package/lib/types/node/agents/sandbox/node.d.cts +47 -0
  831. package/lib/types/node/agents/sandbox/node.d.mts +47 -0
  832. package/lib/types/node/agents/scorers/scorer/node.d.cts +33 -0
  833. package/lib/types/node/agents/scorers/scorer/node.d.mts +33 -0
  834. package/lib/types/node/agents/scorers/scorer-selector/node.d.cts +33 -0
  835. package/lib/types/node/agents/scorers/scorer-selector/node.d.mts +33 -0
  836. package/lib/types/node/agents/skills/skill/node.d.cts +32 -0
  837. package/lib/types/node/agents/skills/skill/node.d.mts +32 -0
  838. package/lib/types/node/agents/skills/skill-selector/node.d.cts +33 -0
  839. package/lib/types/node/agents/skills/skill-selector/node.d.mts +33 -0
  840. package/lib/types/node/agents/tools/tool/node.d.cts +33 -0
  841. package/lib/types/node/agents/tools/tool/node.d.mts +33 -0
  842. package/lib/types/node/agents/tools/tool-selector/node.d.cts +33 -0
  843. package/lib/types/node/agents/tools/tool-selector/node.d.mts +33 -0
  844. package/lib/types/node/agents/triggers/discord/node.d.cts +40 -0
  845. package/lib/types/node/agents/triggers/discord/node.d.mts +40 -0
  846. package/lib/types/node/agents/triggers/mcp-server/node.d.cts +51 -0
  847. package/lib/types/node/agents/triggers/mcp-server/node.d.mts +51 -0
  848. package/lib/types/node/agents/triggers/slack/node.d.cts +40 -0
  849. package/lib/types/node/agents/triggers/slack/node.d.mts +40 -0
  850. package/lib/types/node/agents/triggers/teams/node.d.cts +40 -0
  851. package/lib/types/node/agents/triggers/teams/node.d.mts +40 -0
  852. package/lib/types/node/agents/triggers/telegram/node.d.cts +40 -0
  853. package/lib/types/node/agents/triggers/telegram/node.d.mts +40 -0
  854. package/lib/types/node/agents/voice/node.d.cts +34 -0
  855. package/lib/types/node/agents/voice/node.d.mts +34 -0
  856. package/lib/types/node/agents/zones.d.cts +30 -0
  857. package/lib/types/node/agents/zones.d.mts +30 -0
  858. package/lib/types/node/comms/email-send/node.d.cts +85 -0
  859. package/lib/types/node/comms/email-send/node.d.mts +85 -0
  860. package/lib/types/node/comms/gmail/node.d.cts +67 -0
  861. package/lib/types/node/comms/gmail/node.d.mts +67 -0
  862. package/lib/types/node/comms/slack/node.d.cts +65 -0
  863. package/lib/types/node/comms/slack/node.d.mts +65 -0
  864. package/lib/types/node/comms/teams/node.d.cts +49 -0
  865. package/lib/types/node/comms/teams/node.d.mts +49 -0
  866. package/lib/types/node/comms/telegram/node.d.cts +61 -0
  867. package/lib/types/node/comms/telegram/node.d.mts +61 -0
  868. package/lib/types/node/credentials.d.cts +43 -0
  869. package/lib/types/node/credentials.d.mts +43 -0
  870. package/lib/types/node/data/data-table/node.d.cts +86 -0
  871. package/lib/types/node/data/data-table/node.d.mts +86 -0
  872. package/lib/types/node/data/date-time/node.d.cts +49 -0
  873. package/lib/types/node/data/date-time/node.d.mts +49 -0
  874. package/lib/types/node/data/filter/node.d.cts +31 -0
  875. package/lib/types/node/data/filter/node.d.mts +31 -0
  876. package/lib/types/node/data/limit/node.d.cts +28 -0
  877. package/lib/types/node/data/limit/node.d.mts +28 -0
  878. package/lib/types/node/data/merge/node.d.cts +63 -0
  879. package/lib/types/node/data/merge/node.d.mts +63 -0
  880. package/lib/types/node/data/rename-keys/node.d.cts +35 -0
  881. package/lib/types/node/data/rename-keys/node.d.mts +35 -0
  882. package/lib/types/node/data/set/node.d.cts +52 -0
  883. package/lib/types/node/data/set/node.d.mts +52 -0
  884. package/lib/types/node/data/sort/node.d.cts +40 -0
  885. package/lib/types/node/data/sort/node.d.mts +40 -0
  886. package/lib/types/node/data/split-out/node.d.cts +30 -0
  887. package/lib/types/node/data/split-out/node.d.mts +30 -0
  888. package/lib/types/node/data/support.d.cts +164 -0
  889. package/lib/types/node/data/support.d.mts +164 -0
  890. package/lib/types/node/devops/crypto/node.d.cts +65 -0
  891. package/lib/types/node/devops/crypto/node.d.mts +65 -0
  892. package/lib/types/node/devops/execute-command/node.d.cts +55 -0
  893. package/lib/types/node/devops/execute-command/node.d.mts +55 -0
  894. package/lib/types/node/devops/ftp/node.d.cts +55 -0
  895. package/lib/types/node/devops/ftp/node.d.mts +55 -0
  896. package/lib/types/node/devops/github/node.d.cts +61 -0
  897. package/lib/types/node/devops/github/node.d.mts +61 -0
  898. package/lib/types/node/devops/gitlab/node.d.cts +61 -0
  899. package/lib/types/node/devops/gitlab/node.d.mts +61 -0
  900. package/lib/types/node/devops/jwt/node.d.cts +53 -0
  901. package/lib/types/node/devops/jwt/node.d.mts +53 -0
  902. package/lib/types/node/flow/execute-sub-workflow/node.d.cts +63 -0
  903. package/lib/types/node/flow/execute-sub-workflow/node.d.mts +63 -0
  904. package/lib/types/node/index.d.cts +182 -2
  905. package/lib/types/node/index.d.mts +182 -2
  906. package/lib/types/node/io/airtable/node.d.cts +73 -0
  907. package/lib/types/node/io/airtable/node.d.mts +73 -0
  908. package/lib/types/node/io/extract-from-file/node.d.cts +38 -0
  909. package/lib/types/node/io/extract-from-file/node.d.mts +38 -0
  910. package/lib/types/node/io/google-sheets/node.d.cts +77 -0
  911. package/lib/types/node/io/google-sheets/node.d.mts +77 -0
  912. package/lib/types/node/io/graphql/node.d.cts +46 -0
  913. package/lib/types/node/io/graphql/node.d.mts +46 -0
  914. package/lib/types/node/io/http-request/node.d.cts +107 -0
  915. package/lib/types/node/io/http-request/node.d.mts +107 -0
  916. package/lib/types/node/io/read-pdf/node.d.cts +40 -0
  917. package/lib/types/node/io/read-pdf/node.d.mts +40 -0
  918. package/lib/types/node/io/read-write-file/node.d.cts +41 -0
  919. package/lib/types/node/io/read-write-file/node.d.mts +41 -0
  920. package/lib/types/node/io/respond-to-webhook/node.d.cts +45 -0
  921. package/lib/types/node/io/respond-to-webhook/node.d.mts +45 -0
  922. package/lib/types/node/io/spreadsheet-file/node.d.cts +51 -0
  923. package/lib/types/node/io/spreadsheet-file/node.d.mts +51 -0
  924. package/lib/types/node/storage/blob/azure/node.d.cts +27 -0
  925. package/lib/types/node/storage/blob/azure/node.d.mts +27 -0
  926. package/lib/types/node/storage/blob/base.d.cts +83 -0
  927. package/lib/types/node/storage/blob/base.d.mts +83 -0
  928. package/lib/types/node/storage/blob/gcs/node.d.cts +27 -0
  929. package/lib/types/node/storage/blob/gcs/node.d.mts +27 -0
  930. package/lib/types/node/storage/blob/s3/node.d.cts +39 -0
  931. package/lib/types/node/storage/blob/s3/node.d.mts +39 -0
  932. package/lib/types/node/storage/database/base.d.cts +97 -0
  933. package/lib/types/node/storage/database/base.d.mts +97 -0
  934. package/lib/types/node/storage/database/mssql/node.d.cts +8 -0
  935. package/lib/types/node/storage/database/mssql/node.d.mts +8 -0
  936. package/lib/types/node/storage/database/mysql/node.d.cts +8 -0
  937. package/lib/types/node/storage/database/mysql/node.d.mts +8 -0
  938. package/lib/types/node/storage/database/postgres/node.d.cts +8 -0
  939. package/lib/types/node/storage/database/postgres/node.d.mts +8 -0
  940. package/lib/types/node/storage/redis/node.d.cts +68 -0
  941. package/lib/types/node/storage/redis/node.d.mts +68 -0
  942. package/lib/types/node/storage/support.d.cts +36 -0
  943. package/lib/types/node/storage/support.d.mts +36 -0
  944. package/lib/types/node/triggers/execute-workflow/node.d.cts +25 -0
  945. package/lib/types/node/triggers/execute-workflow/node.d.mts +25 -0
  946. package/lib/types/ram/GraphNodeRepository.d.cts +13 -0
  947. package/lib/types/ram/GraphNodeRepository.d.mts +13 -0
  948. package/lib/types/ram/GraphRunEventModel.d.cts +6 -0
  949. package/lib/types/ram/GraphRunEventModel.d.mts +6 -0
  950. package/lib/types/ram/index.d.cts +1 -0
  951. package/lib/types/ram/index.d.mts +1 -0
  952. package/lib/types/shared/graph/GraphNodeConverters.d.cts +15 -0
  953. package/lib/types/shared/graph/GraphNodeConverters.d.mts +15 -0
  954. package/lib/types/shared/graph/GraphNodeModel.d.cts +30 -0
  955. package/lib/types/shared/graph/GraphNodeModel.d.mts +30 -0
  956. package/lib/types/shared/graph/GraphWorkflowModel.d.cts +6 -0
  957. package/lib/types/shared/graph/GraphWorkflowModel.d.mts +6 -0
  958. package/lib/types/shared/graph/catalog/GraphPortManifest.d.cts +7 -0
  959. package/lib/types/shared/graph/catalog/GraphPortManifest.d.mts +7 -0
  960. package/lib/types/shared/graph/constants.d.cts +39 -0
  961. package/lib/types/shared/graph/constants.d.mts +39 -0
  962. package/lib/types/shared/graph/index.d.cts +2 -0
  963. package/lib/types/shared/graph/index.d.mts +2 -0
  964. package/lib/types/typeorm/TypeormGraphAdapter.d.cts +32 -0
  965. package/lib/types/typeorm/TypeormGraphAdapter.d.mts +32 -0
  966. package/lib/types/typeorm/index.d.cts +11 -0
  967. package/lib/types/typeorm/index.d.mts +11 -0
  968. package/package.json +59 -13
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 b={};function _(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){b[e]=t}function N(e,t,o){const n=t?b[t]:void 0;return n?.color?n.color:e||"#64748b"}function I(e,t,o){const n=t?b[t]:void 0;return n?.icon?n.icon:e||"ti-pointer"}const E=["skip","passThroughFirstInput","emitDefaults"];function A(e){return E.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:I(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 be=["any","string","number","boolean","array","object","enum","model"];function _e(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(e=>be.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&&!_e(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&&Ie(t,t.loop,n),t.errorBoundary&&Ee(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 Ie(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 Ee(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=>{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)})(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")}const Ge=["loadOptions","listSearch","resourceLocator","resourceMapping","validateParameter","action"];function Le(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.name&&(e=>Ge.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 Me(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 Fe(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 Ve(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 je(e){switch(e){case"output":return"output";case"connection":return"connection";default:return"input"}}function Ue(e){const t=e.graph?.handle;return"connection"!==e.direction&&"string"==typeof t&&t?t:e.path??e.property}function Be(e,t){const o={id:Ue(e),label:e.label,direction:je(e.direction),schema:Fe(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=Ze(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=Ve(e);return s&&(o.metadata=s),o}function We(e){const t={type:"string",id:Ue(e),label:e.label,required:e.required};if(e.hidden)return((e,t)=>{const o={...t,type:"hidden"},n=Me(e);return void 0!==n&&(o.defaultValue=n),qe(o)})(e,t);const o=Me(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=Ve(e);if(r&&(t.metadata=r),(e=>{const t=ze(e);return"code"===t||"code-editor"===t})(e))return qe({...t,type:"code",language:Ye(e)});const a=Fe(e);switch(a.type){case"number":{const o={...t,type:"number",integer:a.integer,min:a.min,max:a.max},n=Ke(e.validation?.step);return void 0!==n&&(o.step=n),qe(o)}case"boolean":return qe({...t,type:"boolean"});case"enum":return qe({...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),qe(e)}case"object":case"model":return qe({...t,type:"object"});default:return qe({...t,type:"string",multiline:!!Xe(e)||void 0,pattern:He(e.validation?.pattern),minLength:Ke(e.validation?.minlength),maxLength:Ke(e.validation?.maxlength)})}}function qe(e){const t=e;for(const e of Object.keys(t))void 0===t[e]&&delete t[e];return e}function He(e){const t=e?.value;return"string"==typeof t?t:void 0}function Ke(e){const t=e?.value;return"number"==typeof t&&Number.isFinite(t)?t:void 0}function ze(e){const t=e.element?.tag;return"string"==typeof t&&t?t:void 0}function Xe(e){return"textarea"===ze(e)||"textarea"===(e=>{const t=e.element?.props?.type;return"string"==typeof t?t:void 0})(e)}const Je=["javascript","typescript","json","text"];function Ye(e){const t=e.element?.props?.language;return"string"==typeof t&&Je.includes(t)?t:"javascript"}function Qe(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 Ze(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 et(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=Ze(n.graph?.connectionRules);for(const e of r)("connection"===e.direction?d:"output"===e.direction?s:i).push(Be(e,c)),"input"===e.direction&&l.push(We(e));const u={kind:t.kind??n.kind??n.name,display:Qe(n,t),inputs:i,outputs:s,parameters:l};return d.length&&(u.connections=d),n.namespaces?.length&&(u.namespaces=n.namespaces.slice()),$e(u),u}var tt,ot;(e=>{e.READABILITY="readability",e.COMPACTNESS="compactness",e.BALANCED="balanced"})(tt||(tt={})),(e=>{e.TIGHT="tight",e.NORMAL="normal",e.COMFORTABLE="comfortable"})(ot||(ot={})),ot.TIGHT,ot.NORMAL,ot.COMFORTABLE,tt.READABILITY,ot.COMFORTABLE,tt.COMPACTNESS,ot.TIGHT,tt.BALANCED,ot.NORMAL;let nt=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)],nt.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)],nt.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)],nt.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)],nt.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)],nt.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)],nt.prototype,"inputs",void 0),i.__decorate([s.column(),n.prop(),n.description("Execution result, present on successful completion"),i.__metadata("design:type",Object)],nt.prototype,"result",void 0),i.__decorate([s.column(),n.prop(),n.description("Structured error payload, present on failure"),i.__metadata("design:type",Object)],nt.prototype,"error",void 0),i.__decorate([r.date(),s.column(),n.description("Run creation timestamp"),i.__metadata("design:type",Date)],nt.prototype,"createdAt",void 0),i.__decorate([r.date(),s.column(),n.description("Execution start timestamp, once it has started"),i.__metadata("design:type",Date)],nt.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)],nt.prototype,"finishedAt",void 0),nt=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])],nt);let rt=class extends s.BaseModel{constructor(e){super(e)}};i.__decorate([s.pk({type:String,generated:!1}),i.__metadata("design:type",String)],rt.prototype,"workflowId",void 0),i.__decorate([s.column(),i.__metadata("design:type",String)],rt.prototype,"name",void 0),i.__decorate([s.column(),i.__metadata("design:type",Object)],rt.prototype,"document",void 0),i.__decorate([s.column(),i.__metadata("design:type",String)],rt.prototype,"owner",void 0),i.__decorate([s.column(),i.__metadata("design:type",Object)],rt.prototype,"snapshot",void 0),rt=i.__decorate([s.table("graph_workflow"),r.model(),i.__metadata("design:paramtypes",[Object])],rt),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 at=new Set;function it(e,t){return e.config[t]}function st(e){return Array.isArray(e)?e.map(e=>e+"").join(", "):e+""}(()=>{const e=[{key:x.NODE_ID,shouldInclude:e=>null!=it(e,x.NODE_ID),render:e=>it(e,x.NODE_ID)+""},{key:x.WORKFLOW_ID,shouldInclude:e=>null!=it(e,x.WORKFLOW_ID),render:e=>it(e,x.WORKFLOW_ID)+""},{key:x.RUN_ID,shouldInclude:e=>null!=it(e,x.RUN_ID),render:e=>it(e,x.RUN_ID)+""},{key:x.USER,shouldInclude:e=>null!=it(e,x.USER),render:e=>it(e,x.USER)+""},{key:x.ROLES,shouldInclude(e){const t=it(e,x.ROLES);return Array.isArray(t)&&t.length>0},render:e=>st(it(e,x.ROLES))},{key:x.NAMESPACES,shouldInclude(e){const t=it(e,x.NAMESPACES);return Array.isArray(t)&&t.length>0},render:e=>st(it(e,x.NAMESPACES))},{key:x.ORGANIZATION,shouldInclude:e=>null!=it(e,x.ORGANIZATION),render:e=>it(e,x.ORGANIZATION)+""},{key:x.IP,shouldInclude:e=>null!=it(e,x.IP),render:e=>it(e,x.IP)+""}];for(const o of e)at.has(o.key)||(t.logParameterRegistry.register(o),at.add(o.key))})();const dt="$workflow",lt="local",ct=1e3,ut=1e4,pt=3e4;var ht,ft;e.GraphPinningStrategy=void 0,(ht=e.GraphPinningStrategy||(e.GraphPinningStrategy={})).MANUAL="manual",ht.AUTOMATIC="automatic",ht.DISABLED="disabled",e.GraphConditionType=void 0,(ft=e.GraphConditionType||(e.GraphConditionType={})).TRUTHY="truthy",ft.FALSY="falsy",ft.EQUALS="equals",ft.NOT_EQUALS="notEquals",ft.GREATER_THAN="greaterThan",ft.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",ft.LESS_THAN="lessThan",ft.LESS_THAN_OR_EQUAL="lessThanOrEqual",ft.EXISTS="exists",ft.CUSTOM="custom";class gt extends a.InternalError{constructor(e,t="GRAPH_EXECUTION_ERROR",o){super(e,gt.name,500),this.graphCode=t,this.details=o,this.name=this.constructor.name}}class mt extends gt{constructor(e){super("Graph workflow contains an unsupported cycle","GRAPH_CYCLE_ERROR",e)}}class yt extends gt{constructor(e,t){super(e,"GRAPH_INPUT_ERROR",t)}}class wt extends gt{constructor(e,t){super(e,"GRAPH_LOOP_LIMIT_ERROR",t)}}class bt extends gt{constructor(e,t){super(e,"GRAPH_PINNING_ERROR",t)}}class _t extends gt{constructor(e,t){super(e,"GRAPH_STORE_ERROR",t)}}class vt extends gt{constructor(e,t){super(e,"GRAPH_TOPOLOGY_ERROR",t)}}class Nt extends gt{constructor(e){super("Break signal","GRAPH_BREAK_SIGNAL",{value:e}),this.isBreakSignal=!0,this.name="GraphBreakSignal"}}class It extends gt{constructor(e){super(`Graph run '${e}' was cancelled`,"GRAPH_RUN_CANCELLED",{runId:e}),this.name=It.name}}class Et 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=Et.name,this.issues=e}}class At{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 Ot{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 gt("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 kt(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 xt(e){return`${e.organization}.${e.departments.join(",")}.${e.role}`}function St(e){if(!e||"string"!=typeof e.namespace||!e.parts)return!1;const t=kt(e.namespace);return!!t&&xt(t)===xt(e.parts)}function Dt(e,t){const o="string"==typeof e?e.trim():"";if(o){if(t)for(const e of t)if(e&&e.namespace===o&&St(e))return e.parts;return kt(o)}}function Rt(e,t,o={},n){const r=Dt(e,n),a=Dt(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 Pt(e,t,o={},n){return e.filter(e=>!t.some(t=>Rt(t,e,o,n)))}function Ct(e){return e.filter(e=>void 0===kt(e))}function Tt(e,t){const o=new Set;for(const n of e){const e=Dt(n,t);e&&o.add(e.role)}return[...o]}function $t(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function Gt(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 Lt(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=$t(e.roles);a&&(t.roles=a);const i=$t(e.namespaces);return i&&(t.namespaces=i,t.namespaceCache=Ft(i)),t}function Mt(e){return e?Lt({user:Gt(e,"user"),organization:Gt(e,"organization"),ip:Gt(e,"ip"),roles:Gt(e,"roles"),namespaces:Gt(e,"namespaces")}):{}}function Ft(e){const t=[];for(const o of e){const e=kt(o);e&&t.push({namespace:o,parts:e})}return t}function Vt(...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??Ft(o.namespaces):void 0!==o.namespaceCache&&(t.namespaceCache=o.namespaceCache));return t}class jt{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=Pt(t,a,this.options.match,o.namespaceCache),d=Tt(a,o.namespaceCache),l=n.filter(e=>!d.includes(e));if(0===i.length&&0===l.length)return;const c=[...new Set([...Ct(t),...Ct(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 Ut{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 Bt(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}class Wt 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=Lt(d);this.accumulate({...p,operation:"execute"});const h="string"==typeof d?.user?d.user:null;this.runLogger=new Ut({runId:e,workflowId:o,nodeId:r.id,user:h,roles:Bt(d?.roles),namespaces:Bt(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 Mt(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 qt{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 Ht(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 Kt{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 zt(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 Xt{static{this._cache={}}static register(e,t){return Xt._cache[e]=t,t}static get(e){const t=e??Xt._currentFlavour;if(t)return Xt._cache[t]}static getOrFail(e){const t=Xt.get(e);if(!t)throw new gt(`No graph execution backend registered under '${e}'`,"GRAPH_EXECUTION_BACKEND_NOT_REGISTERED");return t}static get current(){return Xt.get()}static get currentFlavour(){return Xt._currentFlavour??lt}static setCurrent(e){Xt._currentFlavour=e}static list(){return Object.entries(Xt._cache).map(([e,t])=>({flavour:e,backend:t}))}static unregister(e){e&&(delete Xt._cache[e],Xt._currentFlavour===e&&(Xt._currentFlavour=void 0))}static clear(){for(const e of Object.keys(Xt._cache))delete Xt._cache[e];Xt._currentFlavour=void 0}}class Jt{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 gt(`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 gt("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 Yt(e){return"object"==typeof e&&null!==e&&"type"in e&&"code"===e.type}function Qt(e){return"object"==typeof e&&null!==e&&"op"in e&&"string"==typeof e.op}async function Zt(e,t,o){const n=o.engine?.codeSandboxEvaluator;if(!n)throw new gt("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 eo(e,t,o){if(Qt(e))return(new Jt).evaluate(e,t);throw((e,t)=>new gt(`Unknown ${t??"flow"} condition type \u2014 must be ConditionExpression (op) or CodeCondition (type: 'code')`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e}))(e,o)}async function to(e,t,o){return Yt(e)?Zt(e,t.input,o):eo(e,t.state,t.label)}function oo(e,t,o,n){if(e&&"object"==typeof e&&!n.has(e))if(n.add(e),Yt(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))ro(e,o,n);else if(Array.isArray(e))for(const r of e)oo(r,t,o,n);else for(const r of Object.keys(e))oo(e[r],t,o,n)}function no(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});oo(e.parameters,n,t,o),oo(e.metadata,n,t,o),oo(e.state,n,t,o),oo(e.loop,n,t,o)}function ro(e,t,o){for(const n of e.nodes??[])no(n,t,o)}function ao(e){const t=[];return ro(e,t,new Set),t}function io(e,t){if(!t)return{valid:!0};switch(t.type){case"any":default:return{valid:!0};case"string":return"string"!=typeof e?so("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}:so("number");case"boolean":return"boolean"!=typeof e?so("boolean"):{valid:!0};case"array":if(!Array.isArray(e))return so("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=io(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 so(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=io(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 so(e){return{valid:!1,message:`expected a ${e} value`}}function lo(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 co=new Set(["loop"]),uo=["secret","secrets","password","passwd","token","accessToken","refreshToken","apiKey","api_key","privateKey","credentials"];class po{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?so("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?{valid:!0}:so("number");case"boolean":return"boolean"!=typeof e?so("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}:so("array");case"object":case"resourceLocator":return null===e||"object"!=typeof e||Array.isArray(e)?so("object"):{valid:!0};case"credential":return lo(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??{}))co.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: ${E.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=io(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 ho(e){return[e.namespace??"default",e.workflowId,e.nodeId,e.version??"default",e.fingerprint].join(":")}function fo(t){return new e.GraphValueModel({id:ho(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 go(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 mo(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(dt,{...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(dt)??{};o[e]=t,this.runtimeValues.set(dt,o)}getWorkflowValues(){return{...this.runtimeValues.get(dt)??{}}}snapshot(){return Object.fromEntries(this.runtimeValues.entries())}async readCached(e,...t){try{return go(await this.read(ho(e),...t))}catch{return}}async writeCached(e,t,...o){const n=ho(e);let r;try{r=await this.read(n,...o)}catch{r=void 0}r?await this.update(Object.assign(r,fo(t)),...o):await this.create(fo(t),...o)}async deleteCached(e,...t){try{await this.delete(ho(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=>go(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 yo{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 wo{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 bt(`Node '${e}' not found in plan`);if(!this.policy.canPin(o))throw new bt(`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 bt(`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=yo.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 bo={enabled:!0,strategy:"manual",includeDependencies:!0};function _o(e){return!0===e?.enabled&&"disabled"!==e.strategy}class vo{canPin(e){return _o(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?{...bo,...t}:{...bo,enabled:!1}}}class No{getDependencies(e,t){return yo.upstreamNodes(t,e.incomingByNode,!1)}getPinSet(e,t){const o=this.getDependencies(e,t);return o.add(t),o}}class Io{constructor(){this.local=!0,this.codeMode="hostSide",Xt.register(lt,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 gt("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 gt("LocalGraphExecutionBackend has no workflowStore configured; workflow lookup is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");return await o.getDocument(e,...t)}async execute(e){const{document:t,plan:o,inputs:n,options:r,events:a}=e,i=a,s=i.frame;if(!s)throw new gt("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 gt(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()}}),Ht(s,t,n,O.SUCCEEDED,r.metadata)}catch(e){if(e instanceof Nt)throw s.finish(),e;s.finish();const a=this.toErrorPayload(e);return e instanceof It||!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}),Ht(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}),Ht(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 Wt(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 Nt)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===dt||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=po.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 gt(`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 gt(`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??""}:lo(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:""}:lo(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 gt(`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 gt(`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 vo).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 No).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===dt&&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=mo(e.valueStore.getAdapter()??this.valueAdapter);return new wo(t,new vo,new No)}executionLimits(e){return{maxLoopIterations:e.maxLoopIterations??ct,maxForeachIterations:e.maxForeachIterations??ut}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new It(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 Eo{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 Ao(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&&Ao(e,t,`${o}.nodes[${r.id}].loop.body`)}}class Oo{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:dt,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===dt?void 0:n.get(t.nodeId),d=o.nodeId===dt?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 ko{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 xo{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];lo(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))lo(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(uo);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 So extends a.ValidationError{constructor(e,t=[]){super(e),this.issues=t,this.name=So.name}}class Do extends a.ValidationError{constructor(e,t){super(e),this.edgeId=t,this.name=Do.name}}class Ro extends s.AuthorizationError{constructor(e){super(e),this.name=Ro.name}}const Po={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},Co=["node","definition","executor","execute","ports","component"];function To(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 $o(e,t){const o=[];for(const n of Object.keys(e))Co.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 Go{constructor(e){this.options=e,this.parameterValidator=new po,this.edgeValidator=new Oo,this.connectionPolicyValidator=new ko,this.nodeValidator=new Eo(e.catalogue),this.credentialValidator=new xo(e.credentialAuthorizer)}async validateOrThrow(e,...t){const o=await this.validate(e,0,...t);if(!o.valid||!o.resolved)throw new So(`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={...Po,...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!==dt){const t=l.get(e.targetNodeId)??[];t.push(e),l.set(e.targetNodeId,t)}if(e.sourceNodeId!==dt){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),Ao(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(...$o(e,"$"));for(const t of[...e.inputs,...e.outputs])n.push(...$o(t,"ports"));for(const t of e.nodes)n.push(...$o(t,`nodes[${t.id}]`));for(const t of e.edges)n.push(...$o(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===dt&&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"}'`),!To(e))throw new vt("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===dt)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===dt)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!==dt),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 mt({unplannedNodes:e,workflowId:o[0]?.manifest.kind})}return i}},e.GraphExecutionPlanner=i.__decorate([s.service(),i.__metadata("design:paramtypes",[])],e.GraphExecutionPlanner);const Lo=new Set(["engine","valueAdapter","codeSandboxEvaluator","workflowStore"]);function Mo(e,t){const o={};for(const[n,r]of Object.entries(e??{}))Lo.has(n)&&!t.has(n)||(o[n]=r);return o}class Fo 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 gt("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??Xt.current??new Io,i={registry:o.registry,catalogue:n,planner:o.planner??new e.GraphExecutionPlanner,backend:a,valueAdapter:r,eventEmitter:o.eventEmitter??new At,documentValidator:o.documentValidator??new Go({catalogue:n,limits:o.documentLimits,credentialAuthorizer:o.credentialAuthorizer}),authValidator:new jt({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=Mo(a.config,d);return await a.initialize({...l,valueAdapter:r,...o.codeSandboxEvaluator?{codeSandboxEvaluator:o.codeSandboxEvaluator}:{},...o.workflowStore?{workflowStore:o.workflowStore}:{},engine:this}),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=Vt(Mt(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 Ot,u=mo(this.valueAdapter);u.seedWorkflowInputs(this.withWorkflowInputDefaults(e,t));const p=new Kt(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 So(`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 qt(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 zt(this.client.backend)}async listWorkflows(...e){const t=this.client.backend;if("supported"!==zt(t).workflows.list||"function"!=typeof t.listWorkflows)throw new gt(`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"!==zt(o).workflows.get||"function"!=typeof o.getWorkflow)throw new gt(`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=Xt.getOrFail(e);if("supported"!==zt(o).workflows.list||"function"!=typeof o.listWorkflows)throw new gt(`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=Xt.getOrFail(e);if("supported"!==zt(n).workflows.get||"function"!=typeof n.getWorkflow)throw new gt(`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=ao(e);if(0!==o.length){if("unsupported"===t.codeMode)throw new gt(`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 gt("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=mo(this.valueAdapter);return new wo(e,new vo,new No)}async emitPinningEvent(e,t){const o=(new Ot).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:ct,maxForeachIterations:ut,usePinnedValues:!0,writeThroughCache:!1,path:[],metadata:{},...this.defaultOptions,...e}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new It(e.runId??"unknown")}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new gt("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 Vo=new Set(["process","require","module","exports","global","globalThis","Function","eval","fetch","XMLHttpRequest","WebSocket","Worker","Deno","Bun","__dispatch"]);class jo 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 gt("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 gt("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 gt("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 gt("Imports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"import"});if("ExportNamedDeclaration"===t.type||"ExportDefaultDeclaration"===t.type)throw new gt("Exports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"export"});if("Identifier"===t.type&&"string"==typeof t.name&&Vo.has(t.name))throw new gt(`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 gt("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 gt("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 gt("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 gt("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 gt)throw e;const t=e.message;if(t.includes("timed out")||t.includes("timeout"))throw new gt(`Code execution timed out after ${l} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:l});if(t.includes("memory")||t.includes("heap"))throw new gt(`Code exceeded the memory limit of ${this.defaultMemoryMb} MB`,"GRAPH_CODE_SANDBOX_MEMORY_LIMIT",{memoryMb:this.defaultMemoryMb});throw new gt("Code execution failed: "+t,"GRAPH_CODE_SANDBOX_RUNTIME_ERROR",{code:n,error:t})}if("string"!=typeof h)throw new gt("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 gt(`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 gt(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 Uo extends a.InternalError{constructor(e){super(e,Uo.name,500)}}class Bo extends a.NotFoundError{constructor(e){super(e),this.name=Bo.name}}class Wo extends a.NotFoundError{constructor(e){super(e),this.name=Wo.name}}class qo{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 Uo(`Method declaration for kind '${this.kind}' is missing a name`);if(this.declarations.has(e.name))throw new Uo(`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 Uo(`Method implementation '${e}' for kind '${this.kind}' is not a function`);if(!this.declarations.has(e))throw new Uo(`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 Uo(`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 Wo(`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 Ho(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 Ko(e,t,o){const n=Ho(t,e.itemIdPath),r=e.itemLabelPath?Ho(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 zo(e,t){switch(t){case"input":return e.inputs;case"output":return e.outputs;default:return e.connections}}function Xo(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=zo(o,n.direction);e.forEach((e,t)=>{const{id:o,label:i}=Ko(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;zo(o,e.direction).push(e)}return o}function Jo(e,t){const o=Xo(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 Yo{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 Uo(`resolveManifest provider for kind '${e}' returned a value that does not conform to GraphResolvedNodeManifest`);if(!ae(a))throw new Uo(`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 Jo(t,n.parameters??{})}}const Qo=["edge","literal","expression"];function Zo(e){return Qo.includes(e)}function en(e,t,o){if("string"!=typeof o||!o)throw new Uo(`Manifest for kind '${e}' has a ${t} with an empty port id`);if(te(o))throw new Uo(`Manifest for kind '${e}' has a ${t} with unsafe port id '${o}'`)}function tn(e){return e}function on(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 Yo,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 Uo("Graph node registration is required");if(!e.manifest||"object"!=typeof e.manifest)throw new Uo("Graph node registration is missing a manifest");if(!e.executor||"function"!=typeof e.executor.execute)throw new Uo(`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 Uo("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 Uo(`Graph node kind '${a}' is already registered; pass { replace: true } to replace it`);try{$e(r)}catch(e){throw new Uo(`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(en(e,t+" port",r?.id),o.has(r.id))throw new Uo(`Manifest for kind '${e}' declares duplicate static ${t} port id '${r.id}'`);if(o.add(r.id),void 0!==r.defaultMode&&!Zo(r.defaultMode))throw new Uo(`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 Uo(`Manifest for kind '${e}' has a parameter with an empty id`);if(te(t))throw new Uo(`Manifest for kind '${e}' has a parameter with unsafe id '${t}'`);if(o.has(t))throw new Uo(`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 Uo(`Manifest for kind '${e}' has a dynamic-port rule without a parameter reference`);if(!o.has(n.parameter))throw new Uo(`Manifest for kind '${e}' has a dynamic-port rule referencing missing parameter '${n.parameter}'`);if("togglePort"===n.type){if(!n.port)throw new Uo(`Manifest for kind '${e}' has a togglePort rule without a port`);en(e,"togglePort rule port",n.port.id)}if("repeatFromParameter"===n.type&&"string"!=typeof n.portIdTemplate)throw new Uo(`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 Uo(`Manifest for kind '${e}' has a malformed credential requirement`);if(!o.type)throw new Uo(`Manifest for kind '${e}' has a credential requirement with an empty type`)}})(a,r),((e,t)=>{for(const o of t.methods??[])if(!Le(o))throw new Uo(`Manifest for kind '${e}' has a malformed method declaration`)})(a,r);const s=new qo(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 Uo("Graph executor kind is required");if(!t||"function"!=typeof t.execute)throw new Uo(`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 qo(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 Bo(`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 gt("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 Bo)throw new gt(`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 nn extends r.Model{constructor(e){super(),r.Model.fromModel(this,e)}execute(e,t){throw new gt(`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 rn(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 nn{execute(e,t){throw new Nt(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 nn{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 gt("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 gt(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:rn(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 nn{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 nn{execute(e,t){const o=e.inputs,n=o.value??o;if(!this.condition)throw new gt("If node has no condition configured","GRAPH_IF_NO_CONDITION",{input:o});if(Yt(this.condition))return Zt(this.condition,o,t).then(e=>this.route(e,n));const r=eo(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 gt("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 nn{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 to(e.condition,{input:r,state:i,label:"switch case"},t))return{[e.outputPort]:a};if(!0!==o.hasDefault)throw new gt("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:_(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 an={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},sn=t.LoggedEnvironment.accumulate({graph:{workflows:{limits:{...an},allowAnonymousAccess:!1},execution:{maxCodeTimeoutMs:pt}}});function dn(e,t){const o="number"==typeof t?t:Number(t),n=Number.isFinite(o)&&o>0?o:pt,r="number"==typeof e?e:Number(e);return Number.isFinite(r)&&r>0?Math.min(Math.floor(r),n):1e3}const ln=["javascript","typescript"],cn="javascript";e.CodeInputSchema=class extends r.Model{constructor(){super(...arguments),this.language=cn}},i.__decorate([r.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.language.label",type:"select"}),r.option([...ln]),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 nn{async execute(e,t){const o=e.inputs,n=this.input,r=o.code??e.parameters?.code??n?.code??this.defaultCode,a=n?.language??cn;if(!r||"string"!=typeof r||0===r.trim().length)throw new yt("Code node has no code to execute (input.code is empty)",{input:o});const i=t.engine?.codeSandboxEvaluator;if(!i)throw new gt("Code node execution requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:r});const s=sn.graph.execution?.maxCodeTimeoutMs,d="number"==typeof s&&Number.isFinite(s)&&s>0?s:pt,l=dn(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(pt),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 nn{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 nn{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 nn{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 nn{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 nn{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 nn{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 nn{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 nn{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 nn{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 nn{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 nn{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 un=[e.AgentNode];function pn(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 yt(n+" loop maxIterations must be a positive finite number");return Math.min(Math.floor(a),r)}function hn(e,t,o){const n=t.node.loop,r=t.metadata?.loop;if(!n?.body&&!r?.body)throw new yt(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 nn{async execute(e,t){const o=hn(this,t,"foreach"),n=e.inputs,r=n.items,a=pn(o.maxIterations,t.limits?.maxForeachIterations,1e3,"foreach");if(!Array.isArray(r))throw new yt("foreach input 'items' must be an array");const i=t.engine;if(!i)throw new gt("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 wt(`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 Nt){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 fn{constructor(){this.expressionEvaluator=new Jt}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 gt("Custom condition evaluators are not supported in v1","GRAPH_CUSTOM_CONDITION_UNSUPPORTED");default:throw new gt(`Unknown condition type '${t.type}'`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:t})}}async evaluateAsync(e,t,o,n){return Yt(e)?Zt(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 gn(e,t,o,n={}){return{id:e,label:t,direction:o,...n}}function mn(e){const t=e,o=F(t),n=o?.metadata?.title;return et(t,n?{name:n}:{})}e.GraphUntilLoopNode=class extends nn{async execute(e,t){const o=hn(this,t,"until"),n=e.inputs,r=pn(o.maxIterations,t.limits?.maxLoopIterations,100,"until"),a=o.condition;if(!a)throw new yt("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 gt("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 wt(`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 fn).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 nn{async execute(e,t){const o=hn(this,t,"while"),n=e.inputs,r=pn(o.maxIterations,t.limits?.maxLoopIterations,100,"while"),a=o.condition;if(!a)throw new yt("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 gt("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 fn).evaluateAsync(a,u,t,{...n,state:u});){if(p>=r)throw await t.emit({type:S.LOOP_LIMIT_REACHED,iteration:p}),new wt(`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 nn{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 nn{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 yn={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:[gn("items","graph.node.loop.foreach.ports.input.items.label","input",{required:!0,schema:{type:"array",items:{type:"any"}}}),gn("slice","graph.node.loop.foreach.ports.input.slice.label","input",{schema:{type:"number",integer:!0,min:1}}),gn("state","graph.node.loop.foreach.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[gn("results","graph.node.loop.foreach.ports.output.results.label","output",{schema:{type:"array",items:{type:"any"}}}),gn("completed","graph.node.loop.foreach.ports.output.completed.label","output",{schema:{type:"array",items:{type:"any"}}}),gn("iterations","graph.node.loop.foreach.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}}),gn("broken","graph.node.loop.foreach.ports.output.broken.label","output",{schema:{type:"boolean"}}),gn("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}]},wn={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:[gn("state","graph.node.loop.while.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[gn("state","graph.node.loop.while.ports.output.state.label","output",{schema:{type:"any"}}),gn("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"}]},bn={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:[gn("state","graph.node.loop.until.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[gn("state","graph.node.loop.until.ports.output.state.label","output",{schema:{type:"any"}}),gn("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"}]},_n=[mn(e.GraphInputValueNode),mn(e.GraphOutputValueNode),mn(e.ManualTriggerNode),mn(e.WebhookTriggerNode),mn(e.ScheduleTriggerNode),mn(e.EventTriggerNode),mn(e.FormTriggerNode),mn(e.ChatTriggerNode),(vn=mn(e.IfFlowNode),{...vn,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"}}}]}))(mn(e.SwitchFlowNode)),mn(e.MapNode),mn(e.DelayFlowNode),mn(e.ErrorBoundaryFlowNode),mn(e.HumanApprovalFlowNode),mn(e.CodeNode),mn(e.LogFlowNode),mn(e.UtilityLogNode),mn(e.BreakFlowNode),mn(e.AgentNode),yn,wn,bn];var vn;const Nn=Object.fromEntries(_n.map(e=>[e.kind,e])),In=[e.ManualTriggerNode,e.WebhookTriggerNode,e.ScheduleTriggerNode,e.EventTriggerNode,e.FormTriggerNode,e.ChatTriggerNode],En=[e.IfFlowNode,e.SwitchFlowNode,e.DelayFlowNode,e.ErrorBoundaryFlowNode,e.HumanApprovalFlowNode,e.LogFlowNode,e.BreakFlowNode],An=[e.CodeNode,e.MapNode,e.UtilityLogNode],On=[e.GraphForeachLoopNode,e.GraphWhileLoopNode,e.GraphUntilLoopNode],kn=[e.GraphInputValueNode,e.GraphOutputValueNode],xn={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 Sn(e){return{execute:(t,o)=>e.instantiate({...on(o.node),...t.parameters,...o.node.state??{}}).execute(t,o)}}function Dn(){const e=[];for(const[t,o]of Object.entries(Nn)){const n=xn[t];n&&e.push(tn({manifest:o,executor:Sn(n)}))}return e}const Rn=["node","definition","executor","execute","ports","component"];function Pn(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 Cn(e,t){const o=[];for(const n of Object.keys(e))Rn.includes(n)&&o.push(Pn("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 Tn(e,t){t.push(...Cn(e,"$")),e.inputs.forEach((e,o)=>t.push(...Cn(e,`inputs[${o}]`))),e.outputs.forEach((e,o)=>t.push(...Cn(e,`outputs[${o}]`)));for(const o of e.nodes)t.push(...Cn(o,`nodes[${o.id}]`)),o.loop&&(t.push(...Cn(o.loop,`nodes[${o.id}].loop`)),Tn(o.loop.body,t));for(const o of e.edges)t.push(...Cn(o,`edges[${o.id}]`))}function $n(e,t){const o=[];e.nodes.length>t.maxNodes&&o.push(Pn("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(Pn("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=Gn(e);n>t.maxNestingDepth&&o.push(Pn("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(Pn("document.limit.size","$",`Document serializes to ${r} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,{details:{bytes:r,limit:t.maxDocumentBytes}})),o}function Gn(e,t=0){let o=t;for(const n of e.nodes)n.loop?.body&&(o=Math.max(o,Gn(n.loop.body,t+1)));return o}async function Ln(e,t,...o){const n=[];for(const r of e.nodes)t.has(r.kind,...o)||n.push(Pn("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 Ln(r.loop.body,t,...o));return n}async function Mn(e,t={},...o){const n={...an,...t.limits},r=[];if(!Re(e))return r.push(Pn("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(Pn("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};Tn(e,r),r.push(...(e=>{const t=[],o=new Set;for(const n of[...e.inputs,...e.outputs])o.has(n.id)?t.push(Pn("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(Pn("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(Pn("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(...$n(e,n)),Ao(e,r);try{ve(e)}catch(e){const t=e instanceof a.ValidationError?e.message:e+"";r.push(Pn("document.structure","$",t))}return t.catalogue&&r.push(...await Ln(e,t.catalogue,...o)),{valid:0===r.length,issues:r}}function Fn(e,t,o={}){const n=e?.owner??null;return!n||n===t||(null==t||""===t)&&!0===o.allowAnonymousAccess}function Vn(e,t){return(e?.owner??null)===(t??null)}function jn(e,t,o){if(!Vn(e,t))throw new s.ForbiddenError(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function Un(e,t,o){if(!Fn(e,t,o))throw new s.ForbiddenError(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function Bn(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Bn(e)).join(",")}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${Bn(t[e])}`).join(",")}}`}function Wn(e){return p.createHash("sha256").update(Bn(e)).digest("hex")}function qn(e){return new nt({runId:e.runId,workflowId:e.workflowId,...e.ownerUser?{owner:e.ownerUser}:{},status:e.status,...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{},...void 0!==e.result?{result:Hn(e.result)}:{},...e.error?{error:Hn(e.error)}:{},createdAt:new Date(e.createdAt),...e.startedAt?{startedAt:new Date(e.startedAt)}:{},...e.finishedAt?{finishedAt:new Date(e.finishedAt)}:{}})}function Hn(e){if(null!=e)return JSON.parse(JSON.stringify(e))}class Kn{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 zn{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=Xn(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=Xn(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=Xn(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??Xn(new gt(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 Xn(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 Jn(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 Yn(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&Re(e.document)&&!Re(e)}function Qn(e){return JSON.parse(JSON.stringify(e))}function Zn(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(rt),this.catalogue=e}get limits(){return{...an,...sn.graph.workflows.limits??{}}}get allowAnonymousAccess(){return!0===sn.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 Et(i.issues);const s=Jn(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=Qn(t),d.updatedAt=l,this.update(d,...r);const c=new rt({workflowId:e,name:t.name,document:Qn(t),...s?{owner:s}:{},updatedAt:l});return this.create(c,...r)}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,Jn(o)),r.document)return Qn(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=Jn(t);return n.filter(e=>Fn(e,r,{allowAnonymousAccess:this.allowAnonymousAccess})).sort((e,t)=>Zn(t.updatedAt)-Zn(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,Jn(o)),r}async validateDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateDocument",!0)).for(this.validateDocument);return await Mn(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(!Yn(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=Jn(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 rt({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,Jn(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){Un(t??null,o??null,{allowAnonymousAccess:this.allowAnonymousAccess,resourceKind:"Graph workflow",resourceId:e})}assertWriteOwnership(e,t,o){jn(t??null,o??null,{resourceKind:"Graph workflow",resourceId:e})}async applyCanonicalWrapper(e,t,o){if(!Yn(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 Mn(t.document,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o);if(!n.valid)throw new Et(n.issues);e.document=Qn(t.document),e.name=t.document.name}},e.GraphWorkflowService=i.__decorate([s.service(rt),i.__metadata("design:paramtypes",[Function])],e.GraphWorkflowService),e.GraphRunModelService=class extends s.ModelService{constructor(){super(nt)}async saveRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"saveRun",!0)).for(this.saveRun),n=qn(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(nt),i.__metadata("design:paramtypes",[])],e.GraphRunModelService),e.ConditionExpressionEvaluator=Jt,e.DEFAULT_GRAPH_WORKFLOW_DOCUMENT_LIMITS=an,e.DEFAULT_GRAPH_WORKFLOW_VALIDATION_LIMITS=Po,e.DEFAULT_PINNING_METADATA=bo,e.GRAPH_AGENT_NODES=un,e.GRAPH_BOUNDARY_NODES=kn,e.GRAPH_BUILT_IN_NODE_CLASSES_BY_KIND=xn,e.GRAPH_BUILT_IN_NODE_MANIFESTS=_n,e.GRAPH_BUILT_IN_NODE_MANIFESTS_BY_KIND=Nn,e.GRAPH_CODE_DEFAULT_LANGUAGE=cn,e.GRAPH_CODE_DEFAULT_TIMEOUT_MS=1e3,e.GRAPH_CODE_LANGUAGES=ln,e.GRAPH_CODE_MAX_TIMEOUT_MS=pt,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=Co,e.GRAPH_FLOW_CONTROL_NODES=En,e.GRAPH_LOCAL_EXECUTION_BACKEND=lt,e.GRAPH_LOOP_KIND={FOREACH:"core.loop.foreach",WHILE:"core.loop.while",UNTIL:"core.loop.until"},e.GRAPH_LOOP_NODES=On,e.GRAPH_MAX_FOREACH_ITERATIONS=ut,e.GRAPH_MAX_LOOP_ITERATIONS=ct,e.GRAPH_PINNING_METADATA_KEY="graph.pinnable",e.GRAPH_PLAIN_SECRET_KEYS=uo,e.GRAPH_TRIGGER_NODES=In,e.GRAPH_UTILITY_NODES=An,e.GRAPH_WORKFLOW_BOUNDARY=dt,e.GRAPH_WORKFLOW_FORBIDDEN_FIELD_KEYS=Rn,e.GraphAuthValidator=jt,e.GraphBreakSignal=Nt,e.GraphConditionEvaluator=fn,e.GraphConnectionPolicyValidator=ko,e.GraphConnectionValidationError=Do,e.GraphCredentialAuthorizationError=Ro,e.GraphCredentialReferenceValidator=xo,e.GraphCycleError=mt,e.GraphDocumentValidationError=So,e.GraphEdgeInstanceValidator=Oo,e.GraphEngineEventSink=Kt,e.GraphEnvironment=sn,e.GraphExecutionBackendRegistry=Xt,e.GraphExecutionContext=Wt,e.GraphExecutionEngine=Fo,e.GraphExecutionError=gt,e.GraphExecutionEventEmitter=At,e.GraphExecutionEventFactory=Ot,e.GraphExecutionFrame=qt,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=yt,e.GraphLoopExecutionContext=class{constructor(e,t){this.iteration=e,this.metadata=t}},e.GraphLoopLimitError=wt,e.GraphNode=nn,e.GraphNodeInstanceValidator=Eo,e.GraphNodeManifestResolver=Yo,e.GraphNodeMethodNotFoundError=Wo,e.GraphNodeMethodRegistry=qo,e.GraphNodeNotFoundError=Bo,e.GraphNodeRegistrationError=Uo,e.GraphParameterValidator=po,e.GraphPinningDependencyResolver=No,e.GraphPinningError=bt,e.GraphPinningPolicy=vo,e.GraphPinningService=wo,e.GraphPortError=class extends gt{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=It,e.GraphRunEventPublisher=Kn,e.GraphRunExecutor=zn,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 Kn(o,n.limits),this.executor=new zn(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=>Fn({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 gt(`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 gt?new gt(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:Wn(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:Wn(r)}}}assertOwnership(e,t){Un({owner:e.ownerUser},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess,resourceKind:"Graph run",resourceId:e.runId})}assertWriteOwnership(e,t){jn({owner:e.ownerUser},t,{resourceKind:"Graph run",resourceId:e.runId})}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",{runtime:typeof globalThis.crypto});return e.randomUUID()}},e.GraphStoreError=_t,e.GraphTopology=yo,e.GraphTopologyError=vt,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 yt(`Missing required ${o} port '${n.name}'`);if(e&&!this.resolver.resolve(n).validate(t[n.name]))throw new yt(`Invalid value for ${o} port '${n.name}'`)}}},e.GraphWorkflowDocumentRejectedError=Et,e.GraphWorkflowDocumentValidator=Go,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=>qn(e))}release(e){this.runs.delete(e)}},e.IsolatedVmCodeSandboxEvaluator=jo,e.LocalGraphExecutionBackend=Io,e.assertGraphResourceOwnership=Un,e.assertGraphResourceWriteOwnership=jn,e.buildGraphExecutionResult=Ht,e.builtInGraphNodeRegistrations=Dn,e.canAccessGraphResource=Fn,e.canAccessGraphResourcePayload=Vn,e.checkGraphValueAgainstSchema=io,e.clampGraphCodeTimeoutMs=dn,e.collectLooseNodeIssues=Ao,e.composeGraphNamespace=xt,e.createGraphValueRepository=mo,e.declaredGraphNodeMethods=e=>e.methods??[],e.decomposeGraphNamespace=kt,e.decomposeGraphNamespaces=Ft,e.defineGraphNode=tn,e.detectGraphCodeModeSurfaces=ao,e.evaluateCodeCondition=Zt,e.evaluateCondition=to,e.evaluateConditionSync=eo,e.findMalformedGraphNamespaces=Ct,e.findUngrantedGraphNamespaces=Pt,e.graphAuthDataFromRecord=Lt,e.graphAuthDataOf=Mt,e.graphDocumentHasCodeMode=e=>ao(e).length>0,e.graphNamespaceCovers=Rt,e.graphNamespacePartsOf=Dt,e.graphNodeConfig=on,e.graphRolesFromNamespaces=Tt,e.graphRunDocumentFingerprint=Wn,e.graphWorkflowOwnerOf=Jn,e.isCodeCondition=Yt,e.isConditionExpression=Qt,e.isGraphCredentialReferenceLike=lo,e.isGraphNamespaceCacheEntryValid=St,e.isGraphResolvedWorkflow=To,e.isPinnable=_o,e.mergeGraphAuthData=Vt,e.registerBuiltInGraphNodes=(e,...t)=>{for(const o of Dn())e.register(o,{},...t);return e},e.resolveGraphBackendCapabilities=zt,e.resolveGraphDynamicPorts=Xo,e.resolveGraphNodeManifest=Jo,e.serializeGraphValueKey=ho,e.stripFacadeOwnedBackendConfig=Mo,e.validateGraphWorkflowDocumentAtBoundary=Mn},"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,r,a,n,i,d,s,l,c,p,u,g,h,m,f,_,y,b,w,N,v,A,E,S,I,x,R,O,k,T,C,D,P,G,M,j,L){"use strict";function F(e){var t=Object.create(null);return e&&Object.keys(e).forEach(o=>{if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}),t.default=e,Object.freeze(t)}var q,$,H=F(l),U=F(c),B=F(p);a.ValidationKeys.REQUIRED,a.ValidationKeys.MIN,a.ValidationKeys.MIN_LENGTH,a.ValidationKeys.MAX,a.ValidationKeys.MAX_LENGTH,a.ValidationKeys.PATTERN,a.ValidationKeys.URL,a.ValidationKeys.STEP,a.ValidationKeys.DATE,a.ValidationKeys.EMAIL,a.ValidationKeys.PASSWORD,a.ValidationKeys.EQUALS,a.ValidationKeys.DIFF,a.ValidationKeys.LESS_THAN,a.ValidationKeys.LESS_THAN_OR_EQUAL,a.ValidationKeys.GREATER_THAN,a.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"})(q||(q={})),(e=>{e.INPUT="input",e.OUTPUT="output",e.CONNECTION="connection"})($||($={}));const W={};function V(e,t={}){let o=e.width??96,r=e.height??96;for(const a of e.sizeRules??[]){if("parameterCount"!==a.type)continue;const e=t[a.parameter]??0;e>0&&("width"===a.dimension?o+=e*a.perItem:r+=e*a.perItem)}return{width:o,height:r}}function K(e,t){W[e]=t}function z(e,t,o){const r=t?W[t]:void 0;return r?.color?r.color:e||"#64748b"}function Q(e,t,o){const r=t?W[t]:void 0;return r?.icon?r.icon:e||"ti-pointer"}const J=["skip","passThroughFirstInput","emitDefaults"];function X(e){return J.includes(e)}var Y,Z,ee,te;(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"})(Y||(Y={})),(e=>{e.IDLE="idle",e.RUNNING="running",e.BLOCKED="blocked",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped"})(Z||(Z={})),(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"})(ee||(ee={})),(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"})(te||(te={}));const oe={maxRequestBytes:4e6,maxConcurrentRuns:32,maxEventsPerRun:1e4,maxEventPayloadBytes:256e3,executionTimeoutMs:6e5,eventReplayWindowMs:3e5},re=[te.WORKFLOW_COMPLETED,te.WORKFLOW_FAILED,te.WORKFLOW_CANCELLED];function ae(e){return re.includes(e)}function ne(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function ie(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=ne(e.namespaces),o=ne(e.roles);if(!t&&!o)return;const r={};return t&&(r.namespaces=t),o&&(r.roles=o),r})(t):void 0}function de(e){const t=r.Metadata.constr(e);if("function"==typeof t)return t;const o=e.constructor;return"function"==typeof o?o:e}function se(e){if(null!=e)return"string"==typeof e?e:e+""}function le(e,t,o){return se(e?.props?.label??e?.props?.name)??se(t?.name)??o??""}function ce(e,t,o){const n=ge(e,t);if(n?.model&&"function"==typeof n.model&&a.Model.isModel(n.model))return n.model;const i=r.Metadata.type(e,t);if("function"==typeof i&&a.Model.isModel(i))return i;const d=r.Metadata.getPropDesignTypes?.(e,t)?.designTypes||[];for(const e of d)if("function"==typeof e&&a.Model.isModel(e))return e;const s=o?.[a.ValidationKeys.TYPE]?.customTypes||[];for(const e of s)if("function"==typeof e&&a.Model.isModel(e))return e}function pe(e,t){const o=[t,e.path??e.property].filter(Boolean).join(".");return{...e,path:o,children:e.children?.map(e=>pe(e,o))}}function ue(e){const t=de(e);return r.Metadata.get(t,q.NODE)}function ge(e,t){const o=de(e);return r.Metadata.get(o,r.Metadata.key(q.PORT,t+""))}function he(e,t,o,a=new Set){const n=ge(e,t);if(!n?.schema)return;const i=ce(e,t,r.Metadata.validationFor(e,t));if(!i)return;if(a.has(i))return[];const d=new Set(a);return d.add(e),d.add(i),_e(i,d).filter(e=>e.direction===o)}function me(e,t,o=new Set){const n=ge(e,t);if(!n)return;const i=r.Metadata.validationFor(e,t),d=ce(e,t,i);if(n.schema&&d)return;const s=a.Model.uiElementOf(e,t)||void 0,l=a.Model.uiDecorationOf(e,t,"uiprop"),c=r.Metadata.type(e,t),p=se(n.type??i?.[a.ValidationKeys.TYPE]?.customTypes?.[0]?.name??s?.props?.type??l?.type??c?.name),u=(n.expand||d&&!o.has(d))&&d?(()=>{const r=new Set(o);return r.add(e),r.add(d),_e(d,r).map(e=>pe(e,t))})():void 0;return{property:t,path:t,direction:n.direction,name:t,label:le(s,l,t),type:p?.toLowerCase(),required:!!i?.[a.ValidationKeys.REQUIRED],hidden:!!a.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 fe(e){return _e(de(e))}function _e(e,t=new Set){const o=r.Metadata.properties(e)||[],a=[];for(const r of o){const o=r+"",n=ge(e,o);if(n?.schema){const r=he(e,o,n.direction,t);if(r){a.push(...r);continue}}const i=me(e,o,t);i&&a.push(i)}return a}function ye(e){return e.flatMap(e=>e.children&&e.children.length?ye(e.children):[e])}function be(e){const t=de(e),o=a.Model.uiModelOf(t),n=ue(t)||{},i=o?.tag||t.name,d=fe(t),s=((e,t)=>{const o=t.portGroups||[],a=new Map(o.map(e=>[e.property,e])),n=[],i=r.Metadata.properties(e)||[];for(const t of i){const o=t+"",i=ge(e,o);if(!i?.schema)continue;if(!ce(e,o,r.Metadata.validationFor(e,o)))continue;const d=a.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=r.Metadata.constr(e)}catch{o=e}try{t=r.Metadata.get(o,"auth-namespace")}catch{t=void 0}return ne(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:z(n.color,n.category),group:n.group,height:n.height,icon:n.icon,effectiveIcon:Q(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 we=new Set,Ne=new Set;function ve(e,t,a){return r.Decoration.for(q.NODE).define({decorator:(e,t,a)=>{const n={kind:t?.kind||e,...t};return t=>{const i=r.apply(o.uimodel(e,a),r.metadata(q.NODE,n))(t);var d;return d=t,we.add(d),i}},args:[e,t,a]}).apply()}function Ae(e,t){return r.Decoration.for(q.PORT).define({decorator:(e,t)=>(o,a)=>{const n={direction:e,...t};return r.apply(r.propMetadata(r.Metadata.key(q.PORT,a),n))(o,a)},args:[e,t]}).apply()}function Ee(e){return Ae($.INPUT,{...e,schema:!0})}function Se(e){return Ae($.OUTPUT,{...e,schema:!0})}function Ie(e){return Ae($.CONNECTION,e)}o.RenderingEngine.prototype.renderAsNode=(e,t,...o)=>be(e),r.Metadata.nodes=(()=>[...we]).bind(r.Metadata),r.Metadata.workflows=(()=>[...Ne]).bind(r.Metadata);const xe=["__proto__","prototype","constructor"];function Re(e){return xe.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 ke(e){return null===e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e}function Te(e){return!!ke(e)||(Array.isArray(e)?e.every(e=>Te(e)):!!Oe(e)&&Reflect.ownKeys(e).every(t=>"string"==typeof t&&!Re(t)&&Te(e[t])))}function Ce(e){if(void 0===e)return!1;if("number"==typeof e)return Number.isFinite(e);if("function"==typeof e)return!1;if(Te(e))return!0;if(Array.isArray(e))return e.every(e=>Ce(e));if(Oe(e)){const t=Reflect.ownKeys(e);for(const o of t){if("string"!=typeof o)return!1;if(Re(o))return!1;if(!Ce(e[o]))return!1}return!0}return!1}function De(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>De(e));const t={};for(const[o,r]of Object.entries(e))t[o]=De(r);return t}const Pe={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"},Ge={date:"date",datetime:"date-time","date-time":"date-time",duration:"duration"};function Me(e){return e?Pe[e.toLowerCase()]??"any":"any"}function je(e,t){const o=e[t];if(o&&"object"==typeof o)return o.value}function Le(e,t){const o=je(e,t);return"number"==typeof o&&Number.isFinite(o)?o:void 0}function Fe(e,t,o){const r=e??{},n=(e=>{const t=je(e,a.ValidationKeys.ENUM);if(Array.isArray(t)&&t.every(ke))return t})(r);if(n)return{type:"enum",values:n};const i=(e=>{const t=e[a.ValidationKeys.TYPE],o=t?.customTypes?.[0],r="function"==typeof o?o.name:o?.name;if(r)return r})(r)??o;return i?{type:"model",name:i}:((e,t)=>{switch(Me(e)){case"string":{const t=(e=>{if(e)return Ge[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 r=Le(t,a.ValidationKeys.MIN),n=Le(t,a.ValidationKeys.MAX);return void 0!==r&&(o.min=r),void 0!==n&&(o.max=n),o}case"boolean":return{type:"boolean"};case"array":return((e,t)=>{const o={type:"array",items:qe(e,t)},r=Le(e,a.ValidationKeys.MIN),n=Le(e,a.ValidationKeys.MAX);return void 0!==r&&(o.minItems=r),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"}}})(t,r)}function qe(e,t){if((e=>{const t=e[a.ValidationKeys.LIST];return!!t?.clazz?.length})(e))return{type:"model",name:$e(e)};const o=je(e,a.ValidationKeys.TYPE);if("string"==typeof o){const e=Me(o);return"model"===e?{type:"model",name:o}:{type:e}}if(t&&"array"!==t){const e=Me(t);return"model"===e?{type:"model",name:t}:{type:e}}return{type:"any"}}function $e(e){const t=e[a.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 He(e){return"workflow"===e.scope}function Ue(e){return"node"===e.scope}function Be(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&&Te(t)}return"expression"===t&&2===Object.keys(e).length&&"string"==typeof e.expression}const Ve=["any","string","number","boolean","array","object","enum","model"];function Ke(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(e=>Ve.includes(e))(e.type)}function ze(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&&!Ke(t.schema))throw new n.ValidationError(`Workflow port '${t.id}' schema must be a valid GraphValueSchema`);o.add(t.id)}const r={seen:[...t.seen,e]},a=new Set;for(const t of e.nodes)Qe(t,a);for(const t of e.nodes)t.loop&&Je(t,t.loop,r),t.errorBoundary&&Xe(t,t.errorBoundary,r);const i=new Set;for(const t of e.edges)Ze(t,i);for(const t of e.edges)et(t.source,0,o,a,`Edge '${t.id}' source`),et(t.target,0,o,a,`Edge '${t.id}' target`);if(void 0!==e.settings&&!Ce(e.settings))throw new n.ValidationError("Document settings must be JSON-safe (a map of JSON-safe values)");if(void 0!==e.metadata&&!Ce(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&&!Ce(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 Qe(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(Re(t))throw new n.ValidationError(`Node '${e.id}' input binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!We(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&&!Ce(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(Re(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(!Ce(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(!Ce(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 Je(e,t,o){if(!t.body||"object"!=typeof t.body)throw new n.ValidationError(`Node '${e.id}' loop configuration requires a body document`);if(ze(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,r]of Object.entries(o)){if(Re(t))throw new n.ValidationError(`Node '${e.id}' loop mapping key '${t}' is not allowed (unsafe prototype-pollutant key)`);Ye(r,e.id,t)}}function Xe(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`);ze(t.try,o);for(const[r,a]of[["catch",t.catch],["finally",t.finally]])if(void 0!==a){if(!a||"object"!=typeof a)throw new n.ValidationError(`Node '${e.id}' error-boundary ${r} body must be a document`);ze(a,o)}}function Ye(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(!Ce(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 Ze(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(!Be(e.source))throw new n.ValidationError(`Edge '${e.id}' source endpoint is not a valid GraphEndpoint`);if(!Be(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),!Ce(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 et(e,t,o,r,a){if(He(e)){if(!o.has(e.port))throw new n.ValidationError(`${a} references workflow port '${e.port}' which is not declared on the document`)}else if(Ue(e)){if(!r.has(e.nodeId))throw new n.ValidationError(`${a} references node '${e.nodeId}' which is not part of the document`);if("string"!=typeof e.port||!e.port)throw new n.ValidationError(a+" node endpoints must reference a non-empty port identifier")}}const tt=["expression","template"],ot=["javascript","typescript","json","text"];function rt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return!(!(e=>tt.includes(e))(t.mode)||"string"!=typeof t.expression||!t.expression||void 0!==t.language&&!(e=>ot.includes(e))(t.language)||void 0!==t.metadata&&!Te(t.metadata))}function at(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 nt(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 it=["trigger","loop","branching","stateful","retryable","cancellable","parallel","resource"];function dt(e){return it.includes(e)}function st(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 lt(e){if(!st(e))throw new n.ValidationError("Graph node manifest does not conform to the required shape");if(!Ce(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 ct(e){return lt(e),De(e)}function pt(e){if(!st(e))throw new n.ValidationError("Serialized graph node manifest does not conform to the required shape");return De(e)}const ut=["loadOptions","listSearch","resourceLocator","resourceMapping","validateParameter","action"];function gt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.name&&(e=>ut.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 ht(e){const t=e.element?.props?.value,o=t??e.prop?.value??e.validation?.defaultValue;if(void 0!==o&&"function"!=typeof o&&Ce(o))try{return JSON.parse(JSON.stringify(o))}catch{return}}function mt(e){if(e.type&&e.type in Ge)return{type:"string",format:Ge[e.type]};const t=(e=>{for(const t of[e.graph?.type,e.element?.props?.type,e.prop?.type])if("string"==typeof t&&"any"!==Me(t))return t})(e);return t?Fe((e=>{if(!e)return;const t=Object.entries(e).filter(([e])=>e!==a.ValidationKeys.TYPE);return Object.fromEntries(t)})(e.validation),t):Fe(e.validation,e.type,e.model)}function ft(e){const t={};for(const[o,r]of Object.entries(e.graph?.metadata??{}))Ce(r)&&(t[o]=JSON.parse(JSON.stringify(r)));return Object.keys(t).length?t:void 0}function _t(e){switch(e){case"output":return"output";case"connection":return"connection";default:return"input"}}function yt(e){const t=e.graph?.handle;return"connection"!==e.direction&&"string"==typeof t&&t?t:e.path??e.property}const bt=["top","bottom","left","right"],wt=["start","center","end"];function Nt(e,t){const o={id:yt(e),label:e.label,direction:_t(e.direction),schema:mt(e)};e.required&&(o.required=!0),e.hidden&&(o.hidden=!0);const r=e.graph?.category;"string"==typeof r&&(o.category=r);const a=(e=>{const t=e.graph?.zone;if(!t||"object"!=typeof t||Array.isArray(t))return;const o=t,r=o.side;if("string"!=typeof r||!bt.includes(r))return;const a={side:r},n=o.align;"string"==typeof n&&wt.includes(n)&&(a.align=n);const i=o.order;return"number"==typeof i&&Number.isFinite(i)&&(a.order=i),a})(e);a&&(o.zone=a),!0===e.graph?.userControlled&&(o.configurable=!0);const n=e.graph?.handle;"string"==typeof n&&(o.handle=n);const i=Tt(e.graph?.connectionRules)??t;i&&(o.connectionPolicy=i);const d=(e=>{const t=e.element;if(!t||!Ce(t))return;const o=t.tag;if("string"!=typeof o)return;const r=t.props;return{tag:o,serialize:!0===t.serialize,props:r&&"object"==typeof r&&!Array.isArray(r)?De(r):{}}})(e);d&&(o.element=d);const s=ft(e);return s&&(o.metadata=s),o}function vt(e){const t={type:"string",id:yt(e),label:e.label,required:e.required};if(e.hidden)return((e,t)=>{const o={...t,type:"hidden"},r=ht(e);return void 0!==r&&(o.defaultValue=r),At(o)})(e,t);const o=ht(e);void 0!==o&&(t.defaultValue=o);const r=(e=>{const t=e.element?.props?.placeholder??e.prop?.placeholder;return"string"==typeof t?t:void 0})(e);r&&(t.placeholder=r);const a=ft(e);if(a&&(t.metadata=a),(e=>{const t=It(e);return"code"===t||"code-editor"===t})(e))return At({...t,type:"code",language:Ot(e)});const n=mt(e);switch(n.type){case"number":{const o={...t,type:"number",integer:n.integer,min:n.min,max:n.max},r=St(e.validation?.step);return void 0!==r&&(o.step=r),At(o)}case"boolean":return At({...t,type:"boolean"});case"enum":return At({...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),At(e)}case"object":case"model":return At({...t,type:"object"});default:return At({...t,type:"string",multiline:!!xt(e)||void 0,pattern:Et(e.validation?.pattern),minLength:St(e.validation?.minlength),maxLength:St(e.validation?.maxlength)})}}function At(e){const t=e;for(const e of Object.keys(t))void 0===t[e]&&delete t[e];return e}function Et(e){const t=e?.value;return"string"==typeof t?t:void 0}function St(e){const t=e?.value;return"number"==typeof t&&Number.isFinite(t)?t:void 0}function It(e){const t=e.element?.tag;return"string"==typeof t&&t?t:void 0}function xt(e){return"textarea"===It(e)||"textarea"===(e=>{const t=e.element?.props?.type;return"string"==typeof t?t:void 0})(e)}const Rt=["javascript","typescript","json","text"];function Ot(e){const t=e.element?.props?.language;return"string"==typeof t&&Rt.includes(t)?t:"javascript"}function kt(e,t){const o={name:t.name??e.name},r=e.graph?.metadata?.description??void 0;"string"==typeof r&&r&&(o.description=r);const a=t.category??e.category;"string"==typeof a&&a&&(o.category=a),"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 Tt(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 r=t.allowedKinds;Array.isArray(r)&&r.every(e=>"string"==typeof e)&&(o.allowedNodeKinds=r);const a=t.blockedKinds;Array.isArray(a)&&a.every(e=>"string"==typeof e)&&(o.blockedNodeKinds=a);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 Ct(e,t={}){const o="function"==typeof e?e:e.constructor;if(!ue(o))throw new n.ValidationError(`Node '${o?.name??e+""}' is not decorated with @node and cannot produce a manifest`);const r=be(o),a=ye(fe(o)),i=[],d=[],s=[],l=[],c=Tt(r.graph?.connectionRules);for(const e of a)("connection"===e.direction?s:"output"===e.direction?d:i).push(Nt(e,c)),"input"===e.direction&&l.push(vt(e));const p={kind:t.kind??r.kind??r.name,display:kt(r,t),inputs:i,outputs:d,parameters:l};return s.length&&(p.connections=s),r.namespaces?.length&&(p.namespaces=r.namespaces.slice()),lt(p),p}var Dt,Pt;(e=>{e.READABILITY="readability",e.COMPACTNESS="compactness",e.BALANCED="balanced"})(Dt||(Dt={})),(e=>{e.TIGHT="tight",e.NORMAL="normal",e.COMFORTABLE="comfortable"})(Pt||(Pt={})),Pt.TIGHT,Pt.NORMAL,Pt.COMFORTABLE,Dt.READABILITY,Pt.COMFORTABLE,Dt.COMPACTNESS,Pt.TIGHT,Dt.BALANCED,Pt.NORMAL;let Gt=class extends d.BaseModel{constructor(e){super(e)}};i.__decorate([d.pk({type:String,generated:!1}),r.description("Unique graph run id"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.id.label",readonly:!0}),i.__metadata("design:type",String)],Gt.prototype,"runId",void 0),i.__decorate([d.column(),a.required(),d.index(),r.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)],Gt.prototype,"workflowId",void 0),i.__decorate([d.column(),r.description("Owning user; absent for anonymous callers"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.owner.label"}),i.__metadata("design:type",String)],Gt.prototype,"owner",void 0),i.__decorate([d.column(),a.required(),a.type(String),d.index(),r.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)],Gt.prototype,"status",void 0),i.__decorate([d.column(),r.description("Fingerprint of the executed document"),o.uielement("ngx-decaf-crud-field",{label:"graph.run.fingerprint.label",readonly:!0}),i.__metadata("design:type",String)],Gt.prototype,"documentFingerprint",void 0),i.__decorate([d.column(),r.prop(),r.description("Workflow input values keyed by input port id"),i.__metadata("design:type",Object)],Gt.prototype,"inputs",void 0),i.__decorate([d.column(),r.prop(),r.description("Execution result, present on successful completion"),i.__metadata("design:type",Object)],Gt.prototype,"result",void 0),i.__decorate([d.column(),r.prop(),r.description("Structured error payload, present on failure"),i.__metadata("design:type",Object)],Gt.prototype,"error",void 0),i.__decorate([a.date(),d.column(),r.description("Run creation timestamp"),i.__metadata("design:type",Date)],Gt.prototype,"createdAt",void 0),i.__decorate([a.date(),d.column(),r.description("Execution start timestamp, once it has started"),i.__metadata("design:type",Date)],Gt.prototype,"startedAt",void 0),i.__decorate([a.date(),d.column(),r.description("Terminal-state timestamp, once the run has finished"),i.__metadata("design:type",Date)],Gt.prototype,"finishedAt",void 0),Gt=i.__decorate([o.uilistmodel("ngx-decaf-list-item",{icon:"ti-player-play"}),o.uimodel("ngx-decaf-crud-form"),r.description("Persistable graph run lifecycle record"),d.table("graph_run"),a.model(),i.__metadata("design:paramtypes",[Object])],Gt);let Mt=class extends d.BaseModel{constructor(e){super(e)}};i.__decorate([d.pk({type:String,generated:!1}),i.__metadata("design:type",String)],Mt.prototype,"workflowId",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],Mt.prototype,"name",void 0),i.__decorate([d.column(),i.__metadata("design:type",Object)],Mt.prototype,"document",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],Mt.prototype,"owner",void 0),i.__decorate([d.column(),i.__metadata("design:type",Object)],Mt.prototype,"snapshot",void 0),i.__decorate([d.noValidateOnUpdate(),i.__metadata("design:type",Date)],Mt.prototype,"createdAt",void 0),Mt=i.__decorate([d.table("graph_workflow"),a.model(),i.__metadata("design:paramtypes",[Object])],Mt);let jt=class extends d.BaseModel{constructor(e){super(e)}};i.__decorate([d.pk({type:String,generated:!1}),i.__metadata("design:type",String)],jt.prototype,"kind",void 0),i.__decorate([d.column(),d.index(),i.__metadata("design:type",String)],jt.prototype,"name",void 0),i.__decorate([d.column(),d.index(),i.__metadata("design:type",String)],jt.prototype,"category",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],jt.prototype,"group",void 0),i.__decorate([d.column(),i.__metadata("design:type",String)],jt.prototype,"description",void 0),i.__decorate([d.column(),i.__metadata("design:type",Object)],jt.prototype,"manifest",void 0),i.__decorate([d.noValidateOnUpdate(),i.__metadata("design:type",Date)],jt.prototype,"createdAt",void 0),jt=i.__decorate([d.table("graph_node"),a.model(),i.__metadata("design:paramtypes",[Object])],jt),K("Trigger",{color:"#3b82f6",icon:"ti-bolt"}),K("Flow Control",{color:"#f59e0b",icon:"ti-arrows-split-2"}),K("Utility",{color:"#0d9488",icon:"ti-tool"}),K("Loop",{color:"#eab308",icon:"ti-repeat"}),K("Workflow",{color:"#f97316",icon:"ti-sitemap"}),K("Pipeline",{color:"#0ea5e9",icon:"ti-git-merge"}),K("Node",{color:"#8b5cf6",icon:"ti-point-filled"}),K("Agent",{color:"#7c3aed",icon:"ti-robot"}),K("Data",{color:"#8b5cf6",icon:"ti-table"}),K("IO",{color:"#0ea5e9",icon:"ti-world-www"}),K("Storage",{color:"#0f766e",icon:"ti-database"}),K("DevOps",{color:"#475569",icon:"ti-terminal-2"}),K("Comms",{color:"#d946ef",icon:"ti-message-circle"}),K("model",{color:"#3b82f6",icon:"ti-cpu"}),K("memory",{color:"#10b981",icon:"ti-database"}),K("workspace",{color:"#f59e0b",icon:"ti-folder"}),K("tools",{color:"#0ea5e9",icon:"ti-tools"}),K("hooks",{color:"#f97316",icon:"ti-webhook"}),K("skill",{color:"#8b5cf6",icon:"ti-bulb"}),K("sandbox",{color:"#14b8a6",icon:"ti-box"}),K("scorers",{color:"#ec4899",icon:"ti-star"}),K("embedding",{color:"#6366f1",icon:"ti-vector"});const Lt=new Set;function Ft(e,t){return e.config[t]}function qt(e){return Array.isArray(e)?e.map(e=>e+"").join(", "):e+""}(()=>{const e=[{key:ee.NODE_ID,shouldInclude:e=>null!=Ft(e,ee.NODE_ID),render:e=>Ft(e,ee.NODE_ID)+""},{key:ee.WORKFLOW_ID,shouldInclude:e=>null!=Ft(e,ee.WORKFLOW_ID),render:e=>Ft(e,ee.WORKFLOW_ID)+""},{key:ee.RUN_ID,shouldInclude:e=>null!=Ft(e,ee.RUN_ID),render:e=>Ft(e,ee.RUN_ID)+""},{key:ee.USER,shouldInclude:e=>null!=Ft(e,ee.USER),render:e=>Ft(e,ee.USER)+""},{key:ee.ROLES,shouldInclude(e){const t=Ft(e,ee.ROLES);return Array.isArray(t)&&t.length>0},render:e=>qt(Ft(e,ee.ROLES))},{key:ee.NAMESPACES,shouldInclude(e){const t=Ft(e,ee.NAMESPACES);return Array.isArray(t)&&t.length>0},render:e=>qt(Ft(e,ee.NAMESPACES))},{key:ee.ORGANIZATION,shouldInclude:e=>null!=Ft(e,ee.ORGANIZATION),render:e=>Ft(e,ee.ORGANIZATION)+""},{key:ee.IP,shouldInclude:e=>null!=Ft(e,ee.IP),render:e=>Ft(e,ee.IP)+""}];for(const o of e)Lt.has(o.key)||(t.logParameterRegistry.register(o),Lt.add(o.key))})();const $t="$workflow",Ht="local",Ut="GRAPH_LOCAL_UNSUPPORTED_NODE_KIND",Bt=1e3,Wt=1e4,Vt=3e4,Kt=3e5,zt=10485760,Qt=1048576,Jt=1e4,Xt=1048576,Yt=1e4;var Zt,eo;e.GraphPinningStrategy=void 0,(Zt=e.GraphPinningStrategy||(e.GraphPinningStrategy={})).MANUAL="manual",Zt.AUTOMATIC="automatic",Zt.DISABLED="disabled",e.GraphConditionType=void 0,(eo=e.GraphConditionType||(e.GraphConditionType={})).TRUTHY="truthy",eo.FALSY="falsy",eo.EQUALS="equals",eo.NOT_EQUALS="notEquals",eo.GREATER_THAN="greaterThan",eo.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",eo.LESS_THAN="lessThan",eo.LESS_THAN_OR_EQUAL="lessThanOrEqual",eo.EXISTS="exists",eo.CUSTOM="custom";class to extends n.InternalError{constructor(e,t="GRAPH_EXECUTION_ERROR",o){super(e,to.name,500),this.graphCode=t,this.details=o,this.name=this.constructor.name}}class oo extends to{constructor(e){super("Graph workflow contains an unsupported cycle","GRAPH_CYCLE_ERROR",e)}}class ro extends to{constructor(e,t){super(e,"GRAPH_INPUT_ERROR",t)}}class ao extends to{constructor(e,t){super(e,"GRAPH_LOOP_LIMIT_ERROR",t)}}class no extends to{constructor(e,t){super(e,"GRAPH_PINNING_ERROR",t)}}class io extends to{constructor(e,t){super(e,"GRAPH_STORE_ERROR",t)}}class so extends to{constructor(e,t){super(e,"GRAPH_TOPOLOGY_ERROR",t)}}class lo extends to{constructor(e){super("Break signal","GRAPH_BREAK_SIGNAL",{value:e}),this.isBreakSignal=!0,this.name="GraphBreakSignal"}}class co extends to{constructor(e){super(`Graph run '${e}' was cancelled`,"GRAPH_RUN_CANCELLED",{runId:e}),this.name=co.name}}class po 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=po.name,this.issues=e}}class uo{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 go{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 to("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 ho(e){if("string"!=typeof e)return;const t=e.trim();if(!t)return;const o=t.split(".");if(3!==o.length)return;const r=o[0].trim(),a=o[2].trim(),n=o[1].split(",").map(e=>e.trim()).filter(e=>e.length>0);return r&&a&&0!==n.length?{organization:r,departments:n,role:a}: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=ho(e.namespace);return!!t&&mo(t)===mo(e.parts)}function _o(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 ho(o)}}function yo(e,t,o={},r){const a=_o(e,r),n=_o(t,r);return!(!a||!n)&&a.organization===n.organization&&a.role===n.role&&("exact"===(o.mode??"inherit")?a.departments.length===n.departments.length&&a.departments.every((e,t)=>e===n.departments[t]):a.departments.length<=n.departments.length&&a.departments.every((e,t)=>e===n.departments[t]))}function bo(e,t,o={},r){return e.filter(e=>!t.some(t=>yo(t,e,o,r)))}function wo(e){return e.filter(e=>void 0===ho(e))}function No(e,t){const o=new Set;for(const r of e){const e=_o(r,t);e&&o.add(e.role)}return[...o]}function vo(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function Ao(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 Eo(e){if(!e)return{};const t={},o=e.user;"string"==typeof o&&o&&(t.user=o);const r=e.organization;"string"==typeof r&&r&&(t.organization=r);const a=e.ip;"string"==typeof a&&a&&(t.ip=a);const n=vo(e.roles);n&&(t.roles=n);const i=vo(e.namespaces);return i&&(t.namespaces=i,t.namespaceCache=Io(i)),t}function So(e){return e?Eo({user:Ao(e,"user"),organization:Ao(e,"organization"),ip:Ao(e,"ip"),roles:Ao(e,"roles"),namespaces:Ao(e,"namespaces")}):{}}function Io(e){const t=[];for(const o of e){const e=ho(o);e&&t.push({namespace:o,parts:e})}return t}function xo(...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??Io(o.namespaces):void 0!==o.namespaceCache&&(t.namespaceCache=o.namespaceCache));return t}class Ro{constructor(e={}){this.options=e}get enabled(){return!0===this.options.enabled}validate(e,o,r,a){if(!this.enabled)return;const n=a??this.options.logger??t.Logging.for("GraphAuth"),i=e.id||e.name||o.workflowId,d=ie(e.metadata);this.assertGranted(`workflow '${i}'`,d?.namespaces??[],r,d?.roles??[],n);for(const e of o.nodes)this.assertGranted(`node '${e.id}'`,e.manifest.namespaces??[],r,[],n)}validateWorkflowRead(e,o,r){if(!this.enabled)return;const a=r??this.options.logger??t.Logging.for("GraphAuth"),n=ie(e.metadata);this.assertGranted(`workflow '${e.id||e.name}'`,n?.namespaces??[],o,n?.roles??[],a)}assertGranted(e,t,o,r,a){const n=o.namespaces??[],i=bo(t,n,this.options.match,o.namespaceCache),s=No(n,o.namespaceCache),l=r.filter(e=>!s.includes(e));if(0===i.length&&0===l.length)return;const c=[...new Set([...wo(t),...wo(n)])],p=[];throw i.length&&p.push("namespace(s) "+i.join(", ")),l.length&&p.push("role(s) "+l.join(", ")),a.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 Oo{constructor(e){this.services=e}async resolve(e,t,o,r,a){if(!e){if(o)throw new to(`${r} node requires a credential of type '${t}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:t});return}if(e.credentialType&&e.credentialType!==t)throw new to(`${r} 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,a)}catch(t){throw new to(`${r} 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 to(`${r} 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 to(`${r} node credential '${e.credentialId}' has expired`,"GRAPH_CREDENTIAL_EXPIRED",{credentialId:e.credentialId});if(n.credentialType&&n.credentialType!==t)throw new to(`${r} 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,r),d=await i.retrieve(n.secretName,{},a);return await(this.services.credentialService.markCredentialUsed?.(e.credentialId,a).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 to(`${t} node credential provider '${e}' requires a configured filesystem secret service`,"GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{provider:e});return this.services.fsSecretService}throw new to(`${t} node credential provider '${e}' is not supported`,"GRAPH_CREDENTIAL_PROVIDER_UNSUPPORTED",{provider:e})}}async function ko(e,t,o,r,a,n="credentialRef"){const i=t?.[n];if(!i){if(!r)return;throw new to(`${a} node requires a credential of type '${o}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:o})}const d=e?.engine,s=d?.nodeCredentials;if(!s)throw new to(a+" node requires ctx-bound credential services, but the engine has none configured","GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{node:a,credentialType:o});return s.resolve(i,o,r,a,e)}class To{constructor(e){this.baseOptions=e,this.inner=t.Logging.for("GraphRun").for(this.attributeConfig(e))}attributeConfig(e){return{[ee.NODE_ID]:e.nodeId,[ee.WORKFLOW_ID]:e.workflowId,[ee.RUN_ID]:e.runId,[ee.USER]:e.user??null,[ee.ROLES]:e.roles,[ee.NAMESPACES]:e.namespaces,[ee.ORGANIZATION]:e.organization,[ee.IP]:e.ip}}emit(e,t,o){const r="string"==typeof t?t:t instanceof Error?t.message:t+"",a={level:e,message:r,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&&(a.roles=this.baseOptions.roles),void 0!==this.baseOptions.namespaces&&(a.namespaces=this.baseOptions.namespaces),void 0!==this.baseOptions.organization&&(a.organization=this.baseOptions.organization),void 0!==this.baseOptions.ip&&(a.ip=this.baseOptions.ip),void 0!==o&&(a.payload=o),this.baseOptions.forward({type:te.GRAPH_RUN_LOG,payload:a}).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](r,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 Co(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}class Do extends d.Context{constructor(e,t,o,r,a,n,i,d,s={},l,c,p){super(),this.runId=e,this.parentRunId=t,this.workflowId=o,this.document=r,this.node=a,this.manifest=n,this.path=i,this.emitFn=d,this.metadata=s,this.engine=l,this.abortSignal=c,this.limits=p;const u=Eo(s);this.accumulate({...u,operation:"execute"});const g="string"==typeof s?.user?s.user:null;this.runLogger=new To({runId:e,workflowId:o,nodeId:a.id,user:g,roles:Co(s?.roles),namespaces:Co(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 So(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:te.NODE_OUTPUT,payload:e})}async log(e,t){await this.emit({type:te.NODE_OUTPUT,payload:{message:e,payload:t}})}}class Po{constructor(e,t,o,r){this.nodeResults=new Map,this.events=[],this.activeDataEdges=new Set,this.runId=e,this.plan=t,this.valueStore=o,this.eventFactory=r,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 Go(e,t,o,r,a){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:r,document:t,inputs:{...o},outputs:n,nodeResults:i,events:d,startedAt:e.startedAt,finishedAt:e.finishedAt,metadata:a}}class Mo{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:te.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 jo(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 Lo{static{this._cache={}}static register(e,t){return Lo._cache[e]=t,t}static get(e){const t=e??Lo._currentFlavour;if(t)return Lo._cache[t]}static getOrFail(e){const t=Lo.get(e);if(!t)throw new to(`No graph execution backend registered under '${e}'`,"GRAPH_EXECUTION_BACKEND_NOT_REGISTERED");return t}static get current(){return Lo.get()}static get currentFlavour(){return Lo._currentFlavour??Ht}static setCurrent(e){Lo._currentFlavour=e}static list(){return Object.entries(Lo._cache).map(([e,t])=>({flavour:e,backend:t}))}static unregister(e){e&&(delete Lo._cache[e],Lo._currentFlavour===e&&(Lo._currentFlavour=void 0))}static clear(){for(const e of Object.keys(Lo._cache))delete Lo._cache[e];Lo._currentFlavour=void 0}}class Fo{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 to(`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 to("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 r=t;for(const e of o){if(null==r)return;r=r[e]}return r}}function qo(e){return"object"==typeof e&&null!==e&&"type"in e&&"code"===e.type}function $o(e){return"object"==typeof e&&null!==e&&"op"in e&&"string"==typeof e.op}async function Ho(e,t,o){const r=o.engine?.codeSandboxEvaluator;if(!r)throw new to("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 a=o.metadata;return!!await r.evaluate({code:e.code,language:e.language,input:t,vars:a?.vars??void 0,item:a?.item,index:a?.index,nodes:a?.nodes??void 0,logger:o.logger,abortSignal:o.abortSignal})}function Uo(e,t,o){if($o(e))return(new Fo).evaluate(e,t);throw((e,t)=>new to(`Unknown ${t??"flow"} condition type \u2014 must be ConditionExpression (op) or CodeCondition (type: 'code')`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e}))(e,o)}async function Bo(e,t,o){return qo(e)?Ho(e,t.input,o):Uo(e,t.state,t.label)}function Wo(e,t,o,r){if(e&&"object"==typeof e&&!r.has(e))if(r.add(e),qo(e))o.push({nodeId:t,kind:"code-condition"});else if(rt(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))Ko(e,o,r);else if(Array.isArray(e))for(const a of e)Wo(a,t,o,r);else for(const a of Object.keys(e))Wo(e[a],t,o,r)}function Vo(e,t,o){const r=e.id;"core.utility.code"===e.kind&&t.push({nodeId:r,kind:"code-node",detail:e.kind});const a=e.inputBindings??{};for(const[e,o]of Object.entries(a))o&&"expression"===o.mode&&t.push({nodeId:r,kind:"expression-binding",detail:e});Wo(e.parameters,r,t,o),Wo(e.metadata,r,t,o),Wo(e.state,r,t,o),Wo(e.loop,r,t,o)}function Ko(e,t,o){for(const r of e.nodes??[])Vo(r,t,o)}function zo(e){const t=[];return Ko(e,t,new Set),t}const Qo="core.agent";function Jo(e,t){if(!t)return{valid:!0};switch(t.type){case"any":default:return{valid:!0};case"string":return"string"!=typeof e?Xo("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}:Xo("number");case"boolean":return"boolean"!=typeof e?Xo("boolean"):{valid:!0};case"array":if(!Array.isArray(e))return Xo("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=Jo(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 Xo(t.type);const o=t,r=o.properties;if(!r)return{valid:!0};for(const[t,o]of Object.entries(r))if(t in e){const r=Jo(e[t],o);if(!r.valid)return{valid:!1,message:`property '${t}': ${r.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 r))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 Xo(e){return{valid:!1,message:`expected a ${e} value`}}function Yo(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 Zo=new Set(["loop"]),er=["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 tr{validate(e,t,o,r,a){this.validateParameters(e,t,o,r,a),this.validateMetadataKeys(e,t,o,r),this.validateDisabledBehavior(e,o,r),this.validateBindingShapes(e,t,o,r)}validateParameters(e,t,o,r,a){const n=!0===t.policies?.allowUndeclaredParameters,i=new Map(t.parameters.map(e=>[e.id,e]));for(const[a,d]of Object.entries(e.parameters??{})){const s=i.get(a);if(!s){n||o.push({code:"parameter.undeclared",path:`${r}.parameters.${a}`,message:`Node '${e.id}' sets parameter '${a}' 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:`${r}.parameters.${a}`,message:`Node '${e.id}' parameter '${a}' must not be undefined`,nodeId:e.id});continue}const l=this.checkParameterValue(d,s);l.valid||o.push({code:"parameter.type-mismatch",path:`${r}.parameters.${a}`,message:`Node '${e.id}' parameter '${a}' 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,a)||(!0===n.required||(n.validation??[]).some(e=>"required"===e.kind))&&void 0===n.defaultValue&&o.push({code:"parameter.required-missing",path:`${r}.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(rt(e))return{valid:!0};switch(t.type){case"string":case"code":case"expression":return"string"!=typeof e?Xo("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?{valid:!0}:Xo("number");case"boolean":return"boolean"!=typeof e?Xo("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}:Xo("array");case"object":case"resourceLocator":return null===e||"object"!=typeof e||Array.isArray(e)?Xo("object"):{valid:!0};case"credential":return Yo(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,r){const a=t.metadata?.allowedInstanceMetadataKeys;for(const n of Object.keys(e.metadata??{}))Zo.has(n)?o.push({code:"metadata.key-not-allowed",path:`${r}.metadata.${n}`,message:`Node '${e.id}' metadata key '${n}' is reserved and must not be set directly`,nodeId:e.id}):Array.isArray(a)&&!a.includes(n)&&o.push({code:"metadata.key-not-allowed",path:`${r}.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 r=(e.metadata??{}).disabledBehavior;void 0===r||X(r)||t.push({code:"disabled.invalid-behavior",path:o+".metadata.disabledBehavior",message:`Node '${e.id}' disabled behavior '${r+""}' is not one of: ${J.join(", ")}`,nodeId:e.id})}validateBindingShapes(e,t,o,r){for(const[a,n]of Object.entries(e.inputBindings??{})){if("literal"===n.mode){const i=t.inputs.find(e=>e.id===a);if(i?.schema){const t=Jo(n.value,i.schema);t.valid||o.push({code:"binding.literal-invalid",path:`${r}.inputBindings.${a}`,message:`Node '${e.id}' literal binding for '${a}' 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:`${r}.inputBindings.${a}`,message:`Node '${e.id}' expression binding for '${a}' must contain a non-empty expression`,nodeId:e.id})}}validateBindingSatisfaction(e,t,o,r,a,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&&r.push({code:"binding.conflict",path:`${a}.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]&&r.push({code:"topology.required-input-unsatisfiable",path:a+".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(X(o))return o;const r=t?.disabledBehavior;return X(r)?r:"skip"}}function or(e){return[e.namespace??"default",e.workflowId,e.nodeId,e.version??"default",e.fingerprint].join(":")}function rr(t){return new e.GraphValueModel({id:or(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 ar(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 nr(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"),a.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($t,{...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($t)??{};o[e]=t,this.runtimeValues.set($t,o)}getWorkflowValues(){return{...this.runtimeValues.get($t)??{}}}snapshot(){return Object.fromEntries(this.runtimeValues.entries())}async readCached(e,...t){try{return ar(await this.read(or(e),...t))}catch{return}}async writeCached(e,t,...o){const r=or(e);let a;try{a=await this.read(r,...o)}catch{a=void 0}a?await this.update(Object.assign(a,rr(t)),...o):await this.create(rr(t),...o)}async deleteCached(e,...t){try{await this.delete(or(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=>ar(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,r.DefaultFlavour),i.__metadata("design:paramtypes",[Function])],e.GraphValueRepository);class ir{static upstreamNodes(e,t,o=!1){const r=new Set,a=[e];for(;a.length;){const e=a.pop(),n=t.get(e)??[];for(const e of n)!o&&this.isBoundary(e.sourceNodeId)||r.has(e.sourceNodeId)||(r.add(e.sourceNodeId),a.push(e.sourceNodeId))}return r}static downstreamNodes(e,t,o=!1){const r=new Set,a=[e];for(;a.length;){const e=a.pop(),n=t.get(e)??[];for(const e of n)!o&&this.isBoundary(e.targetNodeId)||r.has(e.targetNodeId)||(r.add(e.targetNodeId),a.push(e.targetNodeId))}return r}static isBoundary(e){return"$workflow"===e}}class dr{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 no(`Node '${e}' not found in plan`);if(!this.policy.canPin(o))throw new no(`Node '${e}' is not pinnable`,{nodeId:e})}const r=this.topologicalOrder(t,o);for(const o of r){const r=t.nodes.find(e=>e.id===o),a=e.result.nodeResults[o];if(!a||!a.outputs)throw new no(`Node '${o}' has no completed output to pin`);const n=a.inputs??{},i=this.dependencyFingerprints(t,o,e.result),d=this.createValueKey(e.document.id,r,n,i),s=(new Date).toISOString(),l={key:d,outputs:a.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,r,a){const n=this.createValueKey(e,t,o,r,a),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,r,a){return{workflowId:e,nodeId:t.id,fingerprint:this.computeFingerprint(e,t,o,r),namespace:a}}computeFingerprint(e,t,o,r){const a={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(r)},n=this.stableSerialize(a);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=[],r=new Set,a=n=>{if(r.has(n))return;r.add(n);const i=ir.upstreamNodes(n,e.incomingByNode,!1);for(const e of i)t.has(e)&&a(e);o.push(n)};for(const e of t)a(e);return o}dependencyFingerprints(e,t,o){const r=this.dependencyResolver.getDependencies(e,t),a={};for(const t of r){const r=e.nodes.find(e=>e.id===t);if(r){const n=o.nodeResults[t],i=n?.inputs??{},d=this.dependencyFingerprints(e,t,o);a[t]=this.computeFingerprint(e.workflowId,r,i,d)}}return a}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 sr={enabled:!0,strategy:"manual",includeDependencies:!0};function lr(e){return!0===e?.enabled&&"disabled"!==e.strategy}class cr{canPin(e){return lr(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?{...sr,...t}:{...sr,enabled:!1}}}class pr{getDependencies(e,t){return ir.upstreamNodes(t,e.incomingByNode,!1)}getPinSet(e,t){const o=this.getDependencies(e,t);return o.add(t),o}}class ur{constructor(){this.local=!0,this.codeMode="hostSide",Lo.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 to("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 to("LocalGraphExecutionBackend has no workflowStore configured; workflow lookup is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");const r=await o.getDocument(e,...t);return this.engine&&this.engine.assertWorkflowReadAccess(r,(e=>So((e=>{for(let t=e.length-1;t>=0;t-=1){const o=e[t];if(!o||"object"!=typeof o)continue;const r=o;if("function"==typeof r.get&&"function"==typeof r.accumulate&&void 0!==r.cache)return o}})(e)))(t)),r}async seedWorkflows(e,...t){const o=this.workflowStore,r=o?.seedDocument??o?.saveDocument;if(!o||"function"!=typeof r)throw new to("LocalGraphExecutionBackend has no writable workflowStore configured; workflow seeding is not supported","GRAPH_BACKEND_SEED_NOT_SUPPORTED");const a=[];for(const n of e)null!==await r.call(o,n.id,n,...t)&&a.push({id:n.id,...void 0!==n.name?{name:n.name}:{}});return a}async execute(e){const{document:t,plan:o,inputs:r,options:a,events:n}=e,i=n,d=i.frame;if(!d)throw new to("LocalGraphExecutionBackend requires the frame-bound event sink created by GraphExecutionEngine","GRAPH_EXECUTION_FRAME_MISSING");const s=d.valueStore,l=d.runId,c=a.path??[],p=async e=>{await i.emit(e)};try{for(const e of o.layers)this.assertNotAborted(a),await this.executeLayer(d,o,e.nodes,a,p);this.assertNotAborted(a);const e=[...d.nodeResults.values()].find(e=>e.status===Y.FAILED);if(e?.error)throw new to(e.error.message,e.error.code??"GRAPH_EXECUTION_ERROR",e.error.details);return d.finish(),await i.emit({type:te.WORKFLOW_COMPLETED,runId:l,parentRunId:a.parentRunId,workflowId:o.workflowId,path:c,status:Y.SUCCEEDED,payload:{outputs:s.getWorkflowValues()}}),Go(d,t,r,Y.SUCCEEDED,a.metadata)}catch(e){if(e instanceof lo)throw d.finish(),e;d.finish();const n=this.toErrorPayload(e);return e instanceof co||!0===a.abortSignal?.aborted?(await i.emit({type:te.WORKFLOW_CANCELLED,runId:l,parentRunId:a.parentRunId,workflowId:o.workflowId,path:c,status:Y.CANCELLED,error:n}),Go(d,t,r,Y.CANCELLED,a.metadata)):(await i.emit({type:te.WORKFLOW_FAILED,runId:l,parentRunId:a.parentRunId,workflowId:o.workflowId,path:c,status:Y.FAILED,error:n}),Go(d,t,r,Y.FAILED,a.metadata))}}async executeLayer(e,t,o,r,a){const n=Math.max(1,r.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,r,a)))}}async executeNode(e,t,o,r,a){if(this.assertNotAborted(r),!this.isNodeActivated(e,t,o))return void await this.skipInactiveNode(e,t,o,r,a);if(!0===o.instance.disabled)return void await this.executeDisabledNode(e,t,o,r,a);const n=new Date,i=[...r.path??[],o.id];await a({type:te.NODE_STARTED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:Y.RUNNING}),this.emitNodeStateChanged(e,t,o,i,Z.RUNNING,Y.RUNNING,a);const d=await this.resolveNodeInputs(e,t,o,r);if(r.usePinnedValues){const r=await this.tryPinnedValue(e,t,o,d);if(r){e.valueStore.setNodeOutputs(o.id,r.outputs),this.routeOutgoingEdges(e,t,o,r.outputs,a);const s=new Date,l={nodeId:o.id,status:Y.CACHED,inputs:d,outputs:r.outputs,startedAt:n,finishedAt:s,fromCache:!0,pinned:!0,events:[]};return e.recordNodeResult(l),await a({type:te.NODE_CACHE_HIT,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:Y.CACHED,payload:{outputs:r.outputs}}),await a({type:te.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:Y.SUCCEEDED,payload:{outputs:r.outputs,fromCache:!0}}),void this.emitNodeStateChanged(e,t,o,i,Z.SUCCEEDED,Y.SUCCEEDED,a)}}try{const s=new Do(e.runId,r.parentRunId,t.workflowId,t.resolved.document,o.instance,o.manifest,i,a,r.metadata,this.engine,r.abortSignal,this.executionLimits(r)),l=await this.resolveNodeParameters(o,d,r),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,a);const g=new Date,h={nodeId:o.id,status:Y.SUCCEEDED,inputs:d,outputs:u,startedAt:n,finishedAt:g,events:[]};e.recordNodeResult(h),await a({type:te.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:Y.SUCCEEDED,payload:{outputs:u}}),this.emitNodeStateChanged(e,t,o,i,Z.SUCCEEDED,Y.SUCCEEDED,a)}catch(s){if(s instanceof lo)throw s;const l=new Date,c=this.toErrorPayload(s),p={nodeId:o.id,status:Y.FAILED,inputs:d,error:c,startedAt:n,finishedAt:l,events:[]};if(e.recordNodeResult(p),await a({type:te.NODE_FAILED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:Y.FAILED,error:c}),this.emitNodeStateChanged(e,t,o,i,Z.FAILED,Y.FAILED,a),r.failFast??!0)throw s}}isNodeActivated(e,t,o){const r=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type);return 0===r.length||r.some(t=>t.sourceNodeId===$t||e.isDataEdgeActive(t.id))}async skipInactiveNode(e,t,o,r,a){const n=new Date,i=[...r.path??[],o.id];await a({type:te.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:Y.SKIPPED,payload:{reason:"branchNotSelected"}});const d={nodeId:o.id,status:Y.SKIPPED,inputs:{},startedAt:n,finishedAt:new Date,events:[]};e.recordNodeResult(d),this.emitNodeStateChanged(e,t,o,i,Z.SKIPPED,Y.SKIPPED,a)}async executeDisabledNode(e,t,o,r,a){const n=new Date,i=[...r.path??[],o.id],d=tr.disabledBehaviorOf(o.instance,t.resolved.document.settings);if(await a({type:te.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:i,status:Y.SKIPPED,payload:{disabled:!0,behavior:d}}),"skip"===d){const r={nodeId:o.id,status:Y.SKIPPED,inputs:{},startedAt:n,finishedAt:new Date,events:[]};return e.recordNodeResult(r),void this.emitNodeStateChanged(e,t,o,i,Z.SKIPPED,Y.SKIPPED,a)}const s=await this.resolveNodeInputs(e,t,o,r);let l;if("passThroughFirstInput"===d){const r=(t.incomingByNode.get(o.id)??[]).find(e=>"data"===e.type),a=o.manifest.outputs[0]?.id??"value",n=r?e.valueStore.getPort(r.sourceNodeId,r.sourcePort):Object.values(s)[0];l={[a]: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,a);const c={nodeId:o.id,status:Y.SUCCEEDED,inputs:s,outputs:l,startedAt:n,finishedAt:new Date,events:[]};e.recordNodeResult(c),this.emitNodeStateChanged(e,t,o,i,Z.SUCCEEDED,Y.SUCCEEDED,a)}async invokeExecutor(e,t,o){if((r=e.kind)===Qo||r.startsWith(Qo+"."))throw new to(`Node '${e.id}' of kind '${e.kind}' requires the mastra engine, which the local backend does not provide`,Ut,{nodeId:e.id,kind:e.kind,backend:Ht});var r;return await e.executor.execute(t,o)}validateNodeOutputs(e,t){const o=e.manifest;if(!0===o.policies?.allowUnknownOutputs)return t;const r=new Set(o.outputs.map(e=>e.id)),a=Object.keys(t).filter(e=>!r.has(e));if(a.length>0)throw new to(`Node '${e.id}' of kind '${e.kind}' produced unknown output(s): ${a.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,unknownOutputs:a});const n=o.outputs.filter(e=>!0===e.required&&!(e.id in t)).map(e=>e.id);if(n.length>0)throw new to(`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 r=(e.instance.parameters??{})[o.id];"string"==typeof r&&r.length>0?t[o.id]={credentialId:r,credentialType:o.credentialType??""}:Yo(r)&&(t[o.id]={credentialId:r.credentialId,credentialType:r.credentialType})}const o=(e.instance.metadata??{}).credentials;if(o&&"object"==typeof o&&!Array.isArray(o))for(const[e,r]of Object.entries(o)){const o=r;"string"==typeof o&&o.length>0?t[e]={credentialId:o,credentialType:""}:Yo(o)&&(t[e]={credentialId:o.credentialId,credentialType:o.credentialType})}return t}async resolveNodeInputs(e,t,o,r){const a={},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)a[t]=e.valueStore.getPort(o[0].sourceNodeId,o[0].sourcePort);else{let r,n=!1;for(const t of o){const o=e.valueStore.getPort(t.sourceNodeId,t.sourcePort);a[t.sourcePort]=o,void 0!==o&&(r=o,n=!0)}n&&void 0===a[t]&&(a[t]=r)}const d=o.instance.inputBindings??{};for(const e of o.manifest.inputs){const t=d[e.id];if("literal"===t?.mode)a[e.id]=t.value;else if("expression"===t?.mode)a[e.id]=await this.evaluateExpressionBinding(o,t.expression,a,r);else if(void 0===a[e.id]){const t=e.metadata?.defaultValue;void 0!==t&&(a[e.id]=t)}}return a}async resolveNodeParameters(e,t,o){const r=e.instance.parameters??{},a={};for(const[n,i]of Object.entries(r))a[n]=rt(i)?await this.evaluateValueTemplate(i,e,t,o):i;return a}async evaluateValueTemplate(e,t,o,r){const a=this.codeSandboxEvaluator;if(!a)throw new to(`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=r.metadata;return await a.evaluate({code:i,language:"typescript"===n?"typescript":"javascript",input:o,vars:d?.vars??void 0,item:d?.item,index:d?.index,abortSignal:r.abortSignal})}async evaluateExpressionBinding(e,t,o,r){const a=this.codeSandboxEvaluator;if(!a)throw new to(`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=r.metadata;return await a.evaluate({code:t,language:"javascript",input:o,vars:n?.vars??void 0,item:n?.item,index:n?.index,abortSignal:r.abortSignal})}async tryPinnedValue(e,t,o,r){if(!(new cr).shouldUsePinnedValue(o))return;const a=this.createPinningService(e),n=this.computeDependencyFingerprints(e,t,o.id);return a.readPinnedValue(t.workflowId,o,r,n)}computeDependencyFingerprints(e,t,o){const r=this.createPinningService(e),a=(new pr).getDependencies(t,o),n={};for(const o of a){const a=t.nodes.find(e=>e.id===o);if(a){const i=e.nodeResults.get(o),d=i?.inputs??{},s=this.computeDependencyFingerprints(e,t,o);n[o]=r.computeFingerprint(t.workflowId,a,d,s)}}return n}routeOutgoingEdges(e,t,o,r,a){const n=(t.outgoingByNode.get(o.id)??[]).filter(e=>"data"===e.type);for(const i of n){if(!Object.prototype.hasOwnProperty.call(r,i.sourcePort))continue;const n=r[i.sourcePort];e.activateDataEdge(i.id),i.targetNodeId===$t&&e.valueStore.setWorkflowOutput(i.targetPort,n),this.emitEdgeStateChanged(e,t,o,i,Z.SUCCEEDED,Y.SUCCEEDED,a),a({type:te.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,r,a,n,i){i({type:te.NODE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:r,status:n,payload:{nodeId:o.id,state:a,runId:e.runId,workflowId:t.workflowId,status:n}}).catch(()=>{})}emitEdgeStateChanged(e,t,o,r,a,n,i){i({type:te.EDGE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,edgeId:r.id,nodeId:o.id,path:[],status:n,payload:{edgeId:r.id,state:a,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,status:n}}).catch(()=>{})}createPinningService(e){const t=nr(e.valueStore.getAdapter()??this.valueAdapter);return new dr(t,new cr,new pr)}executionLimits(e){return{maxLoopIterations:e.maxLoopIterations??Bt,maxForeachIterations:e.maxForeachIterations??Wt}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new co(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 gr{constructor(e){this.catalogue=e}async resolveNodes(e,t,o,...r){const a=new Map;for(const[n,i]of e.entries()){const e=`nodes[${n}]`;if(this.catalogue.has(i.kind,...r))try{const e=await this.catalogue.resolveManifest(i.kind,i,o,...r),t=this.catalogue.getExecutor(i.kind,...r);a.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 a}validateEffectivePorts(e,t,o,r){const a=!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??{}))a||n.has(i)||o.push({code:"binding.unknown-port",path:`${r}.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??{}))a||i.has(n)||o.push({code:"binding.unknown-port",path:`${r}.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 hr(e,t,o="$"){const r=new Set;for(const t of e.edges)"node"===t.source.scope&&r.add(t.source.nodeId),"node"===t.target.scope&&r.add(t.target.nodeId);for(const a of e.nodes){r.has(a.id)||t.push({code:"topology.loose-node",path:`${o}.nodes[${a.id}]`,message:`Node '${a.id}' is connected to nothing; every node must participate in at least one edge`,nodeId:a.id});const e=a.loop?.body;e&&hr(e,t,`${o}.nodes[${a.id}].loop.body`)}}class mr{resolveEdges(e,t,o){const r=new Set(e.inputs.map(e=>e.id)),a=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,r,a,o,e),l=this.resolveEndpoint(d,"target",t,r,a,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,r,a,n,i){const d=e[t];return He(d)?("source"===t?r.has(d.port):a.has(d.port))?{nodeId:$t,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}}):Ue(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,r,a,n){let i=!0;const d=t.nodeId===$t?void 0:r.get(t.nodeId),s=o.nodeId===$t?void 0:r.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,a,n),i=!1),!s||l(s)||this.hasPortDirection(s,o.port,"input")||(this.pushPortIssue(e,"target",o,s,a,n),i=!1);else{if(!d||!s)return a.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 a.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,r,a,n){const i="source"===t?"output":"input";a.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 '${r.manifest.kind}'`,edgeId:e.id,nodeId:o.nodeId,details:{port:o.port,expected:i}})}}class fr{validate(e,t){this.validateDuplicates(e.edges,t),this.validatePolicies(e,t)}validateDuplicates(e,t){const o=new Map;for(const r of e){const e=`${r.sourceNodeId}:${r.sourcePort}->${r.targetNodeId}:${r.targetPort}`,a=o.get(e);a?t.push({code:"connection.duplicate-edge",path:`edges[${r.id}]`,message:`Edge '${r.id}' duplicates the routing of edge '${a.id}' (${e})`,edgeId:r.id,details:{duplicateOf:a.id,routing:e}}):o.set(e,r)}}validatePolicies(e,t){const o=new Map;for(const t of e.edges){if("connection"!==t.type)continue;const e=`${t.targetNodeId}:${t.targetPort}`,r=o.get(e)??[];r.push(t),o.set(e,r)}for(const o of e.edges){if("connection"!==o.type)continue;const r=e.nodeById.get(o.targetNodeId),a=r?.manifest.connections?.find(e=>e.id===o.targetPort)?.connectionPolicy;this.validateEdgePolicy(o,e.nodeById,a,t),this.validateCategoryMatch(o,e.nodeById,t)}for(const[r,a]of o){const o=r.lastIndexOf(":"),n=r.slice(0,o),i=r.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;a.length>l&&t.push({code:"connection.max-connections",path:`edges[${a[a.length-1].id}]`,message:`Connection port '${i}' on node '${n}' accepts at most ${l} connection(s) but has ${a.length}`,nodeId:n,edgeId:a[a.length-1].id,details:{port:i,max:l,actual:a.length}})}}validateCategoryMatch(e,t,o){const r=t.get(e.sourceNodeId),a=t.get(e.targetNodeId),n=r?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category,i=a?.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,r){if(e.sourceNodeId===e.targetNodeId&&!o?.allowSelf)return void r.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 a=t.get(e.sourceNodeId),n=a?.manifest.kind;if(!o.allowedNodeKinds?.length||n&&o.allowedNodeKinds.includes(n)||r.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)&&r.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=a?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category;t&&o.allowedPortCategories.includes(t)||r.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 _r{constructor(e){this.authorizer=e}async validate(e,t,o,r){const a=this.collectReferences(e,t);for(const n of t.credentials??[]){const i=a.find(e=>void 0===e.credentialType||e.credentialType===n.type);if(i){if(this.checkType(i,n))o.push({code:"credential.type-mismatch",path:r,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:r,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:r,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:r,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,r)}collectReferences(e,t){const o=[];for(const r of t.parameters){if("credential"!==r.type)continue;const t=(e.parameters??{})[r.id];Yo(t)&&o.push(this.normalize(t,r.credentialType))}const r=(e.metadata??{}).credentials;if(r&&"object"==typeof r&&!Array.isArray(r))for(const e of Object.values(r))Yo(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 r=new Set(er.map(e=>e.toLowerCase()));for(const[a,n]of Object.entries(e.parameters??{}))this.scanPlainSecretValue(n,[a],e,o+".parameters",r,t);for(const[a,n]of Object.entries(e.metadata??{}))this.scanPlainSecretValue(n,[a],e,o+".metadata",r,t)}scanPlainSecretValue(e,t,o,r,a,n,i=0){const d=t[t.length-1];if(a.has(d.toLowerCase()))n.push({code:"credential.plain-secret",path:`${r}.${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,r,a,n,i+1);else if("object"==typeof e)for(const[d,s]of Object.entries(e))this.scanPlainSecretValue(s,[...t,d],o,r,a,n,i+1)}}class yr extends n.ValidationError{constructor(e,t=[]){super(e),this.issues=t,this.name=yr.name}}class br extends n.ValidationError{constructor(e,t){super(e),this.edgeId=t,this.name=br.name}}class wr extends d.AuthorizationError{constructor(e){super(e),this.name=wr.name}}const Nr={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},vr=["node","definition","executor","execute","ports","component"];function Ar(e){if(!e||"object"!=typeof e)return!1;const t=e;return at(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 Er(e,t){const o=[];for(const r of Object.keys(e))vr.includes(r)&&o.push({code:"document.forbidden-field",path:`${t}.${r}`,message:`Field '${r}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected`,details:{field:r}});return o}class Sr{constructor(e){this.options=e,this.parameterValidator=new tr,this.edgeValidator=new mr,this.connectionPolicyValidator=new fr,this.nodeValidator=new gr(e.catalogue),this.credentialValidator=new _r(e.credentialAuthorizer)}async validateOrThrow(e,...t){const o=await this.validate(e,0,...t);if(!o.valid||!o.resolved)throw new yr(`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 r=[],a={...Nr,...this.options.limits};if(!await this.validateStructure(e,a,t,r,...o))return{valid:!1,issues:r};const n=await this.nodeValidator.resolveNodes(e.nodes,r,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 r=t.get(e.nodeId)??new Set;r.add(e.port),t.set(e.nodeId,r)}return t})(e);for(const e of i)this.parameterValidator.validate(e.instance,e.manifest,r,`nodes[${e.instance.id}]`,d.get(e.instance.id));for(const e of i)this.nodeValidator.validateEffectivePorts(e.instance,e.manifest,r,`nodes[${e.instance.id}]`);const s=this.edgeValidator.resolveEdges(e,n,r),l=new Map,c=new Map;for(const e of s){if(e.targetNodeId!==$t){const t=l.get(e.targetNodeId)??[];t.push(e),l.set(e.targetNodeId,t)}if(e.sourceNodeId!==$t){const t=c.get(e.sourceNodeId)??[];t.push(e),c.set(e.sourceNodeId,t)}}this.connectionPolicyValidator.validate({edges:s,nodeById:n},r),this.validateAcyclicity(i,s,e,r),hr(e,r);for(const e of i)this.parameterValidator.validateBindingSatisfaction(e.instance,e.manifest,l.get(e.instance.id)??[],r,`nodes[${e.instance.id}]`,{allowLiteralAndEdgeBindings:this.options.allowLiteralAndEdgeBindings});this.validateRequiredWorkflowOutputs(e,c,r);for(const e of i)await this.credentialValidator.validate(e.instance,e.manifest,r,`nodes[${e.instance.id}]`);return this.validateCapabilities(i,r),r.length>0?{valid:!1,issues:r}:{valid:!0,issues:r,resolved:{document:e,nodes:i,edges:s,nodeById:n,incomingByNode:l,outgoingByNode:c}}}async validateStructure(e,t,o,r,...a){if(!at(e))return r.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()||r.push({code:"document.empty-id",path:"$.id",message:"Workflow document id must be a non-empty string"}),!Ce(e))return r.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;r.push(...Er(e,"$"));for(const t of[...e.inputs,...e.outputs])r.push(...Er(t,"ports"));for(const t of e.nodes)r.push(...Er(t,`nodes[${t.id}]`));for(const t of e.edges)r.push(...Er(t,`edges[${t.id}]`));this.validateUniqueIds(e,r),this.validateLimits(e,t,o,r);try{ze(e)}catch(e){r.push({code:"document.structure",path:"$",message:e instanceof Error?e.message:e+""})}return await this.validateNestedBodies(e,o,r,...a),!0}validateUniqueIds(e,t){const o=new Set,r=new Set;for(const[a,n]of[["input",e.inputs],["output",e.outputs]]){const e="input"===a?o:r;for(const o of n)e.has(o.id)?t.push({code:"document.duplicate-port-id",path:`${"input"===a?"inputs":"outputs"}[${o.id}]`,message:`Workflow ${a} port '${o.id}' is declared more than once; workflow port ids must be unique`}):e.add(o.id)}const a=new Set;for(const o of e.nodes)a.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}):a.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,r){e.nodes.length>t.maxNodes&&r.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&&r.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&&r.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 a=Buffer.byteLength(JSON.stringify(e),"utf8");a>t.maxDocumentBytes&&r.push({code:"document.limit.size",path:"$",message:`Document serializes to ${a} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,details:{bytes:a,limit:t.maxDocumentBytes}})}async validateNestedBodies(e,t,o,...r){for(const a of e.nodes){const e=[["loop.body",a.loop?.body],["errorBoundary.try",a.errorBoundary?.try],["errorBoundary.catch",a.errorBoundary?.catch],["errorBoundary.finally",a.errorBoundary?.finally]];for(const[n,i]of e){if(!i)continue;const e=await this.validate(i,t+1,...r);for(const t of e.issues)o.push({...t,path:`nodes[${a.id}].${n}.${t.path}`,nodeId:t.nodeId??a.id})}}}validateAcyclicity(e,t,o,r){const a=new Set(e.map(e=>e.instance.id)),n=new Map(e.map(e=>[e.instance.id,0]));for(const e of t)a.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));r.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 r=new Set;for(const e of t.values())for(const t of e)t.targetNodeId===$t&&r.add(t.targetPort);for(const t of e.outputs)!0===t.required&&void 0===t.defaultValue&&(r.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 r of e.capabilities??[])dt(r)||t.push({code:"capability.invalid",path:`nodes[${o.instance.id}]`,message:`Kind '${e.kind}' declares unknown capability '${r+""}'`,nodeId:o.instance.id,details:{capability:r+""}});!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"}'`),!Ar(e))throw new so("GraphExecutionPlanner.plan accepts only a GraphResolvedWorkflow produced by the nine-stage validation gate; raw workflow definitions and inline node definitions are rejected",{received:(r=e,r&&"object"==typeof r?{reason:"input is not a GraphResolvedWorkflow",looksLikeWorkflowDefinition:"nodes"in r&&"relations"in r&&!("nodeById"in r),hasResolvedNodes:Array.isArray(r.nodes)}:{reason:"input is not an object"})});var r;const a=this.buildPlanNodes(e),n=this.buildPlanEdges(e),i=this.buildIncomingMap(n),d=this.buildOutgoingMap(n),s=this.topologicalLayers(a,n);return{resolved:e,workflowId:e.document.id||e.document.name,nodes:a,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===$t)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===$t)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!==$t),r=new Set(o.map(e=>e.id)),a=t.filter(e=>r.has(e.sourceNodeId)&&r.has(e.targetNodeId)),n=new Map;for(const e of o)n.set(e.id,0);for(const e of a)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 r=a.filter(t=>t.sourceNodeId===e.id);for(const e of r){const r=(n.get(e.targetNodeId)??1)-1;if(n.set(e.targetNodeId,r),0===r&&!d.has(e.targetNodeId)){const r=o.find(t=>t.id===e.targetNodeId);r&&t.push(r)}}}s=t}if(d.size!==o.length){const e=o.filter(e=>!d.has(e.id)).map(e=>e.id);throw new oo({unplannedNodes:e,workflowId:o[0]?.manifest.kind})}return i}},e.GraphExecutionPlanner=i.__decorate([d.service(),i.__metadata("design:paramtypes",[])],e.GraphExecutionPlanner);class Ir{constructor(){this.pending=new Map}register(e,t){return this.cancel(e),new Promise((o,r)=>{const a={resolve:o};void 0!==t&&Number.isFinite(t)&&t>0&&(a.timer=setTimeout(()=>{this.pending.delete(e),r(new to(`No webhook response was produced for run '${e}' within ${t}ms`,"GRAPH_WEBHOOK_RESPONSE_TIMEOUT",{runId:e,timeoutMs:t}))},t),a.timer.unref?.()),this.pending.set(e,a)})}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"),a.model(),i.__metadata("design:paramtypes",[Object])],e.GraphDataTableModel);const xr=/^[A-Za-z0-9_.-]+$/;function Rr(e,t){return`${e}:${t}`}function Or(e){if(!e||e.length>128||!xr.test(e))throw new to(`Data table name '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_NAME",{tableName:e})}function kr(e){if(!e||e.length>256)throw new to(`Data table row id '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_ROW_ID",{rowId:e})}function Tr(e){let t;try{t=JSON.stringify(e)}catch{throw new to("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:Xt})}if(void 0===t)throw new to("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:Xt});const o=Buffer.byteLength(t,"utf8");if(o>Xt)throw new to("Data table row payload exceeds the 1048576-byte limit","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{bytes:o,limitBytes:Xt})}function Cr(e){return{...e.data,id:e.rowId}}function Dr(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,r,...a){Or(t),kr(o),Tr(r),await this.assertRowCapacity(t,...a);const n=new Date,i=new e.GraphDataTableModel({id:Rr(t,o),tableName:t,rowId:o,data:{...r},createdAt:n,updatedAt:n});return Cr(await this.create(i,...a))}async upsertRow(e,t,o,...r){if(Or(e),kr(t),Tr(o),!await this.readRow(e,t,...r))return this.insertRow(e,t,o,...r);const a=await this.read(Rr(e,t),...r);return a.data={...o},a.updatedAt=new Date,Cr(await this.update(a,...r))}async readRow(e,t,...o){Or(e),kr(t);try{return Cr(await this.read(Rr(e,t),...o))}catch{return}}async listRows(e,t,...o){Or(e);const r=void 0!==t&&Number.isFinite(t)&&t>=0?Math.floor(t):Yt;if(0===r)return[];const a=Math.min(r,Yt);return(await this.select().where(d.Condition.attr("tableName").eq(e)).orderBy("rowId",d.OrderDirection.ASC).limit(a).execute(...o)).map(Cr)}async assertRowCapacity(e,...t){if((await this.listRows(e,Jt,...t)).length>=Jt)throw new to(`Data table '${e}' reached the 10000-row limit`,"GRAPH_DATA_TABLE_ROW_LIMIT_EXCEEDED",{tableName:e,limit:Jt})}async deleteRow(e,t,...o){Or(e),kr(t);try{return await this.delete(Rr(e,t),...o),!0}catch{return!1}}async clearTable(e,...t){const o=await this.listRows(e,void 0,...t);for(const r of o)await this.deleteRow(e,r.id+"",...t);return o.length}},e.GraphDataTableRepository=i.__decorate([d.repository(e.GraphDataTableModel,r.DefaultFlavour),i.__metadata("design:paramtypes",[Function])],e.GraphDataTableRepository);const Pr=new Set(["engine","valueAdapter","codeSandboxEvaluator","workflowStore"]);function Gr(e){for(let t=e.length-1;t>=0;t-=1){const o=e[t];if(!o||"object"!=typeof o)continue;const r=o;if("function"==typeof r.get&&"function"==typeof r.accumulate&&void 0!==r.cache)return So(o)}return{}}function Mr(e,t){const o={};for(const[r,a]of Object.entries(e??{}))Pr.has(r)&&!t.has(r)||(o[r]=a);return o}class jr extends d.ClientBasedService{constructor(){super(),this.webhookResponseRegistry=new Ir,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 r=o.catalogue??o.registry.catalog,a=o.valueAdapter??d.Adapter.current;if(!a)throw new to("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??Lo.current??new ur,i={registry:o.registry,catalogue:r,planner:o.planner??new e.GraphExecutionPlanner,backend:n,valueAdapter:a,eventEmitter:o.eventEmitter??new uo,documentValidator:o.documentValidator??new Sr({catalogue:r,limits:o.documentLimits,credentialAuthorizer:o.credentialAuthorizer}),authValidator:new Ro({enabled:!0===o.authEnabled,...o.authMatch?{match:o.authMatch}:{}}),...o.codeSandboxEvaluator?{codeSandboxEvaluator:o.codeSandboxEvaluator}:{},...o.nodeCredentials?{nodeCredentials:new Oo(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=Mr(n.config,s);if(await n.initialize({...l,valueAdapter:a,...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 to(`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=Dr(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}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={},...r){const{log:a,ctx:n}=(await this.logCtx(r,"execute",!0)).for(this.execute);a.debug(`Executing workflow '${e.id||e.name}'`);const i=this.mergeOptions(o);this.assertNotAborted(i);const d=xo(So(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 go,c=nr(this.valueAdapter);c.seedWorkflowInputs(this.withWorkflowInputDefaults(e,t));const p=new Mo(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:te.VALIDATION_STARTED,status:Y.PLANNING});const u=await this.documentValidator.validate(e,0,n);if(!u.valid||!u.resolved)throw await p.emit({type:te.VALIDATION_FAILED,status:Y.FAILED,payload:{issues:u.issues}}),new yr(`Graph workflow document '${e.id}' failed validation with ${u.issues.length} issue(s)`,u.issues);await p.emit({type:te.VALIDATION_COMPLETED,status:Y.PLANNING,payload:{issues:u.issues.length}}),this.assertNotAborted(i);const g=await this.planner.plan(u.resolved);this.client.authValidator.validate(e,g,d,a),a.debug(`Authorized workflow '${e.id||e.name}' for user ${d.user??"anonymous"}`),this.assertCodeModeSupported(e);const h=new Po(s,g,c,o);return p.bindFrame(h),await p.emit({type:te.WORKFLOW_STARTED,runId:s,parentRunId:i.parentRunId,workflowId:g.workflowId,path:l,status:Y.RUNNING,payload:{inputs:t}}),await p.emit({type:te.WORKFLOW_PLANNED,runId:s,parentRunId:i.parentRunId,workflowId:g.workflowId,path:l,status:Y.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},...r)}finally{this.releaseExecutionBudget(s)}}get backend(){return this.client.backend}get backendCapabilities(){return jo(this.client.backend)}async listWorkflows(...e){const t=this.client.backend;if("supported"!==jo(t).workflows.list||"function"!=typeof t.listWorkflows)throw new to(`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"!==jo(o).workflows.get||"function"!=typeof o.getWorkflow)throw new to(`Graph execution backend '${this.backendName}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:this.backendName,workflowId:e});const r=await o.getWorkflow(e,...t);return this.assertWorkflowReadAccess(r,Gr(t)),r}assertWorkflowReadAccess(e,t,o){this.client.authValidator.validateWorkflowRead(e,t,o)}async listEngineWorkflows(e,...t){const o=Lo.getOrFail(e);if("supported"!==jo(o).workflows.list||"function"!=typeof o.listWorkflows)throw new to(`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 r=Lo.getOrFail(e);if("supported"!==jo(r).workflows.get||"function"!=typeof r.getWorkflow)throw new to(`Graph execution backend '${e}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e,workflowId:t});const a=await r.getWorkflow(t,...o);return this.assertWorkflowReadAccess(a,Gr(o)),a}get backendName(){return this.client.backend.constructor?.name??"GraphExecutionBackend"}assertCodeModeSupported(e){const t=this.client.backend;if(t.local)return;const o=zo(e);if(0!==o.length){if("unsupported"===t.codeMode)throw new to(`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 to("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,te.NODE_PINNED)}async unpinNode(e){const t=this.createPinningService();await t.unpinNode(e),await this.emitPinningEvent(e.nodeId,te.NODE_UNPINNED)}createPinningService(){const e=nr(this.valueAdapter);return new dr(e,new cr,new pr)}async emitPinningEvent(e,t){const o=(new go).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:Bt,maxForeachIterations:Wt,usePinnedValues:!0,writeThroughCache:!1,path:[],metadata:{},...this.defaultOptions,...e}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new co(e.runId??"unknown")}enterExecutionBudget(e,t){const o=t.parentRunId,r=t.path??[],a="subworkflow"===r[r.length-1],n=r.filter(e=>"subworkflow"===e).length,i=o?this.runSubWorkflowDepth.get(o)??Math.max(0,n-(a?1:0)):0,d=o?i+(a?1:0):0,s=t.maxSubWorkflowDepth??10;if(d>s)throw new to(`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(a){if(p+=1,p>c)throw new to(`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 to("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 Fr 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 to("Code sandbox received empty code","GRAPH_CODE_SANDBOX_EMPTY_CODE");const r=((e,t)=>"javascript"===t?e:B.transpileModule(e,{compilerOptions:{target:B.ScriptTarget.ES2022,module:B.ModuleKind.None,strict:!0,noEmitHelpers:!0,importHelpers:!1}}).outputText.replace(/^"use strict";\s*/,""))(o,e.language??"javascript");(e=>{if(e.length>1e5)throw new to("Code exceeds the maximum length of 100000 characters","GRAPH_CODE_SANDBOX_CODE_TOO_LONG",{length:e.length});let t;try{t=H.parse(`async function __validate() {\n${e}\n}`,{ecmaVersion:"latest",sourceType:"script"})}catch{try{t=H.parse(e,{ecmaVersion:"latest",sourceType:"module"})}catch(t){throw new to("Code failed to parse: "+t.message,"GRAPH_CODE_SANDBOX_PARSE_ERROR",{code:e,error:t.message})}}U.full(t,e=>{const t=e;if("ImportDeclaration"===t.type)throw new to("Imports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"import"});if("ExportNamedDeclaration"===t.type||"ExportDefaultDeclaration"===t.type)throw new to("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 to(`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 to("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 to("eval() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"eval"})})})(r);const a=!(e=>/\breturn\b[\s;]/.test(e))(r),n=a?r.replace(/[\s;]+$/,""):r,i={$input:e.input??{},$vars:e.vars??{},$item:e.item,$index:e.index,$node:e.nodes??{},$output:void 0},d=Object.keys(i),l=a?`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(!a)throw new to("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:r,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 to("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:r,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 to)throw e;const t=e.message;if(t.includes("timed out")||t.includes("timeout"))throw new to(`Code execution timed out after ${l} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:l});if(t.includes("memory")||t.includes("heap"))throw new to(`Code exceeded the memory limit of ${this.defaultMemoryMb} MB`,"GRAPH_CODE_SANDBOX_MEMORY_LIMIT",{memoryMb:this.defaultMemoryMb});throw new to("Code execution failed: "+t,"GRAPH_CODE_SANDBOX_RUNTIME_ERROR",{code:r,error:t})}if("string"!=typeof g)throw new to("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,r){const a=e.run(t,{timeout:o,promise:!0});a.catch(()=>{});const n=[a];let i,d;try{return n.push(new Promise((e,t)=>{i=setTimeout(()=>{t(new to(`Code execution timed out after ${o} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:o}))},o+100)})),r&&n.push(new Promise((e,t)=>{const a=()=>{const e="timeout"===r.reason;t(new to(e?`Code execution timed out after ${o} ms`:"Code execution aborted",e?"GRAPH_CODE_SANDBOX_TIMEOUT":"GRAPH_CODE_SANDBOX_ABORTED",{timeoutMs:o,reason:r.reason}))};r.aborted?a():(r.addEventListener("abort",a,{once:!0}),d=()=>r.removeEventListener("abort",a))})),await Promise.race(n)}finally{i&&clearTimeout(i),d?.()}}async injectConsole(e,t){const o=new s.Reference((e,o)=>{let r;try{r=JSON.parse(o)}catch{r=[o]}const a=r.map(e=>"string"==typeof e?e:JSON.stringify(e)).join(" "),n=1===r.length?r[0]:r;switch(e){case"log":case"info":default:t.info(a,n);break;case"warn":t.warn(a,n);break;case"error":t.error(a,n);break;case"debug":case"dir":case"dirxml":case"table":t.debug(a,n);break;case"trace":t.trace(a,n);break;case"group":case"groupCollapsed":t.debug("[group] "+a,n);break;case"groupEnd":t.debug("[groupEnd]",void 0);break;case"time":case"timeEnd":case"timeLog":case"count":case"countReset":t.debug(`[${e}] ${a}`,n);break;case"assert":r[0]||t.error("Assertion failed: "+a,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 qr extends n.InternalError{constructor(e){super(e,qr.name,500)}}class $r extends n.NotFoundError{constructor(e){super(e),this.name=$r.name}}class Hr extends n.NotFoundError{constructor(e){super(e),this.name=Hr.name}}class Ur{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 qr(`Method declaration for kind '${this.kind}' is missing a name`);if(this.declarations.has(e.name))throw new qr(`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 qr(`Method implementation '${e}' for kind '${this.kind}' is not a function`);if(!this.declarations.has(e))throw new qr(`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 qr(`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 Hr(`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 Br(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 Wr(e,t,o){const r=Br(t,e.itemIdPath),a=e.itemLabelPath?Br(t,e.itemLabelPath):void 0;return{id:"string"==typeof r&&r||"number"==typeof r&&Number.isFinite(r)&&r+""||o+"",label:"string"==typeof a?a:void 0}}function Vr(e,t){switch(t){case"input":return e.inputs;case"output":return e.outputs;default:return e.connections}}function Kr(e,t){const o={inputs:[],outputs:[],connections:[]},r={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))},a=(e,t)=>{const o=r[e];return!o.has(t)&&(o.add(t),!0)};for(const r of e.dynamicPorts??[])if("repeatFromParameter"===r.type){const e=t[r.parameter];if(!Array.isArray(e))continue;const n=Vr(o,r.direction);e.forEach((e,t)=>{const{id:o,label:i}=Wr(r,e,t),d=(s={id:o,index:t,label:i??o},r.portIdTemplate.replaceAll("${id}",s.id).replaceAll("${index}",s.index+"").replaceAll("${label}",s.label));var s;if(!a(r.direction,d))return;const l=r.defaultPort?De(r.defaultPort):{id:d,label:i??d,direction:r.direction};l.id=d,l.direction=r.direction,i&&(l.label=i),n.push(l)})}else if("togglePort"===r.type){if(t[r.parameter]!==r.equals)continue;const e=De(r.port);if(!a(e.direction,e.id))continue;Vr(o,e.direction).push(e)}return o}function zr(e,t){const o=Kr(e,t),r={kind:e.kind,display:e.display,inputs:[...e.inputs,...o.inputs],outputs:[...e.outputs,...o.outputs],parameters:e.parameters},a=[...e.connections??[],...o.connections];return a.length&&(r.connections=a),e.dynamicPorts?.length&&(r.dynamicPorts=e.dynamicPorts),e.credentials?.length&&(r.credentials=e.credentials),e.capabilities?.length&&(r.capabilities=e.capabilities),e.policies&&(r.policies=e.policies),e.metadata&&(r.metadata=e.metadata),e.namespaces?.length&&(r.namespaces=e.namespaces),De(r)}class Qr{async resolve(e,t,o,r,a){if(o){const n=await o(r,a);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 qr(`resolveManifest provider for kind '${e}' returned a value that does not conform to GraphResolvedNodeManifest`);if(!Ce(n))throw new qr(`resolveManifest provider for kind '${e}' returned a non-JSON-safe resolved manifest`);const i=De(n);return!i.namespaces?.length&&t.namespaces?.length&&(i.namespaces=t.namespaces.slice()),i}return zr(t,r.parameters??{})}}const Jr=["edge","literal","expression"];function Xr(e){return Jr.includes(e)}function Yr(e,t,o){if("string"!=typeof o||!o)throw new qr(`Manifest for kind '${e}' has a ${t} with an empty port id`);if(Re(o))throw new qr(`Manifest for kind '${e}' has a ${t} with unsafe port id '${o}'`)}function Zr(e){return e}function ea(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 Qr,this.fallbackContext=new d.Context}withContext(e){return e[e.length-1]instanceof d.Context?e:[this.fallbackContext]}register(e,t={},...o){const{log:r}=this.logCtx(this.withContext(o),"register").for(this.register);r.debug(`Registering graph node kind '${e?.manifest?.kind??"unknown"}'`),(e=>{if(!e||"object"!=typeof e)throw new qr("Graph node registration is required");if(!e.manifest||"object"!=typeof e.manifest)throw new qr("Graph node registration is missing a manifest");if(!e.executor||"function"!=typeof e.executor.execute)throw new qr(`Graph node registration for kind '${e.manifest?.kind+""}' is missing an executor`)})(e);const a=e.manifest;if("string"!=typeof a.kind||!a.kind.trim())throw new qr("Graph node manifest kind is required and must be a non-empty string");const n=a.kind;if(this.entries.has(n)&&!t.replace)throw new qr(`Graph node kind '${n}' is already registered; pass { replace: true } to replace it`);try{lt(a)}catch(e){throw new qr(`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,r]of o){const o=new Set;for(const a of r){if(Yr(e,t+" port",a?.id),o.has(a.id))throw new qr(`Manifest for kind '${e}' declares duplicate static ${t} port id '${a.id}'`);if(o.add(a.id),void 0!==a.defaultMode&&!Xr(a.defaultMode))throw new qr(`Manifest for kind '${e}' declares invalid default binding mode '${a.defaultMode+""}' on ${t} port '${a.id}'`)}}})(n,a);const i=((e,t)=>{const o=new Set;for(const r of t.parameters){const t=r?.id;if("string"!=typeof t||!t)throw new qr(`Manifest for kind '${e}' has a parameter with an empty id`);if(Re(t))throw new qr(`Manifest for kind '${e}' has a parameter with unsafe id '${t}'`);if(o.has(t))throw new qr(`Manifest for kind '${e}' declares duplicate parameter id '${t}'`);o.add(t)}return o})(n,a);((e,t,o)=>{for(const r of t.dynamicPorts??[]){if(!r||"string"!=typeof r.parameter||!r.parameter)throw new qr(`Manifest for kind '${e}' has a dynamic-port rule without a parameter reference`);if(!o.has(r.parameter))throw new qr(`Manifest for kind '${e}' has a dynamic-port rule referencing missing parameter '${r.parameter}'`);if("togglePort"===r.type){if(!r.port)throw new qr(`Manifest for kind '${e}' has a togglePort rule without a port`);Yr(e,"togglePort rule port",r.port.id)}if("repeatFromParameter"===r.type&&"string"!=typeof r.portIdTemplate)throw new qr(`Manifest for kind '${e}' has a repeatFromParameter rule without a portIdTemplate`)}})(n,a,i),((e,t)=>{for(const o of t.credentials??[]){if(!nt(o))throw new qr(`Manifest for kind '${e}' has a malformed credential requirement`);if(!o.type)throw new qr(`Manifest for kind '${e}' has a credential requirement with an empty type`)}})(n,a),((e,t)=>{for(const o of t.methods??[])if(!gt(o))throw new qr(`Manifest for kind '${e}' has a malformed method declaration`)})(n,a);const d=new Ur(n,a.methods??[],e.methods??{});return this.entries.set(n,{registration:e,methods:d,placeholderManifest:!1}),this}registerExecutor(e,t,...o){const{log:r}=this.logCtx(this.withContext(o),"registerExecutor").for(this.registerExecutor);if(r.debug(`Registering graph executor for kind '${e}'`),"string"!=typeof e||!e.trim())throw new qr("Graph executor kind is required");if(!t||"function"!=typeof t.execute)throw new qr(`Executor registered for kind '${e}' is missing an execute method`);const a=this.entries.get(e);if(a)return a.registration={...a.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 Ur(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 $r(`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),De(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(),r=e?.categories?.length?new Set(e.categories):void 0,a=e?.kinds?.length?new Set(e.kinds):void 0,n=[];for(const e of o){if(a&&!a.has(e))continue;const o=this.getManifest(e,...t);r&&!r.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,...r){this.logCtx(this.withContext(r),"resolveManifest").for(this.resolveManifest);const a=this.entry(e);return this.resolver.resolve(e,a.registration.manifest,a.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:r}=this.logCtx(o,"register").for(this.register);if(r.debug(`Registering graph executor for kind '${e}'`),!e)throw new to("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 $r)throw new to(`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 ta extends a.Model{constructor(e){super(),a.Model.fromModel(this,e)}execute(e,t){throw new to(`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 oa(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 ta{execute(e,t){throw new lo(e.inputs.value)}},i.__decorate([a.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"}),Ee({handle:"value"}),i.__metadata("design:type",Object)],e.BreakFlowNode.prototype,"value",void 0),e.BreakFlowNode=i.__decorate([ve("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"}}),a.model()],e.BreakFlowNode),e.ErrorBoundaryFlowNode=class extends ta{async execute(e,t){const o=t.node.errorBoundary;if(!o?.try)return{result:e.inputs.value??e.inputs};const r=t.engine;if(!r)throw new to("errorBoundary node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");try{const a=await r.execute(o.try,e.inputs,{parentRunId:t.runId,path:[...t.path,"try"]}),n=Object.values(a.nodeResults).find(e=>e.status===Y.FAILED);if(n)throw new to(n.error?.message??"error boundary try body failed",n.error?.code??"GRAPH_ERROR_BOUNDARY",n.error?.details);return{result:a.outputs.result??a.outputs}}catch(a){let n=a;if(o.catch){const i=await r.execute(o.catch,{...e.inputs,error:oa(a)},{parentRunId:t.runId,path:[...t.path,"catch"]});n=i.outputs.error??i.outputs}return{error:n}}finally{o.finally&&await r.execute(o.finally,e.inputs,{parentRunId:t.runId,path:[...t.path,"finally"]})}}},i.__decorate([a.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"}),Ee({handle:"value"}),i.__metadata("design:type",Object)],e.ErrorBoundaryFlowNode.prototype,"value",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.ErrorBoundaryFlowNode.prototype,"result",void 0),i.__decorate([Se({handle:"error"}),i.__metadata("design:type",Object)],e.ErrorBoundaryFlowNode.prototype,"error",void 0),e.ErrorBoundaryFlowNode=i.__decorate([ve("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}}),a.model()],e.ErrorBoundaryFlowNode),e.HumanApprovalFlowNode=class extends ta{execute(e){const t=e.inputs.value??e.inputs;return!1===this.approved?{rejected:t}:{approved:t}}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"approved",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HumanApprovalFlowNode.prototype,"approved",void 0),i.__decorate([Se({handle:"approved"}),i.__metadata("design:type",Object)],e.HumanApprovalFlowNode.prototype,"approvedOut",void 0),i.__decorate([Se({handle:"rejected"}),i.__metadata("design:type",Object)],e.HumanApprovalFlowNode.prototype,"rejectedOut",void 0),e.HumanApprovalFlowNode=i.__decorate([ve("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}}),a.model()],e.HumanApprovalFlowNode),e.IfFlowNode=class extends ta{execute(e,t){const o=e.inputs,r=o.value??o;if(!this.condition)throw new to("If node has no condition configured","GRAPH_IF_NO_CONDITION",{input:o});if(qo(this.condition))return Ho(this.condition,o,t).then(e=>this.route(e,r));const a=Uo(this.condition,((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(o,r),"if");return this.route(a,r)}route(e,t){if(e)return{then:t};if(!0===this.else)return{else:t};throw new to("If node condition evaluated to false and the else branch is disabled","GRAPH_IF_ELSE_DISABLED",{condition:this.condition})}},i.__decorate([a.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"}),Ee({handle:"value"}),i.__metadata("design:type",Object)],e.IfFlowNode.prototype,"value",void 0),i.__decorate([a.required(),Se({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"}),Ee({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"}),Ee({handle:"else",userControlled:!0}),i.__metadata("design:type",Boolean)],e.IfFlowNode.prototype,"else",void 0),e.IfFlowNode=i.__decorate([ve("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"}}),a.model()],e.IfFlowNode),e.SwitchFlowNode=class extends ta{async execute(e,t){const o=((e,t)=>{const o={cases:t.cases??[],defaultPort:t.defaultPort??"default",hasDefault:!0===t.hasDefault},r=e.node.metadata?.switch;return r&&Array.isArray(r.cases)?{cases:r.cases,defaultPort:r.defaultPort??o.defaultPort,hasDefault:!0===r.hasDefault||o.hasDefault}:o})(t,this),r=o.cases,a=e.inputs,n=a.value??a,i=((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(a,n);for(const e of r)if(await Bo(e.condition,{input:a,state:i,label:"switch case"},t))return{[e.outputPort]:n};if(!0!==o.hasDefault)throw new to("No switch case matched and default port is not enabled","GRAPH_SWITCH_NO_MATCH",{cases:r.map(e=>e.id)});const d=o.defaultPort??"default";return{[d]:n}}static applyMetadata(e){const t=be(this),o=e.defaultPort??"default",r=!0===e.hasDefault,a=t.ports.filter(t=>!e.cases.some(e=>e.outputPort===t.property)),n=a.filter(e=>e.property!==o),i=a.find(e=>e.property===o),d=[...n,...e.cases.map(e=>({property:e.outputPort,name:e.label,direction:$.OUTPUT,label:e.label,required:!1,hidden:!1,path:e.outputPort}))];return r&&i&&d.push(i),{ports:d,size:V(t,{cases:e.cases.length}),dataPatch:{switchMetadata:e}}}},i.__decorate([a.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"}),Ee({handle:"value"}),i.__metadata("design:type",Object)],e.SwitchFlowNode.prototype,"value",void 0),i.__decorate([a.required(),Se({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([ve("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"}}),a.model()],e.SwitchFlowNode);const ra={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},aa=t.LoggedEnvironment.accumulate({graph:{workflows:{limits:{...ra},allowAnonymousAccess:!1},execution:{maxCodeTimeoutMs:Vt}}});function na(e,t){const o="number"==typeof t?t:Number(t),r=Number.isFinite(o)&&o>0?o:Vt,a="number"==typeof e?e:Number(e);return Number.isFinite(a)&&a>0?Math.min(Math.floor(a),r):1e3}const ia=["javascript","typescript"],da="javascript";e.CodeInputSchema=class extends a.Model{constructor(){super(...arguments),this.language=da}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.language.label",type:"select"}),a.option([...ia]),a.type(String),i.__metadata("design:type",String)],e.CodeInputSchema.prototype,"language",void 0),i.__decorate([a.required(),o.uielement("code-editor",{label:"graph.node.utility.code.fields.code.label",placeholder:"graph.node.utility.code.fields.code.placeholder"}),Ee({handle:"code"}),i.__metadata("design:type",String)],e.CodeInputSchema.prototype,"code",void 0),i.__decorate([o.hidden(),Ee({handle:"data"}),i.__metadata("design:type",Object)],e.CodeInputSchema.prototype,"data",void 0),e.CodeInputSchema=i.__decorate([a.model()],e.CodeInputSchema),e.CodeNode=class extends ta{async execute(e,t){const o=e.inputs,r=this.input,a=o.code??e.parameters?.code??r?.code??this.defaultCode,n=r?.language??da;if(!a||"string"!=typeof a||0===a.trim().length)throw new ro("Code node has no code to execute (input.code is empty)",{input:o});const i=t.engine?.codeSandboxEvaluator;if(!i)throw new to("Code node execution requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:a});const d=aa.graph.execution?.maxCodeTimeoutMs,s="number"==typeof d&&Number.isFinite(d)&&d>0?d:Vt,l=na(this.timeoutMs,s),c=t.metadata,p={code:a,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:a.length,timeoutMs:l});const u=await i.evaluate(p);return await t.log("Code node executed",{hasResult:void 0!==u}),{result:u}}},i.__decorate([a.required(),Ee({handle:"input",model:e.CodeInputSchema}),i.__metadata("design:type",e.CodeInputSchema)],e.CodeNode.prototype,"input",void 0),i.__decorate([a.min(1),a.max(Vt),o.uielement("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.timeoutMs.label",type:"number"}),Ee({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"}),Ee({handle:"defaultCode",userControlled:!0}),i.__metadata("design:type",String)],e.CodeNode.prototype,"defaultCode",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.CodeNode.prototype,"result",void 0),e.CodeNode=i.__decorate([ve("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"}}),a.model()],e.CodeNode),e.DelayFlowNode=class extends ta{execute(e){return{value:e.inputs.value??e.inputs}}},i.__decorate([a.required(),Ee({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"}),Ee({handle:"timeoutMs"}),i.__metadata("design:type",Number)],e.DelayFlowNode.prototype,"timeoutMs",void 0),i.__decorate([a.required(),Se({handle:"value"}),i.__metadata("design:type",Object)],e.DelayFlowNode.prototype,"valueOut",void 0),e.DelayFlowNode=i.__decorate([ve("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"}}),a.model()],e.DelayFlowNode),e.LogFlowNode=class extends ta{execute(e,t){const o=e.inputs.value,r=this.level??"info";return t.logger[r](this.message??"Log node",{value:o}),{value:o}}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"level",userControlled:!0}),i.__metadata("design:type",String)],e.LogFlowNode.prototype,"level",void 0),i.__decorate([a.required(),Se({handle:"value"}),i.__metadata("design:type",Object)],e.LogFlowNode.prototype,"valueOut",void 0),e.LogFlowNode=i.__decorate([ve("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"}}),a.model()],e.LogFlowNode),e.MapNode=class extends ta{execute(e){return{result:{mapped:e.inputs.value??e.inputs}}}},i.__decorate([a.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"}),Ee({handle:"value"}),i.__metadata("design:type",Object)],e.MapNode.prototype,"value",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.MapNode.prototype,"result",void 0),e.MapNode=i.__decorate([ve("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:{}}}),a.model()],e.MapNode),e.UtilityLogNode=class extends ta{execute(e,t){const o=e.inputs.value,r=this.level??"info";return t.logger[r](this.message??"Log node",{value:o}),{value:o}}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"level",userControlled:!0,type:"string"}),i.__metadata("design:type",String)],e.UtilityLogNode.prototype,"level",void 0),i.__decorate([a.required(),Se({handle:"value"}),i.__metadata("design:type",Object)],e.UtilityLogNode.prototype,"valueOut",void 0),e.UtilityLogNode=i.__decorate([ve("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"}}),a.model()],e.UtilityLogNode);const sa=new Set(["__proto__","constructor","prototype"]);function la(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ca(e){return null==e?[]:(Array.isArray(e)?e:[e]).filter(e=>null!=e)}function pa(e,t){if(sa.has(t))throw new to(`Graph data path '${e}' contains the reserved segment '${t}'`,"GRAPH_DATA_UNSAFE_PATH",{path:e,segment:t})}function ua(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)pa(e,o);return t})(e):(pa(e,e),[e])}function ga(e,t,o=!0){if(!t)return e;const r=ua(t,o);let a=e;for(const e of r){if(!la(a))return;a=a[e]}return a}function ha(e,t,o,r=!0){const a=ua(t,r);if(0===a.length)return;let n=e;for(let e=0;e<a.length-1;e++){const t=a[e],o=n[t];if(la(o))n=o;else{const e={};n[t]=e,n=e}}n[a[a.length-1]]=o}function ma(e,t,o=!0){const r=ua(t,o);if(0===r.length)return;let a=e;for(let e=0;e<r.length-1;e++){const t=a[r[e]];if(!la(t))return;a=t}delete a[r[r.length-1]]}function fa(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 to(`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 la(e)?e:{};default:if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}}function _a(e,t,o="auto"){const r=null==e,a=null==t;return r&&a?0:r?1:a?-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 ya(e,t){if(!t||"iso"===t)return e.toISOString();const o=(e,t=2)=>(e+"").padStart(t,"0"),r={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=>r[e]??e)}function ba(e,t,o){const r=new Date(e.getTime());switch(o){case"seconds":r.setUTCSeconds(r.getUTCSeconds()+t);break;case"minutes":r.setUTCMinutes(r.getUTCMinutes()+t);break;case"hours":r.setUTCHours(r.getUTCHours()+t);break;case"days":r.setUTCDate(r.getUTCDate()+t);break;case"weeks":r.setUTCDate(r.getUTCDate()+7*t);break;case"months":r.setUTCMonth(r.getUTCMonth()+t);break;case"years":r.setUTCFullYear(r.getUTCFullYear()+t)}return r}function wa(e){if(e instanceof Date){if(Number.isNaN(e.getTime()))throw new to("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 to("Date & Time node requires a valid date value","GRAPH_DATA_INVALID_DATE",{value:e})}function Na(e){return"undefined"!=typeof Buffer&&Buffer.isBuffer(e)||e instanceof Uint8Array||e instanceof ArrayBuffer}function va(e,t){return la(t)?{...e,...t,item:t}:{...e,item:t}}function Aa(e,t,o){const r={...e};for(const[e,a]of Object.entries(t))"keepFirst"===o&&Object.prototype.hasOwnProperty.call(r,e)||(r[e]=a);return r}function Ea(e,t,o){const r={...e};for(const e of t){if(!e||!e.from||!e.to||e.from===e.to)continue;const t=ga(r,e.from,o);void 0!==t&&(ma(r,e.from,o),ha(r,e.to,t,o))}return r}function Sa(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(Na(e))return(Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e)).toString("utf8");if(la(e)){if("string"==typeof e.data)return Sa(e.data,t);if("string"==typeof e.content)return Sa(e.content,t);throw new to("Extract from File node received an object without file content","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT")}throw new to("Extract from File node requires a file payload","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT",{valueType:typeof e})}e.DateTimeNode=class extends ta{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=ba(wa(e),this.amount??0,this.unit??"days");break;case"subtract":t=ba(wa(e),-(this.amount??0),this.unit??"days");break;case"parse":case"format":t=wa(e);break;default:throw new to(`Unsupported Date & Time operation '${this.operation+""}'`,"GRAPH_DATE_TIME_UNSUPPORTED_OPERATION",{operation:this.operation})}return{result:ya(t,this.format),iso:t.toISOString(),timestamp:t.getTime()}}},i.__decorate([Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"unit",userControlled:!0}),i.__metadata("design:type",String)],e.DateTimeNode.prototype,"unit",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.DateTimeNode.prototype,"result",void 0),i.__decorate([Se({handle:"iso"}),i.__metadata("design:type",String)],e.DateTimeNode.prototype,"iso",void 0),i.__decorate([Se({handle:"timestamp"}),i.__metadata("design:type",Number)],e.DateTimeNode.prototype,"timestamp",void 0),e.DateTimeNode=i.__decorate([ve("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"}}),a.model()],e.DateTimeNode),e.DataTableNode=class extends ta{constructor(){super(...arguments),this.operation="insert",this.tableName="default"}async execute(e,t){const o=t.engine?.dataTableStore;if(!o)throw new to("Data table node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");if(!this.tableName)throw new to("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 to("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 to("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 to(`Unsupported data table operation '${this.operation+""}'`,"GRAPH_DATA_TABLE_UNSUPPORTED_OPERATION",{operation:this.operation})}}rowsOf(e){const t=ca(e.inputs.value).filter(la);return t.length>0?t:la(this.row)?[this.row]:[]}async insertRows(e,t,o){const r=this.rowsOf(e),a=[];for(const e of r){const r=this.rowId??this.rowIdOf(e)??u.randomUUID();a.push(await t.insertRow(this.tableName,r,e,o))}return a}async upsertRows(e,t,o){const r=this.rowsOf(e),a=[];for(const e of r){const r=this.rowId??this.rowIdOf(e)??u.randomUUID();a.push(await t.upsertRow(this.tableName,r,e,o))}return a}rowIdOf(e){const t=e[this.rowIdField||"id"];return"string"==typeof t&&t.length>0?t:"number"==typeof t?t+"":void 0}},i.__decorate([Ee({handle:"value"}),i.__metadata("design:type",Object)],e.DataTableNode.prototype,"value",void 0),i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.operation.label",type:"select"}),Ee({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.DataTableNode.prototype,"operation",void 0),i.__decorate([a.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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],e.DataTableNode.prototype,"limit",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.DataTableNode.prototype,"result",void 0),i.__decorate([Se({handle:"count"}),i.__metadata("design:type",Number)],e.DataTableNode.prototype,"count",void 0),e.DataTableNode=i.__decorate([ve("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"}}),a.model()],e.DataTableNode),e.FilterNode=class extends ta{constructor(){super(...arguments),this.negate=!1}async execute(e,t){if(!this.condition)throw new to("Filter node has no condition configured","GRAPH_FILTER_NO_CONDITION");const o=ca(e.inputs.value),r=[];for(let a=0;a<o.length;a++){const n=o[a];await Bo(this.condition,{input:{...e.inputs,item:n,index:a},state:va(e.inputs,n),label:"filter"},t)!==(!0===this.negate)&&r.push(n)}return{result:r}}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"negate",userControlled:!0}),i.__metadata("design:type",Boolean)],e.FilterNode.prototype,"negate",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Array)],e.FilterNode.prototype,"result",void 0),e.FilterNode=i.__decorate([ve("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"}}),a.model()],e.FilterNode),e.LimitNode=class extends ta{constructor(){super(...arguments),this.maxItems=1,this.keep="firstItems"}execute(e){const t=ca(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([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"keep",userControlled:!0}),i.__metadata("design:type",String)],e.LimitNode.prototype,"keep",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Array)],e.LimitNode.prototype,"result",void 0),e.LimitNode=i.__decorate([ve("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"}}),a.model()],e.LimitNode),e.MergeNode=class extends ta{constructor(){super(...arguments),this.mode="append",this.combineBy="position",this.joinMode="inner",this.clashHandling="keepFirst"}execute(e){const t=ca(e.inputs.input),o=ca(e.inputs.input2);if("append"===this.mode)return{result:[...t,...o]};if("fields"===this.combineBy)return{result:this.mergeByFields(t,o)};const r=Math.max(t.length,o.length),a=[];for(let e=0;r>e;e++){if(e>=t.length){if("inner"===this.joinMode||"left"===this.joinMode)continue;a.push(o[e]);continue}if(e>=o.length){if("inner"===this.joinMode||"right"===this.joinMode)continue;a.push(t[e]);continue}const r=t[e],n=o[e];la(r)&&la(n)?a.push(Aa(r,n,this.clashHandling)):a.push([r,n])}return{result:a}}mergeByFields(e,t){const o=this.joinField;if(!o)throw new to("Merge node in 'fields' mode requires a join field","GRAPH_MERGE_JOIN_FIELD_REQUIRED");const r=new Map;for(const e of t){if(!la(e))continue;const t=ga(e,o);if(null==t)continue;const a=r.get(t);r.set(t,a?Aa(a,e,this.clashHandling):e)}const a=[],n=new Set;for(const t of e){if(!la(t)){"inner"!==this.joinMode&&"right"!==this.joinMode&&a.push(t);continue}const e=ga(t,o),i=r.get(e);i?(n.add(e),a.push(Aa(t,i,this.clashHandling))):"inner"!==this.joinMode&&"right"!==this.joinMode&&a.push(t)}if("right"===this.joinMode||"outer"===this.joinMode)for(const[e,t]of r)n.has(e)||a.push(t);return a}},i.__decorate([a.required(),Ee({handle:"input"}),i.__metadata("design:type",Object)],e.MergeNode.prototype,"input",void 0),i.__decorate([Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"clashHandling",userControlled:!0}),i.__metadata("design:type",String)],e.MergeNode.prototype,"clashHandling",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Array)],e.MergeNode.prototype,"result",void 0),e.MergeNode=i.__decorate([ve("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"}}),a.model()],e.MergeNode),e.RenameKeysNode=class extends ta{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,r=!1!==this.dotNotation;return Array.isArray(o)?{result:o.filter(e=>null!=e).map(e=>la(e)?Ea(e,t,r):e)}:la(o)?{result:Ea(o,t,r)}:{result:ca(o)}}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"dotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.RenameKeysNode.prototype,"dotNotation",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.RenameKeysNode.prototype,"result",void 0),e.RenameKeysNode=i.__decorate([ve("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"}}),a.model()],e.RenameKeysNode),e.SetNode=class extends ta{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?la(e)?{...e}:void 0===e?{}:{value:e}:{};for(const e of this.assignments??[]){if(!e||"string"!=typeof e.name)continue;const o=fa(e.value,e.type??"json");null!=o&&ha(t,e.name,o,!1!==this.dotNotation)}return t}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"dotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SetNode.prototype,"dotNotation",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.SetNode.prototype,"result",void 0),e.SetNode=i.__decorate([ve("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"}}),a.model()],e.SetNode),e.SortNode=class extends ta{constructor(){super(...arguments),this.sortFields=[],this.valueType="auto",this.dotNotation=!0}execute(e){const t=[...ca(e.inputs.value)],o=(this.sortFields??[]).filter(e=>e&&"string"==typeof e.field);return 0===o.length||t.sort((e,t)=>{for(const r of o){const o=_a(ga(e,r.field,!1!==this.dotNotation),ga(t,r.field,!1!==this.dotNotation),this.valueType??"auto");if(0!==o)return"desc"===r.direction?-o:o}return 0}),{result:t}}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"dotNotation",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SortNode.prototype,"dotNotation",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Array)],e.SortNode.prototype,"result",void 0),e.SortNode=i.__decorate([ve("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"}}),a.model()],e.SortNode),e.SplitOutNode=class extends ta{constructor(){super(...arguments),this.field="",this.include="noOtherFields"}execute(e){if(!this.field)throw new to("Split Out node requires a field name","GRAPH_SPLIT_OUT_FIELD_REQUIRED");const t=ca(e.inputs.value),o=[];for(const e of t){const t=ga(e,this.field,!0);if(null==t)continue;const r=Array.isArray(t)?t:[t];for(const t of r){if(null==t)continue;if("allOtherFields"!==this.include){o.push(t);continue}const r=this.destinationField||this.field,a=la(e)?{...e}:{};ma(a,this.field,!0),ha(a,r,t,!0),o.push(a)}}return{result:o}}},i.__decorate([a.required(),Ee({handle:"value"}),i.__metadata("design:type",Object)],e.SplitOutNode.prototype,"value",void 0),i.__decorate([a.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"}),Ee({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"}),Ee({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"}),Ee({handle:"destinationField",userControlled:!0}),i.__metadata("design:type",String)],e.SplitOutNode.prototype,"destinationField",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Array)],e.SplitOutNode.prototype,"result",void 0),e.SplitOutNode=i.__decorate([ve("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"}}),a.model()],e.SplitOutNode),e.ExtractFromFileNode=class extends ta{constructor(){super(...arguments),this.format="json",this.encoding="utf8",this.delimiter=",",this.headerRow=!0}execute(e){const t=Sa(e.inputs.value,this.encoding??"utf8");switch(this.format){case"json":try{return{result:JSON.parse(t)}}catch(e){throw new to("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 r=((e,t)=>{const o=[];let r=[],a="",n=!1;for(let i=0;i<e.length;i++){const d=e[i];n?'"'===d?'"'===e[i+1]?(a+='"',i++):n=!1:a+=d:'"'!==d?d!==t?"\n"!==d?"\r"!==d&&(a+=d):(r.push(a),o.push(r),r=[],a=""):(r.push(a),a=""):n=!0}return(a.length>0||r.length>0)&&(r.push(a),o.push(r)),o.filter(e=>e.length>1||(e[0]??"").trim().length>0)})(e,t);if(0===r.length)return[];const a=o?r[0]:r[0].map((e,t)=>"column"+t);return(o?r.slice(1):r).map(e=>{const t={};for(let o=0;o<a.length;o++)t[a[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 to(`Unsupported file extraction format '${this.format+""}'`,"GRAPH_EXTRACT_FROM_FILE_UNSUPPORTED_FORMAT",{format:this.format})}}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"headerRow",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ExtractFromFileNode.prototype,"headerRow",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.ExtractFromFileNode.prototype,"result",void 0),i.__decorate([Se({handle:"rows"}),i.__metadata("design:type",Number)],e.ExtractFromFileNode.prototype,"rows",void 0),e.ExtractFromFileNode=i.__decorate([ve("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"}}),a.model()],e.ExtractFromFileNode);const Ia=new Set(["http:","https:"]);function xa(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(la(e)){const o=e.data??e.content;if(void 0!==o)return xa(o,t)}if(Na(e))return Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e);throw new to("Read PDF node requires a PDF file payload","GRAPH_READ_PDF_INVALID_INPUT",{valueType:typeof e})}e.HttpRequestNode=class extends ta{constructor(){super(...arguments),this.url="",this.method="GET",this.responseFormat="json",this.failOnError=!1}async execute(e,t){if(!this.url)throw new to("HTTP Request node requires a URL","GRAPH_HTTP_URL_REQUIRED");let o;try{o=new URL(this.url)}catch{throw new to(`HTTP Request node URL '${this.url}' is invalid`,"GRAPH_HTTP_INVALID_URL",{url:this.url})}if(!Ia.has(o.protocol))throw new to(`HTTP Request node protocol '${o.protocol}' is not allowed`,"GRAPH_HTTP_PROTOCOL_NOT_ALLOWED",{protocol:o.protocol});this.appendQuery(o);const r=this.method??"GET",a={};for(const[e,t]of Object.entries(this.headers??{}))"string"==typeof t&&e.trim().length>0&&(a[e.trim()]=t);const n=this.resolveBody(e,r);void 0!==n&&void 0===a["content-type"]&&(a["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:r,headers:a,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 to("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 to)throw e;if(d.signal.aborted)throw new to(`HTTP Request node timed out after ${i}ms`,"GRAPH_HTTP_REQUEST_TIMEOUT",{url:o.toString(),timeoutMs:i});throw new to("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,Kt):3e4}async fetchFollowingRedirects(e,t){let o=e,r=t;for(let e=0;5>=e;e++){const t=await fetch(o,{...r,redirect:"manual"});if(!this.isRedirectStatus(t.status))return{response:t,url:o};const a=t.headers.get("location");if(!a)return{response:t,url:o};if(5===e)throw await this.discardResponseBody(t),new to("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(a,o)}catch{throw await this.discardResponseBody(t),new to(`HTTP Request node redirect target '${a}' is invalid`,"GRAPH_HTTP_INVALID_URL",{location:a})}if(!Ia.has(n.protocol))throw await this.discardResponseBody(t),new to(`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){r={...r,method:"GET",body:void 0};const e={...r.headers};for(const t of Object.keys(e))"content-type"===t.toLowerCase()&&delete e[t];r={...r,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 r=0;try{for(;;){const{done:e,value:a}=await t.read();if(e)break;if(a){if(r+=a.byteLength,r>zt){try{await t.cancel()}catch{}throw new to("HTTP Request node response body exceeds the 10485760-byte limit","GRAPH_HTTP_RESPONSE_TOO_LARGE",{limitBytes:zt})}o.push(a)}}}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 r of o)null!=r&&e.searchParams.append(t,r+"");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([Ee({handle:"value"}),i.__metadata("design:type",Object)],e.HttpRequestNode.prototype,"value",void 0),i.__decorate([a.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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"failOnError",userControlled:!0}),i.__metadata("design:type",Boolean)],e.HttpRequestNode.prototype,"failOnError",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.HttpRequestNode.prototype,"result",void 0),i.__decorate([Se({handle:"status"}),i.__metadata("design:type",Number)],e.HttpRequestNode.prototype,"status",void 0),i.__decorate([Se({handle:"headers"}),i.__metadata("design:type",Object)],e.HttpRequestNode.prototype,"headersOut",void 0),e.HttpRequestNode=i.__decorate([ve("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"}}),a.model()],e.HttpRequestNode),e.ReadPDFNode=class extends ta{constructor(){super(...arguments),this.encoding="utf8"}async execute(e){const t=xa(e.inputs.value,this.encoding??"utf8");let o;try{o=await(import("pdf-parse"))}catch(e){throw new to("Read PDF node requires the 'pdf-parse' dependency: "+(e instanceof Error?e.message:e+""),"GRAPH_READ_PDF_DEPENDENCY_MISSING")}const r=o.PDFParse;if(!r)throw new to("Read PDF node could not resolve the PDF parser","GRAPH_READ_PDF_DEPENDENCY_MISSING");const a=new r({data:t,...this.password?{password:this.password}:{}});try{const e=await a.getText();return{result:e.text??"",pages:(e.pages??[]).map((e,t)=>({pageNumber:t+1,text:e.text??""}))}}catch(e){throw new to("Read PDF node failed to extract text: "+(e instanceof Error?e.message:e+""),"GRAPH_READ_PDF_FAILED")}finally{await(a.destroy?.())}}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"password",userControlled:!0}),i.__metadata("design:type",String)],e.ReadPDFNode.prototype,"password",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",String)],e.ReadPDFNode.prototype,"result",void 0),i.__decorate([Se({handle:"pages"}),i.__metadata("design:type",Array)],e.ReadPDFNode.prototype,"pages",void 0),e.ReadPDFNode=i.__decorate([ve("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"}}),a.model()],e.ReadPDFNode);const Ra=new Set(["workdocs"]);function Oa(){return["/etc","/proc","/root",g.resolve(h.homedir(),".ssh")]}function ka(e,t){const o=g.relative(e,t);return""===o||!o.startsWith("..")&&!g.isAbsolute(o)}function Ta(e,t,o){if(!ka(e,t))throw new to(`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 Oa())if(ka(e,t))throw new to(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o});const r=g.relative(e,t).split(g.sep).filter(Boolean);for(const e of r)if(Ra.has(e.toLowerCase()))throw new to(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o,segment:e})}async function Ca(e){let t=e;for(;;)try{return await f.realpath(t)}catch{const e=g.dirname(t);if(e===t)return;t=e}}function Da(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:void 0}function Pa(e){return"string"==typeof e&&e.trim().length>0?e.trim():void 0}function Ga(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 Ma(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 ja(e){return Array.isArray(e)?e:void 0}function La(e,t){try{const t=Da(e);if(t)return t;const o=Da(JSON.parse(e));if(!o)throw Error("not an object");return o}catch{throw new to(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}function Fa(e,t){if(e){if("string"!=typeof e)return Array.isArray(e)?void 0:e;if(e.trim().startsWith("{"))try{const t=Da(JSON.parse(e));if(!t)throw Error("not an object");return t}catch{throw new to(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}}function qa(e,t,o){const r=Fa(e,o);return r?Pa(r[t]):"token"===t&&"string"==typeof e?Pa(e):void 0}function $a(e,t){return qa(e,"token",t)}function Ha(e,t,o){if("string"==typeof e)return Pa(e);const r=Fa(e,o);if(r)for(const e of Array.isArray(t)?t:[t]){const t=Pa(r[e]);if(t)return t}}e.ReadWriteFileNode=class extends ta{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 to("Read/Write Files from Disk node requires a path","GRAPH_READ_WRITE_FILE_PATH_REQUIRED");if(this.path.includes("\0"))throw new to("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 Oa())if(ka(o,t))throw new to(`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(/^[/\\]+/,""),r=g.resolve(t,o);return Ta(t,r,e),{base:t,candidate:r}})(this.path);if("read"===this.operation){let e;try{e=await f.realpath(o)}catch{throw new to(`Read/Write Files from Disk node path '${this.path}' does not exist`,"GRAPH_READ_WRITE_FILE_INVALID_PATH",{path:this.path})}Ta(t,e,this.path);const r=await f.readFile(e);return{result:"base64"===this.encoding?r.toString("base64"):r.toString("utf8"),bytes:r.byteLength}}const r=void 0!==this.content?this.content:e.inputs.value;if(null==r)throw new to("Read/Write Files from Disk node requires content to write","GRAPH_READ_WRITE_FILE_CONTENT_REQUIRED");const a="string"==typeof r?"base64"===this.encoding?Buffer.from(r,"base64"):Buffer.from(r,"utf8"):Buffer.isBuffer(r)?r:r instanceof Uint8Array?Buffer.from(r):Buffer.from(r+"","utf8"),n=await Ca(o);n&&Ta(t,n,this.path),this.createDirectories&&await f.mkdir(g.dirname(o),{recursive:!0}),Ta(t,await f.realpath(g.dirname(o)),this.path);const i=await Ca(o);return i&&Ta(t,i,this.path),this.append?await f.appendFile(o,a):await f.writeFile(o,a),{result:{path:this.path,bytes:a.byteLength},bytes:a.byteLength}}},i.__decorate([Ee({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"}),Ee({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.ReadWriteFileNode.prototype,"operation",void 0),i.__decorate([a.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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"createDirectories",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ReadWriteFileNode.prototype,"createDirectories",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.ReadWriteFileNode.prototype,"result",void 0),i.__decorate([Se({handle:"bytes"}),i.__metadata("design:type",Number)],e.ReadWriteFileNode.prototype,"bytes",void 0),e.ReadWriteFileNode=i.__decorate([ve("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"}}),a.model()],e.ReadWriteFileNode),e.RespondToWebhookNode=class extends ta{constructor(){super(...arguments),this.respondWith="firstIncomingItem",this.responseCode=200}async execute(e,t){const o=this.resolveBody(e),r={};for(const[e,t]of Object.entries(this.responseHeaders??{}))"string"==typeof t&&e.trim().length>0&&(r[e.trim()]=t);null!=o&&"string"!=typeof o&&void 0===r["content-type"]&&(r["content-type"]="application/json");const a={statusCode:this.responseCode??200,headers:r,body:o,runId:t.runId,respondedAt:(new Date).toISOString()},n=t.engine?.webhookResponses.deliver(t.runId,a)??!1;return await t.progress({...a,delivered:n}),{response:a,delivered:n}}resolveBody(e){const t=e.inputs.value;switch(this.respondWith){case"noData":return null;case"allIncomingItems":return ca(t);case"firstIncomingItem":return ca(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([Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"responseBody",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.RespondToWebhookNode.prototype,"responseBody",void 0),i.__decorate([a.required(),Se({handle:"response"}),i.__metadata("design:type",Object)],e.RespondToWebhookNode.prototype,"response",void 0),i.__decorate([Se({handle:"delivered"}),i.__metadata("design:type",Boolean)],e.RespondToWebhookNode.prototype,"delivered",void 0),e.RespondToWebhookNode=i.__decorate([ve("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"}}),a.model()],e.RespondToWebhookNode);const Ua={postgres:5432,mysql:3306,mssql:1433};class Ba extends ta{constructor(){super(...arguments),this.ssl=!1,this.acceptSelfSigned=!1}dataSourceOptions(e,t,o,r,a){const n=Ga(this.ssl,!1),i=Ga(this.acceptSelfSigned,!1),d={host:e,port:t,database:o,username:r,password:a,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,r=this.sql?.trim();if(!r)throw new to(o+" node requires a SQL statement","GRAPH_DATABASE_SQL_REQUIRED");const a=this.host?.trim(),n=this.database?.trim(),i=this.username?.trim();if(!a||!n||!i)throw new to(o+" node requires host, database, and username","GRAPH_DATABASE_CONNECTION_REQUIRED");const s=Ha(await ko(t,e.credentials,this.credentialType,!1,o),["password","secret","token"],o),l=ja(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(a,Ma(this.port)??Ua[this.driver],n,i,s),c),u=new d.Context;try{await p.initialize(u);const e=await p.raw({query:r,values:l},!0,u),{rows:t,rowCount:o}=(e=>{if(Array.isArray(e))return{rows:e,rowCount:e.length};const t=Da(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:Ma(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:Ma(t.count)??e.length}}return{rows:[],rowCount:Ma(t.affectedRows)??0}})(e);return{result:t,rows:t,rowCount:o}}catch(e){if(e instanceof to)throw e;throw new to(`${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([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.host.label",type:"string"}),Ee({handle:"host",userControlled:!0}),i.__metadata("design:type",String)],Ba.prototype,"host",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.port.label",type:"number"}),Ee({handle:"port",userControlled:!0}),i.__metadata("design:type",Number)],Ba.prototype,"port",void 0),i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.database.label",type:"string"}),Ee({handle:"database",userControlled:!0}),i.__metadata("design:type",String)],Ba.prototype,"database",void 0),i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.username.label",type:"string"}),Ee({handle:"username",userControlled:!0}),i.__metadata("design:type",String)],Ba.prototype,"username",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.ssl.label",type:"boolean"}),Ee({handle:"ssl",userControlled:!0}),i.__metadata("design:type",Boolean)],Ba.prototype,"ssl",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.acceptSelfSigned.label",type:"boolean"}),Ee({handle:"acceptSelfSigned",userControlled:!0}),i.__metadata("design:type",Boolean)],Ba.prototype,"acceptSelfSigned",void 0),i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sql.label",type:"textarea"}),Ee({handle:"sql",userControlled:!0}),i.__metadata("design:type",String)],Ba.prototype,"sql",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.parameters.label",type:"array"}),Ee({handle:"parameters",userControlled:!0}),i.__metadata("design:type",Array)],Ba.prototype,"parameters",void 0),i.__decorate([Ee({handle:"value"}),i.__metadata("design:type",Object)],Ba.prototype,"value",void 0),i.__decorate([a.required(),Se({handle:"result",type:"array"}),i.__metadata("design:type",Array)],Ba.prototype,"result",void 0),i.__decorate([Se({handle:"rows",type:"array"}),i.__metadata("design:type",Array)],Ba.prototype,"rows",void 0),i.__decorate([Se({handle:"rowCount",type:"number"}),i.__metadata("design:type",Number)],Ba.prototype,"rowCount",void 0),e.PostgresNode=class extends Ba{constructor(){super(...arguments),this.driver="postgres",this.credentialType="postgres"}},e.PostgresNode=i.__decorate([ve("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"}}),a.model()],e.PostgresNode),e.MySqlNode=class extends Ba{constructor(){super(...arguments),this.driver="mysql",this.credentialType="mysql"}},e.MySqlNode=i.__decorate([ve("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"}}),a.model()],e.MySqlNode),e.MicrosoftSqlNode=class extends Ba{constructor(){super(...arguments),this.driver="mssql",this.credentialType="mssql"}},e.MicrosoftSqlNode=i.__decorate([ve("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"}}),a.model()],e.MicrosoftSqlNode);const Wa=["get","set","delete","incr","keys","llen","lpop","rpop","lpush","rpush","publish","info"];function Va(e){if(null===e)return null;try{return JSON.parse(e)}catch{return e}}function Ka(e){return"string"==typeof e?e:null==e?"":JSON.stringify(e)}e.RedisNode=class extends ta{constructor(){super(...arguments),this.operation="get",this.tls=!1}async execute(e,t){const o=Wa.includes(this.operation)?this.operation:"get",r=Ha(await ko(t,e.credentials,"redis",!1,"Redis"),["password","secret","token"],"Redis"),a=Pa(this.host)??"localhost",n=Ma(this.port)??6379,i=Pa(this.key),s=Pa(this.prefix),l=e=>s?`${s}:${e}`:e,c=Pa(this.pattern),p=Pa(this.channel),u=this.value??e.inputs.value;if(!("info"===o||i||"keys"===o&&c||"publish"===o&&p))throw new to(`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:a,port:n,username:Pa(this.username),password:r,database:Ma(this.database),tls:!!this.tls||void 0},g);try{await h.initialize();const e=h.client;switch(o){case"get":return{result:Va(await e.get(l(i)))};case"set":{const t=Ma(this.ttlSeconds);return{result:await e.set(l(i),Ka(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:Va(await e.lPop(l(i)))};case"rpop":return{result:Va(await e.rPop(l(i)))};case"lpush":{const t=await e.lPush(l(i),Ka(u));return{result:t,count:t}}case"rpush":{const t=await e.rPush(l(i),Ka(u));return{result:t,count:t}}case"publish":{const t=await e.publish(p??i,Ka(u));return{result:t,count:t}}default:return{result:await e.info(Pa(this.section))}}}catch(e){if(e instanceof to)throw e;throw new to(`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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"section",userControlled:!0}),i.__metadata("design:type",String)],e.RedisNode.prototype,"section",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.RedisNode.prototype,"result",void 0),i.__decorate([Se({handle:"value"}),i.__metadata("design:type",Object)],e.RedisNode.prototype,"valueOutput",void 0),i.__decorate([Se({handle:"count",type:"number"}),i.__metadata("design:type",Number)],e.RedisNode.prototype,"count",void 0),e.RedisNode=i.__decorate([ve("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"}}),a.model()],e.RedisNode);const za=["put","get","delete","list","stat","has","url","copy"];class Qa extends ta{constructor(){super(...arguments),this.operation="get",this.encoding="utf8",this.urlOperation="get"}async execute(e,t){const o=this.constructor.name,r=za.includes(this.operation)?this.operation:"get",a=Pa(this.key);if("list"!==r&&!a)throw new to(`${o} node operation '${r}' requires a key`,"GRAPH_BLOB_KEY_REQUIRED",{operation:r});const n=await ko(t,e.credentials,this.credentialType,!1,o),i=await this.createService(n);try{switch(r){case"put":{const t=this.content??e.inputs.value,r=Da(this.metadataValues),n=await i.put(a,((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 to(o+" node cannot encode the blob payload","GRAPH_BLOB_INVALID_PAYLOAD")}})(t,this.encoding,o),{contentType:Pa(this.contentType),metadata:r?Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t+""])):void 0});return{result:n}}case"get":{const e=await i.get(a),t=await b.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(a),{result:{key:a,deleted:!0}};case"list":{const e=Ma(this.limit);return{result:await i.list({prefix:Pa(this.prefix),limit:void 0===e?void 0:Math.max(0,Math.floor(e)),cursor:Pa(this.cursor)})}}case"stat":return{result:await i.stat(a)};case"has":return{result:await i.has(a)};case"url":{const e=Ma(this.expiresInSeconds);return{result:await i.url(a,{operation:this.urlOperation,expiresInSeconds:void 0===e?void 0:Math.max(0,Math.floor(e)),contentType:Pa(this.contentType)})}}case"copy":{const e=Pa(this.targetKey);if(!e)throw new to(o+" node copy operation requires a targetKey","GRAPH_BLOB_TARGET_KEY_REQUIRED");return{result:await i.copy(a,e,{contentType:Pa(this.contentType)})}}default:throw new to(`${o} node operation '${r}' is not supported`,"GRAPH_BLOB_OPERATION_NOT_SUPPORTED",{operation:r})}}catch(e){if(e instanceof to)throw e;throw new to(`${o} node operation '${r}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_BLOB_OPERATION_FAILED",{operation:r})}finally{await i.shutdown().catch(()=>{})}}}i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.operation.label",type:"select"}),Ee({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],Qa.prototype,"operation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.key.label",type:"string"}),Ee({handle:"key",userControlled:!0}),i.__metadata("design:type",String)],Qa.prototype,"key",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.targetKey.label",type:"string"}),Ee({handle:"targetKey",userControlled:!0}),i.__metadata("design:type",String)],Qa.prototype,"targetKey",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.content.label",type:"textarea"}),Ee({handle:"content",userControlled:!0}),i.__metadata("design:type",Object)],Qa.prototype,"content",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.contentType.label",type:"string"}),Ee({handle:"contentType",userControlled:!0}),i.__metadata("design:type",String)],Qa.prototype,"contentType",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.encoding.label",type:"select"}),Ee({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],Qa.prototype,"encoding",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.metadataValues.label",type:"object"}),Ee({handle:"metadataValues",userControlled:!0}),i.__metadata("design:type",Object)],Qa.prototype,"metadataValues",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.prefix.label",type:"string"}),Ee({handle:"prefix",userControlled:!0}),i.__metadata("design:type",String)],Qa.prototype,"prefix",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.cursor.label",type:"string"}),Ee({handle:"cursor",userControlled:!0}),i.__metadata("design:type",String)],Qa.prototype,"cursor",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.limit.label",type:"number"}),Ee({handle:"limit",userControlled:!0}),i.__metadata("design:type",Number)],Qa.prototype,"limit",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.urlOperation.label",type:"select"}),Ee({handle:"urlOperation",userControlled:!0}),i.__metadata("design:type",String)],Qa.prototype,"urlOperation",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.expiresInSeconds.label",type:"number"}),Ee({handle:"expiresInSeconds",userControlled:!0}),i.__metadata("design:type",Number)],Qa.prototype,"expiresInSeconds",void 0),i.__decorate([Ee({handle:"value"}),i.__metadata("design:type",Object)],Qa.prototype,"value",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],Qa.prototype,"result",void 0),i.__decorate([Se({handle:"value"}),i.__metadata("design:type",String)],Qa.prototype,"valueOutput",void 0),i.__decorate([Se({handle:"contentLength",type:"number"}),i.__metadata("design:type",Number)],Qa.prototype,"contentLength",void 0),i.__decorate([Se({handle:"contentType"}),i.__metadata("design:type",String)],Qa.prototype,"contentTypeOutput",void 0);class Ja extends Qa{constructor(){super(...arguments),this.credentialType="s3",this.forcePathStyle=!1}async createService(e){const t=Pa(this.bucket);if(!t)throw new to("S3 node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o=new w.S3BlobStoreService;return await N.bootWithoutEnvironment(o,((e,t)=>{const o=e?La(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:Pa(o.sessionToken)}:void 0}})(e,{bucket:t,sourceId:Pa(this.sourceId)??"graph",region:Pa(this.region),endpoint:Pa(this.endpoint),prefix:Pa(this.prefix),forcePathStyle:this.forcePathStyle})),o}}function Xa(e){if(!e)return;if("string"!=typeof e)return Pa(e.connectionString);const t=e.trim();return t.startsWith("{")?Pa(La(t,"Azure Storage").connectionString):t}i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),Ee({handle:"bucket",userControlled:!0}),i.__metadata("design:type",String)],Ja.prototype,"bucket",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),Ee({handle:"sourceId",userControlled:!0}),i.__metadata("design:type",String)],Ja.prototype,"sourceId",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.region.label",type:"string"}),Ee({handle:"region",userControlled:!0}),i.__metadata("design:type",String)],Ja.prototype,"region",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.endpoint.label",type:"string"}),Ee({handle:"endpoint",userControlled:!0}),i.__metadata("design:type",String)],Ja.prototype,"endpoint",void 0),i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.forcePathStyle.label",type:"boolean"}),Ee({handle:"forcePathStyle",userControlled:!0}),i.__metadata("design:type",Boolean)],Ja.prototype,"forcePathStyle",void 0),e.S3StorageNode=class extends Ja{},e.S3StorageNode=i.__decorate([ve("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"}}),a.model()],e.S3StorageNode),e.AwsS3StorageNode=class extends Ja{},e.AwsS3StorageNode=i.__decorate([ve("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"}}),a.model()],e.AwsS3StorageNode),e.GoogleCloudStorageNode=class extends Qa{constructor(){super(...arguments),this.credentialType="gcs"}async createService(e){const t=Pa(this.bucket);if(!t)throw new to("Google Cloud Storage node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o={provider:"gcs",bucket:t,sourceId:Pa(this.sourceId)??"graph",projectId:Pa(this.projectId),apiEndpoint:Pa(this.apiEndpoint),prefix:Pa(this.prefix),credentials:e?La(e,"Google Cloud Storage"):void 0},r=new v.GcsBlobStoreService;return await N.bootWithoutEnvironment(r,o),r}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"apiEndpoint",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleCloudStorageNode.prototype,"apiEndpoint",void 0),e.GoogleCloudStorageNode=i.__decorate([ve("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"}}),a.model()],e.GoogleCloudStorageNode),e.AzureStorageNode=class extends Qa{constructor(){super(...arguments),this.credentialType="azure-blob"}async createService(e){const t=Pa(this.container);if(!t)throw new to("Azure Storage node requires a container","GRAPH_BLOB_CONTAINER_REQUIRED");const o={provider:"azure-blob",container:t,sourceId:Pa(this.sourceId)??"graph",accountName:Pa(this.accountName),endpoint:Pa(this.endpoint),prefix:Pa(this.prefix),connectionString:Xa(e)},r=new A.AzureBlobStoreService;return await N.bootWithoutEnvironment(r,o),r}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.container.label",type:"string"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"endpoint",userControlled:!0}),i.__metadata("design:type",String)],e.AzureStorageNode.prototype,"endpoint",void 0),e.AzureStorageNode=i.__decorate([ve("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"}}),a.model()],e.AzureStorageNode);const Ya=["postMessage","listConversations","getConversation","getUser"];e.SlackNode=class extends ta{constructor(){super(...arguments),this.operation="postMessage"}async execute(e,t){const o=Ya.includes(this.operation)?this.operation:"postMessage";if(!this.operation)throw new to("Slack node requires an operation","GRAPH_SLACK_OPERATION_REQUIRED");const r=$a(await ko(t,e.credentials,"slack",!1,"Slack"),"Slack"),a=new E.SlackService;try{switch(await N.bootWithoutEnvironment(a,{token:r,baseUrl:this.baseUrl}),o){case"postMessage":{const t=this.channel,o=this.text??(e.inputs.value??"")+"";if(!t||!o)throw new to("Slack postMessage requires a channel and text","GRAPH_SLACK_MESSAGE_REQUIRED");const r=await a.postMessage({channel:t,text:o,blocks:ja(this.blocks),threadTs:this.threadTs,replyBroadcast:this.replyBroadcast,unfurlLinks:this.unfurlLinks,unfurlMedia:this.unfurlMedia});return{result:r,channel:r.channel,ts:r.ts}}case"listConversations":return{result:await a.listConversations({limit:Ma(this.limit),cursor:this.cursor,types:this.types,excludeArchived:this.excludeArchived})};case"getConversation":{if(!this.channel)throw new to("Slack getConversation requires a channel","GRAPH_SLACK_CHANNEL_REQUIRED");const e=await a.getConversation(this.channel);return{result:e,channel:e.id}}default:if(!this.userId)throw new to("Slack getUser requires a user ID","GRAPH_SLACK_USER_REQUIRED");return{result:await a.getUser(this.userId)}}}catch(e){if(e instanceof to)throw e;throw new to(`Slack node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SLACK_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.operation.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"unfurlMedia",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SlackNode.prototype,"unfurlMedia",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.SlackNode.prototype,"result",void 0),i.__decorate([Se({handle:"channel",type:"string"}),i.__metadata("design:type",String)],e.SlackNode.prototype,"resultChannel",void 0),i.__decorate([Se({handle:"ts",type:"string"}),i.__metadata("design:type",String)],e.SlackNode.prototype,"resultTs",void 0),e.SlackNode=i.__decorate([ve("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"}}),a.model()],e.SlackNode);const Za=["sendMessage","getMe","getUpdates","sendChatAction"];e.TelegramNode=class extends ta{constructor(){super(...arguments),this.operation="sendMessage"}async execute(e,t){if(!this.operation)throw new to("Telegram node requires an operation","GRAPH_TELEGRAM_OPERATION_REQUIRED");const o=Za.includes(this.operation)?this.operation:"sendMessage",r=$a(await ko(t,e.credentials,"telegram",!1,"Telegram"),"Telegram"),a=new S.TelegramService;try{switch(await N.bootWithoutEnvironment(a,{token:r,baseUrl:this.baseUrl}),o){case"sendMessage":{const t=this.chatId,o=this.text??(e.inputs.value??"")+"";if(null==t||!o)throw new to("Telegram sendMessage requires a chat ID and text","GRAPH_TELEGRAM_MESSAGE_REQUIRED");const r=await a.sendMessage({chatId:t,text:o,parseMode:this.parseMode,disableNotification:this.disableNotification,disablePreview:this.disablePreview,replyToMessageId:Ma(this.replyToMessageId),messageThreadId:Ma(this.messageThreadId)});return{result:r,messageId:Ma(r?.message_id)}}case"getMe":return{result:await a.getMe()};case"getUpdates":return{result:await a.getUpdates({offset:Ma(this.offset),limit:Ma(this.limit),timeoutSeconds:Ma(this.timeoutSeconds)})};default:if(void 0===this.chatId||null===this.chatId)throw new to("Telegram sendChatAction requires a chat ID","GRAPH_TELEGRAM_CHAT_REQUIRED");return{result:await a.sendChatAction(this.chatId,this.action??"typing")}}}catch(e){if(e instanceof to)throw e;throw new to(`Telegram node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TELEGRAM_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.operation.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.TelegramNode.prototype,"baseUrl",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.TelegramNode.prototype,"result",void 0),i.__decorate([Se({handle:"messageId",type:"number"}),i.__metadata("design:type",Number)],e.TelegramNode.prototype,"messageId",void 0),e.TelegramNode=i.__decorate([ve("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"}}),a.model()],e.TelegramNode);const en=["sendWebhook","sendChannelMessage","listTeams","listChannels"];e.TeamsNode=class extends ta{constructor(){super(...arguments),this.operation="sendWebhook"}async execute(e,t){if(!this.operation)throw new to("Microsoft Teams node requires an operation","GRAPH_TEAMS_OPERATION_REQUIRED");const o=en.includes(this.operation)?this.operation:"sendWebhook",r=await ko(t,e.credentials,"teams",!1,"Microsoft Teams"),a=new I.TeamsService;try{switch(await N.bootWithoutEnvironment(a,{token:qa(r,"token","Microsoft Teams"),webhookUrl:qa(r,"webhookUrl","Microsoft Teams"),baseUrl:this.baseUrl}),o){case"sendWebhook":{const t=this.text??(e.inputs.value??"")+"";if(!t)throw new to("Microsoft Teams sendWebhook requires text","GRAPH_TEAMS_TEXT_REQUIRED");return{result:await a.sendWebhook({text:t,title:this.title,markdown:this.markdown})}}case"sendChannelMessage":if(!this.teamId||!this.channelId||!this.content)throw new to("Microsoft Teams sendChannelMessage requires teamId, channelId, and content","GRAPH_TEAMS_CHANNEL_MESSAGE_REQUIRED");return{result:await a.sendChannelMessage({teamId:this.teamId,channelId:this.channelId,content:this.content,contentType:this.contentType})};case"listTeams":return{result:await a.listTeams(Ma(this.limit))};default:if(!this.teamId)throw new to("Microsoft Teams listChannels requires a teamId","GRAPH_TEAMS_TEAM_REQUIRED");return{result:await a.listChannels(this.teamId)}}}catch(e){if(e instanceof to)throw e;throw new to(`Microsoft Teams node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TEAMS_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.operation.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsNode.prototype,"baseUrl",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.TeamsNode.prototype,"result",void 0),e.TeamsNode=i.__decorate([ve("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"}}),a.model()],e.TeamsNode);const tn=["send","list","get","labels"];e.GmailNode=class extends ta{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new to("Gmail node requires an operation","GRAPH_GMAIL_OPERATION_REQUIRED");const o=tn.includes(this.operation)?this.operation:"send",r=await ko(t,e.credentials,"gmail",!1,"Gmail"),a=new x.GmailService;try{switch(await N.bootWithoutEnvironment(a,{token:$a(r,"Gmail"),userId:this.userId??qa(r,"userId","Gmail"),baseUrl:this.baseUrl}),o){case"send":{const t=this.from??qa(r,"from","Gmail");if(!t||!this.to||!this.subject)throw new to("Gmail send requires from, to, and subject","GRAPH_GMAIL_MESSAGE_REQUIRED");const o=await a.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 a.listMessages({query:this.query,maxResults:Ma(this.maxResults),pageToken:this.pageToken,labelIds:ja(this.labelIds)?.map(String)})};case"get":if(!this.messageId)throw new to("Gmail get requires a message ID","GRAPH_GMAIL_MESSAGE_ID_REQUIRED");return{result:await a.getMessage(this.messageId,this.format??"full")};default:return{result:await a.listLabels()}}}catch(e){if(e instanceof to)throw e;throw new to(`Gmail node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GMAIL_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.operation.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GmailNode.prototype,"baseUrl",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.GmailNode.prototype,"result",void 0),i.__decorate([Se({handle:"id",type:"string"}),i.__metadata("design:type",String)],e.GmailNode.prototype,"id",void 0),e.GmailNode=i.__decorate([ve("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"}}),a.model()],e.GmailNode);const on=["send","listInbox","listImap"];e.EmailSendNode=class extends ta{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new to("Email Send node requires an operation","GRAPH_EMAIL_OPERATION_REQUIRED");const o=on.includes(this.operation)?this.operation:"send",r=await ko(t,e.credentials,"email",!1,"Email"),a=Fa(r,"Email"),n=r&&!a?r:void 0,i=new R.EmailService;try{switch(await N.bootWithoutEnvironment(i,{provider:this.provider??a?.provider,host:this.host??this.asCredentialString(a,"host"),port:Ma(this.port)??Ma(a?.port),secure:this.secure??Ga(a?.secure,!1),username:this.username??this.asCredentialString(a,"username"),password:this.asCredentialString(a,"password"),from:this.from??this.asCredentialString(a,"from"),token:n??this.asCredentialString(a,"token"),graphBaseUrl:this.graphBaseUrl??this.asCredentialString(a,"graphBaseUrl"),baseUrl:this.baseUrl}),o){case"send":{if(!this.to||!this.subject)throw new to("Email Send send requires to and subject","GRAPH_EMAIL_MESSAGE_REQUIRED");const t=await i.send({from:this.from??this.asCredentialString(a,"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:Ma(this.limit),since:this.since,subject:this.subjectFilter})};default:return{result:await i.listImapMessages({mailbox:this.mailbox,limit:Ma(this.limit),since:this.since,subject:this.subjectFilter})}}}catch(e){if(e instanceof to)throw e;throw new to(`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([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.operation.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"baseUrl",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.EmailSendNode.prototype,"result",void 0),i.__decorate([Se({handle:"messageId",type:"string"}),i.__metadata("design:type",String)],e.EmailSendNode.prototype,"messageId",void 0),e.EmailSendNode=i.__decorate([ve("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"}}),a.model()],e.EmailSendNode);const rn=["get","update","append","clear","create"];e.GoogleSheetsNode=class extends ta{constructor(){super(...arguments),this.operation="get"}async execute(e,t){if(!this.operation)throw new to("Google Sheets node requires an operation","GRAPH_GOOGLE_SHEETS_OPERATION_REQUIRED");const o=rn.includes(this.operation)?this.operation:"get",r=await ko(t,e.credentials,"google-sheets",!1,"Google Sheets"),a=new O.GoogleSheetsService;try{switch(await N.bootWithoutEnvironment(a,{token:qa(r,"token","Google Sheets"),apiKey:qa(r,"apiKey","Google Sheets"),baseUrl:this.baseUrl}),o){case"get":{const e=await a.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"},r="update"===o?await a.updateValues(t):await a.appendValues(t);return{result:r,values:r.values,spreadsheetId:r.spreadsheetId,range:r.range}}case"clear":{const e=await a.clearValues(this.requireSpreadsheet(),this.requireRange());return{result:e,spreadsheetId:e.spreadsheetId,range:e.clearedRange}}default:{if(!this.title)throw new to("Google Sheets create requires a title","GRAPH_GOOGLE_SHEETS_TITLE_REQUIRED");const e=await a.createSpreadsheet(this.title);return{result:e,spreadsheetId:e.spreadsheetId}}}}catch(e){if(e instanceof to)throw e;throw new to(`Google Sheets node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GOOGLE_SHEETS_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}requireSpreadsheet(){if(!this.spreadsheetId)throw new to("Google Sheets node requires a spreadsheet ID","GRAPH_GOOGLE_SHEETS_SPREADSHEET_REQUIRED");return this.spreadsheetId}requireRange(){if(!this.range)throw new to("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 to("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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"baseUrl",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.GoogleSheetsNode.prototype,"result",void 0),i.__decorate([Se({handle:"values",type:"array"}),i.__metadata("design:type",Array)],e.GoogleSheetsNode.prototype,"outputValues",void 0),i.__decorate([Se({handle:"spreadsheetId",type:"string"}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"outputSpreadsheetId",void 0),i.__decorate([Se({handle:"range",type:"string"}),i.__metadata("design:type",String)],e.GoogleSheetsNode.prototype,"outputRange",void 0),e.GoogleSheetsNode=i.__decorate([ve("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"}}),a.model()],e.GoogleSheetsNode);const an=["list","get","create","update","delete"];e.AirtableNode=class extends ta{constructor(){super(...arguments),this.operation="list"}async execute(e,t){if(!this.operation)throw new to("Airtable node requires an operation","GRAPH_AIRTABLE_OPERATION_REQUIRED");const o=an.includes(this.operation)?this.operation:"list",r=await ko(t,e.credentials,"airtable",!1,"Airtable"),a=new k.AirtableService;try{switch(await N.bootWithoutEnvironment(a,{token:qa(r,"token","Airtable"),baseId:this.baseId??qa(r,"baseId","Airtable"),baseUrl:this.baseUrl}),o){case"list":{const e=await a.listRecords({table:this.requireTable(),view:this.view,filterByFormula:this.filterByFormula,maxRecords:Ma(this.maxRecords),pageSize:Ma(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 a.getRecord(this.requireTable(),this.requireRecordId());return{result:e,records:[e]}}case"create":{const e=await a.createRecord({table:this.requireTable(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}case"update":{const e=await a.updateRecord({table:this.requireTable(),recordId:this.requireRecordId(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}default:return{result:await a.deleteRecord(this.requireTable(),this.requireRecordId())}}}catch(e){if(e instanceof to)throw e;throw new to(`Airtable node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_AIRTABLE_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}requireTable(){if(!this.table)throw new to("Airtable node requires a table","GRAPH_AIRTABLE_TABLE_REQUIRED");return this.table}requireRecordId(){if(!this.recordId)throw new to("Airtable node requires a record ID","GRAPH_AIRTABLE_RECORD_REQUIRED");return this.recordId}requireRecordFields(){const e=Da(this.recordFields);if(!e)throw new to("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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"baseUrl",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.AirtableNode.prototype,"result",void 0),i.__decorate([Se({handle:"records",type:"array"}),i.__metadata("design:type",Array)],e.AirtableNode.prototype,"records",void 0),i.__decorate([Se({handle:"offset",type:"string"}),i.__metadata("design:type",String)],e.AirtableNode.prototype,"nextOffset",void 0),e.AirtableNode=i.__decorate([ve("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"}}),a.model()],e.AirtableNode);const nn=["parse","write"];e.SpreadsheetFileNode=class extends ta{constructor(){super(...arguments),this.spreadsheets=new T.SpreadsheetService,this.operation="parse"}async execute(e){const t=nn.includes(this.operation)?this.operation:"parse";try{if("parse"===t){const t=this.content??e.inputs.value;if("string"!=typeof t)throw new to("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 to("Spreadsheet File write requires rows as an array of arrays","GRAPH_SPREADSHEET_ROWS_REQUIRED");const r=this.spreadsheets.serialize(o,{format:this.format,delimiter:this.delimiter,header:ja(this.header)?.map(String)});return{result:r,content:r}}catch(e){if(e instanceof to)throw e;throw new to(`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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"hasHeader",userControlled:!0}),i.__metadata("design:type",Boolean)],e.SpreadsheetFileNode.prototype,"hasHeader",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.SpreadsheetFileNode.prototype,"result",void 0),i.__decorate([Se({handle:"content",type:"string"}),i.__metadata("design:type",String)],e.SpreadsheetFileNode.prototype,"outputContent",void 0),i.__decorate([Se({handle:"rows",type:"array"}),i.__metadata("design:type",Array)],e.SpreadsheetFileNode.prototype,"outputRows",void 0),i.__decorate([Se({handle:"header",type:"array"}),i.__metadata("design:type",Array)],e.SpreadsheetFileNode.prototype,"outputHeader",void 0),e.SpreadsheetFileNode=i.__decorate([ve("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"}}),a.model()],e.SpreadsheetFileNode);const dn=["query","mutation"];e.GraphqlNode=class extends ta{constructor(){super(...arguments),this.operation="query"}async execute(e,t){if(!this.operation)throw new to("GraphQL node requires an operation","GRAPH_GRAPHQL_OPERATION_REQUIRED");const o=dn.includes(this.operation)?this.operation:"query",r=this.query??(e.inputs.value??"")+"";if(!r)throw new to("GraphQL node requires a query document","GRAPH_GRAPHQL_QUERY_REQUIRED");const a=await ko(t,e.credentials,"graphql",!1,"GraphQL"),n=new C.GraphqlService;try{await N.bootWithoutEnvironment(n,{endpoint:this.endpoint??qa(a,"endpoint","GraphQL"),token:qa(a,"token","GraphQL")});const e=await n.request({query:r,variables:Da(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 to)throw e;throw new to(`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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"operationName",userControlled:!0}),i.__metadata("design:type",String)],e.GraphqlNode.prototype,"operationName",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.GraphqlNode.prototype,"result",void 0),i.__decorate([Se({handle:"errors",type:"array"}),i.__metadata("design:type",Array)],e.GraphqlNode.prototype,"errors",void 0),e.GraphqlNode=i.__decorate([ve("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"}}),a.model()],e.GraphqlNode);const sn=["getRepo","listIssues","createIssue","commentIssue","listPullRequests"];e.GithubNode=class extends ta{constructor(){super(...arguments),this.operation="getRepo"}async execute(e,t){if(!this.operation)throw new to("GitHub node requires an operation","GRAPH_GITHUB_OPERATION_REQUIRED");const o=sn.includes(this.operation)?this.operation:"getRepo",r=await ko(t,e.credentials,"github",!1,"GitHub"),a=new D.GithubService;try{switch(await N.bootWithoutEnvironment(a,{token:$a(r,"GitHub"),owner:this.owner,repo:this.repo,baseUrl:this.baseUrl}),o){case"getRepo":return{result:await a.getRepository({owner:this.owner,repo:this.repo})};case"listIssues":return{result:await a.listIssues({owner:this.owner,repo:this.repo,state:this.state,limit:Ma(this.limit),page:Ma(this.page),labels:this.labels?.join(",")})};case"createIssue":{if(!this.title)throw new to("GitHub createIssue requires a title","GRAPH_GITHUB_TITLE_REQUIRED");const t=await a.createIssue({owner:this.owner,repo:this.repo,title:this.title,body:this.body??(e.inputs.value??"")+"",labels:ja(this.labels)?.map(String),assignees:ja(this.assignees)?.map(String)});return{result:t,number:t.number,url:t.htmlUrl}}case"commentIssue":{const e=Ma(this.number);if(!e||!this.body)throw new to("GitHub commentIssue requires an issue number and body","GRAPH_GITHUB_COMMENT_REQUIRED");const t=await a.commentOnIssue({owner:this.owner,repo:this.repo,number:e,body:this.body});return{result:t,number:e,url:t.htmlUrl}}default:return{result:await a.listPullRequests({owner:this.owner,repo:this.repo,state:this.state,limit:Ma(this.limit),page:Ma(this.page)})}}}catch(e){if(e instanceof to)throw e;throw new to(`GitHub node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITHUB_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.operation.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GithubNode.prototype,"baseUrl",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.GithubNode.prototype,"result",void 0),i.__decorate([Se({handle:"number",type:"number"}),i.__metadata("design:type",Number)],e.GithubNode.prototype,"issueNumber",void 0),i.__decorate([Se({handle:"url",type:"string"}),i.__metadata("design:type",String)],e.GithubNode.prototype,"url",void 0),e.GithubNode=i.__decorate([ve("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"}}),a.model()],e.GithubNode);const ln=["getProject","listIssues","createIssue","commentIssue","listMergeRequests"];e.GitlabNode=class extends ta{constructor(){super(...arguments),this.operation="getProject"}async execute(e,t){if(!this.operation)throw new to("GitLab node requires an operation","GRAPH_GITLAB_OPERATION_REQUIRED");const o=ln.includes(this.operation)?this.operation:"getProject",r=await ko(t,e.credentials,"gitlab",!1,"GitLab"),a=new P.GitlabService;try{switch(await N.bootWithoutEnvironment(a,{token:$a(r,"GitLab"),projectId:this.projectId,baseUrl:this.baseUrl}),o){case"getProject":return{result:await a.getProject(this.projectId)};case"listIssues":return{result:await a.listIssues({projectId:this.projectId,state:this.state,limit:Ma(this.limit),page:Ma(this.page),labels:ja(this.labels)?.map(String).join(","),search:this.search})};case"createIssue":{if(!this.title)throw new to("GitLab createIssue requires a title","GRAPH_GITLAB_TITLE_REQUIRED");const t=await a.createIssue({projectId:this.projectId,title:this.title,description:this.body??(e.inputs.value??"")+"",labels:ja(this.labels)?.map(String).join(","),assigneeIds:ja(this.assigneeIds)?.map(Number)});return{result:t,iid:t.iid,url:t.webUrl}}case"commentIssue":{const e=Ma(this.iid);if(!e||!this.body)throw new to("GitLab commentIssue requires an issue IID and body","GRAPH_GITLAB_COMMENT_REQUIRED");const t=await a.commentOnIssue({projectId:this.projectId,iid:e,body:this.body});return{result:t,iid:e,url:t.webUrl}}default:return{result:await a.listMergeRequests({projectId:this.projectId,state:this.state,limit:Ma(this.limit),page:Ma(this.page),search:this.search})}}}catch(e){if(e instanceof to)throw e;throw new to(`GitLab node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITLAB_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.operation.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"baseUrl",userControlled:!0}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"baseUrl",void 0),i.__decorate([Se({handle:"result"}),i.__metadata("design:type",Object)],e.GitlabNode.prototype,"result",void 0),i.__decorate([Se({handle:"iid",type:"number"}),i.__metadata("design:type",Number)],e.GitlabNode.prototype,"issueIid",void 0),i.__decorate([Se({handle:"url",type:"string"}),i.__metadata("design:type",String)],e.GitlabNode.prototype,"url",void 0),e.GitlabNode=i.__decorate([ve("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"}}),a.model()],e.GitlabNode);const cn={MD5:"md5",SHA1:"sha1",SHA256:"sha256",SHA384:"sha384",SHA512:"sha512","SHA3-256":"sha3-256","SHA3-384":"sha3-384","SHA3-512":"sha3-512"},pn=["hash","hmac","encrypt","decrypt","sign","verify","generate"];e.CryptoNode=class extends ta{constructor(){super(...arguments),this.operation="hash",this.algorithm="SHA256",this.encoding="hex",this.keyType="rsa"}async execute(e,t){const o="Crypto",r=async r=>{const a=Ha(await ko(t,e.credentials,"crypto",!0,o),r,o);if(!a)throw new to(o+" node credential must contain the required key material","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:o});return a},a=pn.includes(this.operation)?this.operation:"hash",n=cn[this.algorithm]??cn.SHA256,i="base64"===this.encoding?"base64":"hex",d=()=>((e,t)=>{if("string"==typeof e)return e;if(null==e)throw new to(t+" node requires a payload","GRAPH_CRYPTO_PAYLOAD_REQUIRED");try{return JSON.stringify(e)}catch{throw new to(t+" node cannot serialize the payload","GRAPH_CRYPTO_INVALID_PAYLOAD")}})(this.payload??e.inputs.value,o),s=new G.CryptoService;await s.boot();const l=s.client;try{switch(a){case"hash":return{result:l.createHash(n).update(d()).digest(i)};case"hmac":{const e=await r(["secret","key","password","token"]);return{result:l.createHmac(n,e).update(d()).digest(i)}}case"encrypt":{const e=await r(["secret","key","password","token"]);return{result:await s.encrypt(d(),e),encodings:["base64"]}}case"decrypt":{const e=await r(["secret","key","password","token"]),t=Pa(this.encryptedData);if(!t)throw new to("Crypto node decrypt requires encryptedData","GRAPH_CRYPTO_ENCRYPTED_DATA_REQUIRED");const o=Pa(this.salt);if(!o)throw new to("Crypto node decrypt requires the encryption salt","GRAPH_CRYPTO_SALT_REQUIRED");return{result:await s.decrypt(t,e,o)}}case"sign":{const e=await r(["privateKey","key","secret","token"]);return{result:l.createSign(n).update(d()).sign(e,i)}}case"verify":{const e=Pa(this.publicKey)??await r(["publicKey","key","secret","token"]),t=Pa(this.signature);if(!t)throw new to("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:Pa(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 to(`Crypto node operation '${a}' is not supported`,"GRAPH_CRYPTO_OPERATION_NOT_SUPPORTED",{operation:a})}}catch(e){if(e instanceof to)throw e;throw new to(`Crypto node operation '${a}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_CRYPTO_OPERATION_FAILED",{operation:a})}finally{await s.shutdown().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.operation.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"encoding",void 0),i.__decorate([Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"namedCurve",userControlled:!0}),i.__metadata("design:type",String)],e.CryptoNode.prototype,"namedCurve",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.CryptoNode.prototype,"result",void 0),i.__decorate([Se({handle:"encodings",type:"array"}),i.__metadata("design:type",Array)],e.CryptoNode.prototype,"encodings",void 0),e.CryptoNode=i.__decorate([ve("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"}}),a.model()],e.CryptoNode);const un=["sign","verify","decode"];function gn(e,t="utf8"){const o=Buffer.isBuffer(e)?e:Buffer.from(e??"",t);return o.length>Qt?{value:o.subarray(0,Qt).toString(t),truncated:!0}:{value:o.toString(t),truncated:!1}}e.JwtNode=class extends ta{constructor(){super(...arguments),this.operation="decode"}async execute(e,t){const o=un.includes(this.operation)?this.operation:"decode",r=Pa(this.token)??Pa(e.inputs.value);if("sign"!==o&&!r)throw new to(`JWT node operation '${o}' requires a token`,"GRAPH_JWT_TOKEN_REQUIRED",{operation:o});try{if("sign"===o){const o=await ko(t,e.credentials,"jwt",!0,"JWT"),r=(e=>{if("string"==typeof e&&e.trim().startsWith("{"))try{return Da(JSON.parse(e))??{}}catch{throw new to("JWT node claims must be a JSON object","GRAPH_JWT_INVALID_CLAIMS")}const t=Da(e);if(!t)throw new to("JWT node sign operation requires claims","GRAPH_JWT_CLAIMS_REQUIRED");return t})(this.claims??e.inputs.value),a={secret:o,expiry:Pa(this.expiry)??"1h"},n=await M.sign(r,a);return{result:n,token:n}}if("verify"===o){const o=await ko(t,e.credentials,"jwt",!1,"JWT"),a=Pa(this.verifyUrl);if(!o&&!a)throw new to("JWT node verify requires a secret credential or verifyUrl","GRAPH_JWT_VERIFICATION_NOT_CONFIGURED");const n=await M.verify(r,{secret:"string"==typeof o?o:Pa(o?.secret),verifyUrl:a,clockToleranceSeconds:Ma(this.clockToleranceSeconds)});return{result:n,payload:n}}const a=M.decodeJwtPayload(r);return{result:a??null,payload:a??null}}catch(e){if(e instanceof to)throw e;throw new to(`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"}),Ee({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.JwtNode.prototype,"operation",void 0),i.__decorate([Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"clockToleranceSeconds",userControlled:!0}),i.__metadata("design:type",Number)],e.JwtNode.prototype,"clockToleranceSeconds",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.JwtNode.prototype,"result",void 0),i.__decorate([Se({handle:"token"}),i.__metadata("design:type",String)],e.JwtNode.prototype,"tokenOutput",void 0),i.__decorate([Se({handle:"payload"}),i.__metadata("design:type",Object)],e.JwtNode.prototype,"payload",void 0),e.JwtNode=i.__decorate([ve("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"}}),a.model()],e.JwtNode),e.ExecuteCommandNode=class extends ta{constructor(){super(...arguments),this.failOnError=!1}async execute(e,t){const o=Pa(this.command);if(!o)throw new to("Execute Command node requires a command","GRAPH_EXECUTE_COMMAND_REQUIRED");const r=Math.min(6e4,Math.max(1,Math.floor(Ma(this.timeoutMs)??3e4))),a=await new Promise(e=>{j.exec(o,{timeout:r,maxBuffer:Qt,cwd:Pa(this.cwd),shell:Pa(this.shell),signal:t.abortSignal,windowsHide:!0},(t,o,r)=>{const a=gn(o),n=gn(r),i=t?.code;e({stdout:a.value,stderr:n.value,exitCode:"number"==typeof i?i:t?null:0,error:t??void 0,truncated:a.truncated||n.truncated})})});if(a.error&&this.failOnError)throw new to("Execute Command node command failed: "+a.error.message,"GRAPH_EXECUTE_COMMAND_FAILED",{exitCode:a.exitCode});return{result:{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode,truncated:a.truncated},stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode}}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.command.label",type:"textarea"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"failOnError",userControlled:!0}),i.__metadata("design:type",Boolean)],e.ExecuteCommandNode.prototype,"failOnError",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.ExecuteCommandNode.prototype,"result",void 0),i.__decorate([Se({handle:"stdout"}),i.__metadata("design:type",String)],e.ExecuteCommandNode.prototype,"stdout",void 0),i.__decorate([Se({handle:"stderr"}),i.__metadata("design:type",String)],e.ExecuteCommandNode.prototype,"stderr",void 0),i.__decorate([Se({handle:"exitCode",type:"number"}),i.__metadata("design:type",Object)],e.ExecuteCommandNode.prototype,"exitCode",void 0),e.ExecuteCommandNode=i.__decorate([ve("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"}}),a.model()],e.ExecuteCommandNode);const hn=["list","download","delete"];function mn(e){if(!e)return{};if("string"!=typeof e)return{password:Pa(e.password),privateKey:Pa(e.privateKey),passphrase:Pa(e.passphrase)};if(!e.trim().startsWith("{"))return{password:e};const t=La(e,"FTP");return{password:Pa(t.password),privateKey:Pa(t.privateKey),passphrase:Pa(t.passphrase)}}e.FtpNode=class extends ta{constructor(){super(...arguments),this.operation="list",this.encoding="utf8"}async execute(e,t){const o=Pa(this.host),r=Pa(this.username);if(!o||!r)throw new to("FTP node requires host and username","GRAPH_FTP_CONNECTION_REQUIRED");const a=hn.includes(this.operation)?this.operation:"list",n=Pa(this.path);if("list"!==a&&!n)throw new to(`FTP node operation '${a}' requires a path`,"GRAPH_FTP_PATH_REQUIRED",{operation:a});const i=await ko(t,e.credentials,"sftp",!1,"FTP"),d={provider:"ssh2",sourceId:Pa(this.sourceId)??"graph",host:o,port:Ma(this.port)??22,username:r,remotePath:Pa(this.remotePath),...mn(i)},s=new L.Ssh2SftpService;try{if(await s.initialize(d),"list"===a)return{result:await s.list(n)};if("delete"===a)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 to)throw e;throw new to(`FTP node operation '${a}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_FTP_OPERATION_FAILED",{operation:a})}finally{await s.close().catch(()=>{})}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.operation.label",type:"select"}),Ee({handle:"operation",userControlled:!0}),i.__metadata("design:type",String)],e.FtpNode.prototype,"operation",void 0),i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.host.label",type:"string"}),Ee({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"}),Ee({handle:"port",userControlled:!0}),i.__metadata("design:type",Number)],e.FtpNode.prototype,"port",void 0),i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.username.label",type:"string"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"encoding",userControlled:!0}),i.__metadata("design:type",String)],e.FtpNode.prototype,"encoding",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.FtpNode.prototype,"result",void 0),i.__decorate([Se({handle:"content"}),i.__metadata("design:type",String)],e.FtpNode.prototype,"content",void 0),i.__decorate([Se({handle:"size",type:"number"}),i.__metadata("design:type",Number)],e.FtpNode.prototype,"size",void 0),e.FtpNode=i.__decorate([ve("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"}}),a.model()],e.FtpNode),e.ExecuteSubWorkflowNode=class extends ta{constructor(){super(...arguments),this.mode="once",this.inputPort="value"}async execute(e,t){const o=t.engine;if(!o)throw new to("Execute Sub-workflow node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const r=await this.documentOf(o,t),a=this.inputPort||"value",n=e.inputs.value??e.inputs.input;if("perItem"===this.mode){const e=[];let i,d;for(const s of ca(n)){const n=await o.execute(r,{[a]: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(r,{[a]: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(la(o=this.workflow)&&"string"==typeof o.id&&Array.isArray(o.nodes)&&Array.isArray(o.edges))return this.workflow;var o;const r=this.workflowId;if(!r)throw new to("Execute Sub-workflow node requires a workflow id or an inline workflow document","GRAPH_SUB_WORKFLOW_REQUIRED");try{return await e.getWorkflow(r,t)}catch(e){throw new to(`Execute Sub-workflow node could not resolve workflow '${r}': ${e instanceof Error?e.message:e+""}`,"GRAPH_SUB_WORKFLOW_NOT_FOUND",{workflowId:r})}}},i.__decorate([Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"inputPort",userControlled:!0}),i.__metadata("design:type",String)],e.ExecuteSubWorkflowNode.prototype,"inputPort",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.ExecuteSubWorkflowNode.prototype,"result",void 0),i.__decorate([Se({handle:"outputs"}),i.__metadata("design:type",Object)],e.ExecuteSubWorkflowNode.prototype,"outputs",void 0),i.__decorate([Se({handle:"childRunId"}),i.__metadata("design:type",String)],e.ExecuteSubWorkflowNode.prototype,"childRunId",void 0),e.ExecuteSubWorkflowNode=i.__decorate([ve("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"}}),a.model()],e.ExecuteSubWorkflowNode),e.ExecuteWorkflowTriggerNode=class extends ta{execute(e){const t=e.inputs.payload;return{result:void 0!==t?t:e.inputs.value??e.inputs}}},i.__decorate([Ee({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"}),Ee({handle:"schema",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.ExecuteWorkflowTriggerNode.prototype,"schema",void 0),i.__decorate([a.required(),Se({handle:"result"}),i.__metadata("design:type",Object)],e.ExecuteWorkflowTriggerNode.prototype,"result",void 0),e.ExecuteWorkflowTriggerNode=i.__decorate([ve("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"}}}),a.model()],e.ExecuteWorkflowTriggerNode),e.ChatTriggerNode=class extends ta{execute(e){return{message:e.inputs.message??null,sessionId:e.inputs.sessionId??null,userId:e.inputs.userId??null}}},i.__decorate([a.required(),Se({handle:"message"}),i.__metadata("design:type",String)],e.ChatTriggerNode.prototype,"message",void 0),i.__decorate([a.required(),Se({handle:"sessionId"}),i.__metadata("design:type",String)],e.ChatTriggerNode.prototype,"sessionId",void 0),i.__decorate([a.required(),Se({handle:"userId"}),i.__metadata("design:type",String)],e.ChatTriggerNode.prototype,"userId",void 0),e.ChatTriggerNode=i.__decorate([ve("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"}}}),a.model()],e.ChatTriggerNode),e.EventTriggerNode=class extends ta{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([a.required(),Se({handle:"payload"}),i.__metadata("design:type",Object)],e.EventTriggerNode.prototype,"payload",void 0),e.EventTriggerNode=i.__decorate([ve("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"}}}),a.model()],e.EventTriggerNode),e.FormTriggerNode=class extends ta{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([a.required(),Ee({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([a.required(),Se({handle:"payload"}),i.__metadata("design:type",Object)],e.FormTriggerNode.prototype,"payload",void 0),e.FormTriggerNode=i.__decorate([ve("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:[]}}}),a.model()],e.FormTriggerNode),e.ManualTriggerNode=class extends ta{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([a.required(),Se({handle:"payload"}),i.__metadata("design:type",Object)],e.ManualTriggerNode.prototype,"payload",void 0),e.ManualTriggerNode=i.__decorate([ve("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:{}}}}),a.model()],e.ManualTriggerNode),e.ScheduleTriggerNode=class extends ta{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([a.required(),Ee({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([a.required(),Se({handle:"payload"}),i.__metadata("design:type",Object)],e.ScheduleTriggerNode.prototype,"payload",void 0),e.ScheduleTriggerNode=i.__decorate([ve("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"}}}),a.model()],e.ScheduleTriggerNode),e.WebhookTriggerNode=class extends ta{execute(e){return{payload:e.inputs.payload??null}}},i.__decorate([a.required(),Ee({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([a.required(),Se({handle:"payload"}),i.__metadata("design:type",Object)],e.WebhookTriggerNode.prototype,"payload",void 0),e.WebhookTriggerNode=i.__decorate([ve("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"}}}),a.model()],e.WebhookTriggerNode);const fn={memory:"memory",scorers:"scorers",embedding:"embedding",hooks:"hooks",sandbox:"sandbox",tools:"tools",skill:"skill",inputProcessors:"inputProcessors",outputProcessors:"outputProcessors"},_n=[fn.memory,fn.scorers,fn.embedding,fn.hooks,fn.sandbox,fn.tools,fn.skill,fn.inputProcessors,fn.outputProcessors];e.AgentNode=class extends ta{execute(e){throw new to("Node kind 'core.agent' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent",backend:"local"})}},i.__decorate([a.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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"agentOptions",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"agentOptions",void 0),i.__decorate([a.required(),Se({handle:"response"}),i.__metadata("design:type",String)],e.AgentNode.prototype,"response",void 0),i.__decorate([a.required(),Se({handle:"actions"}),i.__metadata("design:type",Array)],e.AgentNode.prototype,"actions",void 0),i.__decorate([Ie({category:fn.memory,handle:"memory",zone:{side:"bottom",align:"start",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"memory",void 0),i.__decorate([Ie({category:fn.scorers,handle:"scorers",zone:{side:"top",align:"end",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"scorers",void 0),i.__decorate([Ie({category:fn.embedding,handle:"embedding",zone:{side:"bottom",align:"end",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"embedding",void 0),i.__decorate([Ie({category:fn.hooks,handle:"hooks",zone:{side:"top",align:"center",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"hooks",void 0),i.__decorate([Ie({category:fn.sandbox,handle:"sandbox",zone:{side:"top",align:"center",order:1}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"sandbox",void 0),i.__decorate([Ie({category:fn.tools,handle:"tools",zone:{side:"bottom",align:"center",order:0}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"tools",void 0),i.__decorate([Ie({category:fn.skill,handle:"skill",zone:{side:"bottom",align:"center",order:1}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"skill",void 0),i.__decorate([Ie({category:fn.inputProcessors,handle:"inputProcessors",zone:{side:"top",align:"center",order:2}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"inputProcessors",void 0),i.__decorate([Ie({category:fn.outputProcessors,handle:"outputProcessors",zone:{side:"bottom",align:"center",order:2}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"outputProcessors",void 0),i.__decorate([Ie({category:"model",handle:"model",zone:{side:"bottom",align:"start",order:1}}),i.__metadata("design:type",Object)],e.AgentNode.prototype,"model",void 0),i.__decorate([Ie({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([ve("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"}}),a.model()],e.AgentNode);const yn=[e.AgentNode];e.AgentToolNode=class extends ta{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"}),Ee({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"}),Ee({handle:"description",userControlled:!0}),i.__metadata("design:type",String)],e.AgentToolNode.prototype,"description",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentToolNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.tools,handle:"tool"}),i.__metadata("design:type",Object)],e.AgentToolNode.prototype,"tool",void 0),e.AgentToolNode=i.__decorate([ve("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"}}),a.model()],e.AgentToolNode);const bn=[e.AgentToolNode];e.AgentToolSelectorNode=class extends ta{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.tools??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.tool",toolId:r}:null}}},i.__decorate([Ee({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"}),Ee({handle:"tools",userControlled:!0}),i.__metadata("design:type",Array)],e.AgentToolSelectorNode.prototype,"tools",void 0),i.__decorate([Se({handle:"selected"}),i.__metadata("design:type",Object)],e.AgentToolSelectorNode.prototype,"selectedOut",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentToolSelectorNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.tools,handle:"tool"}),i.__metadata("design:type",Object)],e.AgentToolSelectorNode.prototype,"tool",void 0),e.AgentToolSelectorNode=i.__decorate([ve("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"}}),a.model()],e.AgentToolSelectorNode);const wn=[e.AgentToolSelectorNode];e.AgentHookNode=class extends ta{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"}),Ee({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"}),Ee({handle:"toolName",userControlled:!0}),i.__metadata("design:type",String)],e.AgentHookNode.prototype,"toolName",void 0),i.__decorate([a.required(),Ee({handle:"value"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"value",void 0),i.__decorate([a.required(),Se({handle:"toolName"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"toolNameOut",void 0),i.__decorate([Se({handle:"input"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"inputOut",void 0),i.__decorate([Se({handle:"output"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"outputOut",void 0),i.__decorate([Se({handle:"error"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"errorOut",void 0),i.__decorate([Se({handle:"value"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"valueOut",void 0),i.__decorate([Ie({category:fn.hooks,handle:"hook"}),i.__metadata("design:type",Object)],e.AgentHookNode.prototype,"hook",void 0),e.AgentHookNode=i.__decorate([ve("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"}}),a.model()],e.AgentHookNode);const Nn=[e.AgentHookNode];e.AgentToolDenyNode=class extends ta{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"}),Ee({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"}),Ee({handle:"reason",userControlled:!0}),i.__metadata("design:type",String)],e.AgentToolDenyNode.prototype,"reason",void 0),i.__decorate([Ee({handle:"value"}),i.__metadata("design:type",Object)],e.AgentToolDenyNode.prototype,"value",void 0),i.__decorate([Se({handle:"proceed"}),i.__metadata("design:type",Boolean)],e.AgentToolDenyNode.prototype,"proceedOut",void 0),i.__decorate([Se({handle:"value"}),i.__metadata("design:type",Object)],e.AgentToolDenyNode.prototype,"valueOut",void 0),i.__decorate([Se({handle:"denied"}),i.__metadata("design:type",Boolean)],e.AgentToolDenyNode.prototype,"deniedOut",void 0),i.__decorate([Se({handle:"reason"}),i.__metadata("design:type",Object)],e.AgentToolDenyNode.prototype,"reasonOut",void 0),e.AgentToolDenyNode=i.__decorate([ve("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"}}),a.model()],e.AgentToolDenyNode);const vn=[e.AgentToolDenyNode];e.AgentDelegationHookNode=class extends ta{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"}),Ee({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"}),Ee({handle:"subAgentId",userControlled:!0}),i.__metadata("design:type",String)],e.AgentDelegationHookNode.prototype,"subAgentId",void 0),i.__decorate([a.required(),Ee({handle:"value"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"value",void 0),i.__decorate([Se({handle:"fromAgentId"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"fromAgentIdOut",void 0),i.__decorate([Se({handle:"toAgentId"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"toAgentIdOut",void 0),i.__decorate([Se({handle:"input"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"inputOut",void 0),i.__decorate([Se({handle:"output"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"outputOut",void 0),i.__decorate([Se({handle:"error"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"errorOut",void 0),i.__decorate([Se({handle:"value"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"valueOut",void 0),i.__decorate([Ie({category:fn.hooks,handle:"hook"}),i.__metadata("design:type",Object)],e.AgentDelegationHookNode.prototype,"hook",void 0),e.AgentDelegationHookNode=i.__decorate([ve("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"}}),a.model()],e.AgentDelegationHookNode);const An=[e.AgentDelegationHookNode];e.AgentSkillNode=class extends ta{execute(e){return{resource:{type:"mastra.skill",name:this.name,description:this.description,input:e.inputs}}}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.name.label",type:"text"}),Ee({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"}),Ee({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"}),Ee({handle:"instructions",userControlled:!0}),i.__metadata("design:type",String)],e.AgentSkillNode.prototype,"instructions",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentSkillNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.skill,handle:"skill"}),i.__metadata("design:type",Object)],e.AgentSkillNode.prototype,"skill",void 0),e.AgentSkillNode=i.__decorate([ve("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"}}),a.model()],e.AgentSkillNode);const En=[e.AgentSkillNode];e.AgentSkillSelectorNode=class extends ta{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.skills??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.skill",name:r}:null}}},i.__decorate([Ee({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"}),Ee({handle:"skills",userControlled:!0}),i.__metadata("design:type",Array)],e.AgentSkillSelectorNode.prototype,"skills",void 0),i.__decorate([Se({handle:"selected"}),i.__metadata("design:type",Object)],e.AgentSkillSelectorNode.prototype,"selectedOut",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentSkillSelectorNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.skill,handle:"skill"}),i.__metadata("design:type",Object)],e.AgentSkillSelectorNode.prototype,"skill",void 0),e.AgentSkillSelectorNode=i.__decorate([ve("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"}}),a.model()],e.AgentSkillSelectorNode);const Sn=[e.AgentSkillSelectorNode];function In(e){const t=aa.graph.execution?.maxCodeTimeoutMs;return na(e,"number"==typeof t&&Number.isFinite(t)&&t>0?t:Vt)}e.AgentSandboxNode=class extends ta{execute(e){return{resource:{type:"mastra.sandbox",workingDirectory:this.workingDirectory,isolation:this.isolation,timeoutMs:In(this.timeoutMs),input:e.inputs}}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.workingDirectory.label",type:"text"}),Ee({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"}),Ee({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"}),Ee({handle:"timeoutMs",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentSandboxNode.prototype,"timeoutMs",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentSandboxNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.sandbox,handle:"sandbox"}),i.__metadata("design:type",Object)],e.AgentSandboxNode.prototype,"sandbox",void 0),e.AgentSandboxNode=i.__decorate([ve("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"}}),a.model()],e.AgentSandboxNode);const xn=[e.AgentSandboxNode];e.AgentScorerNode=class extends ta{execute(e){return{resource:{type:"mastra.scorer",id:this.scorerId,description:this.description,scorerType:this.scorerType,input:e.inputs}}}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.scorerId.label",type:"text"}),Ee({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"}),Ee({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"}),Ee({handle:"scorerType",userControlled:!0}),i.__metadata("design:type",String)],e.AgentScorerNode.prototype,"scorerType",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentScorerNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.scorers,handle:"scorer"}),i.__metadata("design:type",Object)],e.AgentScorerNode.prototype,"scorer",void 0),e.AgentScorerNode=i.__decorate([ve("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"}}),a.model()],e.AgentScorerNode);const Rn=[e.AgentScorerNode];e.AgentScorerSelectorNode=class extends ta{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.scorers??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.scorer",id:r}:null}}},i.__decorate([Ee({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"}),Ee({handle:"scorers",userControlled:!0}),i.__metadata("design:type",Array)],e.AgentScorerSelectorNode.prototype,"scorers",void 0),i.__decorate([Se({handle:"selected"}),i.__metadata("design:type",Object)],e.AgentScorerSelectorNode.prototype,"selectedOut",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentScorerSelectorNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.scorers,handle:"scorer"}),i.__metadata("design:type",Object)],e.AgentScorerSelectorNode.prototype,"scorer",void 0),e.AgentScorerSelectorNode=i.__decorate([ve("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"}}),a.model()],e.AgentScorerSelectorNode);const On=[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 kn=[...er,"connectionString","dsn","pwd","passphrase","authToken"];function Tn(e,t,o,r=0){if(8>=r&&null!==e)if(Array.isArray(e))for(const a of e)Tn(a,t,o,r+1);else if("object"==typeof e)for(const[a,n]of Object.entries(e)){const e=[...t,a];if(kn.includes(a))throw new to(`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:a,path:e.join(".")});Tn(n,e,o,r+1)}}function Cn(e,t){Tn(e,[],t)}const Dn=["memory","libsql","pg","mongodb","upstash","cloud","d1","dynamodb","convex","astra","redis"];function Pn(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 ta{execute(e){return{resource:Pn(this.configOf(e))}}configOf(e){const t=this.provider??"memory";if(!Dn.includes(t))throw new to(`Memory provider node '${e.nodeId}' declares unknown provider '${t+""}'`,"GRAPH_MASTRA_MEMORY_PROVIDER_UNKNOWN",{nodeId:e.nodeId,provider:t+""});const o=e.inputs.workingMemoryTemplate,r={provider:t};void 0!==this.memoryId&&(r.id=this.memoryId),void 0!==this.threadId&&(r.threadId=this.threadId),void 0!==this.resourceId&&(r.resourceId=this.resourceId),void 0!==this.lastMessages&&(r.lastMessages=this.lastMessages),void 0!==this.semanticRecall&&(r.semanticRecall=this.semanticRecall),void 0!==this.generateTitle&&(r.generateTitle=this.generateTitle),void 0!==this.memoryOptions&&(r.memoryOptions=this.memoryOptions),void 0!==this.connection&&(r.connection=this.connection),void 0!==this.credentialKey&&(r.credentialKey=this.credentialKey),void 0!==this.credentialRef&&(r.credentialRef=this.credentialRef);const a="string"==typeof o&&o.trim().length>0?o:this.workingMemoryTemplate;return"string"==typeof a&&a.trim().length>0&&(r.workingMemoryTemplate=a),r}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.provider.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"credentialRef",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentMemoryNode.prototype,"credentialRef",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentMemoryNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.memory,handle:"memory"}),i.__metadata("design:type",Object)],e.AgentMemoryNode.prototype,"memory",void 0),e.AgentMemoryNode=i.__decorate([ve("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"}}),a.model()],e.AgentMemoryNode),e.AgentMemorySelectorNode=class extends ta{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.memories??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.memory",id:r}:null}}},i.__decorate([Ee({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"}),Ee({handle:"memories",userControlled:!0}),i.__metadata("design:type",Array)],e.AgentMemorySelectorNode.prototype,"memories",void 0),i.__decorate([Se({handle:"selected"}),i.__metadata("design:type",Object)],e.AgentMemorySelectorNode.prototype,"selectedOut",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentMemorySelectorNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.memory,handle:"memory"}),i.__metadata("design:type",Object)],e.AgentMemorySelectorNode.prototype,"memory",void 0),e.AgentMemorySelectorNode=i.__decorate([ve("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"}}),a.model()],e.AgentMemorySelectorNode);const Gn=[e.AgentMemorySelectorNode];e.AgentEmbeddingNode=class extends ta{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([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.modelAdapter.label",type:"object"}),Ee({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"}),Ee({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"}),Ee({handle:"batchSize",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentEmbeddingNode.prototype,"batchSize",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentEmbeddingNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.embedding,handle:"embedding"}),i.__metadata("design:type",Object)],e.AgentEmbeddingNode.prototype,"embedding",void 0),e.AgentEmbeddingNode=i.__decorate([ve("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"}}),a.model()],e.AgentEmbeddingNode);const Mn=[e.AgentEmbeddingNode];e.AgentVectorStoreNode=class extends ta{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&&(Cn(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 r=e.inputs.ids;return{resource:o,inserted:Array.isArray(r)?r:[],documents:e.inputs.documents??[]}}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.provider.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"credentialRef",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"credentialRef",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"resource",void 0),i.__decorate([Se({handle:"inserted"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"insertedOut",void 0),i.__decorate([Se({handle:"documents"}),i.__metadata("design:type",Object)],e.AgentVectorStoreNode.prototype,"documentsOut",void 0),e.AgentVectorStoreNode=i.__decorate([ve("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"}}),a.model()],e.AgentVectorStoreNode);const jn=[e.AgentVectorStoreNode];e.AgentRetrieverNode=class extends ta{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([a.required(),Ee({handle:"store"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"store",void 0),i.__decorate([a.required(),Ee({handle:"query"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"query",void 0),i.__decorate([Ee({handle:"queryVector"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"queryVector",void 0),i.__decorate([Ee({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"}),Ee({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"}),Ee({handle:"indexName",userControlled:!0}),i.__metadata("design:type",String)],e.AgentRetrieverNode.prototype,"indexName",void 0),i.__decorate([a.required(),Se({handle:"documents"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"documents",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentRetrieverNode.prototype,"resource",void 0),e.AgentRetrieverNode=i.__decorate([ve("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"}}),a.model()],e.AgentRetrieverNode);const Ln=[e.AgentRetrieverNode];function Fn(e,t,o){if("number"!=typeof e||!Number.isFinite(e))return t;const r=Math.floor(e);return o>r?t:r}function qn(e,t,o){if(e.length<=t)return e.length?[e]:[];const r=Math.max(1,t-o),a=[];for(let o=0;o<e.length;o+=r){const r=Math.min(o+t,e.length);if(a.push(e.slice(o,r)),r>=e.length)break}return a}function $n(e,t={}){if("string"!=typeof e||0===e.length)return[];const o=t.strategy??"recursive",r=Fn(t.chunkSize,1e3,1),a=Fn(t.chunkOverlap,200,0),n=Math.min(a,Math.max(0,r-1));if("character"===o)return qn(e,r,n);if("token"===o){const t=e.split(/\s+/).filter(e=>e.length>0);if(0===t.length)return[];const o=Math.max(1,r-n),a=[];for(let e=0;e<t.length&&(a.push(t.slice(e,e+r).join(" ")),e+r<t.length);e+=o);return a}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>r?s.push(...qn(t,r,n)):s.push(t))}),s.length?s:qn(e,r,n)}function Hn(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 ta{execute(e){const t=Hn(e.inputs),o={strategy:this.strategy,chunkSize:this.chunkSize,chunkOverlap:this.chunkOverlap,separator:this.separator},r=t.flatMap(e=>$n(e,o));return{chunks:r,count:r.length}}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.strategy.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"separator",userControlled:!0}),i.__metadata("design:type",String)],e.AgentChunkingNode.prototype,"separator",void 0),i.__decorate([a.required(),Se({handle:"chunks"}),i.__metadata("design:type",Object)],e.AgentChunkingNode.prototype,"chunks",void 0),i.__decorate([Se({handle:"count"}),i.__metadata("design:type",Object)],e.AgentChunkingNode.prototype,"countOut",void 0),e.AgentChunkingNode=i.__decorate([ve("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"}}),a.model()],e.AgentChunkingNode);const Un=[e.AgentChunkingNode];e.AgentRerankNode=class extends ta{execute(e){const t=e.inputs.documents,o=Array.isArray(t)?t:[],r="number"==typeof this.topN&&this.topN>0?this.topN:void 0,a=this.modelAdapter??{};return{documents:void 0!==r?o.slice(0,r):o,resource:{type:"mastra.rerank",provider:a.provider,modelId:a.modelId,topN:r}}}},i.__decorate([a.required(),Ee({handle:"documents"}),i.__metadata("design:type",Object)],e.AgentRerankNode.prototype,"documents",void 0),i.__decorate([Ee({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"}),Ee({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"}),Ee({handle:"topN",userControlled:!0}),i.__metadata("design:type",Number)],e.AgentRerankNode.prototype,"topN",void 0),i.__decorate([a.required(),Se({handle:"documents"}),i.__metadata("design:type",Object)],e.AgentRerankNode.prototype,"documentsOut",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentRerankNode.prototype,"resource",void 0),e.AgentRerankNode=i.__decorate([ve("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"}}),a.model()],e.AgentRerankNode);const Bn=[e.AgentRerankNode];e.AgentQaChainNode=class extends ta{execute(e){const t=this.modelAdapter??{},o=e.inputs.context??e.inputs.documents,r=Array.isArray(o)?o:[];return{text:"string"==typeof e.inputs.text?e.inputs.text:"",sourceDocuments:this.returnSourceDocuments?r:[],resource:{type:"mastra.chain.qa",provider:t.provider,modelId:t.modelId,returnSourceDocuments:this.returnSourceDocuments??!1}}}},i.__decorate([a.required(),Ee({handle:"query"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"query",void 0),i.__decorate([Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"returnSourceDocuments",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AgentQaChainNode.prototype,"returnSourceDocuments",void 0),i.__decorate([a.required(),Se({handle:"text"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"text",void 0),i.__decorate([Se({handle:"sourceDocuments"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"sourceDocumentsOut",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentQaChainNode.prototype,"resource",void 0),e.AgentQaChainNode=i.__decorate([ve("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"}}),a.model()],e.AgentQaChainNode);const Wn=[e.AgentQaChainNode];e.AgentBasicChainNode=class extends ta{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([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"promptTemplate",userControlled:!0}),i.__metadata("design:type",String)],e.AgentBasicChainNode.prototype,"promptTemplate",void 0),i.__decorate([a.required(),Se({handle:"text"}),i.__metadata("design:type",Object)],e.AgentBasicChainNode.prototype,"text",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentBasicChainNode.prototype,"resource",void 0),e.AgentBasicChainNode=i.__decorate([ve("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"}}),a.model()],e.AgentBasicChainNode);const Vn=[e.AgentBasicChainNode];e.AgentSummarizationChainNode=class extends ta{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([a.required(),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"instructions",userControlled:!0}),i.__metadata("design:type",String)],e.AgentSummarizationChainNode.prototype,"instructions",void 0),i.__decorate([a.required(),Se({handle:"text"}),i.__metadata("design:type",Object)],e.AgentSummarizationChainNode.prototype,"text",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentSummarizationChainNode.prototype,"resource",void 0),e.AgentSummarizationChainNode=i.__decorate([ve("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"}}),a.model()],e.AgentSummarizationChainNode);const Kn=[e.AgentSummarizationChainNode];function zn(e){if("string"!=typeof e||0===e.trim().length)return null;try{return JSON.parse(e)}catch{return null}}e.AgentStructuredOutputParserNode=class extends ta{execute(e){return{object:zn(e.inputs.text??e.inputs.input),resource:{type:"mastra.structuredOutputParser",strict:this.strict??!1,hasSchema:void 0!==this.structuredOutput}}}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"strict",userControlled:!0}),i.__metadata("design:type",Boolean)],e.AgentStructuredOutputParserNode.prototype,"strict",void 0),i.__decorate([a.required(),Se({handle:"object"}),i.__metadata("design:type",Object)],e.AgentStructuredOutputParserNode.prototype,"object",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentStructuredOutputParserNode.prototype,"resource",void 0),e.AgentStructuredOutputParserNode=i.__decorate([ve("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"}}),a.model()],e.AgentStructuredOutputParserNode);const Qn=[e.AgentStructuredOutputParserNode];e.AgentInformationExtractorNode=class extends ta{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([a.required(),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"instructions",userControlled:!0}),i.__metadata("design:type",String)],e.AgentInformationExtractorNode.prototype,"instructions",void 0),i.__decorate([a.required(),Se({handle:"data"}),i.__metadata("design:type",Object)],e.AgentInformationExtractorNode.prototype,"data",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentInformationExtractorNode.prototype,"resource",void 0),e.AgentInformationExtractorNode=i.__decorate([ve("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"}}),a.model()],e.AgentInformationExtractorNode);const Jn=[e.AgentInformationExtractorNode];e.AgentLangChainCodeNode=class extends ta{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([a.required(),Ee({handle:"input"}),i.__metadata("design:type",Object)],e.AgentLangChainCodeNode.prototype,"input",void 0),i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.code.label",type:"textarea"}),Ee({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"}),Ee({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"}),Ee({handle:"mode",userControlled:!0}),i.__metadata("design:type",String)],e.AgentLangChainCodeNode.prototype,"mode",void 0),i.__decorate([Se({handle:"output"}),i.__metadata("design:type",Object)],e.AgentLangChainCodeNode.prototype,"outputOut",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentLangChainCodeNode.prototype,"resource",void 0),e.AgentLangChainCodeNode=i.__decorate([ve("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"}}),a.model()],e.AgentLangChainCodeNode);const Xn=[e.AgentLangChainCodeNode];e.AgentInputProcessorNode=class extends ta{execute(e){return{resource:{type:"mastra.inputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.processorType.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentInputProcessorNode.prototype,"modelAdapter",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentInputProcessorNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.inputProcessors,handle:"processors"}),i.__metadata("design:type",Object)],e.AgentInputProcessorNode.prototype,"processors",void 0),e.AgentInputProcessorNode=i.__decorate([ve("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"}}),a.model()],e.AgentInputProcessorNode);const Yn=[e.AgentInputProcessorNode];e.AgentOutputProcessorNode=class extends ta{execute(e){return{resource:{type:"mastra.outputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.output_processor.fields.processorType.label",type:"select"}),Ee({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"}),Ee({handle:"options",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentOutputProcessorNode.prototype,"options",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentOutputProcessorNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.outputProcessors,handle:"processors"}),i.__metadata("design:type",Object)],e.AgentOutputProcessorNode.prototype,"processors",void 0),e.AgentOutputProcessorNode=i.__decorate([ve("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"}}),a.model()],e.AgentOutputProcessorNode);const Zn=[e.AgentOutputProcessorNode];e.AgentGuardrailNode=class extends ta{execute(e){return{resource:{type:"mastra.guardrail",guardrailType:this.guardrailType,strategy:this.strategy,options:this.options,input:e.inputs}}}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.guardrailType.label",type:"select"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"modelAdapter",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentGuardrailNode.prototype,"modelAdapter",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentGuardrailNode.prototype,"resource",void 0),i.__decorate([Ie({category:fn.outputProcessors,handle:"guardrail"}),i.__metadata("design:type",Object)],e.AgentGuardrailNode.prototype,"guardrail",void 0),e.AgentGuardrailNode=i.__decorate([ve("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"}}),a.model()],e.AgentGuardrailNode);const ei=[e.AgentGuardrailNode];e.AgentHitlNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.hitl' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.hitl",backend:"local"})}},i.__decorate([a.required(),Ee({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"}),Ee({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"}),Ee({handle:"prompt",userControlled:!0}),i.__metadata("design:type",String)],e.AgentHitlNode.prototype,"prompt",void 0),i.__decorate([a.required(),Ee({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([Se({handle:"approved"}),i.__metadata("design:type",Object)],e.AgentHitlNode.prototype,"approvedOut",void 0),i.__decorate([Se({handle:"rejected"}),i.__metadata("design:type",Object)],e.AgentHitlNode.prototype,"rejectedOut",void 0),e.AgentHitlNode=i.__decorate([ve("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"}}),a.model()],e.AgentHitlNode);const ti=[e.AgentHitlNode];e.McpServerTriggerNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.trigger.mcp' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.trigger.mcp",backend:"local"})}},i.__decorate([a.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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"pendingTimeoutMs",userControlled:!0}),i.__metadata("design:type",Number)],e.McpServerTriggerNode.prototype,"pendingTimeoutMs",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.McpServerTriggerNode.prototype,"resource",void 0),e.McpServerTriggerNode=i.__decorate([ve("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"}}),a.model()],e.McpServerTriggerNode);const oi=[e.McpServerTriggerNode];e.SlackChannelTriggerNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.trigger.slack' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.trigger.slack",backend:"local"})}},i.__decorate([a.required(),Se({handle:"message"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"message",void 0),i.__decorate([a.required(),Se({handle:"sessionId"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"sessionId",void 0),i.__decorate([a.required(),Se({handle:"userId"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"userId",void 0),i.__decorate([a.required(),Se({handle:"threadId"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"threadId",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.SlackChannelTriggerNode.prototype,"resource",void 0),e.SlackChannelTriggerNode=i.__decorate([ve("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"}}),a.model()],e.SlackChannelTriggerNode);const ri=[e.SlackChannelTriggerNode];e.DiscordChannelTriggerNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.trigger.discord' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.trigger.discord",backend:"local"})}},i.__decorate([a.required(),Se({handle:"message"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"message",void 0),i.__decorate([a.required(),Se({handle:"sessionId"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"sessionId",void 0),i.__decorate([a.required(),Se({handle:"userId"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"userId",void 0),i.__decorate([a.required(),Se({handle:"threadId"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"threadId",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.DiscordChannelTriggerNode.prototype,"resource",void 0),e.DiscordChannelTriggerNode=i.__decorate([ve("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"}}),a.model()],e.DiscordChannelTriggerNode);const ai=[e.DiscordChannelTriggerNode];e.TelegramChannelTriggerNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.trigger.telegram' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.trigger.telegram",backend:"local"})}},i.__decorate([a.required(),Se({handle:"message"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"message",void 0),i.__decorate([a.required(),Se({handle:"sessionId"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"sessionId",void 0),i.__decorate([a.required(),Se({handle:"userId"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"userId",void 0),i.__decorate([a.required(),Se({handle:"threadId"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"threadId",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.TelegramChannelTriggerNode.prototype,"resource",void 0),e.TelegramChannelTriggerNode=i.__decorate([ve("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"}}),a.model()],e.TelegramChannelTriggerNode);const ni=[e.TelegramChannelTriggerNode];e.TeamsChannelTriggerNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.trigger.teams' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.trigger.teams",backend:"local"})}},i.__decorate([a.required(),Se({handle:"message"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"message",void 0),i.__decorate([a.required(),Se({handle:"sessionId"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"sessionId",void 0),i.__decorate([a.required(),Se({handle:"userId"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"userId",void 0),i.__decorate([a.required(),Se({handle:"threadId"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"threadId",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.TeamsChannelTriggerNode.prototype,"resource",void 0),e.TeamsChannelTriggerNode=i.__decorate([ve("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"}}),a.model()],e.TeamsChannelTriggerNode);const ii=[e.TeamsChannelTriggerNode];e.SlackChannelResponseNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.response.slack' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.response.slack",backend:"local"})}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.slack_response.fields.response.label",type:"textarea"}),Ee({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"}),Ee({handle:"threadId",userControlled:!0}),i.__metadata("design:type",String)],e.SlackChannelResponseNode.prototype,"threadId",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.SlackChannelResponseNode.prototype,"resource",void 0),e.SlackChannelResponseNode=i.__decorate([ve("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"}}),a.model()],e.SlackChannelResponseNode);const di=[e.SlackChannelResponseNode];e.DiscordChannelResponseNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.response.discord' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.response.discord",backend:"local"})}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.discord_response.fields.response.label",type:"textarea"}),Ee({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"}),Ee({handle:"threadId",userControlled:!0}),i.__metadata("design:type",String)],e.DiscordChannelResponseNode.prototype,"threadId",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.DiscordChannelResponseNode.prototype,"resource",void 0),e.DiscordChannelResponseNode=i.__decorate([ve("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"}}),a.model()],e.DiscordChannelResponseNode);const si=[e.DiscordChannelResponseNode];e.TelegramChannelResponseNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.response.telegram' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.response.telegram",backend:"local"})}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.telegram_response.fields.response.label",type:"textarea"}),Ee({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"}),Ee({handle:"threadId",userControlled:!0}),i.__metadata("design:type",String)],e.TelegramChannelResponseNode.prototype,"threadId",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.TelegramChannelResponseNode.prototype,"resource",void 0),e.TelegramChannelResponseNode=i.__decorate([ve("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"}}),a.model()],e.TelegramChannelResponseNode);const li=[e.TelegramChannelResponseNode];e.TeamsChannelResponseNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.response.teams' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.response.teams",backend:"local"})}},i.__decorate([a.required(),o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.teams_response.fields.response.label",type:"textarea"}),Ee({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"}),Ee({handle:"threadId",userControlled:!0}),i.__metadata("design:type",String)],e.TeamsChannelResponseNode.prototype,"threadId",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.TeamsChannelResponseNode.prototype,"resource",void 0),e.TeamsChannelResponseNode=i.__decorate([ve("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"}}),a.model()],e.TeamsChannelResponseNode);const ci=[e.TeamsChannelResponseNode];e.AgentVoiceNode=class extends ta{execute(e){throw new to("Node kind 'core.agent.voice' requires the mastra engine, which the local backend does not provide",Ut,{kind:"core.agent.voice",backend:"local"})}},i.__decorate([o.uielement("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.speaker.label",type:"text"}),Ee({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"}),Ee({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"}),Ee({handle:"listeningModel",userControlled:!0,type:"object"}),i.__metadata("design:type",Object)],e.AgentVoiceNode.prototype,"listeningModel",void 0),i.__decorate([a.required(),Se({handle:"resource"}),i.__metadata("design:type",Object)],e.AgentVoiceNode.prototype,"resource",void 0),e.AgentVoiceNode=i.__decorate([ve("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"}}),a.model()],e.AgentVoiceNode);const pi=[e.AgentVoiceNode];function ui(e,t,o,r){const a=t??o;if(null==e)return Math.min(o,a);const n=Number(e);if(!Number.isFinite(n)||0>=n)throw new ro(r+" loop maxIterations must be a positive finite number");return Math.min(Math.floor(n),a)}function gi(e,t,o){const r=t.node.loop,a=t.metadata?.loop;if(!r?.body&&!a?.body)throw new ro(o+" node is missing loop configuration (instance.loop.body)");const n=t=>{const o=e[t]??r?.[t]??a?.[t],n=Number(o);return void 0!==o&&Number.isFinite(n)?n:void 0},i=t=>{const o=e[t]??a?.[t];return"string"==typeof o?o:void 0};return{body:r?.body??a?.body,maxIterations:n("maxIterations"),timeoutMs:n("timeoutMs"),concurrency:n("concurrency"),condition:e.condition??a?.condition,inputPort:i("inputPort"),outputPort:i("outputPort"),itemPort:i("itemPort"),resultPort:i("resultPort"),statePort:i("statePort"),slice:n("slice")}}e.GraphForeachLoopNode=class extends ta{async execute(e,t){const o=gi(this,t,"foreach"),r=e.inputs,a=r.items,n=ui(o.maxIterations,t.limits?.maxForeachIterations,1e3,"foreach");if(!Array.isArray(a))throw new ro("foreach input 'items' must be an array");const i=t.engine;if(!i)throw new to("foreach node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const d=Number(r.slice??o.slice??1),s=Number.isFinite(d)&&d>0?Math.floor(d):1,l=s>1?Math.ceil(a.length/s):a.length;if(l>n)throw new ao(`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=r.state,f=!1;await t.emit({type:te.LOOP_STARTED});for(let e=0;l>e;e++){await t.emit({type:te.LOOP_ITERATION_STARTED,iteration:e});const o=s>1?a.slice(e*s,e*s+s):a[e],r={[c]:o,index:e};s>1&&(r.slice=o),void 0!==m&&(r[u]=m);try{const a=await i.execute(g,r,{parentRunId:t.runId,path:[...t.path,"iteration:"+e],metadata:{item:o,index:e,slice:s},auth:t.auth},t);h.push(a.outputs[p]),void 0!==a.outputs[u]&&(m=a.outputs[u])}catch(o){if(o instanceof lo){const r=o.details?.value;void 0!==r&&h.push(r),f=!0,await t.emit({type:te.LOOP_ITERATION_COMPLETED,iteration:e,metadata:{broken:!0}});break}throw o}await t.emit({type:te.LOOP_ITERATION_COMPLETED,iteration:e})}await t.emit({type:te.LOOP_COMPLETED,metadata:{broken:f}});const _={results:h,completed:h,iterations:h.length,broken:f};return void 0!==m&&(_[u]=m),_}},i.__decorate([a.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"}),Ee({handle:"items"}),i.__metadata("design:type",Array)],e.GraphForeachLoopNode.prototype,"items",void 0),i.__decorate([a.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"}),Ee({handle:"slice"}),i.__metadata("design:type",Number)],e.GraphForeachLoopNode.prototype,"slice",void 0),i.__decorate([a.required(),Se({handle:"item"}),i.__metadata("design:type",Object)],e.GraphForeachLoopNode.prototype,"item",void 0),i.__decorate([a.required(),Ie({handle:"loop",connectionRules:{allowSelf:!0,maxConnections:1}}),i.__metadata("design:type",Object)],e.GraphForeachLoopNode.prototype,"loop",void 0),i.__decorate([a.required(),Se({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"statePort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphForeachLoopNode.prototype,"statePort",void 0),e.GraphForeachLoopNode=i.__decorate([ve("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}}}),a.model()],e.GraphForeachLoopNode);class hi{constructor(){this.expressionEvaluator=new Fo}evaluate(t,o){if(this.isConditionExpression(t))return this.expressionEvaluator.evaluate(t,o);const r=this.resolveValue(t.left,o),a=t.right;switch(t.type){case e.GraphConditionType.TRUTHY:return!!r;case e.GraphConditionType.FALSY:return!r;case e.GraphConditionType.EQUALS:return r===a;case e.GraphConditionType.NOT_EQUALS:return r!==a;case e.GraphConditionType.GREATER_THAN:return Number(r)>Number(a);case e.GraphConditionType.GREATER_THAN_OR_EQUAL:return Number(r)>=Number(a);case e.GraphConditionType.LESS_THAN:return Number(a)>Number(r);case e.GraphConditionType.LESS_THAN_OR_EQUAL:return Number(a)>=Number(r);case e.GraphConditionType.EXISTS:return null!=r;case e.GraphConditionType.CUSTOM:throw new to("Custom condition evaluators are not supported in v1","GRAPH_CUSTOM_CONDITION_UNSUPPORTED");default:throw new to(`Unknown condition type '${t.type}'`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:t})}}async evaluateAsync(e,t,o,r){return qo(e)?Ho(e,r,o):this.evaluate(e,t)}resolveValue(e,t){if(!e)return t;const o=e.split(".");let r=t;for(const e of o){if(null==r)return;r=r[e]}return r}isConditionExpression(e){return"string"==typeof e.op}}function mi(e,t,o,r={}){return{id:e,label:t,direction:o,...r}}function fi(e){const t=e,o=ue(t),r=o?.metadata?.title;return Ct(t,r?{name:r}:{})}function _i(e,t){const o=e,r=ue(o),a=r?.metadata?.title;return Ct(o,{...a?{name:a}:{},icon:{type:"catalogue",name:t}})}function yi(e,t,o){const r={type:"credential",id:"credentialRef",label:o,required:!1,credentialType:t};return{...e,parameters:[...e.parameters,r],credentials:[...(e.credentials??[]).filter(e=>e.type!==t),{type:t,required:!1}]}}e.GraphUntilLoopNode=class extends ta{async execute(e,t){const o=gi(this,t,"until"),r=e.inputs,a=ui(o.maxIterations,t.limits?.maxLoopIterations,100,"until"),n=o.condition;if(!n)throw new ro("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 to("until node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=r.state,u=0;await t.emit({type:te.LOOP_STARTED});let g=!1;do{if(u>=a)throw await t.emit({type:te.LOOP_LIMIT_REACHED,iteration:u}),new ao(`until loop exceeded max iterations (${a})`);await t.emit({type:te.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:te.LOOP_ITERATION_COMPLETED,iteration:u});const e=await(new hi).evaluateAsync(n,p,t,{...r,state:p});await t.emit({type:te.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:e}}),u++,g=e}while(!g);return await t.emit({type:te.LOOP_COMPLETED}),{state:p,iterations:u}}},i.__decorate([a.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"}),Ee({handle:"state"}),i.__metadata("design:type",Object)],e.GraphUntilLoopNode.prototype,"state",void 0),i.__decorate([a.required(),Se({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"outputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphUntilLoopNode.prototype,"outputPort",void 0),e.GraphUntilLoopNode=i.__decorate([ve("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}}}}),a.model()],e.GraphUntilLoopNode),e.GraphWhileLoopNode=class extends ta{async execute(e,t){const o=gi(this,t,"while"),r=e.inputs,a=ui(o.maxIterations,t.limits?.maxLoopIterations,100,"while"),n=o.condition;if(!n)throw new ro("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 to("while node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=r.state,u=0;for(await t.emit({type:te.LOOP_STARTED});await(new hi).evaluateAsync(n,p,t,{...r,state:p});){if(u>=a)throw await t.emit({type:te.LOOP_LIMIT_REACHED,iteration:u}),new ao(`while loop exceeded max iterations (${a})`);await t.emit({type:te.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:!0}}),await t.emit({type:te.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:te.LOOP_ITERATION_COMPLETED,iteration:u}),u++}return await t.emit({type:te.LOOP_COMPLETED}),{state:p,iterations:u}}},i.__decorate([a.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"}),Ee({handle:"state"}),i.__metadata("design:type",Object)],e.GraphWhileLoopNode.prototype,"state",void 0),i.__decorate([a.required(),Se({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({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"}),Ee({handle:"outputPort",userControlled:!0}),i.__metadata("design:type",String)],e.GraphWhileLoopNode.prototype,"outputPort",void 0),e.GraphWhileLoopNode=i.__decorate([ve("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}}}}),a.model()],e.GraphWhileLoopNode),e.GraphInputValueNode=class extends ta{execute(e){const t=e.inputs;return{value:t?.value??null}}},i.__decorate([Se({handle:"value",connectionRules:{allowMultiple:!0}}),i.__metadata("design:type",Object)],e.GraphInputValueNode.prototype,"value",void 0),e.GraphInputValueNode=i.__decorate([ve("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"}}),a.model()],e.GraphInputValueNode),e.GraphOutputValueNode=class extends ta{execute(e){return{}}},i.__decorate([a.required(),Ee({handle:"value"}),i.__metadata("design:type",Object)],e.GraphOutputValueNode.prototype,"value",void 0),e.GraphOutputValueNode=i.__decorate([ve("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"}}),a.model()],e.GraphOutputValueNode);const bi={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:[mi("items","graph.node.loop.foreach.ports.input.items.label","input",{required:!0,schema:{type:"array",items:{type:"any"}}}),mi("slice","graph.node.loop.foreach.ports.input.slice.label","input",{schema:{type:"number",integer:!0,min:1}}),mi("state","graph.node.loop.foreach.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[mi("results","graph.node.loop.foreach.ports.output.results.label","output",{schema:{type:"array",items:{type:"any"}}}),mi("completed","graph.node.loop.foreach.ports.output.completed.label","output",{schema:{type:"array",items:{type:"any"}}}),mi("iterations","graph.node.loop.foreach.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}}),mi("broken","graph.node.loop.foreach.ports.output.broken.label","output",{schema:{type:"boolean"}}),mi("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}]},wi={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:[mi("state","graph.node.loop.while.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[mi("state","graph.node.loop.while.ports.output.state.label","output",{schema:{type:"any"}}),mi("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"}]},Ni={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:[mi("state","graph.node.loop.until.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[mi("state","graph.node.loop.until.ports.output.state.label","output",{schema:{type:"any"}}),mi("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"}]},vi=[fi(e.GraphInputValueNode),fi(e.GraphOutputValueNode),fi(e.DateTimeNode),fi(e.DataTableNode),fi(e.FilterNode),fi(e.LimitNode),fi(e.MergeNode),fi(e.RenameKeysNode),fi(e.SetNode),fi(e.SortNode),fi(e.SplitOutNode),fi(e.ExtractFromFileNode),fi(e.HttpRequestNode),fi(e.ReadPDFNode),fi(e.ReadWriteFileNode),yi(fi(e.PostgresNode),"postgres","graph.node.storage.common.fields.credentialRef.label"),yi(fi(e.MySqlNode),"mysql","graph.node.storage.common.fields.credentialRef.label"),yi(fi(e.MicrosoftSqlNode),"mssql","graph.node.storage.common.fields.credentialRef.label"),yi(fi(e.RedisNode),"redis","graph.node.storage.common.fields.credentialRef.label"),yi(fi(e.S3StorageNode),"s3","graph.node.storage.common.fields.credentialRef.label"),yi(fi(e.AwsS3StorageNode),"s3","graph.node.storage.common.fields.credentialRef.label"),yi(fi(e.GoogleCloudStorageNode),"gcs","graph.node.storage.common.fields.credentialRef.label"),yi(fi(e.AzureStorageNode),"azure-blob","graph.node.storage.common.fields.credentialRef.label"),yi(fi(e.CryptoNode),"crypto","graph.node.devops.common.fields.credentialRef.label"),yi(fi(e.JwtNode),"jwt","graph.node.devops.common.fields.credentialRef.label"),(e=>{const t=fi(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),yi(fi(e.FtpNode),"sftp","graph.node.devops.common.fields.credentialRef.label"),yi(fi(e.GithubNode),"github","graph.node.devops.common.fields.credentialRef.label"),yi(fi(e.GitlabNode),"gitlab","graph.node.devops.common.fields.credentialRef.label"),yi(fi(e.SlackNode),"slack","graph.node.comms.common.fields.credentialRef.label"),yi(fi(e.TelegramNode),"telegram","graph.node.comms.common.fields.credentialRef.label"),yi(fi(e.TeamsNode),"teams","graph.node.comms.common.fields.credentialRef.label"),yi(fi(e.GmailNode),"gmail","graph.node.comms.common.fields.credentialRef.label"),yi(fi(e.EmailSendNode),"email","graph.node.comms.common.fields.credentialRef.label"),yi(fi(e.GoogleSheetsNode),"google-sheets","graph.node.io.common.fields.credentialRef.label"),yi(fi(e.AirtableNode),"airtable","graph.node.io.common.fields.credentialRef.label"),yi(fi(e.GraphqlNode),"graphql","graph.node.io.common.fields.credentialRef.label"),fi(e.SpreadsheetFileNode),fi(e.RespondToWebhookNode),fi(e.ExecuteSubWorkflowNode),fi(e.ExecuteWorkflowTriggerNode),fi(e.ManualTriggerNode),fi(e.WebhookTriggerNode),fi(e.ScheduleTriggerNode),fi(e.EventTriggerNode),fi(e.FormTriggerNode),fi(e.ChatTriggerNode),(Ai=fi(e.IfFlowNode),{...Ai,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"}}}]}))(fi(e.SwitchFlowNode)),fi(e.MapNode),fi(e.DelayFlowNode),fi(e.ErrorBoundaryFlowNode),fi(e.HumanApprovalFlowNode),fi(e.CodeNode),fi(e.LogFlowNode),fi(e.UtilityLogNode),fi(e.BreakFlowNode),fi(e.AgentNode),fi(e.AgentToolNode),fi(e.AgentToolSelectorNode),fi(e.AgentHookNode),fi(e.AgentToolDenyNode),fi(e.AgentDelegationHookNode),fi(e.AgentSkillNode),fi(e.AgentSkillSelectorNode),fi(e.AgentSandboxNode),fi(e.AgentScorerNode),fi(e.AgentScorerSelectorNode),fi(e.AgentMemoryNode),fi(e.AgentMemorySelectorNode),fi(e.AgentEmbeddingNode),fi(e.AgentVectorStoreNode),fi(e.AgentRetrieverNode),fi(e.AgentChunkingNode),fi(e.AgentRerankNode),fi(e.AgentQaChainNode),fi(e.AgentBasicChainNode),fi(e.AgentSummarizationChainNode),fi(e.AgentStructuredOutputParserNode),fi(e.AgentInformationExtractorNode),fi(e.AgentLangChainCodeNode),fi(e.AgentInputProcessorNode),fi(e.AgentOutputProcessorNode),fi(e.AgentGuardrailNode),fi(e.AgentHitlNode),fi(e.McpServerTriggerNode),_i(e.SlackChannelTriggerNode,"ti-brand-slack"),_i(e.DiscordChannelTriggerNode,"ti-brand-discord"),_i(e.TelegramChannelTriggerNode,"ti-brand-telegram"),_i(e.TeamsChannelTriggerNode,"ti-brand-teams"),_i(e.SlackChannelResponseNode,"ti-brand-slack"),_i(e.DiscordChannelResponseNode,"ti-brand-discord"),_i(e.TelegramChannelResponseNode,"ti-brand-telegram"),_i(e.TeamsChannelResponseNode,"ti-brand-teams"),_i(e.AgentVoiceNode,"ti-volume-2"),bi,wi,Ni];var Ai;const Ei=Object.fromEntries(vi.map(e=>[e.kind,e])),Si=[e.ManualTriggerNode,e.WebhookTriggerNode,e.ScheduleTriggerNode,e.EventTriggerNode,e.FormTriggerNode,e.ChatTriggerNode],Ii=[e.IfFlowNode,e.SwitchFlowNode,e.DelayFlowNode,e.ErrorBoundaryFlowNode,e.HumanApprovalFlowNode,e.LogFlowNode,e.BreakFlowNode],xi=[e.CodeNode,e.MapNode,e.UtilityLogNode],Ri=[e.GraphForeachLoopNode,e.GraphWhileLoopNode,e.GraphUntilLoopNode],Oi=[e.GraphInputValueNode,e.GraphOutputValueNode],ki=[e.AgentToolNode,e.AgentToolSelectorNode,e.AgentHookNode,e.AgentToolDenyNode,e.AgentDelegationHookNode,e.AgentSkillNode,e.AgentSkillSelectorNode,e.AgentSandboxNode,e.AgentScorerNode,e.AgentScorerSelectorNode],Ti=[e.AgentMemoryNode,e.AgentMemorySelectorNode],Ci=[e.AgentEmbeddingNode,e.AgentVectorStoreNode,e.AgentRetrieverNode,e.AgentChunkingNode,e.AgentRerankNode,e.AgentQaChainNode,e.AgentBasicChainNode,e.AgentSummarizationChainNode,e.AgentStructuredOutputParserNode,e.AgentInformationExtractorNode,e.AgentLangChainCodeNode],Di=[e.AgentInputProcessorNode,e.AgentOutputProcessorNode,e.AgentGuardrailNode],Pi=[e.AgentHitlNode,e.McpServerTriggerNode],Gi=[e.SlackChannelTriggerNode,e.DiscordChannelTriggerNode,e.TelegramChannelTriggerNode,e.TeamsChannelTriggerNode,e.SlackChannelResponseNode,e.DiscordChannelResponseNode,e.TelegramChannelResponseNode,e.TeamsChannelResponseNode,e.AgentVoiceNode],Mi=[e.SetNode,e.MergeNode,e.FilterNode,e.SplitOutNode,e.DateTimeNode,e.DataTableNode,e.LimitNode,e.SortNode,e.RenameKeysNode],ji=[e.HttpRequestNode,e.RespondToWebhookNode,e.ExtractFromFileNode,e.ReadPDFNode,e.ReadWriteFileNode],Li={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.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.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.io.googleSheets":e.GoogleSheetsNode,"core.io.airtable":e.AirtableNode,"core.io.spreadsheetFile":e.SpreadsheetFileNode,"core.io.graphql":e.GraphqlNode,"core.flow.executeSubWorkflow":e.ExecuteSubWorkflowNode,"core.trigger.executeWorkflow":e.ExecuteWorkflowTriggerNode,"core.loop.foreach":e.GraphForeachLoopNode,"core.loop.while":e.GraphWhileLoopNode,"core.loop.until":e.GraphUntilLoopNode};function Fi(e){return{execute:(t,o)=>e.instantiate({...ea(o.node),...t.parameters,...o.node.state??{}}).execute(t,o)}}function qi(){const e=[];for(const[t,o]of Object.entries(Ei)){const r=Li[t];r&&e.push(Zr({manifest:o,executor:Fi(r)}))}return e}const $i=["node","definition","executor","execute","ports","component"];function Hi(e,t,o,r){return{code:e,path:t,message:o,...void 0!==r?.nodeId?{nodeId:r.nodeId}:{},...void 0!==r?.edgeId?{edgeId:r.edgeId}:{},...r?.details?{details:r.details}:{}}}function Ui(e,t){const o=[];for(const r of Object.keys(e))$i.includes(r)&&o.push(Hi("document.forbidden-field",`${t}.${r}`,`Field '${r}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected at the boundary`,{details:{field:r}}));return o}function Bi(e,t){t.push(...Ui(e,"$")),e.inputs.forEach((e,o)=>t.push(...Ui(e,`inputs[${o}]`))),e.outputs.forEach((e,o)=>t.push(...Ui(e,`outputs[${o}]`)));for(const o of e.nodes)t.push(...Ui(o,`nodes[${o.id}]`)),o.loop&&(t.push(...Ui(o.loop,`nodes[${o.id}].loop`)),Bi(o.loop.body,t));for(const o of e.edges)t.push(...Ui(o,`edges[${o.id}]`))}function Wi(e,t){const o=[];e.nodes.length>t.maxNodes&&o.push(Hi("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(Hi("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 r=Vi(e);r>t.maxNestingDepth&&o.push(Hi("document.limit.depth","$.nodes",`Document nests loop bodies ${r} levels deep; at most ${t.maxNestingDepth} levels are allowed`,{details:{depth:r,limit:t.maxNestingDepth}}));const a=Buffer.byteLength(JSON.stringify(e),"utf8");return a>t.maxDocumentBytes&&o.push(Hi("document.limit.size","$",`Document serializes to ${a} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,{details:{bytes:a,limit:t.maxDocumentBytes}})),o}function Vi(e,t=0){let o=t;for(const r of e.nodes)r.loop?.body&&(o=Math.max(o,Vi(r.loop.body,t+1)));return o}async function Ki(e,t,...o){const r=[];for(const a of e.nodes)t.has(a.kind,...o)||r.push(Hi("node.unknown-kind",`nodes[${a.id}].kind`,`Node '${a.id}' references kind '${a.kind}' which is not registered in the backend catalogue`,{nodeId:a.id,details:{kind:a.kind}})),a.loop?.body&&r.push(...await Ki(a.loop.body,t,...o));return r}async function zi(e,t={},...o){const r={...ra,...t.limits},a=[];if(!at(e))return a.push(Hi("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:a};if(!Ce(e))return a.push(Hi("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:a};Bi(e,a),a.push(...(e=>{const t=[],o=new Set;for(const r of[...e.inputs,...e.outputs])o.has(r.id)?t.push(Hi("document.duplicate-port-id",`ports[${r.id}]`,`Workflow port '${r.id}' is declared more than once; workflow port ids must be unique`)):o.add(r.id);const r=new Set;for(const o of e.nodes)r.has(o.id)?t.push(Hi("document.duplicate-node-id",`nodes[${o.id}]`,`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(Hi("document.duplicate-edge-id",`edges[${o.id}]`,`Edge '${o.id}' is declared more than once; edge ids must be unique`,{edgeId:o.id})):a.add(o.id);return t})(e)),a.push(...Wi(e,r)),hr(e,a);try{ze(e)}catch(e){const t=e instanceof n.ValidationError?e.message:e+"";a.push(Hi("document.structure","$",t))}return t.catalogue&&a.push(...await Ki(e,t.catalogue,...o)),{valid:0===a.length,issues:a}}function Qi(e,t,o={}){const r=e?.owner??null;return!r||r===t||(null==t||""===t)&&!0===o.allowAnonymousAccess}function Ji(e,t){return(e?.owner??null)===(t??null)}function Xi(e,t,o){if(!Ji(e,t))throw new d.ForbiddenError(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function Yi(e,t,o){if(!Qi(e,t,o))throw new d.ForbiddenError(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function Zi(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Zi(e)).join(",")}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${Zi(t[e])}`).join(",")}}`}function ed(e){return u.createHash("sha256").update(Zi(e)).digest("hex")}function td(e){return new Gt({runId:e.runId,workflowId:e.workflowId,...e.ownerUser?{owner:e.ownerUser}:{},status:e.status,...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{},...void 0!==e.result?{result:od(e.result)}:{},...e.error?{error:od(e.error)}:{},createdAt:new Date(e.createdAt),...e.startedAt?{startedAt:new Date(e.startedAt)}:{},...e.finishedAt?{finishedAt:new Date(e.finishedAt)}:{}})}function od(e){if(null!=e)return JSON.parse(JSON.stringify(e))}class rd{constructor(e,t={}){this.sequences=new Map,this.chains=new Map,this.store=e,this.limits={...oe,...t}}async publish(e){const t=e.runId,o=(this.sequences.get(t)??0)+1;this.sequences.set(t,o);const r={...e,payload:this.limitPayload(e.payload),sequence:o,timestamp:(new Date).toISOString()},a=(this.chains.get(t)??Promise.resolve()).then(()=>this.store.append(r));return this.chains.set(t,a.catch(()=>{})),await a,r}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 ad{constructor(e,t,o,r={},a={}){this.controllers=new Map,this.completions=new Map,this.timeouts=new Map,this.engine=e,this.runStore=t,this.publisher=o,this.hooks=r,this.limits={...oe,...a}}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,...r){const a=this.completions.get(e.runId);if(a)return a;const n=this.runExecution({...e},t,o,...r).catch(async t=>{const o=nd(t);try{await this.emitTerminal({...e},te.WORKFLOW_FAILED,o)}catch{}return await this.finalize({...e},"failed",void 0,o,...r)});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,...r){const a=e.runId;let n,i,d=!1;const s=this.engine.observe({refresh:async t=>{t.runId===a&&(t.error&&(n=t.error),ae((await this.publisher.publish(this.envelopeOf(e,t))).type)?d=!0:t.type===te.WORKFLOW_STARTED&&"validating"===e.status&&(e.status="running",await this.persist(e,...r)))}});this.armTimeout(a);try{if(this.isAborted(a)){const t={name:"GraphRunCancelledError",message:`Graph run '${a}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return n=t,await this.emitTerminal(e,te.WORKFLOW_CANCELLED,t),d=!0,await this.finalize(e,"cancelled",void 0,t,...r)}let s,l;e.status="validating",e.startedAt=(new Date).toISOString(),await this.persist(e,...r);try{({document:s,fingerprint:l}=await t(...r)),e.documentFingerprint=l,await this.persist(e,...r)}catch(t){const o=nd(t);return n=o,d||(await this.emitTerminal(e,te.WORKFLOW_FAILED,o),d=!0),await this.finalize(e,"failed",void 0,o,...r)}if(this.isAborted(a)){const t={name:"GraphRunCancelledError",message:`Graph run '${a}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return n=t,d||(await this.emitTerminal(e,te.WORKFLOW_CANCELLED,t),d=!0),await this.finalize(e,"cancelled",void 0,t,...r)}try{i=await this.engine.execute(s,o,{runId:a,abortSignal:this.controllers.get(a)?.signal,metadata:{documentFingerprint:l}},...r)}catch(e){n=nd(e)}const c=this.abortReason(a);let p,u;return"timeout"===c?(p="failed",u=n??{name:"GraphRunTimeoutError",message:`Graph run '${a}' exceeded the configured execution timeout of ${this.limits.executionTimeoutMs}ms`,code:"GRAPH_RUN_TIMEOUT"}):"user"===c?(p="cancelled",u=n):i?.status===Y.SUCCEEDED?p="succeeded":i?.status===Y.CANCELLED?(p="cancelled",u=n):(p="failed",u=n??nd(new to(i?`Graph run '${a}' failed`:`Graph run '${a}' failed without a result`,"GRAPH_RUN_FAILED",{runId:a}))),d||await this.emitTerminal(e,"succeeded"===p?te.WORKFLOW_COMPLETED:"cancelled"===p?te.WORKFLOW_CANCELLED:te.WORKFLOW_FAILED,u),await this.finalize(e,p,i,u,...r)}finally{s();const e=this.timeouts.get(a);e&&(clearTimeout(e),this.timeouts.delete(a))}}async emitTerminal(e,t,o){await this.publisher.publish({runId:e.runId,workflowId:e.workflowId,type:t,error:o})}async finalize(e,t,o,r,...a){e.status=t,o&&(e.result=o),r&&(e.error=r),e.startedAt||(e.startedAt=(new Date).toISOString()),e.finishedAt=(new Date).toISOString(),await this.persist(e,...a);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:Te(t.payload)?t.payload:{nonSerializable:!0},error:t.error,parentRunId:t.parentRunId,path:t.path}}}function nd(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 id(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 dd(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&at(e.document)&&!at(e)}function sd(e){return JSON.parse(JSON.stringify(e))}function ld(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(Mt),this.catalogue=e}get limits(){return{...ra,...aa.graph.workflows.limits??{}}}get allowAnonymousAccess(){return!0===aa.graph.workflows.allowAnonymousAccess}async saveDocument(e,t,...o){const{ctx:r,ctxArgs:a}=(await this.logCtx(o,"saveDocument",!0)).for(this.saveDocument);if(!at(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,r);if(!i.valid)throw new po(i.issues);const d=id(r),s=await this.readExistingForWrite(e,a);s&&this.assertWriteOwnership(e,s,d);const l=new Date;if(s)return s.name=t.name,s.document=sd(t),s.updatedAt=l,this.update(s,...a);const c=new Mt({workflowId:e,name:t.name,document:sd(t),...d?{owner:d}:{},updatedAt:l});return this.create(c,...a)}async seedDocument(e,t,...o){const{log:r,ctxArgs:a}=(await this.logCtx(o,"seedDocument",!0)).for(this.seedDocument);try{return await this.saveDocument(e,t,...a)}catch(t){if(t instanceof d.ForbiddenError)return r.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:r}=(await this.logCtx(t,"getDocument",!0)).for(this.getDocument);let a;try{a=await this.read(e,...r)}catch{a=null}if(!a)throw new n.NotFoundError(`No graph workflow found for workflowId '${e}'`);if(this.assertOwnership(e,a,id(o)),a.document)return sd(a.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),r=await this.listBy("workflowId",d.OrderDirection.ASC,...o),a=id(t);return r.filter(e=>Qi(e,a,{allowAnonymousAccess:this.allowAnonymousAccess})).sort((e,t)=>ld(t.updatedAt)-ld(e.updatedAt))}async assertAccess(e,...t){const{ctx:o,ctxArgs:r}=(await this.logCtx(t,"assertAccess",!0)).for(this.assertAccess);let a;try{a=await this.read(e,...r)}catch{a=null}if(!a)throw new n.NotFoundError(`No graph workflow found for workflowId '${e}'`);return this.assertOwnership(e,a,id(o)),a}async validateDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateDocument",!0)).for(this.validateDocument);return await zi(e,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o)}async saveSnapshot(e,t,...o){const{ctx:r,ctxArgs:a}=(await this.logCtx(o,"saveSnapshot",!0)).for(this.saveSnapshot);if(!Ce(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(!dd(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=id(r),d=await this.readExistingForWrite(e,a);d&&this.assertWriteOwnership(e,d,i);const s=new Date;if(d)return d.snapshot=t,await this.applyCanonicalWrapper(d,t,r),d.updatedAt=s,this.update(d,...a);const l=new Mt({workflowId:e,snapshot:t,...i?{owner:i}:{},updatedAt:s});return await this.applyCanonicalWrapper(l,t,r),this.create(l,...a)}async loadSnapshot(e,...t){const{ctx:o,ctxArgs:r}=(await this.logCtx(t,"loadSnapshot",!0)).for(this.loadSnapshot);try{const t=await this.read(e,...r);return this.assertOwnership(e,t,id(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){Yi(t??null,o??null,{allowAnonymousAccess:this.allowAnonymousAccess,resourceKind:"Graph workflow",resourceId:e})}assertWriteOwnership(e,t,o){Xi(t??null,o??null,{resourceKind:"Graph workflow",resourceId:e})}async applyCanonicalWrapper(e,t,o){if(!dd(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 r=await zi(t.document,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o);if(!r.valid)throw new po(r.issues);e.document=sd(t.document),e.name=t.document.name}},e.GraphWorkflowService=i.__decorate([d.service(Mt),i.__metadata("design:paramtypes",[Function])],e.GraphWorkflowService),e.GraphRunModelService=class extends d.ModelService{constructor(){super(Gt)}async saveRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"saveRun",!0)).for(this.saveRun),r=td(e);let a;try{a=await super.read(e.runId,...o)}catch{a=null}if(a)return a.workflowId=r.workflowId,a.owner=r.owner,a.status=r.status,a.documentFingerprint=r.documentFingerprint,a.result=r.result,a.error=r.error,a.startedAt=r.startedAt,a.finishedAt=r.finishedAt,void await this.update(a,...o);await this.create(r,...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(Gt),i.__metadata("design:paramtypes",[])],e.GraphRunModelService),e.GraphNodeModelService=class extends d.ModelService{constructor(){super(jt)}async upsertManifest(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"upsertManifest",!0)).for(this.upsertManifest),r=(e=>new jt({kind:e.kind,name:e.display?.name,category:e.display?.category,group:e.display?.group,description:e.display?.description,manifest:pt(ct(e))}))(e);let a;try{a=await this.read(r.kind,...o)}catch{a=void 0}return a?(a.name=r.name,a.category=r.category,a.group=r.group,a.description=r.description,a.manifest=r.manifest,await this.update(a,...o)):await this.create(r,...o)}async syncFromCatalogue(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"syncFromCatalogue",!0)).for(this.syncFromCatalogue),r=e.listManifests(void 0,...o),a=[];for(const e of r)a.push(await this.upsertManifest(e,...o));return a}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 pt(ct(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(jt),i.__metadata("design:paramtypes",[])],e.GraphNodeModelService),e.ConditionExpressionEvaluator=Fo,e.DEFAULT_GRAPH_WORKFLOW_DOCUMENT_LIMITS=ra,e.DEFAULT_GRAPH_WORKFLOW_VALIDATION_LIMITS=Nr,e.DEFAULT_PINNING_METADATA=sr,e.DEFAULT_RAG_CHUNK_OVERLAP=200,e.DEFAULT_RAG_CHUNK_SIZE=1e3,e.GRAPH_AGENT_BASIC_CHAIN_NODES=Vn,e.GRAPH_AGENT_CHUNKING_NODES=Un,e.GRAPH_AGENT_DELEGATION_HOOK_NODES=An,e.GRAPH_AGENT_DISCORD_RESPONSE_NODES=si,e.GRAPH_AGENT_DISCORD_TRIGGER_NODES=ai,e.GRAPH_AGENT_EMBEDDING_NODES=Mn,e.GRAPH_AGENT_FAMILY_NODES=ki,e.GRAPH_AGENT_GUARDRAIL_NODES=ei,e.GRAPH_AGENT_HITL_NODES=ti,e.GRAPH_AGENT_HOOK_NODES=Nn,e.GRAPH_AGENT_INFORMATION_EXTRACTOR_NODES=Jn,e.GRAPH_AGENT_INPUT_PROCESSOR_NODES=Yn,e.GRAPH_AGENT_LANGCHAIN_CODE_NODES=Xn,e.GRAPH_AGENT_M5_NODES=Pi,e.GRAPH_AGENT_M6_NODES=Gi,e.GRAPH_AGENT_MCP_TRIGGER_NODES=oi,e.GRAPH_AGENT_MEMORY_NODES=Ti,e.GRAPH_AGENT_MEMORY_SELECTOR_NODES=Gn,e.GRAPH_AGENT_NODES=yn,e.GRAPH_AGENT_OUTPUT_PROCESSOR_NODES=Zn,e.GRAPH_AGENT_PROCESSOR_NODES=Di,e.GRAPH_AGENT_QA_CHAIN_NODES=Wn,e.GRAPH_AGENT_RAG_NODES=Ci,e.GRAPH_AGENT_RERANK_NODES=Bn,e.GRAPH_AGENT_RETRIEVER_NODES=Ln,e.GRAPH_AGENT_SANDBOX_NODES=xn,e.GRAPH_AGENT_SCORER_NODES=Rn,e.GRAPH_AGENT_SCORER_SELECTOR_NODES=On,e.GRAPH_AGENT_SKILL_NODES=En,e.GRAPH_AGENT_SKILL_SELECTOR_NODES=Sn,e.GRAPH_AGENT_SLACK_RESPONSE_NODES=di,e.GRAPH_AGENT_SLACK_TRIGGER_NODES=ri,e.GRAPH_AGENT_STRUCTURED_OUTPUT_PARSER_NODES=Qn,e.GRAPH_AGENT_SUMMARIZATION_CHAIN_NODES=Kn,e.GRAPH_AGENT_TEAMS_RESPONSE_NODES=ci,e.GRAPH_AGENT_TEAMS_TRIGGER_NODES=ii,e.GRAPH_AGENT_TELEGRAM_RESPONSE_NODES=li,e.GRAPH_AGENT_TELEGRAM_TRIGGER_NODES=ni,e.GRAPH_AGENT_TOOL_DENY_NODES=vn,e.GRAPH_AGENT_TOOL_NODES=bn,e.GRAPH_AGENT_TOOL_SELECTOR_NODES=wn,e.GRAPH_AGENT_VECTOR_STORE_NODES=jn,e.GRAPH_AGENT_VOICE_NODES=pi,e.GRAPH_BOUNDARY_NODES=Oi,e.GRAPH_BUILT_IN_NODE_CLASSES_BY_KIND=Li,e.GRAPH_BUILT_IN_NODE_MANIFESTS=vi,e.GRAPH_BUILT_IN_NODE_MANIFESTS_BY_KIND=Ei,e.GRAPH_CODE_DEFAULT_LANGUAGE=da,e.GRAPH_CODE_DEFAULT_TIMEOUT_MS=1e3,e.GRAPH_CODE_LANGUAGES=ia,e.GRAPH_CODE_MAX_TIMEOUT_MS=Vt,e.GRAPH_DATA_NODES=Mi,e.GRAPH_DATA_TABLE_MAX_LIST_ROWS=Yt,e.GRAPH_DATA_TABLE_MAX_ROWS=Jt,e.GRAPH_DATA_TABLE_MAX_ROW_BYTES=Xt,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=vr,e.GRAPH_EXECUTE_COMMAND_DEFAULT_TIMEOUT_MS=3e4,e.GRAPH_EXECUTE_COMMAND_MAX_OUTPUT_BYTES=Qt,e.GRAPH_EXECUTE_COMMAND_MAX_TIMEOUT_MS=6e4,e.GRAPH_FLOW_CONTROL_NODES=Ii,e.GRAPH_HTTP_MAX_REDIRECTS=5,e.GRAPH_HTTP_MAX_RESPONSE_BYTES=zt,e.GRAPH_HTTP_MAX_TIMEOUT_MS=Kt,e.GRAPH_IO_NODES=ji,e.GRAPH_LOCAL_EXECUTION_BACKEND=Ht,e.GRAPH_LOCAL_UNSUPPORTED_NODE_KIND=Ut,e.GRAPH_LOOP_KIND={FOREACH:"core.loop.foreach",WHILE:"core.loop.while",UNTIL:"core.loop.until"},e.GRAPH_LOOP_NODES=Ri,e.GRAPH_MAX_CHILD_RUNS=1e3,e.GRAPH_MAX_FOREACH_ITERATIONS=Wt,e.GRAPH_MAX_LOOP_ITERATIONS=Bt,e.GRAPH_MAX_SUB_WORKFLOW_DEPTH=10,e.GRAPH_PINNING_METADATA_KEY="graph.pinnable",e.GRAPH_PLAIN_SECRET_KEYS=er,e.GRAPH_TRIGGER_NODES=Si,e.GRAPH_UTILITY_NODES=xi,e.GRAPH_WORKFLOW_BOUNDARY=$t,e.GRAPH_WORKFLOW_FORBIDDEN_FIELD_KEYS=$i,e.GraphAuthValidator=Ro,e.GraphBreakSignal=lo,e.GraphConditionEvaluator=hi,e.GraphConnectionPolicyValidator=fr,e.GraphConnectionValidationError=br,e.GraphCredentialAuthorizationError=wr,e.GraphCredentialReferenceValidator=_r,e.GraphCycleError=oo,e.GraphDocumentValidationError=yr,e.GraphEdgeInstanceValidator=mr,e.GraphEngineEventSink=Mo,e.GraphEnvironment=aa,e.GraphExecutionBackendRegistry=Lo,e.GraphExecutionContext=Do,e.GraphExecutionEngine=jr,e.GraphExecutionError=to,e.GraphExecutionEventEmitter=uo,e.GraphExecutionEventFactory=go,e.GraphExecutionFrame=Po,e.GraphExecutionSnapshotMapper=class{map(e){const t={};for(const[o,r]of Object.entries(e.nodeResults))t[o]={status:r.status,startedAt:r.startedAt?.toISOString(),finishedAt:r.finishedAt?.toISOString(),error:r.error,outputs:r.outputs,fromCache:r.fromCache,pinned:r.pinned};const o={};for(const t of e.events)t.edgeId&&"edge.valueRouted"===t.type&&(o[t.edgeId]={status:Y.SUCCEEDED,lastValue:t.payload?.value,updatedAt:t.timestamp.toISOString()});const r=[...e.events];return{runId:e.runId,status:e.status,nodes:t,edges:o,outputs:e.outputs,events:r}}},e.GraphInputError=ro,e.GraphLoopExecutionContext=class{constructor(e,t){this.iteration=e,this.metadata=t}},e.GraphLoopLimitError=ao,e.GraphNode=ta,e.GraphNodeCredentialResolver=Oo,e.GraphNodeInstanceValidator=gr,e.GraphNodeManifestResolver=Qr,e.GraphNodeMethodNotFoundError=Hr,e.GraphNodeMethodRegistry=Ur,e.GraphNodeNotFoundError=$r,e.GraphNodeRegistrationError=qr,e.GraphParameterValidator=tr,e.GraphPinningDependencyResolver=pr,e.GraphPinningError=no,e.GraphPinningPolicy=cr,e.GraphPinningService=dr,e.GraphPortError=class extends to{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=co,e.GraphRunEventPublisher=rd,e.GraphRunExecutor=ad,e.GraphRunService=class{constructor(e,t,o,r={}){this.activeByCaller=new Map,this.callerKeysByRun=new Map,this.releaseTimers=new Map,this.engine=e,this.runStore=t,this.eventStore=o,this.publisher=new rd(o,r.limits),this.executor=new ad(e,t,this.publisher,{onRunCompleted:r.onRunCompleted},r.limits),this.options={...r,limits:{...oe,...r.limits}}}get limits(){return this.options.limits}async createRun(e,t,o,...r){this.validateCreateRequest(e);const a=e.workflowId??e.workflow?.id??"";if(!a)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:a,ownerUser:t,status:"queued",createdAt:(new Date).toISOString()};this.executor.begin(s),await this.runStore.saveRun({...l},...r);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??{},...r).catch(()=>{}).finally(()=>this.finishActiveRun(s)),l}async getRun(e,t,...o){const r=await this.runStore.readRun(e,...o);if(!r)throw new n.NotFoundError(`No graph run found for runId '${e}'`);return this.assertOwnership(r,t),r}async listRunsByWorkflow(e,t,...o){return(await this.runStore.listRuns(e,...o)).filter(e=>Qi({owner:e.owner},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess})).sort((e,t)=>{const o=e.updatedAt instanceof Date?e.updatedAt.getTime():NaN,r=t.updatedAt instanceof Date?t.updatedAt.getTime():NaN;return(Number.isFinite(r)?r:0)-(Number.isFinite(o)?o:0)})}async cancelRun(e,t,...o){const r=await this.runStore.readRun(e,...o);if(!r)throw new n.NotFoundError(`No graph run found for runId '${e}'`);return this.assertWriteOwnership(r,t),"succeeded"===(a=r.status)||"failed"===a||"cancelled"===a||(this.executor.abort(e,"user"),r.status="cancelled",r.finishedAt=(new Date).toISOString(),await this.runStore.saveRun({...r},...o)),r;var a}async resumeRun(e,t,o,...r){const a=await this.runStore.readRun(e,...r);if(!a)throw new n.NotFoundError(`No graph run found for runId '${e}'`);this.assertWriteOwnership(a,o);const i=this.engine.backend,d=i.resume;if("function"!=typeof d)throw new to(`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,...r)}catch(e){throw(l=e)instanceof to?new to(l.message,l.graphCode):l}var l;const c={...s,runId:e,caller:o};return await this.publisher.publish({runId:e,workflowId:a.workflowId,type:te.WORKFLOW_RESUMED,payload:c}),c}async listEvents(e,t,o,...r){return await this.getRun(e,o,...r),this.eventStore.listAfter(e,t)}async subscribeEvents(e,t,o,...r){return await this.getRun(e,t,...r),this.eventStore.subscribe(e,o)}subscribeRunEvents(e,t){return this.eventStore.subscribe(e.runId,t)}async waitForRun(e,t,...o){const r=this.executor.waitFor(e);return r&&await r,this.getRun(e,t,...o)}async executeAndWait(e,t,o,...r){const a=await this.createRun(e,t,o,...r);return this.waitForRun(a.runId,t,...r)}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&&!at(e.workflow))throw new n.ValidationError("Graph run request carries a payload that is not a canonical GraphWorkflowDocument");if(void 0!==e.inputs&&!Ce(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 r=(e=>{try{return JSON.stringify(e)?.length??0}catch{return Number.MAX_SAFE_INTEGER}})(e);if(r>this.options.limits.maxRequestBytes)throw new n.ValidationError(`Graph run request of ${r} 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:ed(t)})}const o=e.workflowId;return async(...e)=>{const r=this.options.documentResolver;if(!r)throw new n.ValidationError("Graph run requests by workflowId require a document resolver");const a=await r.resolve(o,t,...e);return{document:a,fingerprint:ed(a)}}}assertOwnership(e,t){Yi({owner:e.ownerUser},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess,resourceKind:"Graph run",resourceId:e.runId})}assertWriteOwnership(e,t){Xi({owner:e.ownerUser},t,{resourceKind:"Graph run",resourceId:e.runId})}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new io("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime",{runtime:typeof globalThis.crypto});return e.randomUUID()}},e.GraphStoreError=io,e.GraphTopology=ir,e.GraphTopologyError=so,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 r of e){const e=Object.prototype.hasOwnProperty.call(t,r.name);if(r.required&&!e)throw new ro(`Missing required ${o} port '${r.name}'`);if(e&&!this.resolver.resolve(r).validate(t[r.name]))throw new ro(`Invalid value for ${o} port '${r.name}'`)}}},e.GraphWebhookResponseRegistry=Ir,e.GraphWorkflowDocumentRejectedError=po,e.GraphWorkflowDocumentValidator=Sr,e.InMemoryGraphRunEventStore=class{constructor(e={}){this.events=new Map,this.listeners=new Map,this.limits={...oe,...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=>!ae(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=>td(e))}release(e){this.runs.delete(e)}},e.IsolatedVmCodeSandboxEvaluator=Fr,e.LocalGraphExecutionBackend=ur,e.MASTRA_AGENT_ZONE=fn,e.MASTRA_AGENT_ZONES=_n,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=Ja,e.assertGraphResourceOwnership=Yi,e.assertGraphResourceWriteOwnership=Xi,e.buildGraphExecutionResult=Go,e.builtInGraphNodeRegistrations=qi,e.canAccessGraphResource=Qi,e.canAccessGraphResourcePayload=Ji,e.checkGraphValueAgainstSchema=Jo,e.chunkText=$n,e.clampGraphCodeTimeoutMs=na,e.clampSandboxTimeoutMs=In,e.collectLooseNodeIssues=hr,e.composeGraphNamespace=mo,e.createGraphDataTableRepository=Dr,e.createGraphValueRepository=nr,e.declaredGraphNodeMethods=e=>e.methods??[],e.decomposeGraphNamespace=ho,e.decomposeGraphNamespaces=Io,e.defineGraphNode=Zr,e.detectGraphCodeModeSurfaces=zo,e.evaluateCodeCondition=Ho,e.evaluateCondition=Bo,e.evaluateConditionSync=Uo,e.extractChunkTexts=Hn,e.findMalformedGraphNamespaces=wo,e.findUngrantedGraphNamespaces=bo,e.graphAuthDataFromRecord=Eo,e.graphAuthDataOf=So,e.graphDocumentHasCodeMode=e=>zo(e).length>0,e.graphNamespaceCovers=yo,e.graphNamespacePartsOf=_o,e.graphNodeConfig=ea,e.graphRolesFromNamespaces=No,e.graphRunDocumentFingerprint=ed,e.graphWorkflowOwnerOf=id,e.isCodeCondition=qo,e.isConditionExpression=$o,e.isGraphCredentialReferenceLike=Yo,e.isGraphNamespaceCacheEntryValid=fo,e.isGraphResolvedWorkflow=Ar,e.isPinnable=lr,e.mergeGraphAuthData=xo,e.registerBuiltInGraphNodes=(e,...t)=>{for(const o of qi())e.register(o,{},...t);return e},e.resolveGraphBackendCapabilities=jo,e.resolveGraphDynamicPorts=Kr,e.resolveGraphNodeManifest=zr,e.resolveNodeCredential=ko,e.serializeGraphValueKey=or,e.stripFacadeOwnedBackendConfig=Mr,e.validateGraphWorkflowDocumentAtBoundary=zi},"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("@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/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/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("@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","@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/io/google-sheets","@decaf-ts/integrations/io/airtable","@decaf-ts/integrations/io/spreadsheet","@decaf-ts/integrations/io/graphql","@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","@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.blob,e.s3,e.http,e.gcp,e.azure,e.slack,e.telegram,e.teams,e.gmail,e.email,e.googleSheets,e.airtable,e.spreadsheet,e.graphql,e.github,e.gitlab,e.crypto,e.jwt,e.node_child_process,e.sftp);
2
2
  //# sourceMappingURL=as-graph.cjs.map