@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.
- package/README.md +834 -38
- package/assets/i18n/en.json +2527 -32
- package/dist/as-graph.cjs +1 -1
- package/dist/as-graph.cjs.map +1 -1
- package/dist/as-graph.js +1 -1
- package/dist/as-graph.js.map +1 -1
- package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs +102 -11
- package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs.map +1 -1
- package/lib/cjs/engine/auth/GraphAuthValidator.cjs +19 -0
- package/lib/cjs/engine/auth/GraphAuthValidator.cjs.map +1 -1
- package/lib/cjs/engine/constants.cjs +61 -1
- package/lib/cjs/engine/constants.cjs.map +1 -1
- package/lib/cjs/engine/credentials/GraphNodeCredentials.cjs +158 -0
- package/lib/cjs/engine/credentials/GraphNodeCredentials.cjs.map +1 -0
- package/lib/cjs/engine/execution/GraphExecutionEngine.cjs +235 -67
- package/lib/cjs/engine/execution/GraphExecutionEngine.cjs.map +1 -1
- package/lib/cjs/engine/execution/GraphNodeEngineRequirements.cjs +33 -0
- package/lib/cjs/engine/execution/GraphNodeEngineRequirements.cjs.map +1 -0
- package/lib/cjs/engine/execution/GraphWebhookResponseRegistry.cjs +108 -0
- package/lib/cjs/engine/execution/GraphWebhookResponseRegistry.cjs.map +1 -0
- package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs +92 -1
- package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs.map +1 -1
- package/lib/cjs/engine/execution/index.cjs +1 -0
- package/lib/cjs/engine/execution/index.cjs.map +1 -1
- package/lib/cjs/engine/index.cjs +5 -0
- package/lib/cjs/engine/index.cjs.map +1 -1
- package/lib/cjs/engine/services/GraphNodeModelService.cjs +129 -0
- package/lib/cjs/engine/services/GraphNodeModelService.cjs.map +1 -0
- package/lib/cjs/engine/services/GraphWorkflowService.cjs +33 -0
- package/lib/cjs/engine/services/GraphWorkflowService.cjs.map +1 -1
- package/lib/cjs/engine/store/GraphDataTableModel.cjs +76 -0
- package/lib/cjs/engine/store/GraphDataTableModel.cjs.map +1 -0
- package/lib/cjs/engine/store/GraphDataTableRepository.cjs +324 -0
- package/lib/cjs/engine/store/GraphDataTableRepository.cjs.map +1 -0
- package/lib/cjs/engine/store/index.cjs +2 -0
- package/lib/cjs/engine/store/index.cjs.map +1 -1
- package/lib/cjs/engine/validation/GraphConnectionPolicyValidator.cjs +28 -0
- package/lib/cjs/engine/validation/GraphConnectionPolicyValidator.cjs.map +1 -1
- package/lib/cjs/engine/validation/GraphCredentialReferenceValidator.cjs +4 -2
- package/lib/cjs/engine/validation/GraphCredentialReferenceValidator.cjs.map +1 -1
- package/lib/cjs/engine/validation/GraphParameterValidator.cjs +6 -0
- package/lib/cjs/engine/validation/GraphParameterValidator.cjs.map +1 -1
- package/lib/cjs/mastra/MastraAgeVectorDriver.cjs +298 -0
- package/lib/cjs/mastra/MastraAgeVectorDriver.cjs.map +1 -0
- package/lib/cjs/mastra/MastraAgentBuilder.cjs +249 -0
- package/lib/cjs/mastra/MastraAgentBuilder.cjs.map +1 -0
- package/lib/cjs/mastra/MastraAgentModelAdapter.cjs +65 -0
- package/lib/cjs/mastra/MastraAgentModelAdapter.cjs.map +1 -0
- package/lib/cjs/mastra/MastraAgentProcessors.cjs +397 -0
- package/lib/cjs/mastra/MastraAgentProcessors.cjs.map +1 -0
- package/lib/cjs/mastra/MastraAgentStepHandler.cjs +332 -0
- package/lib/cjs/mastra/MastraAgentStepHandler.cjs.map +1 -0
- package/lib/cjs/mastra/MastraCapabilities.cjs +115 -0
- package/lib/cjs/mastra/MastraCapabilities.cjs.map +1 -1
- package/lib/cjs/mastra/MastraChannelResponse.cjs +162 -0
- package/lib/cjs/mastra/MastraChannelResponse.cjs.map +1 -0
- package/lib/cjs/mastra/MastraChannelTrigger.cjs +124 -0
- package/lib/cjs/mastra/MastraChannelTrigger.cjs.map +1 -0
- package/lib/cjs/mastra/MastraDefaultStepHandlers.cjs +435 -0
- package/lib/cjs/mastra/MastraDefaultStepHandlers.cjs.map +1 -0
- package/lib/cjs/mastra/MastraEnvironment.cjs +297 -0
- package/lib/cjs/mastra/MastraEnvironment.cjs.map +1 -0
- package/lib/cjs/mastra/MastraEvalModels.cjs +546 -0
- package/lib/cjs/mastra/MastraEvalModels.cjs.map +1 -0
- package/lib/cjs/mastra/MastraEventBridge.cjs +31 -4
- package/lib/cjs/mastra/MastraEventBridge.cjs.map +1 -1
- package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs +513 -20
- package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs.map +1 -1
- package/lib/cjs/mastra/MastraGraphExecutionModule.cjs +148 -0
- package/lib/cjs/mastra/MastraGraphExecutionModule.cjs.map +1 -0
- package/lib/cjs/mastra/MastraHitlStepHandler.cjs +67 -0
- package/lib/cjs/mastra/MastraHitlStepHandler.cjs.map +1 -0
- package/lib/cjs/mastra/MastraMcpTrigger.cjs +254 -0
- package/lib/cjs/mastra/MastraMcpTrigger.cjs.map +1 -0
- package/lib/cjs/mastra/MastraMemory.cjs +467 -0
- package/lib/cjs/mastra/MastraMemory.cjs.map +1 -0
- package/lib/cjs/mastra/MastraMetricsAdapter.cjs +279 -0
- package/lib/cjs/mastra/MastraMetricsAdapter.cjs.map +1 -0
- package/lib/cjs/mastra/MastraMetricsGateway.cjs +404 -0
- package/lib/cjs/mastra/MastraMetricsGateway.cjs.map +1 -0
- package/lib/cjs/mastra/MastraMetricsModels.cjs +498 -0
- package/lib/cjs/mastra/MastraMetricsModels.cjs.map +1 -0
- package/lib/cjs/mastra/MastraMetricsStatement.cjs +220 -0
- package/lib/cjs/mastra/MastraMetricsStatement.cjs.map +1 -0
- package/lib/cjs/mastra/MastraModelSchemaConverter.cjs +84 -0
- package/lib/cjs/mastra/MastraModelSchemaConverter.cjs.map +1 -0
- package/lib/cjs/mastra/MastraObservability.cjs +335 -0
- package/lib/cjs/mastra/MastraObservability.cjs.map +1 -0
- package/lib/cjs/mastra/MastraPersistence.cjs +545 -0
- package/lib/cjs/mastra/MastraPersistence.cjs.map +1 -0
- package/lib/cjs/mastra/MastraRagStepHandlers.cjs +927 -0
- package/lib/cjs/mastra/MastraRagStepHandlers.cjs.map +1 -0
- package/lib/cjs/mastra/MastraRunMetricsEndpoint.cjs +153 -0
- package/lib/cjs/mastra/MastraRunMetricsEndpoint.cjs.map +1 -0
- package/lib/cjs/mastra/MastraRunRecovery.cjs +94 -0
- package/lib/cjs/mastra/MastraRunRecovery.cjs.map +1 -0
- package/lib/cjs/mastra/MastraScheduleTrigger.cjs +115 -0
- package/lib/cjs/mastra/MastraScheduleTrigger.cjs.map +1 -0
- package/lib/cjs/mastra/MastraStorageWiring.cjs +125 -0
- package/lib/cjs/mastra/MastraStorageWiring.cjs.map +1 -0
- package/lib/cjs/mastra/MastraStructuredOutput.cjs +152 -0
- package/lib/cjs/mastra/MastraStructuredOutput.cjs.map +1 -0
- package/lib/cjs/mastra/MastraToolBuilder.cjs +73 -0
- package/lib/cjs/mastra/MastraToolBuilder.cjs.map +1 -0
- package/lib/cjs/mastra/MastraToolConfig.cjs +42 -0
- package/lib/cjs/mastra/MastraToolConfig.cjs.map +1 -0
- package/lib/cjs/mastra/MastraToolDecorator.cjs +99 -0
- package/lib/cjs/mastra/MastraToolDecorator.cjs.map +1 -0
- package/lib/cjs/mastra/MastraVectorStore.cjs +618 -0
- package/lib/cjs/mastra/MastraVectorStore.cjs.map +1 -0
- package/lib/cjs/mastra/MastraVoiceStepHandler.cjs +90 -0
- package/lib/cjs/mastra/MastraVoiceStepHandler.cjs.map +1 -0
- package/lib/cjs/mastra/MastraWorkflowCompiler.cjs +41 -9
- package/lib/cjs/mastra/MastraWorkflowCompiler.cjs.map +1 -1
- package/lib/cjs/mastra/MastraWorkflowManager.cjs +100 -50
- package/lib/cjs/mastra/MastraWorkflowManager.cjs.map +1 -1
- package/lib/cjs/mastra/index.cjs +41 -1
- package/lib/cjs/mastra/index.cjs.map +1 -1
- package/lib/cjs/mastra/nodes/MastraNodeRegistry.cjs +232 -0
- package/lib/cjs/mastra/nodes/MastraNodeRegistry.cjs.map +1 -0
- package/lib/cjs/mastra/nodes/index.cjs +29 -0
- package/lib/cjs/mastra/nodes/index.cjs.map +1 -0
- package/lib/cjs/mastra/nodes/types.cjs +4 -0
- package/lib/cjs/mastra/nodes/types.cjs.map +1 -0
- package/lib/cjs/mastra/types.cjs +130 -1
- package/lib/cjs/mastra/types.cjs.map +1 -1
- package/lib/cjs/nest/graph/GraphBackendHost.cjs +117 -23
- package/lib/cjs/nest/graph/GraphBackendHost.cjs.map +1 -1
- package/lib/cjs/nest/graph/GraphExecutionModule.cjs +72 -2
- package/lib/cjs/nest/graph/GraphExecutionModule.cjs.map +1 -1
- package/lib/cjs/nest/graph/GraphRunController.cjs +47 -6
- package/lib/cjs/nest/graph/GraphRunController.cjs.map +1 -1
- package/lib/cjs/nest/graph/main.cjs +99 -2
- package/lib/cjs/nest/graph/main.cjs.map +1 -1
- package/lib/cjs/node/agents/agent/node.cjs +189 -31
- package/lib/cjs/node/agents/agent/node.cjs.map +1 -1
- package/lib/cjs/node/agents/hitl/node.cjs +115 -0
- package/lib/cjs/node/agents/hitl/node.cjs.map +1 -0
- package/lib/cjs/node/agents/hooks/delegation/node.cjs +122 -0
- package/lib/cjs/node/agents/hooks/delegation/node.cjs.map +1 -0
- package/lib/cjs/node/agents/hooks/hook/node.cjs +120 -0
- package/lib/cjs/node/agents/hooks/hook/node.cjs.map +1 -0
- package/lib/cjs/node/agents/hooks/tool-deny/node.cjs +104 -0
- package/lib/cjs/node/agents/hooks/tool-deny/node.cjs.map +1 -0
- package/lib/cjs/node/agents/memory/memory/node.cjs +231 -0
- package/lib/cjs/node/agents/memory/memory/node.cjs.map +1 -0
- package/lib/cjs/node/agents/memory/memory-selector/node.cjs +101 -0
- package/lib/cjs/node/agents/memory/memory-selector/node.cjs.map +1 -0
- package/lib/cjs/node/agents/processors/guardrail/node.cjs +126 -0
- package/lib/cjs/node/agents/processors/guardrail/node.cjs.map +1 -0
- package/lib/cjs/node/agents/processors/input-processor/node.cjs +118 -0
- package/lib/cjs/node/agents/processors/input-processor/node.cjs.map +1 -0
- package/lib/cjs/node/agents/processors/output-processor/node.cjs +108 -0
- package/lib/cjs/node/agents/processors/output-processor/node.cjs.map +1 -0
- package/lib/cjs/node/agents/processors/types.cjs +68 -0
- package/lib/cjs/node/agents/processors/types.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/chains/basic/node.cjs +103 -0
- package/lib/cjs/node/agents/rag/chains/basic/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/chains/qa/node.cjs +124 -0
- package/lib/cjs/node/agents/rag/chains/qa/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/chains/summarization/node.cjs +116 -0
- package/lib/cjs/node/agents/rag/chains/summarization/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/chunking/node.cjs +222 -0
- package/lib/cjs/node/agents/rag/chunking/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/embedding/node.cjs +110 -0
- package/lib/cjs/node/agents/rag/embedding/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/information-extractor/node.cjs +115 -0
- package/lib/cjs/node/agents/rag/information-extractor/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/langchain-code/node.cjs +113 -0
- package/lib/cjs/node/agents/rag/langchain-code/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/rerank/node.cjs +112 -0
- package/lib/cjs/node/agents/rag/rerank/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/retriever/node.cjs +120 -0
- package/lib/cjs/node/agents/rag/retriever/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/structured-output-parser/node.cjs +121 -0
- package/lib/cjs/node/agents/rag/structured-output-parser/node.cjs.map +1 -0
- package/lib/cjs/node/agents/rag/vector-store/node.cjs +187 -0
- package/lib/cjs/node/agents/rag/vector-store/node.cjs.map +1 -0
- package/lib/cjs/node/agents/responses/discord/node.cjs +101 -0
- package/lib/cjs/node/agents/responses/discord/node.cjs.map +1 -0
- package/lib/cjs/node/agents/responses/slack/node.cjs +101 -0
- package/lib/cjs/node/agents/responses/slack/node.cjs.map +1 -0
- package/lib/cjs/node/agents/responses/teams/node.cjs +101 -0
- package/lib/cjs/node/agents/responses/teams/node.cjs.map +1 -0
- package/lib/cjs/node/agents/responses/telegram/node.cjs +101 -0
- package/lib/cjs/node/agents/responses/telegram/node.cjs.map +1 -0
- package/lib/cjs/node/agents/sandbox/node.cjs +135 -0
- package/lib/cjs/node/agents/sandbox/node.cjs.map +1 -0
- package/lib/cjs/node/agents/scorers/scorer/node.cjs +107 -0
- package/lib/cjs/node/agents/scorers/scorer/node.cjs.map +1 -0
- package/lib/cjs/node/agents/scorers/scorer-selector/node.cjs +100 -0
- package/lib/cjs/node/agents/scorers/scorer-selector/node.cjs.map +1 -0
- package/lib/cjs/node/agents/skills/skill/node.cjs +105 -0
- package/lib/cjs/node/agents/skills/skill/node.cjs.map +1 -0
- package/lib/cjs/node/agents/skills/skill-selector/node.cjs +98 -0
- package/lib/cjs/node/agents/skills/skill-selector/node.cjs.map +1 -0
- package/lib/cjs/node/agents/tools/tool/node.cjs +100 -0
- package/lib/cjs/node/agents/tools/tool/node.cjs.map +1 -0
- package/lib/cjs/node/agents/tools/tool-selector/node.cjs +99 -0
- package/lib/cjs/node/agents/tools/tool-selector/node.cjs.map +1 -0
- package/lib/cjs/node/agents/triggers/discord/node.cjs +101 -0
- package/lib/cjs/node/agents/triggers/discord/node.cjs.map +1 -0
- package/lib/cjs/node/agents/triggers/mcp-server/node.cjs +147 -0
- package/lib/cjs/node/agents/triggers/mcp-server/node.cjs.map +1 -0
- package/lib/cjs/node/agents/triggers/slack/node.cjs +101 -0
- package/lib/cjs/node/agents/triggers/slack/node.cjs.map +1 -0
- package/lib/cjs/node/agents/triggers/teams/node.cjs +101 -0
- package/lib/cjs/node/agents/triggers/teams/node.cjs.map +1 -0
- package/lib/cjs/node/agents/triggers/telegram/node.cjs +101 -0
- package/lib/cjs/node/agents/triggers/telegram/node.cjs.map +1 -0
- package/lib/cjs/node/agents/voice/node.cjs +107 -0
- package/lib/cjs/node/agents/voice/node.cjs.map +1 -0
- package/lib/cjs/node/agents/zones.cjs +43 -0
- package/lib/cjs/node/agents/zones.cjs.map +1 -0
- package/lib/cjs/node/comms/email-send/node.cjs +340 -0
- package/lib/cjs/node/comms/email-send/node.cjs.map +1 -0
- package/lib/cjs/node/comms/gmail/node.cjs +287 -0
- package/lib/cjs/node/comms/gmail/node.cjs.map +1 -0
- package/lib/cjs/node/comms/slack/node.cjs +276 -0
- package/lib/cjs/node/comms/slack/node.cjs.map +1 -0
- package/lib/cjs/node/comms/teams/node.cjs +231 -0
- package/lib/cjs/node/comms/teams/node.cjs.map +1 -0
- package/lib/cjs/node/comms/telegram/node.cjs +260 -0
- package/lib/cjs/node/comms/telegram/node.cjs.map +1 -0
- package/lib/cjs/node/credentials.cjs +103 -0
- package/lib/cjs/node/credentials.cjs.map +1 -0
- package/lib/cjs/node/data/data-table/node.cjs +265 -0
- package/lib/cjs/node/data/data-table/node.cjs.map +1 -0
- package/lib/cjs/node/data/date-time/node.cjs +180 -0
- package/lib/cjs/node/data/date-time/node.cjs.map +1 -0
- package/lib/cjs/node/data/filter/node.cjs +134 -0
- package/lib/cjs/node/data/filter/node.cjs.map +1 -0
- package/lib/cjs/node/data/limit/node.cjs +104 -0
- package/lib/cjs/node/data/limit/node.cjs.map +1 -0
- package/lib/cjs/node/data/merge/node.cjs +251 -0
- package/lib/cjs/node/data/merge/node.cjs.map +1 -0
- package/lib/cjs/node/data/rename-keys/node.cjs +139 -0
- package/lib/cjs/node/data/rename-keys/node.cjs.map +1 -0
- package/lib/cjs/node/data/set/node.cjs +148 -0
- package/lib/cjs/node/data/set/node.cjs.map +1 -0
- package/lib/cjs/node/data/sort/node.cjs +125 -0
- package/lib/cjs/node/data/sort/node.cjs.map +1 -0
- package/lib/cjs/node/data/split-out/node.cjs +140 -0
- package/lib/cjs/node/data/split-out/node.cjs.map +1 -0
- package/lib/cjs/node/data/support.cjs +398 -0
- package/lib/cjs/node/data/support.cjs.map +1 -0
- package/lib/cjs/node/devops/crypto/node.cjs +364 -0
- package/lib/cjs/node/devops/crypto/node.cjs.map +1 -0
- package/lib/cjs/node/devops/execute-command/node.cjs +201 -0
- package/lib/cjs/node/devops/execute-command/node.cjs.map +1 -0
- package/lib/cjs/node/devops/ftp/node.cjs +241 -0
- package/lib/cjs/node/devops/ftp/node.cjs.map +1 -0
- package/lib/cjs/node/devops/github/node.cjs +282 -0
- package/lib/cjs/node/devops/github/node.cjs.map +1 -0
- package/lib/cjs/node/devops/gitlab/node.cjs +273 -0
- package/lib/cjs/node/devops/gitlab/node.cjs.map +1 -0
- package/lib/cjs/node/devops/jwt/node.cjs +204 -0
- package/lib/cjs/node/devops/jwt/node.cjs.map +1 -0
- package/lib/cjs/node/flow/execute-sub-workflow/node.cjs +223 -0
- package/lib/cjs/node/flow/execute-sub-workflow/node.cjs.map +1 -0
- package/lib/cjs/node/index.cjs +402 -66
- package/lib/cjs/node/index.cjs.map +1 -1
- package/lib/cjs/node/io/airtable/node.cjs +318 -0
- package/lib/cjs/node/io/airtable/node.cjs.map +1 -0
- package/lib/cjs/node/io/extract-from-file/node.cjs +269 -0
- package/lib/cjs/node/io/extract-from-file/node.cjs.map +1 -0
- package/lib/cjs/node/io/google-sheets/node.cjs +267 -0
- package/lib/cjs/node/io/google-sheets/node.cjs.map +1 -0
- package/lib/cjs/node/io/graphql/node.cjs +169 -0
- package/lib/cjs/node/io/graphql/node.cjs.map +1 -0
- package/lib/cjs/node/io/http-request/node.cjs +415 -0
- package/lib/cjs/node/io/http-request/node.cjs.map +1 -0
- package/lib/cjs/node/io/read-pdf/node.cjs +206 -0
- package/lib/cjs/node/io/read-pdf/node.cjs.map +1 -0
- package/lib/cjs/node/io/read-write-file/node.cjs +314 -0
- package/lib/cjs/node/io/read-write-file/node.cjs.map +1 -0
- package/lib/cjs/node/io/respond-to-webhook/node.cjs +183 -0
- package/lib/cjs/node/io/respond-to-webhook/node.cjs.map +1 -0
- package/lib/cjs/node/io/spreadsheet-file/node.cjs +192 -0
- package/lib/cjs/node/io/spreadsheet-file/node.cjs.map +1 -0
- package/lib/cjs/node/manifests.cjs +264 -36
- package/lib/cjs/node/manifests.cjs.map +1 -1
- package/lib/cjs/node/storage/blob/azure/node.cjs +138 -0
- package/lib/cjs/node/storage/blob/azure/node.cjs.map +1 -0
- package/lib/cjs/node/storage/blob/base.cjs +321 -0
- package/lib/cjs/node/storage/blob/base.cjs.map +1 -0
- package/lib/cjs/node/storage/blob/gcs/node.cjs +126 -0
- package/lib/cjs/node/storage/blob/gcs/node.cjs.map +1 -0
- package/lib/cjs/node/storage/blob/s3/node.cjs +186 -0
- package/lib/cjs/node/storage/blob/s3/node.cjs.map +1 -0
- package/lib/cjs/node/storage/database/base.cjs +301 -0
- package/lib/cjs/node/storage/database/base.cjs.map +1 -0
- package/lib/cjs/node/storage/database/mssql/node.cjs +50 -0
- package/lib/cjs/node/storage/database/mssql/node.cjs.map +1 -0
- package/lib/cjs/node/storage/database/mysql/node.cjs +50 -0
- package/lib/cjs/node/storage/database/mysql/node.cjs.map +1 -0
- package/lib/cjs/node/storage/database/postgres/node.cjs +50 -0
- package/lib/cjs/node/storage/database/postgres/node.cjs.map +1 -0
- package/lib/cjs/node/storage/redis/node.cjs +340 -0
- package/lib/cjs/node/storage/redis/node.cjs.map +1 -0
- package/lib/cjs/node/storage/support.cjs +81 -0
- package/lib/cjs/node/storage/support.cjs.map +1 -0
- package/lib/cjs/node/triggers/execute-workflow/node.cjs +94 -0
- package/lib/cjs/node/triggers/execute-workflow/node.cjs.map +1 -0
- package/lib/cjs/ram/GraphNodeRepository.cjs +40 -0
- package/lib/cjs/ram/GraphNodeRepository.cjs.map +1 -0
- package/lib/cjs/ram/GraphRunEventModel.cjs +4 -0
- package/lib/cjs/ram/GraphRunEventModel.cjs.map +1 -1
- package/lib/cjs/ram/index.cjs +1 -0
- package/lib/cjs/ram/index.cjs.map +1 -1
- package/lib/cjs/shared/graph/GraphNodeConverters.cjs +43 -0
- package/lib/cjs/shared/graph/GraphNodeConverters.cjs.map +1 -0
- package/lib/cjs/shared/graph/GraphNodeModel.cjs +78 -0
- package/lib/cjs/shared/graph/GraphNodeModel.cjs.map +1 -0
- package/lib/cjs/shared/graph/GraphWorkflowModel.cjs +4 -0
- package/lib/cjs/shared/graph/GraphWorkflowModel.cjs.map +1 -1
- package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs +40 -0
- package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs.map +1 -1
- package/lib/cjs/shared/graph/category-styles.cjs +12 -0
- package/lib/cjs/shared/graph/category-styles.cjs.map +1 -1
- package/lib/cjs/shared/graph/index.cjs +2 -0
- package/lib/cjs/shared/graph/index.cjs.map +1 -1
- package/lib/cjs/typeorm/TypeormGraphAdapter.cjs +250 -0
- package/lib/cjs/typeorm/TypeormGraphAdapter.cjs.map +1 -0
- package/lib/cjs/typeorm/index.cjs +29 -0
- package/lib/cjs/typeorm/index.cjs.map +1 -0
- package/lib/esm/dagster/DagsterGraphExecutionBackend.js +102 -11
- package/lib/esm/dagster/DagsterGraphExecutionBackend.js.map +1 -1
- package/lib/esm/engine/auth/GraphAuthValidator.js +19 -0
- package/lib/esm/engine/auth/GraphAuthValidator.js.map +1 -1
- package/lib/esm/engine/constants.js +60 -0
- package/lib/esm/engine/constants.js.map +1 -1
- package/lib/esm/engine/credentials/GraphNodeCredentials.js +152 -0
- package/lib/esm/engine/credentials/GraphNodeCredentials.js.map +1 -0
- package/lib/esm/engine/execution/GraphExecutionBackend.js.map +1 -1
- package/lib/esm/engine/execution/GraphExecutionEngine.js +236 -68
- package/lib/esm/engine/execution/GraphExecutionEngine.js.map +1 -1
- package/lib/esm/engine/execution/GraphNodeEngineRequirements.js +28 -0
- package/lib/esm/engine/execution/GraphNodeEngineRequirements.js.map +1 -0
- package/lib/esm/engine/execution/GraphWebhookResponseRegistry.js +103 -0
- package/lib/esm/engine/execution/GraphWebhookResponseRegistry.js.map +1 -0
- package/lib/esm/engine/execution/LocalGraphExecutionBackend.js +93 -2
- package/lib/esm/engine/execution/LocalGraphExecutionBackend.js.map +1 -1
- package/lib/esm/engine/execution/index.js +1 -0
- package/lib/esm/engine/execution/index.js.map +1 -1
- package/lib/esm/engine/index.js +5 -0
- package/lib/esm/engine/index.js.map +1 -1
- package/lib/esm/engine/services/GraphNodeModelService.js +120 -0
- package/lib/esm/engine/services/GraphNodeModelService.js.map +1 -0
- package/lib/esm/engine/services/GraphWorkflowService.js +34 -1
- package/lib/esm/engine/services/GraphWorkflowService.js.map +1 -1
- package/lib/esm/engine/store/GraphDataTableModel.js +67 -0
- package/lib/esm/engine/store/GraphDataTableModel.js.map +1 -0
- package/lib/esm/engine/store/GraphDataTableRepository.js +314 -0
- package/lib/esm/engine/store/GraphDataTableRepository.js.map +1 -0
- package/lib/esm/engine/store/index.js +2 -0
- package/lib/esm/engine/store/index.js.map +1 -1
- package/lib/esm/engine/validation/GraphConnectionPolicyValidator.js +28 -0
- package/lib/esm/engine/validation/GraphConnectionPolicyValidator.js.map +1 -1
- package/lib/esm/engine/validation/GraphCredentialReferenceValidator.js +4 -2
- package/lib/esm/engine/validation/GraphCredentialReferenceValidator.js.map +1 -1
- package/lib/esm/engine/validation/GraphParameterValidator.js +6 -0
- package/lib/esm/engine/validation/GraphParameterValidator.js.map +1 -1
- package/lib/esm/mastra/MastraAgeVectorDriver.js +294 -0
- package/lib/esm/mastra/MastraAgeVectorDriver.js.map +1 -0
- package/lib/esm/mastra/MastraAgentBuilder.js +244 -0
- package/lib/esm/mastra/MastraAgentBuilder.js.map +1 -0
- package/lib/esm/mastra/MastraAgentModelAdapter.js +59 -0
- package/lib/esm/mastra/MastraAgentModelAdapter.js.map +1 -0
- package/lib/esm/mastra/MastraAgentProcessors.js +391 -0
- package/lib/esm/mastra/MastraAgentProcessors.js.map +1 -0
- package/lib/esm/mastra/MastraAgentStepHandler.js +327 -0
- package/lib/esm/mastra/MastraAgentStepHandler.js.map +1 -0
- package/lib/esm/mastra/MastraCapabilities.js +115 -0
- package/lib/esm/mastra/MastraCapabilities.js.map +1 -1
- package/lib/esm/mastra/MastraChannelResponse.js +154 -0
- package/lib/esm/mastra/MastraChannelResponse.js.map +1 -0
- package/lib/esm/mastra/MastraChannelTrigger.js +116 -0
- package/lib/esm/mastra/MastraChannelTrigger.js.map +1 -0
- package/lib/esm/mastra/MastraDefaultStepHandlers.js +430 -0
- package/lib/esm/mastra/MastraDefaultStepHandlers.js.map +1 -0
- package/lib/esm/mastra/MastraEnvironment.js +287 -0
- package/lib/esm/mastra/MastraEnvironment.js.map +1 -0
- package/lib/esm/mastra/MastraEvalModels.js +535 -0
- package/lib/esm/mastra/MastraEvalModels.js.map +1 -0
- package/lib/esm/mastra/MastraEventBridge.js +31 -4
- package/lib/esm/mastra/MastraEventBridge.js.map +1 -1
- package/lib/esm/mastra/MastraGraphExecutionBackend.js +514 -21
- package/lib/esm/mastra/MastraGraphExecutionBackend.js.map +1 -1
- package/lib/esm/mastra/MastraGraphExecutionModule.js +139 -0
- package/lib/esm/mastra/MastraGraphExecutionModule.js.map +1 -0
- package/lib/esm/mastra/MastraHitlStepHandler.js +62 -0
- package/lib/esm/mastra/MastraHitlStepHandler.js.map +1 -0
- package/lib/esm/mastra/MastraMcpTrigger.js +246 -0
- package/lib/esm/mastra/MastraMcpTrigger.js.map +1 -0
- package/lib/esm/mastra/MastraMemory.js +455 -0
- package/lib/esm/mastra/MastraMemory.js.map +1 -0
- package/lib/esm/mastra/MastraMetricsAdapter.js +273 -0
- package/lib/esm/mastra/MastraMetricsAdapter.js.map +1 -0
- package/lib/esm/mastra/MastraMetricsGateway.js +394 -0
- package/lib/esm/mastra/MastraMetricsGateway.js.map +1 -0
- package/lib/esm/mastra/MastraMetricsModels.js +486 -0
- package/lib/esm/mastra/MastraMetricsModels.js.map +1 -0
- package/lib/esm/mastra/MastraMetricsStatement.js +213 -0
- package/lib/esm/mastra/MastraMetricsStatement.js.map +1 -0
- package/lib/esm/mastra/MastraModelSchemaConverter.js +78 -0
- package/lib/esm/mastra/MastraModelSchemaConverter.js.map +1 -0
- package/lib/esm/mastra/MastraObservability.js +327 -0
- package/lib/esm/mastra/MastraObservability.js.map +1 -0
- package/lib/esm/mastra/MastraPersistence.js +530 -0
- package/lib/esm/mastra/MastraPersistence.js.map +1 -0
- package/lib/esm/mastra/MastraRagStepHandlers.js +920 -0
- package/lib/esm/mastra/MastraRagStepHandlers.js.map +1 -0
- package/lib/esm/mastra/MastraRunMetricsEndpoint.js +147 -0
- package/lib/esm/mastra/MastraRunMetricsEndpoint.js.map +1 -0
- package/lib/esm/mastra/MastraRunRecovery.js +89 -0
- package/lib/esm/mastra/MastraRunRecovery.js.map +1 -0
- package/lib/esm/mastra/MastraScheduleTrigger.js +110 -0
- package/lib/esm/mastra/MastraScheduleTrigger.js.map +1 -0
- package/lib/esm/mastra/MastraStorageWiring.js +119 -0
- package/lib/esm/mastra/MastraStorageWiring.js.map +1 -0
- package/lib/esm/mastra/MastraStructuredOutput.js +144 -0
- package/lib/esm/mastra/MastraStructuredOutput.js.map +1 -0
- package/lib/esm/mastra/MastraToolBuilder.js +68 -0
- package/lib/esm/mastra/MastraToolBuilder.js.map +1 -0
- package/lib/esm/mastra/MastraToolConfig.js +37 -0
- package/lib/esm/mastra/MastraToolConfig.js.map +1 -0
- package/lib/esm/mastra/MastraToolDecorator.js +92 -0
- package/lib/esm/mastra/MastraToolDecorator.js.map +1 -0
- package/lib/esm/mastra/MastraVectorStore.js +605 -0
- package/lib/esm/mastra/MastraVectorStore.js.map +1 -0
- package/lib/esm/mastra/MastraVoiceStepHandler.js +84 -0
- package/lib/esm/mastra/MastraVoiceStepHandler.js.map +1 -0
- package/lib/esm/mastra/MastraWorkflowCompiler.js +41 -9
- package/lib/esm/mastra/MastraWorkflowCompiler.js.map +1 -1
- package/lib/esm/mastra/MastraWorkflowManager.js +101 -51
- package/lib/esm/mastra/MastraWorkflowManager.js.map +1 -1
- package/lib/esm/mastra/index.js +41 -1
- package/lib/esm/mastra/index.js.map +1 -1
- package/lib/esm/mastra/nodes/MastraNodeRegistry.js +225 -0
- package/lib/esm/mastra/nodes/MastraNodeRegistry.js.map +1 -0
- package/lib/esm/mastra/nodes/index.js +12 -0
- package/lib/esm/mastra/nodes/index.js.map +1 -0
- package/lib/esm/mastra/nodes/types.js +2 -0
- package/lib/esm/mastra/nodes/types.js.map +1 -0
- package/lib/esm/mastra/types.js +129 -0
- package/lib/esm/mastra/types.js.map +1 -1
- package/lib/esm/nest/graph/GraphBackendHost.js +79 -20
- package/lib/esm/nest/graph/GraphBackendHost.js.map +1 -1
- package/lib/esm/nest/graph/GraphExecutionModule.js +73 -3
- package/lib/esm/nest/graph/GraphExecutionModule.js.map +1 -1
- package/lib/esm/nest/graph/GraphRunController.js +47 -6
- package/lib/esm/nest/graph/GraphRunController.js.map +1 -1
- package/lib/esm/nest/graph/main.js +100 -3
- package/lib/esm/nest/graph/main.js.map +1 -1
- package/lib/esm/node/agents/agent/node.js +189 -31
- package/lib/esm/node/agents/agent/node.js.map +1 -1
- package/lib/esm/node/agents/hitl/node.js +106 -0
- package/lib/esm/node/agents/hitl/node.js.map +1 -0
- package/lib/esm/node/agents/hooks/delegation/node.js +113 -0
- package/lib/esm/node/agents/hooks/delegation/node.js.map +1 -0
- package/lib/esm/node/agents/hooks/hook/node.js +111 -0
- package/lib/esm/node/agents/hooks/hook/node.js.map +1 -0
- package/lib/esm/node/agents/hooks/tool-deny/node.js +95 -0
- package/lib/esm/node/agents/hooks/tool-deny/node.js.map +1 -0
- package/lib/esm/node/agents/memory/memory/node.js +222 -0
- package/lib/esm/node/agents/memory/memory/node.js.map +1 -0
- package/lib/esm/node/agents/memory/memory-selector/node.js +92 -0
- package/lib/esm/node/agents/memory/memory-selector/node.js.map +1 -0
- package/lib/esm/node/agents/processors/guardrail/node.js +117 -0
- package/lib/esm/node/agents/processors/guardrail/node.js.map +1 -0
- package/lib/esm/node/agents/processors/input-processor/node.js +109 -0
- package/lib/esm/node/agents/processors/input-processor/node.js.map +1 -0
- package/lib/esm/node/agents/processors/output-processor/node.js +99 -0
- package/lib/esm/node/agents/processors/output-processor/node.js.map +1 -0
- package/lib/esm/node/agents/processors/types.js +64 -0
- package/lib/esm/node/agents/processors/types.js.map +1 -0
- package/lib/esm/node/agents/rag/chains/basic/node.js +94 -0
- package/lib/esm/node/agents/rag/chains/basic/node.js.map +1 -0
- package/lib/esm/node/agents/rag/chains/qa/node.js +115 -0
- package/lib/esm/node/agents/rag/chains/qa/node.js.map +1 -0
- package/lib/esm/node/agents/rag/chains/summarization/node.js +107 -0
- package/lib/esm/node/agents/rag/chains/summarization/node.js.map +1 -0
- package/lib/esm/node/agents/rag/chunking/node.js +211 -0
- package/lib/esm/node/agents/rag/chunking/node.js.map +1 -0
- package/lib/esm/node/agents/rag/embedding/node.js +101 -0
- package/lib/esm/node/agents/rag/embedding/node.js.map +1 -0
- package/lib/esm/node/agents/rag/information-extractor/node.js +106 -0
- package/lib/esm/node/agents/rag/information-extractor/node.js.map +1 -0
- package/lib/esm/node/agents/rag/langchain-code/node.js +104 -0
- package/lib/esm/node/agents/rag/langchain-code/node.js.map +1 -0
- package/lib/esm/node/agents/rag/rerank/node.js +103 -0
- package/lib/esm/node/agents/rag/rerank/node.js.map +1 -0
- package/lib/esm/node/agents/rag/retriever/node.js +111 -0
- package/lib/esm/node/agents/rag/retriever/node.js.map +1 -0
- package/lib/esm/node/agents/rag/structured-output-parser/node.js +112 -0
- package/lib/esm/node/agents/rag/structured-output-parser/node.js.map +1 -0
- package/lib/esm/node/agents/rag/vector-store/node.js +178 -0
- package/lib/esm/node/agents/rag/vector-store/node.js.map +1 -0
- package/lib/esm/node/agents/responses/discord/node.js +92 -0
- package/lib/esm/node/agents/responses/discord/node.js.map +1 -0
- package/lib/esm/node/agents/responses/slack/node.js +92 -0
- package/lib/esm/node/agents/responses/slack/node.js.map +1 -0
- package/lib/esm/node/agents/responses/teams/node.js +92 -0
- package/lib/esm/node/agents/responses/teams/node.js.map +1 -0
- package/lib/esm/node/agents/responses/telegram/node.js +92 -0
- package/lib/esm/node/agents/responses/telegram/node.js.map +1 -0
- package/lib/esm/node/agents/sandbox/node.js +125 -0
- package/lib/esm/node/agents/sandbox/node.js.map +1 -0
- package/lib/esm/node/agents/scorers/scorer/node.js +98 -0
- package/lib/esm/node/agents/scorers/scorer/node.js.map +1 -0
- package/lib/esm/node/agents/scorers/scorer-selector/node.js +91 -0
- package/lib/esm/node/agents/scorers/scorer-selector/node.js.map +1 -0
- package/lib/esm/node/agents/skills/skill/node.js +96 -0
- package/lib/esm/node/agents/skills/skill/node.js.map +1 -0
- package/lib/esm/node/agents/skills/skill-selector/node.js +89 -0
- package/lib/esm/node/agents/skills/skill-selector/node.js.map +1 -0
- package/lib/esm/node/agents/tools/tool/node.js +91 -0
- package/lib/esm/node/agents/tools/tool/node.js.map +1 -0
- package/lib/esm/node/agents/tools/tool-selector/node.js +90 -0
- package/lib/esm/node/agents/tools/tool-selector/node.js.map +1 -0
- package/lib/esm/node/agents/triggers/discord/node.js +92 -0
- package/lib/esm/node/agents/triggers/discord/node.js.map +1 -0
- package/lib/esm/node/agents/triggers/mcp-server/node.js +138 -0
- package/lib/esm/node/agents/triggers/mcp-server/node.js.map +1 -0
- package/lib/esm/node/agents/triggers/slack/node.js +92 -0
- package/lib/esm/node/agents/triggers/slack/node.js.map +1 -0
- package/lib/esm/node/agents/triggers/teams/node.js +92 -0
- package/lib/esm/node/agents/triggers/teams/node.js.map +1 -0
- package/lib/esm/node/agents/triggers/telegram/node.js +92 -0
- package/lib/esm/node/agents/triggers/telegram/node.js.map +1 -0
- package/lib/esm/node/agents/voice/node.js +98 -0
- package/lib/esm/node/agents/voice/node.js.map +1 -0
- package/lib/esm/node/agents/zones.js +39 -0
- package/lib/esm/node/agents/zones.js.map +1 -0
- package/lib/esm/node/comms/email-send/node.js +331 -0
- package/lib/esm/node/comms/email-send/node.js.map +1 -0
- package/lib/esm/node/comms/gmail/node.js +278 -0
- package/lib/esm/node/comms/gmail/node.js.map +1 -0
- package/lib/esm/node/comms/slack/node.js +267 -0
- package/lib/esm/node/comms/slack/node.js.map +1 -0
- package/lib/esm/node/comms/teams/node.js +222 -0
- package/lib/esm/node/comms/teams/node.js.map +1 -0
- package/lib/esm/node/comms/telegram/node.js +251 -0
- package/lib/esm/node/comms/telegram/node.js.map +1 -0
- package/lib/esm/node/credentials.js +96 -0
- package/lib/esm/node/credentials.js.map +1 -0
- package/lib/esm/node/data/data-table/node.js +256 -0
- package/lib/esm/node/data/data-table/node.js.map +1 -0
- package/lib/esm/node/data/date-time/node.js +171 -0
- package/lib/esm/node/data/date-time/node.js.map +1 -0
- package/lib/esm/node/data/filter/node.js +125 -0
- package/lib/esm/node/data/filter/node.js.map +1 -0
- package/lib/esm/node/data/limit/node.js +95 -0
- package/lib/esm/node/data/limit/node.js.map +1 -0
- package/lib/esm/node/data/merge/node.js +242 -0
- package/lib/esm/node/data/merge/node.js.map +1 -0
- package/lib/esm/node/data/rename-keys/node.js +130 -0
- package/lib/esm/node/data/rename-keys/node.js.map +1 -0
- package/lib/esm/node/data/set/node.js +139 -0
- package/lib/esm/node/data/set/node.js.map +1 -0
- package/lib/esm/node/data/sort/node.js +116 -0
- package/lib/esm/node/data/sort/node.js.map +1 -0
- package/lib/esm/node/data/split-out/node.js +131 -0
- package/lib/esm/node/data/split-out/node.js.map +1 -0
- package/lib/esm/node/data/support.js +382 -0
- package/lib/esm/node/data/support.js.map +1 -0
- package/lib/esm/node/devops/crypto/node.js +355 -0
- package/lib/esm/node/devops/crypto/node.js.map +1 -0
- package/lib/esm/node/devops/execute-command/node.js +192 -0
- package/lib/esm/node/devops/execute-command/node.js.map +1 -0
- package/lib/esm/node/devops/ftp/node.js +232 -0
- package/lib/esm/node/devops/ftp/node.js.map +1 -0
- package/lib/esm/node/devops/github/node.js +273 -0
- package/lib/esm/node/devops/github/node.js.map +1 -0
- package/lib/esm/node/devops/gitlab/node.js +264 -0
- package/lib/esm/node/devops/gitlab/node.js.map +1 -0
- package/lib/esm/node/devops/jwt/node.js +195 -0
- package/lib/esm/node/devops/jwt/node.js.map +1 -0
- package/lib/esm/node/flow/execute-sub-workflow/node.js +214 -0
- package/lib/esm/node/flow/execute-sub-workflow/node.js.map +1 -0
- package/lib/esm/node/index.js +338 -2
- package/lib/esm/node/index.js.map +1 -1
- package/lib/esm/node/io/airtable/node.js +309 -0
- package/lib/esm/node/io/airtable/node.js.map +1 -0
- package/lib/esm/node/io/extract-from-file/node.js +260 -0
- package/lib/esm/node/io/extract-from-file/node.js.map +1 -0
- package/lib/esm/node/io/google-sheets/node.js +258 -0
- package/lib/esm/node/io/google-sheets/node.js.map +1 -0
- package/lib/esm/node/io/graphql/node.js +160 -0
- package/lib/esm/node/io/graphql/node.js.map +1 -0
- package/lib/esm/node/io/http-request/node.js +406 -0
- package/lib/esm/node/io/http-request/node.js.map +1 -0
- package/lib/esm/node/io/read-pdf/node.js +164 -0
- package/lib/esm/node/io/read-pdf/node.js.map +1 -0
- package/lib/esm/node/io/read-write-file/node.js +305 -0
- package/lib/esm/node/io/read-write-file/node.js.map +1 -0
- package/lib/esm/node/io/respond-to-webhook/node.js +174 -0
- package/lib/esm/node/io/respond-to-webhook/node.js.map +1 -0
- package/lib/esm/node/io/spreadsheet-file/node.js +183 -0
- package/lib/esm/node/io/spreadsheet-file/node.js.map +1 -0
- package/lib/esm/node/manifests.js +228 -0
- package/lib/esm/node/manifests.js.map +1 -1
- package/lib/esm/node/storage/blob/azure/node.js +129 -0
- package/lib/esm/node/storage/blob/azure/node.js.map +1 -0
- package/lib/esm/node/storage/blob/base.js +311 -0
- package/lib/esm/node/storage/blob/base.js.map +1 -0
- package/lib/esm/node/storage/blob/gcs/node.js +117 -0
- package/lib/esm/node/storage/blob/gcs/node.js.map +1 -0
- package/lib/esm/node/storage/blob/s3/node.js +176 -0
- package/lib/esm/node/storage/blob/s3/node.js.map +1 -0
- package/lib/esm/node/storage/database/base.js +291 -0
- package/lib/esm/node/storage/database/base.js.map +1 -0
- package/lib/esm/node/storage/database/mssql/node.js +42 -0
- package/lib/esm/node/storage/database/mssql/node.js.map +1 -0
- package/lib/esm/node/storage/database/mysql/node.js +42 -0
- package/lib/esm/node/storage/database/mysql/node.js.map +1 -0
- package/lib/esm/node/storage/database/postgres/node.js +42 -0
- package/lib/esm/node/storage/database/postgres/node.js.map +1 -0
- package/lib/esm/node/storage/redis/node.js +331 -0
- package/lib/esm/node/storage/redis/node.js.map +1 -0
- package/lib/esm/node/storage/support.js +69 -0
- package/lib/esm/node/storage/support.js.map +1 -0
- package/lib/esm/node/triggers/execute-workflow/node.js +85 -0
- package/lib/esm/node/triggers/execute-workflow/node.js.map +1 -0
- package/lib/esm/ram/GraphNodeRepository.js +31 -0
- package/lib/esm/ram/GraphNodeRepository.js.map +1 -0
- package/lib/esm/ram/GraphRunEventModel.js +5 -1
- package/lib/esm/ram/GraphRunEventModel.js.map +1 -1
- package/lib/esm/ram/index.js +1 -0
- package/lib/esm/ram/index.js.map +1 -1
- package/lib/esm/shared/graph/GraphNodeConverters.js +38 -0
- package/lib/esm/shared/graph/GraphNodeConverters.js.map +1 -0
- package/lib/esm/shared/graph/GraphNodeModel.js +69 -0
- package/lib/esm/shared/graph/GraphNodeModel.js.map +1 -0
- package/lib/esm/shared/graph/GraphWorkflowModel.js +5 -1
- package/lib/esm/shared/graph/GraphWorkflowModel.js.map +1 -1
- package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js +40 -0
- package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js.map +1 -1
- package/lib/esm/shared/graph/catalog/GraphPortManifest.js.map +1 -1
- package/lib/esm/shared/graph/category-styles.js +12 -0
- package/lib/esm/shared/graph/category-styles.js.map +1 -1
- package/lib/esm/shared/graph/constants.js.map +1 -1
- package/lib/esm/shared/graph/index.js +2 -0
- package/lib/esm/shared/graph/index.js.map +1 -1
- package/lib/esm/typeorm/TypeormGraphAdapter.js +213 -0
- package/lib/esm/typeorm/TypeormGraphAdapter.js.map +1 -0
- package/lib/esm/typeorm/index.js +12 -0
- package/lib/esm/typeorm/index.js.map +1 -0
- package/lib/types/dagster/DagsterGraphExecutionBackend.d.cts +40 -4
- package/lib/types/dagster/DagsterGraphExecutionBackend.d.mts +40 -4
- package/lib/types/engine/auth/GraphAuthValidator.d.cts +13 -0
- package/lib/types/engine/auth/GraphAuthValidator.d.mts +13 -0
- package/lib/types/engine/constants.d.cts +60 -0
- package/lib/types/engine/constants.d.mts +60 -0
- package/lib/types/engine/credentials/GraphNodeCredentials.d.cts +145 -0
- package/lib/types/engine/credentials/GraphNodeCredentials.d.mts +145 -0
- package/lib/types/engine/execution/GraphExecutionBackend.d.cts +27 -0
- package/lib/types/engine/execution/GraphExecutionBackend.d.mts +27 -0
- package/lib/types/engine/execution/GraphExecutionEngine.d.cts +97 -1
- package/lib/types/engine/execution/GraphExecutionEngine.d.mts +97 -1
- package/lib/types/engine/execution/GraphNodeEngineRequirements.d.cts +24 -0
- package/lib/types/engine/execution/GraphNodeEngineRequirements.d.mts +24 -0
- package/lib/types/engine/execution/GraphWebhookResponseRegistry.d.cts +67 -0
- package/lib/types/engine/execution/GraphWebhookResponseRegistry.d.mts +67 -0
- package/lib/types/engine/execution/LocalGraphExecutionBackend.d.cts +26 -3
- package/lib/types/engine/execution/LocalGraphExecutionBackend.d.mts +26 -3
- package/lib/types/engine/execution/index.d.cts +1 -0
- package/lib/types/engine/execution/index.d.mts +1 -0
- package/lib/types/engine/index.d.cts +5 -0
- package/lib/types/engine/index.d.mts +5 -0
- package/lib/types/engine/services/GraphNodeModelService.d.cts +54 -0
- package/lib/types/engine/services/GraphNodeModelService.d.mts +54 -0
- package/lib/types/engine/services/GraphWorkflowService.d.cts +21 -0
- package/lib/types/engine/services/GraphWorkflowService.d.mts +21 -0
- package/lib/types/engine/store/GraphDataTableModel.d.cts +24 -0
- package/lib/types/engine/store/GraphDataTableModel.d.mts +24 -0
- package/lib/types/engine/store/GraphDataTableRepository.d.cts +136 -0
- package/lib/types/engine/store/GraphDataTableRepository.d.mts +136 -0
- package/lib/types/engine/store/index.d.cts +2 -0
- package/lib/types/engine/store/index.d.mts +2 -0
- package/lib/types/engine/types.d.cts +12 -0
- package/lib/types/engine/types.d.mts +12 -0
- package/lib/types/engine/validation/GraphConnectionPolicyValidator.d.cts +10 -0
- package/lib/types/engine/validation/GraphConnectionPolicyValidator.d.mts +10 -0
- package/lib/types/engine/validation/GraphParameterValidator.d.cts +1 -1
- package/lib/types/engine/validation/GraphParameterValidator.d.mts +1 -1
- package/lib/types/mastra/MastraAgeVectorDriver.d.cts +55 -0
- package/lib/types/mastra/MastraAgeVectorDriver.d.mts +55 -0
- package/lib/types/mastra/MastraAgentBuilder.d.cts +188 -0
- package/lib/types/mastra/MastraAgentBuilder.d.mts +188 -0
- package/lib/types/mastra/MastraAgentModelAdapter.d.cts +76 -0
- package/lib/types/mastra/MastraAgentModelAdapter.d.mts +76 -0
- package/lib/types/mastra/MastraAgentProcessors.d.cts +50 -0
- package/lib/types/mastra/MastraAgentProcessors.d.mts +50 -0
- package/lib/types/mastra/MastraAgentStepHandler.d.cts +128 -0
- package/lib/types/mastra/MastraAgentStepHandler.d.mts +128 -0
- package/lib/types/mastra/MastraCapabilities.d.cts +20 -0
- package/lib/types/mastra/MastraCapabilities.d.mts +20 -0
- package/lib/types/mastra/MastraChannelResponse.d.cts +64 -0
- package/lib/types/mastra/MastraChannelResponse.d.mts +64 -0
- package/lib/types/mastra/MastraChannelTrigger.d.cts +57 -0
- package/lib/types/mastra/MastraChannelTrigger.d.mts +57 -0
- package/lib/types/mastra/MastraDefaultStepHandlers.d.cts +121 -0
- package/lib/types/mastra/MastraDefaultStepHandlers.d.mts +121 -0
- package/lib/types/mastra/MastraEnvironment.d.cts +270 -0
- package/lib/types/mastra/MastraEnvironment.d.mts +270 -0
- package/lib/types/mastra/MastraEvalModels.d.cts +191 -0
- package/lib/types/mastra/MastraEvalModels.d.mts +191 -0
- package/lib/types/mastra/MastraEventBridge.d.cts +17 -0
- package/lib/types/mastra/MastraEventBridge.d.mts +17 -0
- package/lib/types/mastra/MastraGraphExecutionBackend.d.cts +137 -1
- package/lib/types/mastra/MastraGraphExecutionBackend.d.mts +137 -1
- package/lib/types/mastra/MastraGraphExecutionModule.d.cts +114 -0
- package/lib/types/mastra/MastraGraphExecutionModule.d.mts +114 -0
- package/lib/types/mastra/MastraHitlStepHandler.d.cts +18 -0
- package/lib/types/mastra/MastraHitlStepHandler.d.mts +18 -0
- package/lib/types/mastra/MastraMcpTrigger.d.cts +133 -0
- package/lib/types/mastra/MastraMcpTrigger.d.mts +133 -0
- package/lib/types/mastra/MastraMemory.d.cts +362 -0
- package/lib/types/mastra/MastraMemory.d.mts +362 -0
- package/lib/types/mastra/MastraMetricsAdapter.d.cts +216 -0
- package/lib/types/mastra/MastraMetricsAdapter.d.mts +216 -0
- package/lib/types/mastra/MastraMetricsGateway.d.cts +265 -0
- package/lib/types/mastra/MastraMetricsGateway.d.mts +265 -0
- package/lib/types/mastra/MastraMetricsModels.d.cts +175 -0
- package/lib/types/mastra/MastraMetricsModels.d.mts +175 -0
- package/lib/types/mastra/MastraMetricsStatement.d.cts +116 -0
- package/lib/types/mastra/MastraMetricsStatement.d.mts +116 -0
- package/lib/types/mastra/MastraModelSchemaConverter.d.cts +45 -0
- package/lib/types/mastra/MastraModelSchemaConverter.d.mts +45 -0
- package/lib/types/mastra/MastraObservability.d.cts +197 -0
- package/lib/types/mastra/MastraObservability.d.mts +197 -0
- package/lib/types/mastra/MastraPersistence.d.cts +241 -0
- package/lib/types/mastra/MastraPersistence.d.mts +241 -0
- package/lib/types/mastra/MastraRagStepHandlers.d.cts +137 -0
- package/lib/types/mastra/MastraRagStepHandlers.d.mts +137 -0
- package/lib/types/mastra/MastraRunMetricsEndpoint.d.cts +53 -0
- package/lib/types/mastra/MastraRunMetricsEndpoint.d.mts +53 -0
- package/lib/types/mastra/MastraRunRecovery.d.cts +26 -0
- package/lib/types/mastra/MastraRunRecovery.d.mts +26 -0
- package/lib/types/mastra/MastraScheduleTrigger.d.cts +20 -0
- package/lib/types/mastra/MastraScheduleTrigger.d.mts +20 -0
- package/lib/types/mastra/MastraStorageWiring.d.cts +71 -0
- package/lib/types/mastra/MastraStorageWiring.d.mts +71 -0
- package/lib/types/mastra/MastraStructuredOutput.d.cts +165 -0
- package/lib/types/mastra/MastraStructuredOutput.d.mts +165 -0
- package/lib/types/mastra/MastraToolBuilder.d.cts +70 -0
- package/lib/types/mastra/MastraToolBuilder.d.mts +70 -0
- package/lib/types/mastra/MastraToolConfig.d.cts +136 -0
- package/lib/types/mastra/MastraToolConfig.d.mts +136 -0
- package/lib/types/mastra/MastraToolDecorator.d.cts +47 -0
- package/lib/types/mastra/MastraToolDecorator.d.mts +47 -0
- package/lib/types/mastra/MastraVectorStore.d.cts +383 -0
- package/lib/types/mastra/MastraVectorStore.d.mts +383 -0
- package/lib/types/mastra/MastraVoiceStepHandler.d.cts +40 -0
- package/lib/types/mastra/MastraVoiceStepHandler.d.mts +40 -0
- package/lib/types/mastra/MastraWorkflowCompiler.d.cts +3 -3
- package/lib/types/mastra/MastraWorkflowCompiler.d.mts +3 -3
- package/lib/types/mastra/MastraWorkflowManager.d.cts +36 -28
- package/lib/types/mastra/MastraWorkflowManager.d.mts +36 -28
- package/lib/types/mastra/index.d.cts +41 -1
- package/lib/types/mastra/index.d.mts +41 -1
- package/lib/types/mastra/nodes/MastraNodeRegistry.d.cts +41 -0
- package/lib/types/mastra/nodes/MastraNodeRegistry.d.mts +41 -0
- package/lib/types/mastra/nodes/index.d.cts +11 -0
- package/lib/types/mastra/nodes/index.d.mts +11 -0
- package/lib/types/mastra/nodes/types.d.cts +57 -0
- package/lib/types/mastra/nodes/types.d.mts +57 -0
- package/lib/types/mastra/types.d.cts +377 -6
- package/lib/types/mastra/types.d.mts +377 -6
- package/lib/types/nest/graph/GraphBackendHost.d.cts +52 -0
- package/lib/types/nest/graph/GraphBackendHost.d.mts +52 -0
- package/lib/types/nest/graph/GraphExecutionModule.d.cts +28 -0
- package/lib/types/nest/graph/GraphExecutionModule.d.mts +28 -0
- package/lib/types/nest/graph/GraphRunController.d.cts +24 -4
- package/lib/types/nest/graph/GraphRunController.d.mts +24 -4
- package/lib/types/node/agents/agent/node.d.cts +72 -16
- package/lib/types/node/agents/agent/node.d.mts +72 -16
- package/lib/types/node/agents/hitl/node.d.cts +45 -0
- package/lib/types/node/agents/hitl/node.d.mts +45 -0
- package/lib/types/node/agents/hooks/delegation/node.d.cts +48 -0
- package/lib/types/node/agents/hooks/delegation/node.d.mts +48 -0
- package/lib/types/node/agents/hooks/hook/node.d.cts +45 -0
- package/lib/types/node/agents/hooks/hook/node.d.mts +45 -0
- package/lib/types/node/agents/hooks/tool-deny/node.d.cts +39 -0
- package/lib/types/node/agents/hooks/tool-deny/node.d.mts +39 -0
- package/lib/types/node/agents/memory/memory/node.d.cts +73 -0
- package/lib/types/node/agents/memory/memory/node.d.mts +73 -0
- package/lib/types/node/agents/memory/memory-selector/node.d.cts +34 -0
- package/lib/types/node/agents/memory/memory-selector/node.d.mts +34 -0
- package/lib/types/node/agents/processors/guardrail/node.d.cts +47 -0
- package/lib/types/node/agents/processors/guardrail/node.d.mts +47 -0
- package/lib/types/node/agents/processors/input-processor/node.d.cts +40 -0
- package/lib/types/node/agents/processors/input-processor/node.d.mts +40 -0
- package/lib/types/node/agents/processors/output-processor/node.d.cts +34 -0
- package/lib/types/node/agents/processors/output-processor/node.d.mts +34 -0
- package/lib/types/node/agents/processors/types.d.cts +45 -0
- package/lib/types/node/agents/processors/types.d.mts +45 -0
- package/lib/types/node/agents/rag/chains/basic/node.d.cts +36 -0
- package/lib/types/node/agents/rag/chains/basic/node.d.mts +36 -0
- package/lib/types/node/agents/rag/chains/qa/node.d.cts +44 -0
- package/lib/types/node/agents/rag/chains/qa/node.d.mts +44 -0
- package/lib/types/node/agents/rag/chains/summarization/node.d.cts +39 -0
- package/lib/types/node/agents/rag/chains/summarization/node.d.mts +39 -0
- package/lib/types/node/agents/rag/chunking/node.d.cts +73 -0
- package/lib/types/node/agents/rag/chunking/node.d.mts +73 -0
- package/lib/types/node/agents/rag/embedding/node.d.cts +37 -0
- package/lib/types/node/agents/rag/embedding/node.d.mts +37 -0
- package/lib/types/node/agents/rag/information-extractor/node.d.cts +39 -0
- package/lib/types/node/agents/rag/information-extractor/node.d.mts +39 -0
- package/lib/types/node/agents/rag/langchain-code/node.d.cts +36 -0
- package/lib/types/node/agents/rag/langchain-code/node.d.mts +36 -0
- package/lib/types/node/agents/rag/rerank/node.d.cts +39 -0
- package/lib/types/node/agents/rag/rerank/node.d.mts +39 -0
- package/lib/types/node/agents/rag/retriever/node.d.cts +42 -0
- package/lib/types/node/agents/rag/retriever/node.d.mts +42 -0
- package/lib/types/node/agents/rag/structured-output-parser/node.d.cts +35 -0
- package/lib/types/node/agents/rag/structured-output-parser/node.d.mts +35 -0
- package/lib/types/node/agents/rag/vector-store/node.d.cts +59 -0
- package/lib/types/node/agents/rag/vector-store/node.d.mts +59 -0
- package/lib/types/node/agents/responses/discord/node.d.cts +34 -0
- package/lib/types/node/agents/responses/discord/node.d.mts +34 -0
- package/lib/types/node/agents/responses/slack/node.d.cts +34 -0
- package/lib/types/node/agents/responses/slack/node.d.mts +34 -0
- package/lib/types/node/agents/responses/teams/node.d.cts +34 -0
- package/lib/types/node/agents/responses/teams/node.d.mts +34 -0
- package/lib/types/node/agents/responses/telegram/node.d.cts +34 -0
- package/lib/types/node/agents/responses/telegram/node.d.mts +34 -0
- package/lib/types/node/agents/sandbox/node.d.cts +47 -0
- package/lib/types/node/agents/sandbox/node.d.mts +47 -0
- package/lib/types/node/agents/scorers/scorer/node.d.cts +33 -0
- package/lib/types/node/agents/scorers/scorer/node.d.mts +33 -0
- package/lib/types/node/agents/scorers/scorer-selector/node.d.cts +33 -0
- package/lib/types/node/agents/scorers/scorer-selector/node.d.mts +33 -0
- package/lib/types/node/agents/skills/skill/node.d.cts +32 -0
- package/lib/types/node/agents/skills/skill/node.d.mts +32 -0
- package/lib/types/node/agents/skills/skill-selector/node.d.cts +33 -0
- package/lib/types/node/agents/skills/skill-selector/node.d.mts +33 -0
- package/lib/types/node/agents/tools/tool/node.d.cts +33 -0
- package/lib/types/node/agents/tools/tool/node.d.mts +33 -0
- package/lib/types/node/agents/tools/tool-selector/node.d.cts +33 -0
- package/lib/types/node/agents/tools/tool-selector/node.d.mts +33 -0
- package/lib/types/node/agents/triggers/discord/node.d.cts +40 -0
- package/lib/types/node/agents/triggers/discord/node.d.mts +40 -0
- package/lib/types/node/agents/triggers/mcp-server/node.d.cts +51 -0
- package/lib/types/node/agents/triggers/mcp-server/node.d.mts +51 -0
- package/lib/types/node/agents/triggers/slack/node.d.cts +40 -0
- package/lib/types/node/agents/triggers/slack/node.d.mts +40 -0
- package/lib/types/node/agents/triggers/teams/node.d.cts +40 -0
- package/lib/types/node/agents/triggers/teams/node.d.mts +40 -0
- package/lib/types/node/agents/triggers/telegram/node.d.cts +40 -0
- package/lib/types/node/agents/triggers/telegram/node.d.mts +40 -0
- package/lib/types/node/agents/voice/node.d.cts +34 -0
- package/lib/types/node/agents/voice/node.d.mts +34 -0
- package/lib/types/node/agents/zones.d.cts +30 -0
- package/lib/types/node/agents/zones.d.mts +30 -0
- package/lib/types/node/comms/email-send/node.d.cts +85 -0
- package/lib/types/node/comms/email-send/node.d.mts +85 -0
- package/lib/types/node/comms/gmail/node.d.cts +67 -0
- package/lib/types/node/comms/gmail/node.d.mts +67 -0
- package/lib/types/node/comms/slack/node.d.cts +65 -0
- package/lib/types/node/comms/slack/node.d.mts +65 -0
- package/lib/types/node/comms/teams/node.d.cts +49 -0
- package/lib/types/node/comms/teams/node.d.mts +49 -0
- package/lib/types/node/comms/telegram/node.d.cts +61 -0
- package/lib/types/node/comms/telegram/node.d.mts +61 -0
- package/lib/types/node/credentials.d.cts +43 -0
- package/lib/types/node/credentials.d.mts +43 -0
- package/lib/types/node/data/data-table/node.d.cts +86 -0
- package/lib/types/node/data/data-table/node.d.mts +86 -0
- package/lib/types/node/data/date-time/node.d.cts +49 -0
- package/lib/types/node/data/date-time/node.d.mts +49 -0
- package/lib/types/node/data/filter/node.d.cts +31 -0
- package/lib/types/node/data/filter/node.d.mts +31 -0
- package/lib/types/node/data/limit/node.d.cts +28 -0
- package/lib/types/node/data/limit/node.d.mts +28 -0
- package/lib/types/node/data/merge/node.d.cts +63 -0
- package/lib/types/node/data/merge/node.d.mts +63 -0
- package/lib/types/node/data/rename-keys/node.d.cts +35 -0
- package/lib/types/node/data/rename-keys/node.d.mts +35 -0
- package/lib/types/node/data/set/node.d.cts +52 -0
- package/lib/types/node/data/set/node.d.mts +52 -0
- package/lib/types/node/data/sort/node.d.cts +40 -0
- package/lib/types/node/data/sort/node.d.mts +40 -0
- package/lib/types/node/data/split-out/node.d.cts +30 -0
- package/lib/types/node/data/split-out/node.d.mts +30 -0
- package/lib/types/node/data/support.d.cts +164 -0
- package/lib/types/node/data/support.d.mts +164 -0
- package/lib/types/node/devops/crypto/node.d.cts +65 -0
- package/lib/types/node/devops/crypto/node.d.mts +65 -0
- package/lib/types/node/devops/execute-command/node.d.cts +55 -0
- package/lib/types/node/devops/execute-command/node.d.mts +55 -0
- package/lib/types/node/devops/ftp/node.d.cts +55 -0
- package/lib/types/node/devops/ftp/node.d.mts +55 -0
- package/lib/types/node/devops/github/node.d.cts +61 -0
- package/lib/types/node/devops/github/node.d.mts +61 -0
- package/lib/types/node/devops/gitlab/node.d.cts +61 -0
- package/lib/types/node/devops/gitlab/node.d.mts +61 -0
- package/lib/types/node/devops/jwt/node.d.cts +53 -0
- package/lib/types/node/devops/jwt/node.d.mts +53 -0
- package/lib/types/node/flow/execute-sub-workflow/node.d.cts +63 -0
- package/lib/types/node/flow/execute-sub-workflow/node.d.mts +63 -0
- package/lib/types/node/index.d.cts +182 -2
- package/lib/types/node/index.d.mts +182 -2
- package/lib/types/node/io/airtable/node.d.cts +73 -0
- package/lib/types/node/io/airtable/node.d.mts +73 -0
- package/lib/types/node/io/extract-from-file/node.d.cts +38 -0
- package/lib/types/node/io/extract-from-file/node.d.mts +38 -0
- package/lib/types/node/io/google-sheets/node.d.cts +77 -0
- package/lib/types/node/io/google-sheets/node.d.mts +77 -0
- package/lib/types/node/io/graphql/node.d.cts +46 -0
- package/lib/types/node/io/graphql/node.d.mts +46 -0
- package/lib/types/node/io/http-request/node.d.cts +107 -0
- package/lib/types/node/io/http-request/node.d.mts +107 -0
- package/lib/types/node/io/read-pdf/node.d.cts +40 -0
- package/lib/types/node/io/read-pdf/node.d.mts +40 -0
- package/lib/types/node/io/read-write-file/node.d.cts +41 -0
- package/lib/types/node/io/read-write-file/node.d.mts +41 -0
- package/lib/types/node/io/respond-to-webhook/node.d.cts +45 -0
- package/lib/types/node/io/respond-to-webhook/node.d.mts +45 -0
- package/lib/types/node/io/spreadsheet-file/node.d.cts +51 -0
- package/lib/types/node/io/spreadsheet-file/node.d.mts +51 -0
- package/lib/types/node/storage/blob/azure/node.d.cts +27 -0
- package/lib/types/node/storage/blob/azure/node.d.mts +27 -0
- package/lib/types/node/storage/blob/base.d.cts +83 -0
- package/lib/types/node/storage/blob/base.d.mts +83 -0
- package/lib/types/node/storage/blob/gcs/node.d.cts +27 -0
- package/lib/types/node/storage/blob/gcs/node.d.mts +27 -0
- package/lib/types/node/storage/blob/s3/node.d.cts +39 -0
- package/lib/types/node/storage/blob/s3/node.d.mts +39 -0
- package/lib/types/node/storage/database/base.d.cts +97 -0
- package/lib/types/node/storage/database/base.d.mts +97 -0
- package/lib/types/node/storage/database/mssql/node.d.cts +8 -0
- package/lib/types/node/storage/database/mssql/node.d.mts +8 -0
- package/lib/types/node/storage/database/mysql/node.d.cts +8 -0
- package/lib/types/node/storage/database/mysql/node.d.mts +8 -0
- package/lib/types/node/storage/database/postgres/node.d.cts +8 -0
- package/lib/types/node/storage/database/postgres/node.d.mts +8 -0
- package/lib/types/node/storage/redis/node.d.cts +68 -0
- package/lib/types/node/storage/redis/node.d.mts +68 -0
- package/lib/types/node/storage/support.d.cts +36 -0
- package/lib/types/node/storage/support.d.mts +36 -0
- package/lib/types/node/triggers/execute-workflow/node.d.cts +25 -0
- package/lib/types/node/triggers/execute-workflow/node.d.mts +25 -0
- package/lib/types/ram/GraphNodeRepository.d.cts +13 -0
- package/lib/types/ram/GraphNodeRepository.d.mts +13 -0
- package/lib/types/ram/GraphRunEventModel.d.cts +6 -0
- package/lib/types/ram/GraphRunEventModel.d.mts +6 -0
- package/lib/types/ram/index.d.cts +1 -0
- package/lib/types/ram/index.d.mts +1 -0
- package/lib/types/shared/graph/GraphNodeConverters.d.cts +15 -0
- package/lib/types/shared/graph/GraphNodeConverters.d.mts +15 -0
- package/lib/types/shared/graph/GraphNodeModel.d.cts +30 -0
- package/lib/types/shared/graph/GraphNodeModel.d.mts +30 -0
- package/lib/types/shared/graph/GraphWorkflowModel.d.cts +6 -0
- package/lib/types/shared/graph/GraphWorkflowModel.d.mts +6 -0
- package/lib/types/shared/graph/catalog/GraphPortManifest.d.cts +7 -0
- package/lib/types/shared/graph/catalog/GraphPortManifest.d.mts +7 -0
- package/lib/types/shared/graph/constants.d.cts +39 -0
- package/lib/types/shared/graph/constants.d.mts +39 -0
- package/lib/types/shared/graph/index.d.cts +2 -0
- package/lib/types/shared/graph/index.d.mts +2 -0
- package/lib/types/typeorm/TypeormGraphAdapter.d.cts +32 -0
- package/lib/types/typeorm/TypeormGraphAdapter.d.mts +32 -0
- package/lib/types/typeorm/index.d.cts +11 -0
- package/lib/types/typeorm/index.d.mts +11 -0
- package/package.json +59 -13
package/dist/as-graph.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{logParameterRegistry as e,Logging as t,LoggedEnvironment as o}from"@decaf-ts/logging";import{RenderingEngine as n,uimodel as r,uielement as i,uilistprop as a,uilistmodel as s,hidden as d}from"@decaf-ts/ui-decorators";import{Metadata as l,Decoration as c,apply as u,metadata as p,propMetadata as h,description as f,prop as g,DefaultFlavour as m}from"@decaf-ts/decoration";import{ValidationKeys as y,Model as w,required as b,type as v,date as I,model as E,option as N,min as O,max as k}from"@decaf-ts/decorator-validation";import{ValidationError as A,InternalError as x,NotFoundError as _}from"@decaf-ts/db-decorators";import{__decorate as S,__metadata as D}from"tslib";import{pk as P,column as R,index as $,table as C,BaseModel as T,ForbiddenError as L,Context as M,repository as j,Repository as G,AuthorizationError as U,service as F,Service as B,ClientBasedService as W,Adapter as q,ModelService as H,OrderDirection as K}from"@decaf-ts/core";import V from"isolated-vm";import*as z from"acorn";import*as J from"acorn-walk";import*as X from"typescript";import{createHash as Y}from"node:crypto";var Q,Z;y.REQUIRED,y.MIN,y.MIN_LENGTH,y.MAX,y.MAX_LENGTH,y.PATTERN,y.URL,y.STEP,y.DATE,y.EMAIL,y.PASSWORD,y.EQUALS,y.DIFF,y.LESS_THAN,y.LESS_THAN_OR_EQUAL,y.GREATER_THAN,y.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"})(Z||(Z={}));const ee={};function te(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 oe(e,t){ee[e]=t}function ne(e,t,o){const n=t?ee[t]:void 0;return n?.color?n.color:e||"#64748b"}function re(e,t,o){const n=t?ee[t]:void 0;return n?.icon?n.icon:e||"ti-pointer"}const ie=["skip","passThroughFirstInput","emitDefaults"];function ae(e){return ie.includes(e)}var se,de,le,ce;(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"})(se||(se={})),(e=>{e.IDLE="idle",e.RUNNING="running",e.BLOCKED="blocked",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped"})(de||(de={})),(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"})(le||(le={})),(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"})(ce||(ce={}));const ue={maxRequestBytes:4e6,maxConcurrentRuns:32,maxEventsPerRun:1e4,maxEventPayloadBytes:256e3,executionTimeoutMs:6e5,eventReplayWindowMs:3e5},pe=[ce.WORKFLOW_COMPLETED,ce.WORKFLOW_FAILED,ce.WORKFLOW_CANCELLED];function he(e){return pe.includes(e)}function fe(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function ge(e){const t=l.constr(e);if("function"==typeof t)return t;const o=e.constructor;return"function"==typeof o?o:e}function me(e){if(null!=e)return"string"==typeof e?e:e+""}function ye(e,t,o){return me(e?.props?.label??e?.props?.name)??me(t?.name)??o??""}function we(e,t,o){const n=Ie(e,t);if(n?.model&&"function"==typeof n.model&&w.isModel(n.model))return n.model;const r=l.type(e,t);if("function"==typeof r&&w.isModel(r))return r;const i=l.getPropDesignTypes?.(e,t)?.designTypes||[];for(const e of i)if("function"==typeof e&&w.isModel(e))return e;const a=o?.[y.TYPE]?.customTypes||[];for(const e of a)if("function"==typeof e&&w.isModel(e))return e}function be(e,t){const o=[t,e.path??e.property].filter(Boolean).join(".");return{...e,path:o,children:e.children?.map(e=>be(e,o))}}function ve(e){const t=ge(e);return l.get(t,Q.NODE)}function Ie(e,t){const o=ge(e);return l.get(o,l.key(Q.PORT,t+""))}function Ee(e,t,o,n=new Set){const r=Ie(e,t);if(!r?.schema)return;const i=we(e,t,l.validationFor(e,t));if(!i)return;if(n.has(i))return[];const a=new Set(n);return a.add(e),a.add(i),ke(i,a).filter(e=>e.direction===o)}function Ne(e,t,o=new Set){const n=Ie(e,t);if(!n)return;const r=l.validationFor(e,t),i=we(e,t,r);if(n.schema&&i)return;const a=w.uiElementOf(e,t)||void 0,s=w.uiDecorationOf(e,t,"uiprop"),d=l.type(e,t),c=me(n.type??r?.[y.TYPE]?.customTypes?.[0]?.name??a?.props?.type??s?.type??d?.name),u=(n.expand||i&&!o.has(i))&&i?(()=>{const n=new Set(o);return n.add(e),n.add(i),ke(i,n).map(e=>be(e,t))})():void 0;return{property:t,path:t,direction:n.direction,name:t,label:ye(a,s,t),type:c?.toLowerCase(),required:!!r?.[y.REQUIRED],hidden:!!w.uiIsHidden(e,t),designType:d?.name,element:a,prop:s,validation:r,graph:n,connectionRules:n.connectionRules,composite:!!u?.length,children:u,model:i?.name}}function Oe(e){return ke(ge(e))}function ke(e,t=new Set){const o=l.properties(e)||[],n=[];for(const r of o){const o=r+"",i=Ie(e,o);if(i?.schema){const r=Ee(e,o,i.direction,t);if(r){n.push(...r);continue}}const a=Ne(e,o,t);a&&n.push(a)}return n}function Ae(e){return e.flatMap(e=>e.children&&e.children.length?Ae(e.children):[e])}function xe(e){const t=ge(e),o=w.uiModelOf(t),n=ve(t)||{},r=o?.tag||t.name,i=Oe(t),a=((e,t)=>{const o=t.portGroups||[],n=new Map(o.map(e=>[e.property,e])),r=[],i=l.properties(e)||[];for(const t of i){const o=t+"",i=Ie(e,o);if(!i?.schema)continue;if(!we(e,o,l.validationFor(e,o)))continue;const a=n.get(o);r.push(a?{...a,toggle:a.toggle??"all"}:{property:o,toggle:"all"})}for(const e of o)r.some(t=>t.property===e.property)||r.push(e);return r.length?r:void 0})(t,n),s=n.namespaces?.length?n.namespaces:(e=>{if(null==e)return[];let t,o=e;try{o=l.constr(e)}catch{o=e}try{t=l.get(o,"auth-namespace")}catch{t=void 0}return fe(t)??[]})(t),d=s.length?s:void 0;return{name:t.name,tag:r,kind:n.kind||r,category:n.category,color:n.color,effectiveColor:ne(n.color,n.category),group:n.group,height:n.height,icon:n.icon,effectiveIcon:re(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:i,portGroups:a,namespaces:d}}const _e=new Set,Se=new Set;function De(e,t,o){return c.for(Q.NODE).define({decorator:(e,t,o)=>{const n={kind:t?.kind||e,...t};return t=>{const i=u(r(e,o),p(Q.NODE,n))(t);var a;return a=t,_e.add(a),i}},args:[e,t,o]}).apply()}function Pe(e,t){return c.for(Q.PORT).define({decorator:(e,t)=>(o,n)=>{const r={direction:e,...t};return u(h(l.key(Q.PORT,n),r))(o,n)},args:[e,t]}).apply()}function Re(e){return Pe(Z.INPUT,{...e,schema:!0})}function $e(e){return Pe(Z.OUTPUT,{...e,schema:!0})}function Ce(e){return Pe(Z.CONNECTION,e)}n.prototype.renderAsNode=(e,t,...o)=>xe(e),l.nodes=(()=>[..._e]).bind(l),l.workflows=(()=>[...Se]).bind(l);const Te=["__proto__","prototype","constructor"];function Le(e){return Te.includes(e)}function Me(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function je(e){return null===e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e}function Ge(e){return!!je(e)||(Array.isArray(e)?e.every(e=>Ge(e)):!!Me(e)&&Reflect.ownKeys(e).every(t=>"string"==typeof t&&!Le(t)&&Ge(e[t])))}function Ue(e){if(void 0===e)return!1;if("number"==typeof e)return Number.isFinite(e);if("function"==typeof e)return!1;if(Ge(e))return!0;if(Array.isArray(e))return e.every(e=>Ue(e));if(Me(e)){const t=Reflect.ownKeys(e);for(const o of t){if("string"!=typeof o)return!1;if(Le(o))return!1;if(!Ue(e[o]))return!1}return!0}return!1}function Fe(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>Fe(e));const t={};for(const[o,n]of Object.entries(e))t[o]=Fe(n);return t}const Be={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"},We={date:"date",datetime:"date-time","date-time":"date-time",duration:"duration"};function qe(e){return e?Be[e.toLowerCase()]??"any":"any"}function He(e,t){const o=e[t];if(o&&"object"==typeof o)return o.value}function Ke(e,t){const o=He(e,t);return"number"==typeof o&&Number.isFinite(o)?o:void 0}function Ve(e,t,o){const n=e??{},r=(e=>{const t=He(e,y.ENUM);if(Array.isArray(t)&&t.every(je))return t})(n);if(r)return{type:"enum",values:r};const i=(e=>{const t=e[y.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(qe(e)){case"string":{const t=(e=>{if(e)return We[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=Ke(t,y.MIN),r=Ke(t,y.MAX);return void 0!==n&&(o.min=n),void 0!==r&&(o.max=r),o}case"boolean":return{type:"boolean"};case"array":return((e,t)=>{const o={type:"array",items:ze(e,t)},n=Ke(e,y.MIN),r=Ke(e,y.MAX);return void 0!==n&&(o.minItems=n),void 0!==r&&(o.maxItems=r),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 ze(e,t){if((e=>{const t=e[y.LIST];return!!t?.clazz?.length})(e))return{type:"model",name:Je(e)};const o=He(e,y.TYPE);if("string"==typeof o){const e=qe(o);return"model"===e?{type:"model",name:o}:{type:e}}if(t&&"array"!==t){const e=qe(t);return"model"===e?{type:"model",name:t}:{type:e}}return{type:"any"}}function Je(e){const t=e[y.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 Xe(e){return"workflow"===e.scope}function Ye(e){return"node"===e.scope}function Qe(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 Ze(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&&Ge(t)}return"expression"===t&&2===Object.keys(e).length&&"string"==typeof e.expression}const et=["any","string","number","boolean","array","object","enum","model"];function tt(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(e=>et.includes(e))(e.type)}function ot(e,t={seen:[]}){if(t.seen.includes(e))throw new A(`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("Document 'id' is required and must be a non-empty string");if("string"!=typeof e.name||!e.name)throw new A("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("Workflow port 'id' is required and must be a non-empty string");if(o.has(t.id))throw new A(`Workflow port '${t.id}' is declared more than once; workflow port ids must be unique`);if(void 0!==t.schema&&!tt(t.schema))throw new A(`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)nt(t,r);for(const t of e.nodes)t.loop&&rt(t,t.loop,n),t.errorBoundary&&it(t,t.errorBoundary,n);const i=new Set;for(const t of e.edges)st(t,i);for(const t of e.edges)dt(t.source,0,o,r,`Edge '${t.id}' source`),dt(t.target,0,o,r,`Edge '${t.id}' target`);if(void 0!==e.settings&&!Ue(e.settings))throw new A("Document settings must be JSON-safe (a map of JSON-safe values)");if(void 0!==e.metadata&&!Ue(e.metadata))throw new A("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&&!Ue(e.ui))throw new A("Document ui must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed")}function nt(e,t){if("string"!=typeof e.id||!e.id)throw new A("Node 'id' is required and must be a non-empty string");if(t.has(e.id))throw new A(`Node id '${e.id}' is declared more than once; node ids must be unique`);if("string"!=typeof e.kind||!e.kind)throw new A(`Node '${e.id}' must declare a non-empty string 'kind'`);if(void 0===e.parameters||null===e.parameters)throw new A(`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(Le(t))throw new A(`Node '${e.id}' input binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!Ze(o))throw new A(`Node '${e.id}' input binding for '${t}' must be a valid GraphInputBinding (edge, literal, or expression)`);if("literal"===o.mode&&!Ue(o.value))throw new A(`Node '${e.id}' literal binding for '${t}' must contain JSON-safe values`);if("expression"===o.mode&&!o.expression)throw new A(`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(Le(t))throw new A(`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(`Node '${e.id}' output binding for '${t}' must be an object with enabled and alias settings`)}if(!Ue(e.parameters))throw new A(`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(`Node '${e.id}' state must be an object when present`);if(!Ue(e.state))throw new A(`Node '${e.id}' state must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}}function rt(e,t,o){if(!t.body||"object"!=typeof t.body)throw new A(`Node '${e.id}' loop configuration requires a body document`);if(ot(t.body,o),!(void 0===t.maxIterations||Number.isFinite(t.maxIterations)&&t.maxIterations>0))throw new A(`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(`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(`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(Le(t))throw new A(`Node '${e.id}' loop mapping key '${t}' is not allowed (unsafe prototype-pollutant key)`);at(n,e.id,t)}}function it(e,t,o){if(!t.try||"object"!=typeof t.try)throw new A(`Node '${e.id}' error-boundary configuration requires a try body document`);ot(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(`Node '${e.id}' error-boundary ${n} body must be a document`);ot(r,o)}}function at(e,t,o){if(!e||"object"!=typeof e)throw new A(`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(`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(`Node '${t}' loop mapping '${o}' referencing a node must reference a node id and a port`);break;case"literal":if(!Ue(e.value))throw new A(`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(`Node '${t}' loop mapping '${o}' expression references must be non-empty expressions`);break;default:throw new A(`Node '${t}' loop mapping '${o}' must use a workflow, node, literal, or expression reference source`)}}function st(e,t){if("string"!=typeof e.id||!e.id)throw new A("Edge 'id' is required and must be a non-empty string");if(t.has(e.id))throw new A(`Edge id '${e.id}' is declared more than once; edge ids must be unique`);if(!Qe(e.source))throw new A(`Edge '${e.id}' source endpoint is not a valid GraphEndpoint`);if(!Qe(e.target))throw new A(`Edge '${e.id}' target endpoint is not a valid GraphEndpoint`);if("data"!==e.type&&"connection"!==e.type)throw new A(`Edge '${e.id}' type '${e.type+""}' is not a valid edge type (data or connection are allowed)`);if(t.add(e.id),!Ue(e))throw new A(`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 dt(e,t,o,n,r){if(Xe(e)){if(!o.has(e.port))throw new A(`${r} references workflow port '${e.port}' which is not declared on the document`)}else if(Ye(e)){if(!n.has(e.nodeId))throw new A(`${r} references node '${e.nodeId}' which is not part of the document`);if("string"!=typeof e.port||!e.port)throw new A(r+" node endpoints must reference a non-empty port identifier")}}const lt=["expression","template"],ct=["javascript","typescript","json","text"];function ut(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return!(!(e=>lt.includes(e))(t.mode)||"string"!=typeof t.expression||!t.expression||void 0!==t.language&&!(e=>ct.includes(e))(t.language)||void 0!==t.metadata&&!Ge(t.metadata))}function pt(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 ht(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 ft=["trigger","loop","branching","stateful","retryable","cancellable","parallel","resource"];function gt(e){return ft.includes(e)}function mt(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("Graph node manifest does not conform to the required shape");if(!Ue(e))throw new A("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 yt=["loadOptions","listSearch","resourceLocator","resourceMapping","validateParameter","action"];function wt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.name&&(e=>yt.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 bt(e){const t=e.element?.props?.value,o=t??e.prop?.value??e.validation?.defaultValue;if(void 0!==o&&"function"!=typeof o&&Ue(o))try{return JSON.parse(JSON.stringify(o))}catch{return}}function vt(e){if(e.type&&e.type in We)return{type:"string",format:We[e.type]};const t=(e=>{for(const t of[e.graph?.type,e.element?.props?.type,e.prop?.type])if("string"==typeof t&&"any"!==qe(t))return t})(e);return t?Ve((e=>{if(!e)return;const t=Object.entries(e).filter(([e])=>e!==y.TYPE);return Object.fromEntries(t)})(e.validation),t):Ve(e.validation,e.type,e.model)}function It(e){const t={};for(const[o,n]of Object.entries(e.graph?.metadata??{}))Ue(n)&&(t[o]=JSON.parse(JSON.stringify(n)));return Object.keys(t).length?t:void 0}function Et(e){switch(e){case"output":return"output";case"connection":return"connection";default:return"input"}}function Nt(e){const t=e.graph?.handle;return"connection"!==e.direction&&"string"==typeof t&&t?t:e.path??e.property}function Ot(e,t){const o={id:Nt(e),label:e.label,direction:Et(e.direction),schema:vt(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 i=Ct(e.graph?.connectionRules)??t;i&&(o.connectionPolicy=i);const a=(e=>{const t=e.element;if(!t||!Ue(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)?Fe(n):{}}})(e);a&&(o.element=a);const s=It(e);return s&&(o.metadata=s),o}function kt(e){const t={type:"string",id:Nt(e),label:e.label,required:e.required};if(e.hidden)return((e,t)=>{const o={...t,type:"hidden"},n=bt(e);return void 0!==n&&(o.defaultValue=n),At(o)})(e,t);const o=bt(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=It(e);if(r&&(t.metadata=r),(e=>{const t=St(e);return"code"===t||"code-editor"===t})(e))return At({...t,type:"code",language:Rt(e)});const i=vt(e);switch(i.type){case"number":{const o={...t,type:"number",integer:i.integer,min:i.min,max:i.max},n=_t(e.validation?.step);return void 0!==n&&(o.step=n),At(o)}case"boolean":return At({...t,type:"boolean"});case"enum":return At({...t,type:"options",options:i.values.map(e=>({value:e,label:e+""}))});case"array":{const e={...t,type:"collection"};return void 0!==i.maxItems&&(e.maxItems=i.maxItems),At(e)}case"object":case"model":return At({...t,type:"object"});default:return At({...t,type:"string",multiline:!!Dt(e)||void 0,pattern:xt(e.validation?.pattern),minLength:_t(e.validation?.minlength),maxLength:_t(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 xt(e){const t=e?.value;return"string"==typeof t?t:void 0}function _t(e){const t=e?.value;return"number"==typeof t&&Number.isFinite(t)?t:void 0}function St(e){const t=e.element?.tag;return"string"==typeof t&&t?t:void 0}function Dt(e){return"textarea"===St(e)||"textarea"===(e=>{const t=e.element?.props?.type;return"string"==typeof t?t:void 0})(e)}const Pt=["javascript","typescript","json","text"];function Rt(e){const t=e.element?.props?.language;return"string"==typeof t&&Pt.includes(t)?t:"javascript"}function $t(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 i=((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 i&&(o.icon=i),"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 Ct(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 i=t.maxConnections;return"number"==typeof i&&Number.isFinite(i)&&(o.maxConnections=i),Object.keys(o).length?o:void 0}function Tt(e,t={}){const o="function"==typeof e?e:e.constructor;if(!ve(o))throw new A(`Node '${o?.name??e+""}' is not decorated with @node and cannot produce a manifest`);const n=xe(o),r=Ae(Oe(o)),i=[],a=[],s=[],d=[],l=Ct(n.graph?.connectionRules);for(const e of r)("connection"===e.direction?s:"output"===e.direction?a:i).push(Ot(e,l)),"input"===e.direction&&d.push(kt(e));const c={kind:t.kind??n.kind??n.name,display:$t(n,t),inputs:i,outputs:a,parameters:d};return s.length&&(c.connections=s),n.namespaces?.length&&(c.namespaces=n.namespaces.slice()),mt(c),c}var Lt,Mt;(e=>{e.READABILITY="readability",e.COMPACTNESS="compactness",e.BALANCED="balanced"})(Lt||(Lt={})),(e=>{e.TIGHT="tight",e.NORMAL="normal",e.COMFORTABLE="comfortable"})(Mt||(Mt={})),Mt.TIGHT,Mt.NORMAL,Mt.COMFORTABLE,Lt.READABILITY,Mt.COMFORTABLE,Lt.COMPACTNESS,Mt.TIGHT,Lt.BALANCED,Mt.NORMAL;let jt=class extends T{constructor(e){super(e)}};S([P({type:String,generated:!1}),f("Unique graph run id"),i("ngx-decaf-crud-field",{label:"graph.run.id.label",readonly:!0}),D("design:type",String)],jt.prototype,"runId",void 0),S([R(),b(),$(),f("Workflow document id the run executes"),a("workflowId"),i("ngx-decaf-crud-field",{label:"graph.run.workflowId.label"}),D("design:type",String)],jt.prototype,"workflowId",void 0),S([R(),f("Owning user; absent for anonymous callers"),i("ngx-decaf-crud-field",{label:"graph.run.owner.label"}),D("design:type",String)],jt.prototype,"owner",void 0),S([R(),b(),v(String),$(),f("Current run lifecycle status"),a("status"),i("ngx-decaf-crud-field",{label:"graph.run.status.label",readonly:!0}),D("design:type",String)],jt.prototype,"status",void 0),S([R(),f("Fingerprint of the executed document"),i("ngx-decaf-crud-field",{label:"graph.run.fingerprint.label",readonly:!0}),D("design:type",String)],jt.prototype,"documentFingerprint",void 0),S([R(),g(),f("Workflow input values keyed by input port id"),D("design:type",Object)],jt.prototype,"inputs",void 0),S([R(),g(),f("Execution result, present on successful completion"),D("design:type",Object)],jt.prototype,"result",void 0),S([R(),g(),f("Structured error payload, present on failure"),D("design:type",Object)],jt.prototype,"error",void 0),S([I(),R(),f("Run creation timestamp"),D("design:type",Date)],jt.prototype,"createdAt",void 0),S([I(),R(),f("Execution start timestamp, once it has started"),D("design:type",Date)],jt.prototype,"startedAt",void 0),S([I(),R(),f("Terminal-state timestamp, once the run has finished"),D("design:type",Date)],jt.prototype,"finishedAt",void 0),jt=S([s("ngx-decaf-list-item",{icon:"ti-player-play"}),r("ngx-decaf-crud-form"),f("Persistable graph run lifecycle record"),C("graph_run"),E(),D("design:paramtypes",[Object])],jt);let Gt=class extends T{constructor(e){super(e)}};S([P({type:String,generated:!1}),D("design:type",String)],Gt.prototype,"workflowId",void 0),S([R(),D("design:type",String)],Gt.prototype,"name",void 0),S([R(),D("design:type",Object)],Gt.prototype,"document",void 0),S([R(),D("design:type",String)],Gt.prototype,"owner",void 0),S([R(),D("design:type",Object)],Gt.prototype,"snapshot",void 0),Gt=S([C("graph_workflow"),E(),D("design:paramtypes",[Object])],Gt),oe("Trigger",{color:"#3b82f6",icon:"ti-bolt"}),oe("Flow Control",{color:"#f59e0b",icon:"ti-arrows-split-2"}),oe("Utility",{color:"#0d9488",icon:"ti-tool"}),oe("Loop",{color:"#eab308",icon:"ti-repeat"}),oe("Workflow",{color:"#f97316",icon:"ti-sitemap"}),oe("Pipeline",{color:"#0ea5e9",icon:"ti-git-merge"}),oe("Node",{color:"#8b5cf6",icon:"ti-point-filled"}),oe("Agent",{color:"#7c3aed",icon:"ti-robot"}),oe("model",{color:"#3b82f6",icon:"ti-cpu"}),oe("memory",{color:"#10b981",icon:"ti-database"}),oe("workspace",{color:"#f59e0b",icon:"ti-folder"});const Ut=new Set;function Ft(e,t){return e.config[t]}function Bt(e){return Array.isArray(e)?e.map(e=>e+"").join(", "):e+""}(()=>{const t=[{key:le.NODE_ID,shouldInclude:e=>null!=Ft(e,le.NODE_ID),render:e=>Ft(e,le.NODE_ID)+""},{key:le.WORKFLOW_ID,shouldInclude:e=>null!=Ft(e,le.WORKFLOW_ID),render:e=>Ft(e,le.WORKFLOW_ID)+""},{key:le.RUN_ID,shouldInclude:e=>null!=Ft(e,le.RUN_ID),render:e=>Ft(e,le.RUN_ID)+""},{key:le.USER,shouldInclude:e=>null!=Ft(e,le.USER),render:e=>Ft(e,le.USER)+""},{key:le.ROLES,shouldInclude(e){const t=Ft(e,le.ROLES);return Array.isArray(t)&&t.length>0},render:e=>Bt(Ft(e,le.ROLES))},{key:le.NAMESPACES,shouldInclude(e){const t=Ft(e,le.NAMESPACES);return Array.isArray(t)&&t.length>0},render:e=>Bt(Ft(e,le.NAMESPACES))},{key:le.ORGANIZATION,shouldInclude:e=>null!=Ft(e,le.ORGANIZATION),render:e=>Ft(e,le.ORGANIZATION)+""},{key:le.IP,shouldInclude:e=>null!=Ft(e,le.IP),render:e=>Ft(e,le.IP)+""}];for(const o of t)Ut.has(o.key)||(e.register(o),Ut.add(o.key))})();const Wt="$workflow",qt="local",Ht=4,Kt=100,Vt=1e3,zt=1e3,Jt=1e4,Xt=3e4,Yt="graph.pinnable";var Qt,Zt;(e=>{e.MANUAL="manual",e.AUTOMATIC="automatic",e.DISABLED="disabled"})(Qt||(Qt={})),(e=>{e.TRUTHY="truthy",e.FALSY="falsy",e.EQUALS="equals",e.NOT_EQUALS="notEquals",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.EXISTS="exists",e.CUSTOM="custom"})(Zt||(Zt={}));const eo={FOREACH:"core.loop.foreach",WHILE:"core.loop.while",UNTIL:"core.loop.until"};class to extends x{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 no extends to{constructor(e,t){super(e,"GRAPH_INPUT_ERROR",t)}}class ro extends to{constructor(e,t){super(e,"GRAPH_LOOP_LIMIT_ERROR",t)}}class io extends to{constructor(e,t){super(e,"GRAPH_PINNING_ERROR",t)}}class ao extends to{constructor(e,t){super(e,"GRAPH_PORT_ERROR",t)}}class so extends to{constructor(e,t){super(e,"GRAPH_STORE_ERROR",t)}}class lo extends to{constructor(e,t){super(e,"GRAPH_TOPOLOGY_ERROR",t)}}class co extends to{constructor(e){super("Break signal","GRAPH_BREAK_SIGNAL",{value:e}),this.isBreakSignal=!0,this.name="GraphBreakSignal"}}class uo extends to{constructor(e){super(`Graph run '${e}' was cancelled`,"GRAPH_RUN_CANCELLED",{runId:e}),this.name=uo.name}}class po extends A{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 ho{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 fo{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 go(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(),i=o[1].split(",").map(e=>e.trim()).filter(e=>e.length>0);return n&&r&&0!==i.length?{organization:n,departments:i,role:r}:void 0}function mo(e){return`${e.organization}.${e.departments.join(",")}.${e.role}`}function yo(e){if(!e||"string"!=typeof e.namespace||!e.parts)return!1;const t=go(e.namespace);return!!t&&mo(t)===mo(e.parts)}function wo(e,t){const o="string"==typeof e?e.trim():"";if(o){if(t)for(const e of t)if(e&&e.namespace===o&&yo(e))return e.parts;return go(o)}}function bo(e,t,o={},n){const r=wo(e,n),i=wo(t,n);return!(!r||!i)&&r.organization===i.organization&&r.role===i.role&&("exact"===(o.mode??"inherit")?r.departments.length===i.departments.length&&r.departments.every((e,t)=>e===i.departments[t]):r.departments.length<=i.departments.length&&r.departments.every((e,t)=>e===i.departments[t]))}function vo(e,t,o={},n){return e.filter(e=>!t.some(t=>bo(t,e,o,n)))}function Io(e){return e.filter(e=>void 0===go(e))}function Eo(e,t){const o=new Set;for(const n of e){const e=wo(n,t);e&&o.add(e.role)}return[...o]}function No(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function Oo(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 ko(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 i=No(e.roles);i&&(t.roles=i);const a=No(e.namespaces);return a&&(t.namespaces=a,t.namespaceCache=xo(a)),t}function Ao(e){return e?ko({user:Oo(e,"user"),organization:Oo(e,"organization"),ip:Oo(e,"ip"),roles:Oo(e,"roles"),namespaces:Oo(e,"namespaces")}):{}}function xo(e){const t=[];for(const o of e){const e=go(o);e&&t.push({namespace:o,parts:e})}return t}function _o(...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??xo(o.namespaces):void 0!==o.namespaceCache&&(t.namespaceCache=o.namespaceCache));return t}class So{constructor(e={}){this.options=e}get enabled(){return!0===this.options.enabled}validate(e,o,n,r){if(!this.enabled)return;const i=r??this.options.logger??t.for("GraphAuth"),a=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=fe(e.namespaces),o=fe(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 '${a}'`,s?.namespaces??[],n,s?.roles??[],i);for(const e of o.nodes)this.assertGranted(`node '${e.id}'`,e.manifest.namespaces??[],n,[],i)}assertGranted(e,t,o,n,r){const i=o.namespaces??[],a=vo(t,i,this.options.match,o.namespaceCache),s=Eo(i,o.namespaceCache),d=n.filter(e=>!s.includes(e));if(0===a.length&&0===d.length)return;const l=[...new Set([...Io(t),...Io(i)])],c=[];throw a.length&&c.push("namespace(s) "+a.join(", ")),d.length&&c.push("role(s) "+d.join(", ")),r.warn(`Graph access denied for ${e} for user ${o.user??"anonymous"}: missing ${c.join(" and ")}${l.length?`; malformed namespace(s) ${l.join(", ")} failed closed`:""}`),new L(`Access to ${e} requires ${c.join(" and ")}`)}}class Do{constructor(e){this.baseOptions=e,this.inner=t.for("GraphRun").for(this.attributeConfig(e))}attributeConfig(e){return{[le.NODE_ID]:e.nodeId,[le.WORKFLOW_ID]:e.workflowId,[le.RUN_ID]:e.runId,[le.USER]:e.user??null,[le.ROLES]:e.roles,[le.NAMESPACES]:e.namespaces,[le.ORGANIZATION]:e.organization,[le.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:ce.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 Po(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}class Ro extends M{constructor(e,t,o,n,r,i,a,s,d={},l,c,u){super(),this.runId=e,this.parentRunId=t,this.workflowId=o,this.document=n,this.node=r,this.manifest=i,this.path=a,this.emitFn=s,this.metadata=d,this.engine=l,this.abortSignal=c,this.limits=u;const p=ko(d);this.accumulate({...p,operation:"execute"});const h="string"==typeof d?.user?d.user:null;this.runLogger=new Do({runId:e,workflowId:o,nodeId:r.id,user:h,roles:Po(d?.roles),namespaces:Po(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 Ao(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:ce.NODE_OUTPUT,payload:e})}async log(e,t){await this.emit({type:ce.NODE_OUTPUT,payload:{message:e,payload:t}})}}class $o{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 Co(e,t,o,n,r){const i=e.valueStore.getWorkflowValues(),a={};for(const[t,o]of e.nodeResults)a[t]=o;const s=[...e.events];return{runId:e.runId,workflowId:t.id||t.name,status:n,document:t,inputs:{...o},outputs:i,nodeResults:a,events:s,startedAt:e.startedAt,finishedAt:e.finishedAt,metadata:r}}class To{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:ce.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 Lo(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 Mo{static{this._cache={}}static register(e,t){return Mo._cache[e]=t,t}static get(e){const t=e??Mo._currentFlavour;if(t)return Mo._cache[t]}static getOrFail(e){const t=Mo.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 Mo.get()}static get currentFlavour(){return Mo._currentFlavour??qt}static setCurrent(e){Mo._currentFlavour=e}static list(){return Object.entries(Mo._cache).map(([e,t])=>({flavour:e,backend:t}))}static unregister(e){e&&(delete Mo._cache[e],Mo._currentFlavour===e&&(Mo._currentFlavour=void 0))}static clear(){for(const e of Object.keys(Mo._cache))delete Mo._cache[e];Mo._currentFlavour=void 0}}class jo{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 n=t;for(const e of o){if(null==n)return;n=n[e]}return n}}function Go(e){return"object"==typeof e&&null!==e&&"type"in e&&"code"===e.type}function Uo(e){return"object"==typeof e&&null!==e&&"op"in e&&"string"==typeof e.op}async function Fo(e,t,o){const n=o.engine?.codeSandboxEvaluator;if(!n)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 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 Bo(e,t,o){if(Uo(e))return(new jo).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 Wo(e,t,o){return Go(e)?Fo(e,t.input,o):Bo(e,t.state,t.label)}function qo(e,t,o,n){if(e&&"object"==typeof e&&!n.has(e))if(n.add(e),Go(e))o.push({nodeId:t,kind:"code-condition"});else if(ut(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,n);else if(Array.isArray(e))for(const r of e)qo(r,t,o,n);else for(const r of Object.keys(e))qo(e[r],t,o,n)}function Ho(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});qo(e.parameters,n,t,o),qo(e.metadata,n,t,o),qo(e.state,n,t,o),qo(e.loop,n,t,o)}function Ko(e,t,o){for(const n of e.nodes??[])Ho(n,t,o)}function Vo(e){const t=[];return Ko(e,t,new Set),t}function zo(e){return Vo(e).length>0}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,n=o.properties;if(!n)return{valid:!0};for(const[t,o]of Object.entries(n))if(t in e){const n=Jo(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 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 Qo=new Set(["loop"]),Zo=["secret","secrets","password","passwd","token","accessToken","refreshToken","apiKey","api_key","privateKey","credentials"];class en{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 i=!0===t.policies?.allowUndeclaredParameters,a=new Map(t.parameters.map(e=>[e.id,e]));for(const[r,s]of Object.entries(e.parameters??{})){const d=a.get(r);if(!d){i||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 i of t.parameters)void 0===(e.parameters??{})[i.id]&&(this.isParameterSatisfiedByInput(e,i.id,r)||(!0===i.required||(i.validation??[]).some(e=>"required"===e.kind))&&void 0===i.defaultValue&&o.push({code:"parameter.required-missing",path:`${n}.parameters.${i.id}`,message:`Node '${e.id}' is missing required parameter '${i.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(ut(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,n){const r=t.metadata?.allowedInstanceMetadataKeys;for(const i of Object.keys(e.metadata??{}))Qo.has(i)?o.push({code:"metadata.key-not-allowed",path:`${n}.metadata.${i}`,message:`Node '${e.id}' metadata key '${i}' is reserved and must not be set directly`,nodeId:e.id}):Array.isArray(r)&&!r.includes(i)&&o.push({code:"metadata.key-not-allowed",path:`${n}.metadata.${i}`,message:`Node '${e.id}' metadata key '${i}' 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||ae(n)||t.push({code:"disabled.invalid-behavior",path:o+".metadata.disabledBehavior",message:`Node '${e.id}' disabled behavior '${n+""}' is not one of: ${ie.join(", ")}`,nodeId:e.id})}validateBindingShapes(e,t,o,n){for(const[r,i]of Object.entries(e.inputBindings??{})){if("literal"===i.mode){const a=t.inputs.find(e=>e.id===r);if(a?.schema){const t=Jo(i.value,a.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"!==i.mode||"string"==typeof i.expression&&i.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,i={}){const a=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 a){const o=(e.inputBindings??{})[t];o&&"literal"===o.mode&&!0!==i.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&&(a.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(ae(o))return o;const n=t?.disabledBehavior;return ae(n)?n:"skip"}}let tn=class extends T{constructor(e){super(e)}};function on(e){return[e.namespace??"default",e.workflowId,e.nodeId,e.version??"default",e.fingerprint].join(":")}function nn(e){return new tn({id:on(e.key),workflowId:e.key.workflowId,nodeId:e.key.nodeId,fingerprint:e.key.fingerprint,...void 0!==e.key.namespace?{namespace:e.key.namespace}:{},...void 0!==e.key.version?{version:e.key.version}:{},pinned:e.pinned,outputs:e.outputs,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),...e.expiresAt?{expiresAt:new Date(e.expiresAt)}:{},...e.metadata?{metadata:e.metadata}:{}})}function rn(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}:{}}}S([P({type:String,generated:!1}),D("design:type",String)],tn.prototype,"id",void 0),S([R(),$(),D("design:type",String)],tn.prototype,"workflowId",void 0),S([R(),$(),D("design:type",String)],tn.prototype,"nodeId",void 0),S([R(),D("design:type",String)],tn.prototype,"fingerprint",void 0),S([R(),D("design:type",String)],tn.prototype,"namespace",void 0),S([R(),D("design:type",String)],tn.prototype,"version",void 0),S([R(),D("design:type",Boolean)],tn.prototype,"pinned",void 0),S([R(),D("design:type",Object)],tn.prototype,"outputs",void 0),S([R(),D("design:type",Date)],tn.prototype,"createdAt",void 0),S([R(),D("design:type",Date)],tn.prototype,"updatedAt",void 0),S([R(),D("design:type",Date)],tn.prototype,"expiresAt",void 0),S([R(),D("design:type",Object)],tn.prototype,"metadata",void 0),tn=S([C("graph_value"),E(),D("design:paramtypes",[Object])],tn);let an=class extends G{constructor(e){super(e,tn,!0),this.runtimeValues=new Map}seedWorkflowInputs(e){this.runtimeValues.set(Wt,{...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(Wt)??{};o[e]=t,this.runtimeValues.set(Wt,o)}getWorkflowValues(){return{...this.runtimeValues.get(Wt)??{}}}snapshot(){return Object.fromEntries(this.runtimeValues.entries())}async readCached(e,...t){try{return rn(await this.read(on(e),...t))}catch{return}}async writeCached(e,t,...o){const n=on(e);let r;try{r=await this.read(n,...o)}catch{r=void 0}r?await this.update(Object.assign(r,nn(t)),...o):await this.create(nn(t),...o)}async deleteCached(e,...t){try{await this.delete(on(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=>rn(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}};function sn(e){return new(0,G.forModel(tn,e.alias).constructor)(e)}an=S([j(tn,m),D("design:paramtypes",[Function])],an);class dn{static upstreamNodes(e,t,o=!1){const n=new Set,r=[e];for(;r.length;){const e=r.pop(),i=t.get(e)??[];for(const e of i)!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(),i=t.get(e)??[];for(const e of i)!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 ln{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 io(`Node '${e}' not found in plan`);if(!this.policy.canPin(o))throw new io(`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 io(`Node '${o}' has no completed output to pin`);const i=r.inputs??{},a=this.dependencyFingerprints(t,o,e.result),s=this.createValueKey(e.document.id,n,i,a),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 i=this.createValueKey(e,t,o,n,r),a=await this.store.readCached(i);if(a&&a.pinned){if(a.expiresAt&&new Date(a.expiresAt)<new Date)return;return a}}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)},i=this.stableSerialize(r);return this.simpleHash(i)}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=i=>{if(n.has(i))return;n.add(i);const a=dn.upstreamNodes(i,e.incomingByNode,!1);for(const e of a)t.has(e)&&r(e);o.push(i)};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 i=o.nodeResults[t],a=i?.inputs??{},s=this.dependencyFingerprints(e,t,o);r[t]=this.computeFingerprint(e.workflowId,n,a,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 cn={enabled:!0,strategy:"manual",includeDependencies:!0};function un(e){return!0===e?.enabled&&"disabled"!==e.strategy}class pn{canPin(e){return un(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?{...cn,...t}:{...cn,enabled:!1}}}class hn{getDependencies(e,t){return dn.upstreamNodes(t,e.incomingByNode,!1)}getPinSet(e,t){const o=this.getDependencies(e,t);return o.add(t),o}}class fn{constructor(){this.local=!0,this.codeMode="hostSide",Mo.register(qt,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");return await o.getDocument(e,...t)}async execute(e){const{document:t,plan:o,inputs:n,options:r,events:i}=e,a=i,s=a.frame;if(!s)throw new to("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 a.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===se.FAILED);if(e?.error)throw new to(e.error.message,e.error.code??"GRAPH_EXECUTION_ERROR",e.error.details);return s.finish(),await a.emit({type:ce.WORKFLOW_COMPLETED,runId:l,parentRunId:r.parentRunId,workflowId:o.workflowId,path:c,status:se.SUCCEEDED,payload:{outputs:d.getWorkflowValues()}}),Co(s,t,n,se.SUCCEEDED,r.metadata)}catch(e){if(e instanceof co)throw s.finish(),e;s.finish();const i=this.toErrorPayload(e);return e instanceof uo||!0===r.abortSignal?.aborted?(await a.emit({type:ce.WORKFLOW_CANCELLED,runId:l,parentRunId:r.parentRunId,workflowId:o.workflowId,path:c,status:se.CANCELLED,error:i}),Co(s,t,n,se.CANCELLED,r.metadata)):(await a.emit({type:ce.WORKFLOW_FAILED,runId:l,parentRunId:r.parentRunId,workflowId:o.workflowId,path:c,status:se.FAILED,error:i}),Co(s,t,n,se.FAILED,r.metadata))}}async executeLayer(e,t,o,n,r){const i=Math.max(1,n.concurrency??4),a=[...o];for(;a.length>0;){const o=a.splice(0,i);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 i=new Date,a=[...n.path??[],o.id];await r({type:ce.NODE_STARTED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:se.RUNNING}),this.emitNodeStateChanged(e,t,o,a,de.RUNNING,se.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:se.CACHED,inputs:s,outputs:n.outputs,startedAt:i,finishedAt:d,fromCache:!0,pinned:!0,events:[]};return e.recordNodeResult(l),await r({type:ce.NODE_CACHE_HIT,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:se.CACHED,payload:{outputs:n.outputs}}),await r({type:ce.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:se.SUCCEEDED,payload:{outputs:n.outputs,fromCache:!0}}),void this.emitNodeStateChanged(e,t,o,a,de.SUCCEEDED,se.SUCCEEDED,r)}}try{const d=new Ro(e.runId,n.parentRunId,t.workflowId,t.resolved.document,o.instance,o.manifest,a,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:se.SUCCEEDED,inputs:s,outputs:p,startedAt:i,finishedAt:h,events:[]};e.recordNodeResult(f),await r({type:ce.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:se.SUCCEEDED,payload:{outputs:p}}),this.emitNodeStateChanged(e,t,o,a,de.SUCCEEDED,se.SUCCEEDED,r)}catch(d){if(d instanceof co)throw d;const l=new Date,c=this.toErrorPayload(d),u={nodeId:o.id,status:se.FAILED,inputs:s,error:c,startedAt:i,finishedAt:l,events:[]};if(e.recordNodeResult(u),await r({type:ce.NODE_FAILED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:se.FAILED,error:c}),this.emitNodeStateChanged(e,t,o,a,de.FAILED,se.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===Wt||e.isDataEdgeActive(t.id))}async skipInactiveNode(e,t,o,n,r){const i=new Date,a=[...n.path??[],o.id];await r({type:ce.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:se.SKIPPED,payload:{reason:"branchNotSelected"}});const s={nodeId:o.id,status:se.SKIPPED,inputs:{},startedAt:i,finishedAt:new Date,events:[]};e.recordNodeResult(s),this.emitNodeStateChanged(e,t,o,a,de.SKIPPED,se.SKIPPED,r)}async executeDisabledNode(e,t,o,n,r){const i=new Date,a=[...n.path??[],o.id],s=en.disabledBehaviorOf(o.instance,t.resolved.document.settings);if(await r({type:ce.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:se.SKIPPED,payload:{disabled:!0,behavior:s}}),"skip"===s){const n={nodeId:o.id,status:se.SKIPPED,inputs:{},startedAt:i,finishedAt:new Date,events:[]};return e.recordNodeResult(n),void this.emitNodeStateChanged(e,t,o,a,de.SKIPPED,se.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",i=n?e.valueStore.getPort(n.sourceNodeId,n.sourcePort):Object.values(d)[0];l={[r]:i}}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:se.SUCCEEDED,inputs:d,outputs:l,startedAt:i,finishedAt:new Date,events:[]};e.recordNodeResult(c),this.emitNodeStateChanged(e,t,o,a,de.SUCCEEDED,se.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 to(`Node '${e.id}' of kind '${e.kind}' produced unknown output(s): ${r.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,unknownOutputs:r});const i=o.outputs.filter(e=>!0===e.required&&!(e.id in t)).map(e=>e.id);if(i.length>0)throw new to(`Node '${e.id}' of kind '${e.kind}' did not produce required output(s): ${i.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,missingRequired:i});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??""}:Yo(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:""}:Yo(o)&&(t[e]={credentialId:o.credentialId,credentialType:o.credentialType})}return t}async resolveNodeInputs(e,t,o,n){const r={},i=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type),a=new Map;for(const e of i){const t=a.get(e.targetPort)??[];t.push(e),a.set(e.targetPort,t)}for(const[t,o]of a)if(1===o.length)r[t]=e.valueStore.getPort(o[0].sourceNodeId,o[0].sourcePort);else{let n,i=!1;for(const t of o){const o=e.valueStore.getPort(t.sourceNodeId,t.sourcePort);r[t.sourcePort]=o,void 0!==o&&(n=o,i=!0)}i&&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[i,a]of Object.entries(n))r[i]=ut(a)?await this.evaluateValueTemplate(a,e,t,o):a;return r}async evaluateValueTemplate(e,t,o,n){const r=this.codeSandboxEvaluator;if(!r)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 i=e.language??("expression"===e.mode?"javascript":"text"),a="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:a,language:"typescript"===i?"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 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 i=n.metadata;return await r.evaluate({code:t,language:"javascript",input:o,vars:i?.vars??void 0,item:i?.item,index:i?.index,abortSignal:n.abortSignal})}async tryPinnedValue(e,t,o,n){if(!(new pn).shouldUsePinnedValue(o))return;const r=this.createPinningService(e),i=this.computeDependencyFingerprints(e,t,o.id);return r.readPinnedValue(t.workflowId,o,n,i)}computeDependencyFingerprints(e,t,o){const n=this.createPinningService(e),r=(new hn).getDependencies(t,o),i={};for(const o of r){const r=t.nodes.find(e=>e.id===o);if(r){const a=e.nodeResults.get(o),s=a?.inputs??{},d=this.computeDependencyFingerprints(e,t,o);i[o]=n.computeFingerprint(t.workflowId,r,s,d)}}return i}routeOutgoingEdges(e,t,o,n,r){const i=(t.outgoingByNode.get(o.id)??[]).filter(e=>"data"===e.type);for(const a of i){if(!Object.prototype.hasOwnProperty.call(n,a.sourcePort))continue;const i=n[a.sourcePort];e.activateDataEdge(a.id),a.targetNodeId===Wt&&e.valueStore.setWorkflowOutput(a.targetPort,i),this.emitEdgeStateChanged(e,t,o,a,de.SUCCEEDED,se.SUCCEEDED,r),r({type:ce.EDGE_VALUE_ROUTED,runId:e.runId,workflowId:t.workflowId,edgeId:a.id,nodeId:o.id,path:[],payload:{edge:a,value:i}}).catch(()=>{})}}emitNodeStateChanged(e,t,o,n,r,i,a){a({type:ce.NODE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:n,status:i,payload:{nodeId:o.id,state:r,runId:e.runId,workflowId:t.workflowId,status:i}}).catch(()=>{})}emitEdgeStateChanged(e,t,o,n,r,i,a){a({type:ce.EDGE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,edgeId:n.id,nodeId:o.id,path:[],status:i,payload:{edgeId:n.id,state:r,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,status:i}}).catch(()=>{})}createPinningService(e){const t=sn(e.valueStore.getAdapter()??this.valueAdapter);return new ln(t,new pn,new hn)}executionLimits(e){return{maxLoopIterations:e.maxLoopIterations??zt,maxForeachIterations:e.maxForeachIterations??Jt}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new uo(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 gn{constructor(e){this.catalogue=e}async resolveNodes(e,t,o,...n){const r=new Map;for(const[i,a]of e.entries()){const e=`nodes[${i}]`;if(this.catalogue.has(a.kind,...n))try{const e=await this.catalogue.resolveManifest(a.kind,a,o,...n),t=this.catalogue.getExecutor(a.kind,...n);r.set(a.id,{instance:a,manifest:e,executor:t})}catch(o){t.push({code:"kind.resolution-failed",path:e+".kind",message:`Node '${a.id}' kind '${a.kind}' failed to resolve: ${o.message}`,nodeId:a.id,details:{kind:a.kind}})}else t.push({code:"kind.unknown",path:e+".kind",message:`Node '${a.id}' references kind '${a.kind}' which is not registered in the backend catalogue`,nodeId:a.id,details:{kind:a.kind}})}return r}validateEffectivePorts(e,t,o,n){const r=!0===t.policies?.allowUndeclaredParameters,i=new Set(t.inputs.map(e=>e.id)),a=new Set(t.outputs.map(e=>e.id));for(const a of Object.keys(e.inputBindings??{}))r||i.has(a)||o.push({code:"binding.unknown-port",path:`${n}.inputBindings.${a}`,message:`Node '${e.id}' input binding '${a}' does not refer to an effective input port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveInputs:[...i]}});for(const i of Object.keys(e.outputBindings??{}))r||a.has(i)||o.push({code:"binding.unknown-port",path:`${n}.outputBindings.${i}`,message:`Node '${e.id}' output binding '${i}' does not refer to an effective output port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveOutputs:[...a]}})}}function mn(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&&mn(e,t,`${o}.nodes[${r.id}].loop.body`)}}class yn{resolveEdges(e,t,o){const n=new Set(e.inputs.map(e=>e.id)),r=new Set(e.outputs.map(e=>e.id)),i=[];for(const[a,s]of(e.edges??[]).entries()){const e=`edges[${a}]`,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),i.push(c)}return i}resolveEndpoint(e,t,o,n,r,i,a){const s=e[t];return Xe(s)?("source"===t?n.has(s.port):r.has(s.port))?{nodeId:Wt,port:s.port}:void i.push({code:"edge.unknown-port",path:`${a}.${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}}):Ye(s)?o.get(s.nodeId)?{nodeId:s.nodeId,port:s.port}:void i.push({code:"edge.unknown-node",path:`${a}.${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 i.push({code:"edge.invalid-endpoint",path:`${a}.${t}`,message:`Edge '${e.id}' ${t} endpoint is not a valid GraphEndpoint`,edgeId:e.id})}validateDirectionAndType(e,t,o,n,r,i){let a=!0;const s=t.nodeId===Wt?void 0:n.get(t.nodeId),d=o.nodeId===Wt?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,i),a=!1),!d||l(d)||this.hasPortDirection(d,o.port,"input")||(this.pushPortIssue(e,"target",o,d,r,i),a=!1);else{if(!s||!d)return r.push({code:"edge.boundary-routing",path:i,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:i,message:`Connection edge '${e.id}' endpoints must both be connection ports`,edgeId:e.id,details:{sourcePort:t.port,targetPort:o.port}}),!1}return a}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,i){const a="source"===t?"output":"input";r.push({code:"data"===e.type?"edge.invalid-direction":"edge.type-mismatch",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} port '${o.port}' on node '${o.nodeId}' is not an ${a} port of kind '${n.manifest.kind}'`,edgeId:e.id,nodeId:o.nodeId,details:{port:o.port,expected:a}})}}class wn{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(":"),i=n.slice(0,o),a=n.slice(o+1),s=e.nodeById.get(i),d=s?.manifest.connections?.find(e=>e.id===a)?.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 '${a}' on node '${i}' accepts at most ${l} connection(s) but has ${r.length}`,nodeId:i,edgeId:r[r.length-1].id,details:{port:a,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),i=r?.manifest.kind;if(!o.allowedNodeKinds?.length||i&&o.allowedNodeKinds.includes(i)||n.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${i??"unknown"}' is not in the allowed node kinds of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedNodeKinds:o.allowedNodeKinds}}),i&&o.blockedNodeKinds?.includes(i)&&n.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${i}' 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 bn{constructor(e){this.authorizer=e}async validate(e,t,o,n){const r=this.collectReferences(e,t);for(const i of t.credentials??[]){const a=r.find(e=>void 0===e.credentialType||e.credentialType===i.type);if(a){if(this.checkType(a,i))o.push({code:"credential.type-mismatch",path:n,message:`Node '${e.id}' credential '${a.credentialId}' has type '${a.credentialType}' but kind '${t.kind}' requires '${i.type}'`,nodeId:e.id,details:{credentialType:a.credentialType??"",requiredType:i.type}});else if(this.authorizer){if(!await this.authorizer.hasCredential(a)){o.push({code:"credential.not-found",path:n,message:`Node '${e.id}' references credential '${a.credentialId}' which does not exist`,nodeId:e.id,details:{credentialId:a.credentialId}});continue}await this.authorizer.authorize(a,i)||o.push({code:"credential.unauthorized",path:n,message:`Node '${e.id}' is not authorized to use credential '${a.credentialId}'`,nodeId:e.id,details:{credentialId:a.credentialId}})}}else!1!==i.required&&o.push({code:"credential.missing",path:n,message:`Node '${e.id}' does not provide the required credential of type '${i.type}'`,nodeId:e.id,details:{credentialType:i.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];Yo(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))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 n=new Set(Zo);for(const[r,i]of Object.entries(e.parameters??{}))this.scanPlainSecretValue(i,[r],e,o+".parameters",n,t);for(const[r,i]of Object.entries(e.metadata??{}))this.scanPlainSecretValue(i,[r],e,o+".metadata",n,t)}scanPlainSecretValue(e,t,o,n,r,i,a=0){const s=t[t.length-1];if(r.has(s))i.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>a&&null!==e)if(Array.isArray(e))for(const s of e)this.scanPlainSecretValue(s,[...t,"[]"],o,n,r,i,a+1);else if("object"==typeof e)for(const[s,d]of Object.entries(e))this.scanPlainSecretValue(d,[...t,s],o,n,r,i,a+1)}}class vn extends A{constructor(e,t=[]){super(e),this.issues=t,this.name=vn.name}}class In extends A{constructor(e,t){super(e),this.edgeId=t,this.name=In.name}}class En extends U{constructor(e){super(e),this.name=En.name}}const Nn={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},On=["node","definition","executor","execute","ports","component"];function kn(e){if(!e||"object"!=typeof e)return!1;const t=e;return pt(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 An(e,t){const o=[];for(const n of Object.keys(e))On.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 xn{constructor(e){this.options=e,this.parameterValidator=new en,this.edgeValidator=new yn,this.connectionPolicyValidator=new wn,this.nodeValidator=new gn(e.catalogue),this.credentialValidator=new bn(e.credentialAuthorizer)}async validateOrThrow(e,...t){const o=await this.validate(e,0,...t);if(!o.valid||!o.resolved)throw new vn(`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={...Nn,...this.options.limits};if(!await this.validateStructure(e,r,t,n,...o))return{valid:!1,issues:n};const i=await this.nodeValidator.resolveNodes(e.nodes,n,this.options.resolutionContext,...o),a=e.nodes.filter(e=>i.has(e.id)).map(e=>i.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 a)this.parameterValidator.validate(e.instance,e.manifest,n,`nodes[${e.instance.id}]`,s.get(e.instance.id));for(const e of a)this.nodeValidator.validateEffectivePorts(e.instance,e.manifest,n,`nodes[${e.instance.id}]`);const d=this.edgeValidator.resolveEdges(e,i,n),l=new Map,c=new Map;for(const e of d){if(e.targetNodeId!==Wt){const t=l.get(e.targetNodeId)??[];t.push(e),l.set(e.targetNodeId,t)}if(e.sourceNodeId!==Wt){const t=c.get(e.sourceNodeId)??[];t.push(e),c.set(e.sourceNodeId,t)}}this.connectionPolicyValidator.validate({edges:d,nodeById:i},n),this.validateAcyclicity(a,d,e,n),mn(e,n);for(const e of a)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 a)await this.credentialValidator.validate(e.instance,e.manifest,n,`nodes[${e.instance.id}]`);return this.validateCapabilities(a,n),n.length>0?{valid:!1,issues:n}:{valid:!0,issues:n,resolved:{document:e,nodes:a,edges:d,nodeById:i,incomingByNode:l,outgoingByNode:c}}}async validateStructure(e,t,o,n,...r){if(!pt(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"}),!Ue(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(...An(e,"$"));for(const t of[...e.inputs,...e.outputs])n.push(...An(t,"ports"));for(const t of e.nodes)n.push(...An(t,`nodes[${t.id}]`));for(const t of e.edges)n.push(...An(t,`edges[${t.id}]`));this.validateUniqueIds(e,n),this.validateLimits(e,t,o,n);try{ot(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,i]of[["input",e.inputs],["output",e.outputs]]){const e="input"===r?o:n;for(const o of i)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 i=new Set;for(const o of e.edges)i.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}):i.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[i,a]of e){if(!a)continue;const e=await this.validate(a,t+1,...n);for(const t of e.issues)o.push({...t,path:`nodes[${r.id}].${i}.${t.path}`,nodeId:t.nodeId??r.id})}}}validateAcyclicity(e,t,o,n){const r=new Set(e.map(e=>e.instance.id)),i=new Map(e.map(e=>[e.instance.id,0]));for(const e of t)r.has(e.sourceNodeId)&&i.has(e.targetNodeId)&&i.set(e.targetNodeId,(i.get(e.targetNodeId)??0)+1);const a=[...i.entries()].filter(([,e])=>0===e).map(([e])=>e),s=[];for(;a.length>0;){const e=a.shift();s.push(e);for(const o of t){if(o.sourceNodeId!==e)continue;if(!i.has(o.targetNodeId))continue;const t=(i.get(o.targetNodeId)??1)-1;i.set(o.targetNodeId,t),0===t&&a.push(o.targetNodeId)}}if(s.length!==i.size){const e=[...i.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===Wt&&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??[])gt(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}))}}}let _n=class extends B{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"}'`),!kn(e))throw new lo("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),i=this.buildPlanEdges(e),a=this.buildIncomingMap(i),s=this.buildOutgoingMap(i),d=this.topologicalLayers(r,i);return{resolved:e,workflowId:e.document.id||e.document.name,nodes:r,edges:i,layers:d,incomingByNode:a,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===Wt)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===Wt)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!==Wt),n=new Set(o.map(e=>e.id)),r=t.filter(e=>n.has(e.sourceNodeId)&&n.has(e.targetNodeId)),i=new Map;for(const e of o)i.set(e.id,0);for(const e of r)i.set(e.targetNodeId,(i.get(e.targetNodeId)??0)+1);const a=[],s=new Set;let d=o.filter(e=>0===(i.get(e.id)??0)),l=0;for(;d.length>0;){const e={index:l++,nodes:d};a.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=(i.get(e.targetNodeId)??1)-1;if(i.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 oo({unplannedNodes:e,workflowId:o[0]?.manifest.kind})}return a}};_n=S([F(),D("design:paramtypes",[])],_n);const Sn=new Set(["engine","valueAdapter","codeSandboxEvaluator","workflowStore"]);function Dn(e,t){const o={};for(const[n,r]of Object.entries(e??{}))Sn.has(n)&&!t.has(n)||(o[n]=r);return o}class Pn extends W{constructor(){super()}async initialize(...e){const t=e[0];if(!t||"object"!=typeof t||!t.registry)return this._config=void 0,this._client=void 0,{config:void 0,client:void 0};const o=t.catalogue??t.registry.catalog,n=t.valueAdapter??q.current;if(!n)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 r=t.backend??Mo.current??new fn,i={registry:t.registry,catalogue:o,planner:t.planner??new _n,backend:r,valueAdapter:n,eventEmitter:t.eventEmitter??new ho,documentValidator:t.documentValidator??new xn({catalogue:o,limits:t.documentLimits,credentialAuthorizer:t.credentialAuthorizer}),authValidator:new So({enabled:!0===t.authEnabled,...t.authMatch?{match:t.authMatch}:{}}),...t.codeSandboxEvaluator?{codeSandboxEvaluator:t.codeSandboxEvaluator}:{}};this._config=t,this._client=i;const a=new Set(["engine","valueAdapter"]);t.codeSandboxEvaluator&&a.add("codeSandboxEvaluator"),t.workflowStore&&a.add("workflowStore");const s=Dn(r.config,a);return await r.initialize({...s,valueAdapter:n,...t.codeSandboxEvaluator?{codeSandboxEvaluator:t.codeSandboxEvaluator}:{},...t.workflowStore?{workflowStore:t.workflowStore}:{},engine:this}),await(t.onEngineCreated?.(this)),{config:t,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:i}=(await this.logCtx(n,"execute",!0)).for(this.execute);r.debug(`Executing workflow '${e.id||e.name}'`);const a=this.mergeOptions(o);this.assertNotAborted(a);const s=_o(Ao(i),a.auth);a.auth=s,a.metadata={...a.metadata??{},...s};const d=a.runId??this.generateRunId();a.runId=d;const l=a.path??[],c=new fo,u=sn(this.valueAdapter);u.seedWorkflowInputs(this.withWorkflowInputDefaults(e,t));const p=new To(this.emitter,c,{runId:d,parentRunId:a.parentRunId,workflowId:e.id||e.name,path:l,engine:this,...this.codeSandboxEvaluator?{codeSandboxEvaluator:this.codeSandboxEvaluator}:{}});await p.emit({type:ce.VALIDATION_STARTED,status:se.PLANNING});const h=await this.documentValidator.validate(e,0,i);if(!h.valid||!h.resolved)throw await p.emit({type:ce.VALIDATION_FAILED,status:se.FAILED,payload:{issues:h.issues}}),new vn(`Graph workflow document '${e.id}' failed validation with ${h.issues.length} issue(s)`,h.issues);await p.emit({type:ce.VALIDATION_COMPLETED,status:se.PLANNING,payload:{issues:h.issues.length}}),this.assertNotAborted(a);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 $o(d,f,u,c);return p.bindFrame(g),await p.emit({type:ce.WORKFLOW_STARTED,runId:d,parentRunId:a.parentRunId,workflowId:f.workflowId,path:l,status:se.RUNNING,payload:{inputs:t}}),await p.emit({type:ce.WORKFLOW_PLANNED,runId:d,parentRunId:a.parentRunId,workflowId:f.workflowId,path:l,status:se.PLANNING,payload:{layers:f.layers.length,nodes:f.nodes.length}}),await this.client.backend.execute({document:e,plan:f,inputs:t,options:a,events:p},...n)}get backend(){return this.client.backend}get backendCapabilities(){return Lo(this.client.backend)}async listWorkflows(...e){const t=this.client.backend;if("supported"!==Lo(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"!==Lo(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});return await o.getWorkflow(e,...t)}async listEngineWorkflows(e,...t){const o=Mo.getOrFail(e);if("supported"!==Lo(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 n=Mo.getOrFail(e);if("supported"!==Lo(n).workflows.get||"function"!=typeof n.getWorkflow)throw new to(`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=Vo(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,ce.NODE_PINNED)}async unpinNode(e){const t=this.createPinningService();await t.unpinNode(e),await this.emitPinningEvent(e.nodeId,ce.NODE_UNPINNED)}createPinningService(){const e=sn(this.valueAdapter);return new ln(e,new pn,new hn)}async emitPinningEvent(e,t){const o=(new fo).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:zt,maxForeachIterations:Jt,usePinnedValues:!0,writeThroughCache:!1,path:[],metadata:{},...this.defaultOptions,...e}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new uo(e.runId??"unknown")}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 Rn=new Set(["process","require","module","exports","global","globalThis","Function","eval","fetch","XMLHttpRequest","WebSocket","Worker","Deno","Bun","__dispatch"]);class $n extends W{constructor(){super()}async initialize(...e){const t=e[0]??{},o=t&&"object"==typeof t?t:{};return this._config=o,this._client=V,{config:o,client:V}}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 n=((e,t)=>"javascript"===t?e:X.transpileModule(e,{compilerOptions:{target:X.ScriptTarget.ES2022,module:X.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=z.parse(`async function __validate() {\n${e}\n}`,{ecmaVersion:"latest",sourceType:"script"})}catch{try{t=z.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})}}J.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&&Rn.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"})})})(n);const r=!(e=>/\breturn\b[\s;]/.test(e))(n),i=r?n.replace(/[\s;]+$/,""):n,a={$input:e.input??{},$vars:e.vars??{},$item:e.item,$index:e.index,$node:e.nodes??{},$output:void 0},s=Object.keys(a),d=r?`return (${i});`:i,l=`"use strict";\nasync function __userFunction(${s.join(", ")}) {\n${d}\n}\n__userFunction(${s.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`,c=new V.Isolate({memoryLimit:this.defaultMemoryMb}),u=await c.createContext();try{const t=u.global;e.logger&&await this.injectConsole(u,e.logger);for(const[e,o]of Object.entries(a))await t.set(e,new V.ExternalCopy(void 0===o?null:o).copyInto());let o;try{o=await c.compileScript(l,{filename:"graph-code-node.js"})}catch(e){if(!r)throw new to("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:n,error:e.message});{const e=i,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 c.compileScript(t,{filename:"graph-code-node.js"})}catch(e){throw new to("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:n,error:e.message})}}}const d=e.timeoutMs??this.defaultTimeoutMs;let p;try{p=await this.runBounded(o,u,d,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 ${d} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:d});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:n,error:t})}if("string"!=typeof p)throw new to("Code sandbox returned an unexpected non-string result","GRAPH_CODE_SANDBOX_UNEXPECTED_RESULT",{result:p});return JSON.parse(p).v}finally{u.release(),c.dispose()}}async runBounded(e,t,o,n){const r=e.run(t,{timeout:o,promise:!0});r.catch(()=>{});const i=[r];let a,s;try{return i.push(new Promise((e,t)=>{a=setTimeout(()=>{t(new to(`Code execution timed out after ${o} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:o}))},o+100)})),n&&i.push(new Promise((e,t)=>{const r=()=>{const e="timeout"===n.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:n.reason}))};n.aborted?r():(n.addEventListener("abort",r,{once:!0}),s=()=>n.removeEventListener("abort",r))})),await Promise.race(i)}finally{a&&clearTimeout(a),s?.()}}async injectConsole(e,t){const o=new V.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(" "),i=1===n.length?n[0]:n;switch(e){case"log":case"info":default:t.info(r,i);break;case"warn":t.warn(r,i);break;case"error":t.error(r,i);break;case"debug":case"dir":case"dirxml":case"table":t.debug(r,i);break;case"trace":t.trace(r,i);break;case"group":case"groupCollapsed":t.debug("[group] "+r,i);break;case"groupEnd":t.debug("[groupEnd]",void 0);break;case"time":case"timeEnd":case"timeLog":case"count":case"countReset":t.debug(`[${e}] ${r}`,i);break;case"assert":n[0]||t.error("Assertion failed: "+r,i);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 Cn extends x{constructor(e){super(e,Cn.name,500)}}class Tn extends _{constructor(e){super(e),this.name=Tn.name}}class Ln extends _{constructor(e){super(e),this.name=Ln.name}}class Mn{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 Cn(`Method declaration for kind '${this.kind}' is missing a name`);if(this.declarations.has(e.name))throw new Cn(`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 Cn(`Method implementation '${e}' for kind '${this.kind}' is not a function`);if(!this.declarations.has(e))throw new Cn(`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 Cn(`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 Ln(`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 jn(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 Gn(e,t,o){const n=jn(t,e.itemIdPath),r=e.itemLabelPath?jn(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 Un(e,t){switch(t){case"input":return e.inputs;case"output":return e.outputs;default:return e.connections}}function Fn(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 i=Un(o,n.direction);e.forEach((e,t)=>{const{id:o,label:a}=Gn(n,e,t),s=(d={id:o,index:t,label:a??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?Fe(n.defaultPort):{id:s,label:a??s,direction:n.direction};l.id=s,l.direction=n.direction,a&&(l.label=a),i.push(l)})}else if("togglePort"===n.type){if(t[n.parameter]!==n.equals)continue;const e=Fe(n.port);if(!r(e.direction,e.id))continue;Un(o,e.direction).push(e)}return o}function Bn(e,t){const o=Fn(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),Fe(n)}class Wn{async resolve(e,t,o,n,r){if(o){const i=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)})(i))throw new Cn(`resolveManifest provider for kind '${e}' returned a value that does not conform to GraphResolvedNodeManifest`);if(!Ue(i))throw new Cn(`resolveManifest provider for kind '${e}' returned a non-JSON-safe resolved manifest`);const a=Fe(i);return!a.namespaces?.length&&t.namespaces?.length&&(a.namespaces=t.namespaces.slice()),a}return Bn(t,n.parameters??{})}}const qn=["edge","literal","expression"];function Hn(e){return qn.includes(e)}function Kn(e,t,o){if("string"!=typeof o||!o)throw new Cn(`Manifest for kind '${e}' has a ${t} with an empty port id`);if(Le(o))throw new Cn(`Manifest for kind '${e}' has a ${t} with unsafe port id '${o}'`)}let Vn=class extends B{constructor(){super(),this.entries=new Map,this.resolver=new Wn,this.fallbackContext=new M}withContext(e){return e[e.length-1]instanceof M?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 Cn("Graph node registration is required");if(!e.manifest||"object"!=typeof e.manifest)throw new Cn("Graph node registration is missing a manifest");if(!e.executor||"function"!=typeof e.executor.execute)throw new Cn(`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 Cn("Graph node manifest kind is required and must be a non-empty string");const i=r.kind;if(this.entries.has(i)&&!t.replace)throw new Cn(`Graph node kind '${i}' is already registered; pass { replace: true } to replace it`);try{mt(r)}catch(e){throw new Cn(`Manifest for kind '${i}' 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(Kn(e,t+" port",r?.id),o.has(r.id))throw new Cn(`Manifest for kind '${e}' declares duplicate static ${t} port id '${r.id}'`);if(o.add(r.id),void 0!==r.defaultMode&&!Hn(r.defaultMode))throw new Cn(`Manifest for kind '${e}' declares invalid default binding mode '${r.defaultMode+""}' on ${t} port '${r.id}'`)}}})(i,r);const a=((e,t)=>{const o=new Set;for(const n of t.parameters){const t=n?.id;if("string"!=typeof t||!t)throw new Cn(`Manifest for kind '${e}' has a parameter with an empty id`);if(Le(t))throw new Cn(`Manifest for kind '${e}' has a parameter with unsafe id '${t}'`);if(o.has(t))throw new Cn(`Manifest for kind '${e}' declares duplicate parameter id '${t}'`);o.add(t)}return o})(i,r);((e,t,o)=>{for(const n of t.dynamicPorts??[]){if(!n||"string"!=typeof n.parameter||!n.parameter)throw new Cn(`Manifest for kind '${e}' has a dynamic-port rule without a parameter reference`);if(!o.has(n.parameter))throw new Cn(`Manifest for kind '${e}' has a dynamic-port rule referencing missing parameter '${n.parameter}'`);if("togglePort"===n.type){if(!n.port)throw new Cn(`Manifest for kind '${e}' has a togglePort rule without a port`);Kn(e,"togglePort rule port",n.port.id)}if("repeatFromParameter"===n.type&&"string"!=typeof n.portIdTemplate)throw new Cn(`Manifest for kind '${e}' has a repeatFromParameter rule without a portIdTemplate`)}})(i,r,a),((e,t)=>{for(const o of t.credentials??[]){if(!ht(o))throw new Cn(`Manifest for kind '${e}' has a malformed credential requirement`);if(!o.type)throw new Cn(`Manifest for kind '${e}' has a credential requirement with an empty type`)}})(i,r),((e,t)=>{for(const o of t.methods??[])if(!wt(o))throw new Cn(`Manifest for kind '${e}' has a malformed method declaration`)})(i,r);const s=new Mn(i,r.methods??[],e.methods??{});return this.entries.set(i,{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 Cn("Graph executor kind is required");if(!t||"function"!=typeof t.execute)throw new Cn(`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 i={kind:e,display:{name:e},inputs:[],outputs:[],parameters:[],policies:{allowUndeclaredParameters:!0,allowUnknownOutputs:!0}};return this.entries.set(e,{registration:{manifest:i,executor:t},methods:new Mn(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 Tn(`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),Fe(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,i=[];for(const e of o){if(r&&!r.has(e))continue;const o=this.getManifest(e,...t);n&&!n.has(o.display.category??"")||i.push(o)}return i}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)}};Vn=S([F(),D("design:paramtypes",[])],Vn);let zn=class extends B{constructor(e=new Vn){super(),this.catalogue=e}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 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 Tn)throw new to(`No graph executor registered for kind '${e}'`,"GRAPH_EXECUTOR_NOT_FOUND",{kind:e});throw t}}};zn=S([F(),D("design:paramtypes",[Vn])],zn);let Jn=class extends B{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)}};function Xn(e){return e}function Yn(e){return e.methods??[]}function Qn(e){if(!e)return;const t={...e.metadata??{},...e.parameters??{},...e.state??{}};return e.loop&&(t.loop=e.loop),t}Jn=S([F(),D("design:paramtypes",[Function,Object])],Jn);class Zn extends w{constructor(e){super(),w.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)}}let er=class extends Zn{execute(e,t){throw new co(e.inputs.value)}};function tr(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+""}}S([b(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.break.fields.value.label",placeholder:"graph.node.flow_control.break.fields.value.placeholder",type:"textarea"}),Re({handle:"value"}),D("design:type",Object)],er.prototype,"value",void 0),er=S([De("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"}}),E()],er);let or=class extends Zn{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 to("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"]}),i=Object.values(r.nodeResults).find(e=>e.status===se.FAILED);if(i)throw new to(i.error?.message??"error boundary try body failed",i.error?.code??"GRAPH_ERROR_BOUNDARY",i.error?.details);return{result:r.outputs.result??r.outputs}}catch(r){let i=r;if(o.catch){const a=await n.execute(o.catch,{...e.inputs,error:tr(r)},{parentRunId:t.runId,path:[...t.path,"catch"]});i=a.outputs.error??a.outputs}return{error:i}}finally{o.finally&&await n.execute(o.finally,e.inputs,{parentRunId:t.runId,path:[...t.path,"finally"]})}}};S([b(),i("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"}),Re({handle:"value"}),D("design:type",Object)],or.prototype,"value",void 0),S([$e({handle:"result"}),D("design:type",Object)],or.prototype,"result",void 0),S([$e({handle:"error"}),D("design:type",Object)],or.prototype,"error",void 0),or=S([De("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}}),E()],or);let nr=class extends Zn{execute(e){const t=e.inputs.value??e.inputs;return!1===this.approved?{rejected:t}:{approved:t}}};S([b(),Re({handle:"value"}),D("design:type",Object)],nr.prototype,"value",void 0),S([i("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"}),Re({handle:"message",userControlled:!0}),D("design:type",String)],nr.prototype,"message",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.approved.label",type:"checkbox"}),Re({handle:"approved",userControlled:!0}),D("design:type",Boolean)],nr.prototype,"approved",void 0),S([$e({handle:"approved"}),D("design:type",Object)],nr.prototype,"approvedOut",void 0),S([$e({handle:"rejected"}),D("design:type",Object)],nr.prototype,"rejectedOut",void 0),nr=S([De("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}}),E()],nr);let rr=class extends Zn{execute(e,t){const o=e.inputs,n=o.value??o;if(!this.condition)throw new to("If node has no condition configured","GRAPH_IF_NO_CONDITION",{input:o});if(Go(this.condition))return Fo(this.condition,o,t).then(e=>this.route(e,n));const r=Bo(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 to("If node condition evaluated to false and the else branch is disabled","GRAPH_IF_ELSE_DISABLED",{condition:this.condition})}};S([b(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.value.label",placeholder:"graph.node.flow_control.if.fields.value.placeholder",type:"textarea"}),Re({handle:"value"}),D("design:type",Object)],rr.prototype,"value",void 0),S([b(),$e({handle:"then"}),D("design:type",Object)],rr.prototype,"then",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.condition.label",placeholder:"graph.node.flow_control.if.fields.condition.placeholder",type:"code"}),Re({handle:"condition",userControlled:!0,type:"object"}),D("design:type",Object)],rr.prototype,"condition",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.else.label",type:"checkbox"}),Re({handle:"else",userControlled:!0}),D("design:type",Boolean)],rr.prototype,"else",void 0),rr=S([De("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"}}),E()],rr);let ir=class extends Zn{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,i=r.value??r,a=((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(r,i);for(const e of n)if(await Wo(e.condition,{input:r,state:a,label:"switch case"},t))return{[e.outputPort]:i};if(!0!==o.hasDefault)throw new to("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]:i}}static applyMetadata(e){const t=xe(this),o=e.defaultPort??"default",n=!0===e.hasDefault,r=t.ports.filter(t=>!e.cases.some(e=>e.outputPort===t.property)),i=r.filter(e=>e.property!==o),a=r.find(e=>e.property===o),s=[...i,...e.cases.map(e=>({property:e.outputPort,name:e.label,direction:Z.OUTPUT,label:e.label,required:!1,hidden:!1,path:e.outputPort}))];return n&&a&&s.push(a),{ports:s,size:te(t,{cases:e.cases.length}),dataPatch:{switchMetadata:e}}}};S([b(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.value.label",placeholder:"graph.node.flow_control.switch.fields.value.placeholder",type:"textarea"}),Re({handle:"value"}),D("design:type",Object)],ir.prototype,"value",void 0),S([b(),$e({handle:"default"}),D("design:type",Object)],ir.prototype,"default",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.cases.label",type:"collection"}),D("design:type",Object)],ir.prototype,"cases",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.hasDefault.label",type:"checkbox"}),D("design:type",Boolean)],ir.prototype,"hasDefault",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.defaultPort.label",type:"text"}),D("design:type",String)],ir.prototype,"defaultPort",void 0),ir=S([De("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"}}),E()],ir);const ar={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},sr=o.accumulate({graph:{workflows:{limits:{...ar},allowAnonymousAccess:!1},execution:{maxCodeTimeoutMs:Xt}}}),dr=1e3;function lr(e,t){const o="number"==typeof t?t:Number(t),n=Number.isFinite(o)&&o>0?o:Xt,r="number"==typeof e?e:Number(e);return Number.isFinite(r)&&r>0?Math.min(Math.floor(r),n):1e3}const cr=["javascript","typescript"],ur="javascript";let pr=class extends w{constructor(){super(...arguments),this.language=ur}};S([b(),i("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.language.label",type:"select"}),N([...cr]),v(String),D("design:type",String)],pr.prototype,"language",void 0),S([b(),i("code-editor",{label:"graph.node.utility.code.fields.code.label",placeholder:"graph.node.utility.code.fields.code.placeholder"}),Re({handle:"code"}),D("design:type",String)],pr.prototype,"code",void 0),S([d(),Re({handle:"data"}),D("design:type",Object)],pr.prototype,"data",void 0),pr=S([E()],pr);let hr=class extends Zn{async execute(e,t){const o=e.inputs,n=this.input,r=o.code??e.parameters?.code??n?.code??this.defaultCode,i=n?.language??ur;if(!r||"string"!=typeof r||0===r.trim().length)throw new no("Code node has no code to execute (input.code is empty)",{input:o});const a=t.engine?.codeSandboxEvaluator;if(!a)throw new to("Code node execution requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:r});const s=sr.graph.execution?.maxCodeTimeoutMs,d="number"==typeof s&&Number.isFinite(s)&&s>0?s:Xt,l=lr(this.timeoutMs,d),c=t.metadata,u={code:r,language:i,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:i,length:r.length,timeoutMs:l});const p=await a.evaluate(u);return await t.log("Code node executed",{hasResult:void 0!==p}),{result:p}}};S([b(),Re({handle:"input",model:pr}),D("design:type",pr)],hr.prototype,"input",void 0),S([O(1),k(Xt),i("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.timeoutMs.label",type:"number"}),Re({handle:"timeoutMs"}),D("design:type",Number)],hr.prototype,"timeoutMs",void 0),S([i("code-editor",{label:"graph.node.utility.code.fields.defaultCode.label",placeholder:"graph.node.utility.code.fields.defaultCode.placeholder"}),Re({handle:"defaultCode",userControlled:!0}),D("design:type",String)],hr.prototype,"defaultCode",void 0),S([b(),$e({handle:"result"}),D("design:type",Object)],hr.prototype,"result",void 0),hr=S([De("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"}}),E()],hr);let fr=class extends Zn{execute(e){return{value:e.inputs.value??e.inputs}}};S([b(),Re({handle:"value"}),D("design:type",Object)],fr.prototype,"value",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.utility.delay.fields.timeoutMs.label",type:"number"}),Re({handle:"timeoutMs"}),D("design:type",Number)],fr.prototype,"timeoutMs",void 0),S([b(),$e({handle:"value"}),D("design:type",Object)],fr.prototype,"valueOut",void 0),fr=S([De("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"}}),E()],fr);let gr=class extends Zn{execute(e,t){const o=e.inputs.value,n=this.level??"info";return t.logger[n](this.message??"Log node",{value:o}),{value:o}}};S([b(),Re({handle:"value"}),D("design:type",Object)],gr.prototype,"value",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.message.label",placeholder:"graph.node.utility.log.fields.message.placeholder",type:"textarea"}),Re({handle:"message"}),D("design:type",String)],gr.prototype,"message",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.level.label",placeholder:"graph.node.utility.log.fields.level.placeholder",type:"text"}),Re({handle:"level",userControlled:!0}),D("design:type",String)],gr.prototype,"level",void 0),S([b(),$e({handle:"value"}),D("design:type",Object)],gr.prototype,"valueOut",void 0),gr=S([De("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"}}),E()],gr);let mr=class extends Zn{execute(e){return{result:{mapped:e.inputs.value??e.inputs}}}};S([b(),i("ngx-decaf-crud-field",{label:"graph.node.utility.map.fields.value.label",placeholder:"graph.node.utility.map.fields.value.placeholder",type:"textarea"}),Re({handle:"value"}),D("design:type",Object)],mr.prototype,"value",void 0),S([b(),$e({handle:"result"}),D("design:type",Object)],mr.prototype,"result",void 0),mr=S([De("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:{}}}),E()],mr);let yr=class extends Zn{execute(e,t){const o=e.inputs.value,n=this.level??"info";return t.logger[n](this.message??"Log node",{value:o}),{value:o}}};S([b(),Re({handle:"value"}),D("design:type",Object)],yr.prototype,"value",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.message.label",placeholder:"graph.node.utility.utility_log.fields.message.placeholder",type:"textarea"}),Re({handle:"message"}),D("design:type",String)],yr.prototype,"message",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.level.label",placeholder:"graph.node.utility.utility_log.fields.level.placeholder"}),Re({handle:"level",userControlled:!0,type:"string"}),D("design:type",String)],yr.prototype,"level",void 0),S([b(),$e({handle:"value"}),D("design:type",Object)],yr.prototype,"valueOut",void 0),yr=S([De("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"}}),E()],yr);let wr=class extends Zn{execute(e){return{message:e.inputs.message??null,sessionId:e.inputs.sessionId??null,userId:e.inputs.userId??null}}};S([b(),$e({handle:"message"}),D("design:type",String)],wr.prototype,"message",void 0),S([b(),$e({handle:"sessionId"}),D("design:type",String)],wr.prototype,"sessionId",void 0),S([b(),$e({handle:"userId"}),D("design:type",String)],wr.prototype,"userId",void 0),wr=S([De("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"}}}),E()],wr);let br=class extends Zn{execute(e){return{payload:e.inputs.payload??null}}};S([b(),$e({handle:"payload"}),D("design:type",Object)],br.prototype,"payload",void 0),br=S([De("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"}}}),E()],br);let vr=class extends Zn{execute(e){return{payload:e.inputs.payload??null}}};S([b(),Re({handle:"schema"}),i("ngx-decaf-model-builder",{label:"graph.node.trigger.form.fields.schema.label",placeholder:"graph.node.trigger.form.fields.schema.placeholder"}),D("design:type",Object)],vr.prototype,"schema",void 0),S([b(),$e({handle:"payload"}),D("design:type",Object)],vr.prototype,"payload",void 0),vr=S([De("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:[]}}}),E()],vr);let Ir=class extends Zn{execute(e){return{payload:e.inputs.payload??null}}};S([b(),$e({handle:"payload"}),D("design:type",Object)],Ir.prototype,"payload",void 0),Ir=S([De("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:{}}}}),E()],Ir);let Er=class extends Zn{execute(e){return{payload:e.inputs.payload??null}}};S([b(),Re({handle:"cron"}),i("app-cron-selector-field",{label:"graph.node.trigger.schedule.fields.cron.label",placeholder:"graph.node.trigger.schedule.fields.cron.placeholder"}),D("design:type",String)],Er.prototype,"cron",void 0),S([b(),$e({handle:"payload"}),D("design:type",Object)],Er.prototype,"payload",void 0),Er=S([De("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"}}}),E()],Er);let Nr=class extends Zn{execute(e){return{payload:e.inputs.payload??null}}};S([b(),Re({handle:"schema"}),i("ngx-decaf-model-builder",{label:"graph.node.trigger.webhook.fields.schema.label",placeholder:"graph.node.trigger.webhook.fields.schema.placeholder"}),D("design:type",Object)],Nr.prototype,"schema",void 0),S([b(),$e({handle:"payload"}),D("design:type",Object)],Nr.prototype,"payload",void 0),Nr=S([De("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"}}}),E()],Nr);let Or=class extends Zn{execute(e){return{response:"[Agent response] "+(e.inputs.prompt??""),actions:[]}}};S([b(),i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.prompt.label",placeholder:"graph.node.agent.agent.fields.prompt.placeholder",type:"textarea"}),Re({handle:"prompt"}),D("design:type",String)],Or.prototype,"prompt",void 0),S([b(),$e({handle:"response"}),D("design:type",String)],Or.prototype,"response",void 0),S([b(),$e({handle:"actions"}),D("design:type",Array)],Or.prototype,"actions",void 0),S([Ce({category:"model",handle:"model"}),D("design:type",Object)],Or.prototype,"model",void 0),S([Ce({category:"memory",handle:"memory"}),D("design:type",Object)],Or.prototype,"memory",void 0),S([Ce({category:"workspace",handle:"workspace"}),D("design:type",Object)],Or.prototype,"workspace",void 0),Or=S([De("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"}}),E()],Or);const kr=[Or];function Ar(e,t,o,n){const r=t??o;if(null==e)return Math.min(o,r);const i=Number(e);if(!Number.isFinite(i)||0>=i)throw new no(n+" loop maxIterations must be a positive finite number");return Math.min(Math.floor(i),r)}function xr(e,t,o){const n=t.node.loop,r=t.metadata?.loop;if(!n?.body&&!r?.body)throw new no(o+" node is missing loop configuration (instance.loop.body)");const i=t=>{const o=e[t]??n?.[t]??r?.[t],i=Number(o);return void 0!==o&&Number.isFinite(i)?i:void 0},a=t=>{const o=e[t]??r?.[t];return"string"==typeof o?o:void 0};return{body:n?.body??r?.body,maxIterations:i("maxIterations"),timeoutMs:i("timeoutMs"),concurrency:i("concurrency"),condition:e.condition??r?.condition,inputPort:a("inputPort"),outputPort:a("outputPort"),itemPort:a("itemPort"),resultPort:a("resultPort"),statePort:a("statePort"),slice:i("slice")}}let _r=class extends Zn{async execute(e,t){const o=xr(this,t,"foreach"),n=e.inputs,r=n.items,i=Ar(o.maxIterations,t.limits?.maxForeachIterations,1e3,"foreach");if(!Array.isArray(r))throw new no("foreach input 'items' must be an array");const a=t.engine;if(!a)throw new to("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>i)throw new ro(`foreach exceeded max iterations (${l} > ${i})`);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:ce.LOOP_STARTED});for(let e=0;l>e;e++){await t.emit({type:ce.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 a.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 co){const n=o.details?.value;void 0!==n&&f.push(n),m=!0,await t.emit({type:ce.LOOP_ITERATION_COMPLETED,iteration:e,metadata:{broken:!0}});break}throw o}await t.emit({type:ce.LOOP_ITERATION_COMPLETED,iteration:e})}await t.emit({type:ce.LOOP_COMPLETED,metadata:{broken:m}});const y={results:f,completed:f,iterations:f.length,broken:m};return void 0!==g&&(y[p]=g),y}};S([b(),i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.items.label",placeholder:"graph.node.loop.foreach.fields.items.placeholder",type:"textarea"}),Re({handle:"items"}),D("design:type",Array)],_r.prototype,"items",void 0),S([b(),i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.slice.label",placeholder:"graph.node.loop.foreach.fields.slice.placeholder",type:"number"}),Re({handle:"slice"}),D("design:type",Number)],_r.prototype,"slice",void 0),S([b(),$e({handle:"item"}),D("design:type",Object)],_r.prototype,"item",void 0),S([b(),Ce({handle:"loop",connectionRules:{allowSelf:!0,maxConnections:1}}),D("design:type",Object)],_r.prototype,"loop",void 0),S([b(),$e({handle:"completed"}),D("design:type",Array)],_r.prototype,"completed",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.maxIterations.label",type:"number"}),Re({handle:"maxIterations",userControlled:!0}),D("design:type",Number)],_r.prototype,"maxIterations",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.condition.label",type:"code"}),Re({handle:"condition",userControlled:!0}),D("design:type",Object)],_r.prototype,"condition",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.itemPort.label",type:"text"}),Re({handle:"itemPort",userControlled:!0}),D("design:type",String)],_r.prototype,"itemPort",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.resultPort.label",type:"text"}),Re({handle:"resultPort",userControlled:!0}),D("design:type",String)],_r.prototype,"resultPort",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.statePort.label",type:"text"}),Re({handle:"statePort",userControlled:!0}),D("design:type",String)],_r.prototype,"statePort",void 0),_r=S([De("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}}}),E()],_r);class Sr{constructor(){this.expressionEvaluator=new jo}evaluate(e,t){if(this.isConditionExpression(e))return this.expressionEvaluator.evaluate(e,t);const o=this.resolveValue(e.left,t),n=e.right;switch(e.type){case Zt.TRUTHY:return!!o;case Zt.FALSY:return!o;case Zt.EQUALS:return o===n;case Zt.NOT_EQUALS:return o!==n;case Zt.GREATER_THAN:return Number(o)>Number(n);case Zt.GREATER_THAN_OR_EQUAL:return Number(o)>=Number(n);case Zt.LESS_THAN:return Number(n)>Number(o);case Zt.LESS_THAN_OR_EQUAL:return Number(n)>=Number(o);case Zt.EXISTS:return null!=o;case Zt.CUSTOM:throw new to("Custom condition evaluators are not supported in v1","GRAPH_CUSTOM_CONDITION_UNSUPPORTED");default:throw new to(`Unknown condition type '${e.type}'`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e})}}async evaluateAsync(e,t,o,n){return Go(e)?Fo(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}}let Dr=class extends Zn{async execute(e,t){const o=xr(this,t,"until"),n=e.inputs,r=Ar(o.maxIterations,t.limits?.maxLoopIterations,100,"until"),i=o.condition;if(!i)throw new no("until node is missing a condition");const a=o.statePort??"state",s=o.inputPort??a,d=o.outputPort??a,l=o.body,c=t.engine;if(!c)throw new to("until node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let u=n.state,p=0;await t.emit({type:ce.LOOP_STARTED});let h=!1;do{if(p>=r)throw await t.emit({type:ce.LOOP_LIMIT_REACHED,iteration:p}),new ro(`until loop exceeded max iterations (${r})`);await t.emit({type:ce.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:ce.LOOP_ITERATION_COMPLETED,iteration:p});const e=await(new Sr).evaluateAsync(i,u,t,{...n,state:u});await t.emit({type:ce.LOOP_CONDITION_EVALUATED,iteration:p,payload:{result:e}}),p++,h=e}while(!h);return await t.emit({type:ce.LOOP_COMPLETED}),{state:u,iterations:p}}};S([b(),i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.state.label",placeholder:"graph.node.loop.until.fields.state.placeholder",type:"textarea"}),Re({handle:"state"}),D("design:type",Object)],Dr.prototype,"state",void 0),S([b(),$e({handle:"state"}),D("design:type",Object)],Dr.prototype,"stateOut",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.maxIterations.label",type:"number"}),Re({handle:"maxIterations",userControlled:!0}),D("design:type",Number)],Dr.prototype,"maxIterations",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.condition.label",type:"code"}),Re({handle:"condition",userControlled:!0}),D("design:type",Object)],Dr.prototype,"condition",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.statePort.label",type:"text"}),Re({handle:"statePort",userControlled:!0}),D("design:type",String)],Dr.prototype,"statePort",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.inputPort.label",type:"text"}),Re({handle:"inputPort",userControlled:!0}),D("design:type",String)],Dr.prototype,"inputPort",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.outputPort.label",type:"text"}),Re({handle:"outputPort",userControlled:!0}),D("design:type",String)],Dr.prototype,"outputPort",void 0),Dr=S([De("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}}}}),E()],Dr);let Pr=class extends Zn{async execute(e,t){const o=xr(this,t,"while"),n=e.inputs,r=Ar(o.maxIterations,t.limits?.maxLoopIterations,100,"while"),i=o.condition;if(!i)throw new no("while node is missing a condition");const a=o.statePort??"state",s=o.inputPort??a,d=o.outputPort??a,l=o.body,c=t.engine;if(!c)throw new to("while node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let u=n.state,p=0;for(await t.emit({type:ce.LOOP_STARTED});await(new Sr).evaluateAsync(i,u,t,{...n,state:u});){if(p>=r)throw await t.emit({type:ce.LOOP_LIMIT_REACHED,iteration:p}),new ro(`while loop exceeded max iterations (${r})`);await t.emit({type:ce.LOOP_CONDITION_EVALUATED,iteration:p,payload:{result:!0}}),await t.emit({type:ce.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:ce.LOOP_ITERATION_COMPLETED,iteration:p}),p++}return await t.emit({type:ce.LOOP_COMPLETED}),{state:u,iterations:p}}};S([b(),i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.state.label",placeholder:"graph.node.loop.while.fields.state.placeholder",type:"textarea"}),Re({handle:"state"}),D("design:type",Object)],Pr.prototype,"state",void 0),S([b(),$e({handle:"state"}),D("design:type",Object)],Pr.prototype,"stateOut",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.maxIterations.label",type:"number"}),Re({handle:"maxIterations",userControlled:!0}),D("design:type",Number)],Pr.prototype,"maxIterations",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.condition.label",type:"code"}),Re({handle:"condition",userControlled:!0}),D("design:type",Object)],Pr.prototype,"condition",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.statePort.label",type:"text"}),Re({handle:"statePort",userControlled:!0}),D("design:type",String)],Pr.prototype,"statePort",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.inputPort.label",type:"text"}),Re({handle:"inputPort",userControlled:!0}),D("design:type",String)],Pr.prototype,"inputPort",void 0),S([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.outputPort.label",type:"text"}),Re({handle:"outputPort",userControlled:!0}),D("design:type",String)],Pr.prototype,"outputPort",void 0),Pr=S([De("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}}}}),E()],Pr);let Rr=class extends Zn{execute(e){const t=e.inputs;return{value:t?.value??null}}};S([$e({handle:"value",connectionRules:{allowMultiple:!0}}),D("design:type",Object)],Rr.prototype,"value",void 0),Rr=S([De("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"}}),E()],Rr);let $r=class extends Zn{execute(e){return{}}};function Cr(e,t,o,n={}){return{id:e,label:t,direction:o,...n}}function Tr(e){const t=e,o=ve(t),n=o?.metadata?.title;return Tt(t,n?{name:n}:{})}S([b(),Re({handle:"value"}),D("design:type",Object)],$r.prototype,"value",void 0),$r=S([De("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"}}),E()],$r);const Lr={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:[Cr("items","graph.node.loop.foreach.ports.input.items.label","input",{required:!0,schema:{type:"array",items:{type:"any"}}}),Cr("slice","graph.node.loop.foreach.ports.input.slice.label","input",{schema:{type:"number",integer:!0,min:1}}),Cr("state","graph.node.loop.foreach.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[Cr("results","graph.node.loop.foreach.ports.output.results.label","output",{schema:{type:"array",items:{type:"any"}}}),Cr("completed","graph.node.loop.foreach.ports.output.completed.label","output",{schema:{type:"array",items:{type:"any"}}}),Cr("iterations","graph.node.loop.foreach.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}}),Cr("broken","graph.node.loop.foreach.ports.output.broken.label","output",{schema:{type:"boolean"}}),Cr("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}]},Mr={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:[Cr("state","graph.node.loop.while.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[Cr("state","graph.node.loop.while.ports.output.state.label","output",{schema:{type:"any"}}),Cr("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"}]},jr={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:[Cr("state","graph.node.loop.until.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[Cr("state","graph.node.loop.until.ports.output.state.label","output",{schema:{type:"any"}}),Cr("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"}]},Gr=[Tr(Rr),Tr($r),Tr(Ir),Tr(Nr),Tr(Er),Tr(br),Tr(vr),Tr(wr),(Ur=Tr(rr),{...Ur,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"}}}]}))(Tr(ir)),Tr(mr),Tr(fr),Tr(or),Tr(nr),Tr(hr),Tr(gr),Tr(yr),Tr(er),Tr(Or),Lr,Mr,jr];var Ur;const Fr=Object.fromEntries(Gr.map(e=>[e.kind,e])),Br=[Ir,Nr,Er,br,vr,wr],Wr=[rr,ir,fr,or,nr,gr,er],qr=[hr,mr,yr],Hr=[_r,Pr,Dr],Kr=[Rr,$r],Vr={value:Rr,result:$r,"core.trigger.manual":Ir,"core.trigger.webhook":Nr,"core.trigger.schedule":Er,"core.trigger.event":br,"core.trigger.form":vr,"core.trigger.chat":wr,"core.flow.if":rr,"core.flow.switch":ir,"core.utility.map":mr,"core.flow.delay":fr,"core.flow.errorBoundary":or,"core.flow.humanApproval":nr,"core.utility.code":hr,"core.flow.log":gr,"core.utility.log":yr,"core.flow.break":er,"core.agent":Or,"core.loop.foreach":_r,"core.loop.while":Pr,"core.loop.until":Dr};function zr(e){return{execute:(t,o)=>e.instantiate({...Qn(o.node),...t.parameters,...o.node.state??{}}).execute(t,o)}}function Jr(){const e=[];for(const[t,o]of Object.entries(Fr)){const n=Vr[t];n&&e.push(Xn({manifest:o,executor:zr(n)}))}return e}function Xr(e,...t){for(const o of Jr())e.register(o,{},...t);return e}class Yr{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}}}class Qr{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 no(`Missing required ${o} port '${n.name}'`);if(e&&!this.resolver.resolve(n).validate(t[n.name]))throw new no(`Invalid value for ${o} port '${n.name}'`)}}}const Zr=["node","definition","executor","execute","ports","component"];function ei(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 ti(e,t){const o=[];for(const n of Object.keys(e))Zr.includes(n)&&o.push(ei("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 oi(e,t){t.push(...ti(e,"$")),e.inputs.forEach((e,o)=>t.push(...ti(e,`inputs[${o}]`))),e.outputs.forEach((e,o)=>t.push(...ti(e,`outputs[${o}]`)));for(const o of e.nodes)t.push(...ti(o,`nodes[${o.id}]`)),o.loop&&(t.push(...ti(o.loop,`nodes[${o.id}].loop`)),oi(o.loop.body,t));for(const o of e.edges)t.push(...ti(o,`edges[${o.id}]`))}function ni(e,t){const o=[];e.nodes.length>t.maxNodes&&o.push(ei("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(ei("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=ri(e);n>t.maxNestingDepth&&o.push(ei("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(ei("document.limit.size","$",`Document serializes to ${r} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,{details:{bytes:r,limit:t.maxDocumentBytes}})),o}function ri(e,t=0){let o=t;for(const n of e.nodes)n.loop?.body&&(o=Math.max(o,ri(n.loop.body,t+1)));return o}async function ii(e,t,...o){const n=[];for(const r of e.nodes)t.has(r.kind,...o)||n.push(ei("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 ii(r.loop.body,t,...o));return n}async function ai(e,t={},...o){const n={...ar,...t.limits},r=[];if(!pt(e))return r.push(ei("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(!Ue(e))return r.push(ei("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};oi(e,r),r.push(...(e=>{const t=[],o=new Set;for(const n of[...e.inputs,...e.outputs])o.has(n.id)?t.push(ei("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(ei("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(ei("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(...ni(e,n)),mn(e,r);try{ot(e)}catch(e){const t=e instanceof A?e.message:e+"";r.push(ei("document.structure","$",t))}return t.catalogue&&r.push(...await ii(e,t.catalogue,...o)),{valid:0===r.length,issues:r}}class si{constructor(e,t){this.iteration=e,this.metadata=t}}function di(e,t,o={}){const n=e?.owner??null;return!n||n===t||(null==t||""===t)&&!0===o.allowAnonymousAccess}function li(e,t){return(e?.owner??null)===(t??null)}function ci(e,t,o){if(!li(e,t))throw new L(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function ui(e,t,o){if(!di(e,t,o))throw new L(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function pi(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>pi(e)).join(",")}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${pi(t[e])}`).join(",")}}`}function hi(e){return Y("sha256").update(pi(e)).digest("hex")}class fi{constructor(e={}){this.events=new Map,this.listeners=new Map,this.limits={...ue,...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=>!he(e.type));if(-1===t)break;e.splice(t,1)}}}function gi(e){return new jt({runId:e.runId,workflowId:e.workflowId,...e.ownerUser?{owner:e.ownerUser}:{},status:e.status,...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{},...void 0!==e.result?{result:mi(e.result)}:{},...e.error?{error:mi(e.error)}:{},createdAt:new Date(e.createdAt),...e.startedAt?{startedAt:new Date(e.startedAt)}:{},...e.finishedAt?{finishedAt:new Date(e.finishedAt)}:{}})}function mi(e){if(null!=e)return JSON.parse(JSON.stringify(e))}class yi{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=>gi(e))}release(e){this.runs.delete(e)}}class wi{constructor(e,t={}){this.sequences=new Map,this.chains=new Map,this.store=e,this.limits={...ue,...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 bi{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={...ue,...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 i=this.runExecution({...e},t,o,...n).catch(async t=>{const o=vi(t);try{await this.emitTerminal({...e},ce.WORKFLOW_FAILED,o)}catch{}return await this.finalize({...e},"failed",void 0,o,...n)});return this.completions.set(e.runId,i),i}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 i,a,s=!1;const d=this.engine.observe({refresh:async t=>{t.runId===r&&(t.error&&(i=t.error),he((await this.publisher.publish(this.envelopeOf(e,t))).type)?s=!0:t.type===ce.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 i=t,await this.emitTerminal(e,ce.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=vi(t);return i=o,s||(await this.emitTerminal(e,ce.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 i=t,s||(await this.emitTerminal(e,ce.WORKFLOW_CANCELLED,t),s=!0),await this.finalize(e,"cancelled",void 0,t,...n)}try{a=await this.engine.execute(d,o,{runId:r,abortSignal:this.controllers.get(r)?.signal,metadata:{documentFingerprint:l}},...n)}catch(e){i=vi(e)}const c=this.abortReason(r);let u,p;return"timeout"===c?(u="failed",p=i??{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=i):a?.status===se.SUCCEEDED?u="succeeded":a?.status===se.CANCELLED?(u="cancelled",p=i):(u="failed",p=i??vi(new to(a?`Graph run '${r}' failed`:`Graph run '${r}' failed without a result`,"GRAPH_RUN_FAILED",{runId:r}))),s||await this.emitTerminal(e,"succeeded"===u?ce.WORKFLOW_COMPLETED:"cancelled"===u?ce.WORKFLOW_CANCELLED:ce.WORKFLOW_FAILED,p),await this.finalize(e,u,a,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:Ge(t.payload)?t.payload:{nonSerializable:!0},error:t.error,parentRunId:t.parentRunId,path:t.path}}}function vi(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 Ii{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 wi(o,n.limits),this.executor=new bi(e,t,this.publisher,{onRunCompleted:n.onRunCompleted},n.limits),this.options={...n,limits:{...ue,...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("Graph run request must carry a workflow document with an id or a saved workflowId");if(e.workflowId&&!this.options.documentResolver)throw new A("Graph run requests by workflowId require a document resolver");const i=o??t??"anonymous",a=this.activeByCaller.get(i)??new Set;if(a.size>=this.options.limits.maxConcurrentRuns)throw new A(`Graph run rejected: the configured limit of ${this.options.limits.maxConcurrentRuns} concurrent runs per caller is exhausted`);const s=this.generateRunId(),d={runId:s,workflowId:r,ownerUser:t,status:"queued",createdAt:(new Date).toISOString()};this.executor.begin(s),await this.runStore.saveRun({...d},...n);const l=this.documentProviderFor(e,t);return a.add(s),this.activeByCaller.set(i,a),this.callerKeysByRun.set(s,i),this.executor.schedule(d,l,e.inputs??{},...n).catch(()=>{}).finally(()=>this.finishActiveRun(s)),d}async getRun(e,t,...o){const n=await this.runStore.readRun(e,...o);if(!n)throw new _(`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=>di({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 _(`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 _(`No graph run found for runId '${e}'`);this.assertWriteOwnership(r,o);const i=this.engine.backend,a=i.resume;if("function"!=typeof a)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 a.call(i,e,t,...n)}catch(e){throw(d=e)instanceof to?new to(d.message,d.graphCode):d}var d;const l={...s,runId:e,caller:o};return await this.publisher.publish({runId:e,workflowId:r.workflowId,type:ce.WORKFLOW_RESUMED,payload:l}),l}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("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("Graph run request is ambiguous: supply either an unsaved workflow document or a saved workflowId, not both");if(!t&&!o)throw new A("Graph run request must supply either an unsaved workflow document or a saved workflowId");if(t&&!pt(e.workflow))throw new A("Graph run request carries a payload that is not a canonical GraphWorkflowDocument");if(void 0!==e.inputs&&!Ue(e.inputs))throw new A("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(`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:hi(t)})}const o=e.workflowId;return async(...e)=>{const n=this.options.documentResolver;if(!n)throw new A("Graph run requests by workflowId require a document resolver");const r=await n.resolve(o,t,...e);return{document:r,fingerprint:hi(r)}}}assertOwnership(e,t){ui({owner:e.ownerUser},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess,resourceKind:"Graph run",resourceId:e.runId})}assertWriteOwnership(e,t){ci({owner:e.ownerUser},t,{resourceKind:"Graph run",resourceId:e.runId})}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new so("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime",{runtime:typeof globalThis.crypto});return e.randomUUID()}}function Ei(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 Ni(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&pt(e.document)&&!pt(e)}function Oi(e){return JSON.parse(JSON.stringify(e))}function ki(e){if(null==e)return 0;let t;try{t=e.getTime()}catch{return 0}return Number.isFinite(t)?t:0}let Ai=class extends H{constructor(e){super(Gt),this.catalogue=e}get limits(){return{...ar,...sr.graph.workflows.limits??{}}}get allowAnonymousAccess(){return!0===sr.graph.workflows.allowAnonymousAccess}async saveDocument(e,t,...o){const{ctx:n,ctxArgs:r}=(await this.logCtx(o,"saveDocument",!0)).for(this.saveDocument);if(!pt(t))throw new A("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(`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 po(i.issues);const a=Ei(n),s=await this.readExistingForWrite(e,r);s&&this.assertWriteOwnership(e,s,a);const d=new Date;if(s)return s.name=t.name,s.document=Oi(t),s.updatedAt=d,this.update(s,...r);const l=new Gt({workflowId:e,name:t.name,document:Oi(t),...a?{owner:a}:{},updatedAt:d});return this.create(l,...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 _(`No graph workflow found for workflowId '${e}'`);if(this.assertOwnership(e,r,Ei(o)),r.document)return Oi(r.document);throw new _(`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",K.ASC,...o),r=Ei(t);return n.filter(e=>di(e,r,{allowAnonymousAccess:this.allowAnonymousAccess})).sort((e,t)=>ki(t.updatedAt)-ki(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 _(`No graph workflow found for workflowId '${e}'`);return this.assertOwnership(e,r,Ei(o)),r}async validateDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateDocument",!0)).for(this.validateDocument);return await ai(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(!Ue(t))throw new A("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(!Ni(t))throw new A("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=Ei(n),a=await this.readExistingForWrite(e,r);a&&this.assertWriteOwnership(e,a,i);const s=new Date;if(a)return a.snapshot=t,await this.applyCanonicalWrapper(a,t,n),a.updatedAt=s,this.update(a,...r);const d=new Gt({workflowId:e,snapshot:t,...i?{owner:i}:{},updatedAt:s});return await this.applyCanonicalWrapper(d,t,n),this.create(d,...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,Ei(o)),t}catch{return null}}async readExistingForWrite(e,t){try{return await this.read(e,...t)}catch(e){if(e instanceof _)return null;throw e}}assertOwnership(e,t,o){ui(t??null,o??null,{allowAnonymousAccess:this.allowAnonymousAccess,resourceKind:"Graph workflow",resourceId:e})}assertWriteOwnership(e,t,o){ci(t??null,o??null,{resourceKind:"Graph workflow",resourceId:e})}async applyCanonicalWrapper(e,t,o){if(!Ni(t))return;if(t.document.id!==e.workflowId)throw new A(`Document id '${t.document.id}' does not match the workflow id '${e.workflowId}' from the request path`);const n=await ai(t.document,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o);if(!n.valid)throw new po(n.issues);e.document=Oi(t.document),e.name=t.document.name}};Ai=S([F(Gt),D("design:paramtypes",[Function])],Ai);let xi=class extends H{constructor(){super(jt)}async saveRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"saveRun",!0)).for(this.saveRun),n=gi(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)}};xi=S([F(jt),D("design:paramtypes",[])],xi);class _i{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:se.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}}}export{Or as AgentNode,er as BreakFlowNode,wr as ChatTriggerNode,pr as CodeInputSchema,hr as CodeNode,jo as ConditionExpressionEvaluator,ar as DEFAULT_GRAPH_WORKFLOW_DOCUMENT_LIMITS,Nn as DEFAULT_GRAPH_WORKFLOW_VALIDATION_LIMITS,cn as DEFAULT_PINNING_METADATA,fr as DelayFlowNode,or as ErrorBoundaryFlowNode,br as EventTriggerNode,vr as FormTriggerNode,kr as GRAPH_AGENT_NODES,Kr as GRAPH_BOUNDARY_NODES,Vr as GRAPH_BUILT_IN_NODE_CLASSES_BY_KIND,Gr as GRAPH_BUILT_IN_NODE_MANIFESTS,Fr as GRAPH_BUILT_IN_NODE_MANIFESTS_BY_KIND,ur as GRAPH_CODE_DEFAULT_LANGUAGE,dr as GRAPH_CODE_DEFAULT_TIMEOUT_MS,cr as GRAPH_CODE_LANGUAGES,Xt as GRAPH_CODE_MAX_TIMEOUT_MS,Ht as GRAPH_DEFAULT_CONCURRENCY,Vt as GRAPH_DEFAULT_MAX_FOREACH_ITERATIONS,Kt as GRAPH_DEFAULT_MAX_LOOP_ITERATIONS,On as GRAPH_DOCUMENT_FORBIDDEN_FIELD_KEYS,Wr as GRAPH_FLOW_CONTROL_NODES,qt as GRAPH_LOCAL_EXECUTION_BACKEND,eo as GRAPH_LOOP_KIND,Hr as GRAPH_LOOP_NODES,Jt as GRAPH_MAX_FOREACH_ITERATIONS,zt as GRAPH_MAX_LOOP_ITERATIONS,Yt as GRAPH_PINNING_METADATA_KEY,Zo as GRAPH_PLAIN_SECRET_KEYS,Br as GRAPH_TRIGGER_NODES,qr as GRAPH_UTILITY_NODES,Wt as GRAPH_WORKFLOW_BOUNDARY,Zr as GRAPH_WORKFLOW_FORBIDDEN_FIELD_KEYS,So as GraphAuthValidator,co as GraphBreakSignal,Sr as GraphConditionEvaluator,Zt as GraphConditionType,wn as GraphConnectionPolicyValidator,In as GraphConnectionValidationError,En as GraphCredentialAuthorizationError,bn as GraphCredentialReferenceValidator,oo as GraphCycleError,vn as GraphDocumentValidationError,yn as GraphEdgeInstanceValidator,To as GraphEngineEventSink,sr as GraphEnvironment,Mo as GraphExecutionBackendRegistry,Ro as GraphExecutionContext,Pn as GraphExecutionEngine,to as GraphExecutionError,ho as GraphExecutionEventEmitter,fo as GraphExecutionEventFactory,$o as GraphExecutionFrame,_n as GraphExecutionPlanner,_i as GraphExecutionSnapshotMapper,_r as GraphForeachLoopNode,no as GraphInputError,Rr as GraphInputValueNode,si as GraphLoopExecutionContext,ro as GraphLoopLimitError,Zn as GraphNode,Vn as GraphNodeCatalogue,zn as GraphNodeExecutorRegistry,Jn as GraphNodeExecutorResolver,gn as GraphNodeInstanceValidator,Wn as GraphNodeManifestResolver,Ln as GraphNodeMethodNotFoundError,Mn as GraphNodeMethodRegistry,Tn as GraphNodeNotFoundError,Cn as GraphNodeRegistrationError,$r as GraphOutputValueNode,en as GraphParameterValidator,hn as GraphPinningDependencyResolver,io as GraphPinningError,pn as GraphPinningPolicy,ln as GraphPinningService,Qt as GraphPinningStrategy,ao as GraphPortError,Yr as GraphPortSchemaResolver,uo as GraphRunCancelledError,wi as GraphRunEventPublisher,bi as GraphRunExecutor,xi as GraphRunModelService,Ii as GraphRunService,so as GraphStoreError,dn as GraphTopology,lo as GraphTopologyError,Dr as GraphUntilLoopNode,tn as GraphValueModel,an as GraphValueRepository,Qr as GraphValueValidator,Pr as GraphWhileLoopNode,po as GraphWorkflowDocumentRejectedError,xn as GraphWorkflowDocumentValidator,Ai as GraphWorkflowService,nr as HumanApprovalFlowNode,rr as IfFlowNode,fi as InMemoryGraphRunEventStore,yi as InMemoryGraphRunStore,$n as IsolatedVmCodeSandboxEvaluator,fn as LocalGraphExecutionBackend,gr as LogFlowNode,Ir as ManualTriggerNode,mr as MapNode,Er as ScheduleTriggerNode,ir as SwitchFlowNode,yr as UtilityLogNode,Nr as WebhookTriggerNode,ui as assertGraphResourceOwnership,ci as assertGraphResourceWriteOwnership,Co as buildGraphExecutionResult,Jr as builtInGraphNodeRegistrations,di as canAccessGraphResource,li as canAccessGraphResourcePayload,Jo as checkGraphValueAgainstSchema,lr as clampGraphCodeTimeoutMs,mn as collectLooseNodeIssues,mo as composeGraphNamespace,sn as createGraphValueRepository,Yn as declaredGraphNodeMethods,go as decomposeGraphNamespace,xo as decomposeGraphNamespaces,Xn as defineGraphNode,Vo as detectGraphCodeModeSurfaces,Fo as evaluateCodeCondition,Wo as evaluateCondition,Bo as evaluateConditionSync,Io as findMalformedGraphNamespaces,vo as findUngrantedGraphNamespaces,ko as graphAuthDataFromRecord,Ao as graphAuthDataOf,zo as graphDocumentHasCodeMode,bo as graphNamespaceCovers,wo as graphNamespacePartsOf,Qn as graphNodeConfig,Eo as graphRolesFromNamespaces,hi as graphRunDocumentFingerprint,Ei as graphWorkflowOwnerOf,Go as isCodeCondition,Uo as isConditionExpression,Yo as isGraphCredentialReferenceLike,yo as isGraphNamespaceCacheEntryValid,kn as isGraphResolvedWorkflow,un as isPinnable,_o as mergeGraphAuthData,Xr as registerBuiltInGraphNodes,Lo as resolveGraphBackendCapabilities,Fn as resolveGraphDynamicPorts,Bn as resolveGraphNodeManifest,on as serializeGraphValueKey,Dn as stripFacadeOwnedBackendConfig,ai as validateGraphWorkflowDocumentAtBoundary};
|
|
1
|
+
import{logParameterRegistry as e,Logging as t,LoggedEnvironment as o}from"@decaf-ts/logging";import{RenderingEngine as r,uimodel as n,uielement as i,uilistprop as a,uilistmodel as s,hidden as d}from"@decaf-ts/ui-decorators";import{Metadata as l,Decoration as c,apply as p,metadata as u,propMetadata as h,description as g,prop as f,DefaultFlavour as y}from"@decaf-ts/decoration";import{ValidationKeys as m,Model as b,required as w,type as v,date as x,model as I,option as A,min as _,max as O}from"@decaf-ts/decorator-validation";import{ValidationError as E,InternalError as k,NotFoundError as S}from"@decaf-ts/db-decorators";import{__decorate as R,__metadata as C}from"tslib";import{pk as N,column as T,index as D,table as P,BaseModel as j,noValidateOnUpdate as $,ForbiddenError as L,Context as M,repository as G,Repository as U,AuthorizationError as F,service as B,Service as H,Condition as q,OrderDirection as W,ClientBasedService as K,Adapter as V,ModelService as z}from"@decaf-ts/core";import Q from"isolated-vm";import*as J from"acorn";import*as X from"acorn-walk";import*as Y from"typescript";import{randomUUID as Z,createHash as ee}from"node:crypto";import{dirname as te,resolve as oe,relative as re,sep as ne,isAbsolute as ie}from"node:path";import{homedir as ae}from"node:os";import{realpathSync as se}from"node:fs";import{realpath as de,readFile as le,mkdir as ce,appendFile as pe,writeFile as ue}from"node:fs/promises";import{TypeORMAdapter as he}from"@decaf-ts/for-typeorm";import{RedisAdapter as ge}from"@decaf-ts/integrations/redis";import{collectToBuffer as fe}from"@decaf-ts/integrations/blob";import{S3BlobStoreService as ye}from"@decaf-ts/integrations/blob/s3";import{bootWithoutEnvironment as me}from"@decaf-ts/integrations/shared/http";import{GcsBlobStoreService as be}from"@decaf-ts/integrations/blob/gcp";import{AzureBlobStoreService as we}from"@decaf-ts/integrations/blob/azure";import{SlackService as ve}from"@decaf-ts/integrations/comms/slack";import{TelegramService as xe}from"@decaf-ts/integrations/comms/telegram";import{TeamsService as Ie}from"@decaf-ts/integrations/comms/teams";import{GmailService as Ae}from"@decaf-ts/integrations/comms/gmail";import{EmailService as _e}from"@decaf-ts/integrations/comms/email";import{GoogleSheetsService as Oe}from"@decaf-ts/integrations/io/google-sheets";import{AirtableService as Ee}from"@decaf-ts/integrations/io/airtable";import{SpreadsheetService as ke}from"@decaf-ts/integrations/io/spreadsheet";import{GraphqlService as Se}from"@decaf-ts/integrations/io/graphql";import{GithubService as Re}from"@decaf-ts/integrations/devops/github";import{GitlabService as Ce}from"@decaf-ts/integrations/devops/gitlab";import{CryptoService as Ne}from"@decaf-ts/crypto/integration/services/crypto";import{sign as Te,verify as De,decodeJwtPayload as Pe}from"@decaf-ts/crypto/jwt";import{exec as je}from"node:child_process";import{Ssh2SftpService as $e}from"@decaf-ts/integrations/sftp";import"@mastra/core/storage";import"@mastra/memory";import"@mastra/libsql";import"@mastra/pg";var Le,Me;m.REQUIRED,m.MIN,m.MIN_LENGTH,m.MAX,m.MAX_LENGTH,m.PATTERN,m.URL,m.STEP,m.DATE,m.EMAIL,m.PASSWORD,m.EQUALS,m.DIFF,m.LESS_THAN,m.LESS_THAN_OR_EQUAL,m.GREATER_THAN,m.GREATER_THAN_OR_EQUAL,(e=>{e.GRAPH="graph",e.NODE="graph.node",e.EDGE="graph.edge",e.PORT="graph.port",e.STATE="graph.state"})(Le||(Le={})),(e=>{e.INPUT="input",e.OUTPUT="output",e.CONNECTION="connection"})(Me||(Me={}));const Ge={};function Ue(e,t={}){let o=e.width??96,r=e.height??96;for(const n of e.sizeRules??[]){if("parameterCount"!==n.type)continue;const e=t[n.parameter]??0;e>0&&("width"===n.dimension?o+=e*n.perItem:r+=e*n.perItem)}return{width:o,height:r}}function Fe(e,t){Ge[e]=t}function Be(e,t,o){const r=t?Ge[t]:void 0;return r?.color?r.color:e||"#64748b"}function He(e,t,o){const r=t?Ge[t]:void 0;return r?.icon?r.icon:e||"ti-pointer"}const qe=["skip","passThroughFirstInput","emitDefaults"];function We(e){return qe.includes(e)}var Ke,Ve,ze,Qe;(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"})(Ke||(Ke={})),(e=>{e.IDLE="idle",e.RUNNING="running",e.BLOCKED="blocked",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped"})(Ve||(Ve={})),(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"})(ze||(ze={})),(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"})(Qe||(Qe={}));const Je={maxRequestBytes:4e6,maxConcurrentRuns:32,maxEventsPerRun:1e4,maxEventPayloadBytes:256e3,executionTimeoutMs:6e5,eventReplayWindowMs:3e5},Xe=[Qe.WORKFLOW_COMPLETED,Qe.WORKFLOW_FAILED,Qe.WORKFLOW_CANCELLED];function Ye(e){return Xe.includes(e)}function Ze(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function et(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=Ze(e.namespaces),o=Ze(e.roles);if(!t&&!o)return;const r={};return t&&(r.namespaces=t),o&&(r.roles=o),r})(t):void 0}function tt(e){const t=l.constr(e);if("function"==typeof t)return t;const o=e.constructor;return"function"==typeof o?o:e}function ot(e){if(null!=e)return"string"==typeof e?e:e+""}function rt(e,t,o){return ot(e?.props?.label??e?.props?.name)??ot(t?.name)??o??""}function nt(e,t,o){const r=st(e,t);if(r?.model&&"function"==typeof r.model&&b.isModel(r.model))return r.model;const n=l.type(e,t);if("function"==typeof n&&b.isModel(n))return n;const i=l.getPropDesignTypes?.(e,t)?.designTypes||[];for(const e of i)if("function"==typeof e&&b.isModel(e))return e;const a=o?.[m.TYPE]?.customTypes||[];for(const e of a)if("function"==typeof e&&b.isModel(e))return e}function it(e,t){const o=[t,e.path??e.property].filter(Boolean).join(".");return{...e,path:o,children:e.children?.map(e=>it(e,o))}}function at(e){const t=tt(e);return l.get(t,Le.NODE)}function st(e,t){const o=tt(e);return l.get(o,l.key(Le.PORT,t+""))}function dt(e,t,o,r=new Set){const n=st(e,t);if(!n?.schema)return;const i=nt(e,t,l.validationFor(e,t));if(!i)return;if(r.has(i))return[];const a=new Set(r);return a.add(e),a.add(i),pt(i,a).filter(e=>e.direction===o)}function lt(e,t,o=new Set){const r=st(e,t);if(!r)return;const n=l.validationFor(e,t),i=nt(e,t,n);if(r.schema&&i)return;const a=b.uiElementOf(e,t)||void 0,s=b.uiDecorationOf(e,t,"uiprop"),d=l.type(e,t),c=ot(r.type??n?.[m.TYPE]?.customTypes?.[0]?.name??a?.props?.type??s?.type??d?.name),p=(r.expand||i&&!o.has(i))&&i?(()=>{const r=new Set(o);return r.add(e),r.add(i),pt(i,r).map(e=>it(e,t))})():void 0;return{property:t,path:t,direction:r.direction,name:t,label:rt(a,s,t),type:c?.toLowerCase(),required:!!n?.[m.REQUIRED],hidden:!!b.uiIsHidden(e,t),designType:d?.name,element:a,prop:s,validation:n,graph:r,connectionRules:r.connectionRules,composite:!!p?.length,children:p,model:i?.name}}function ct(e){return pt(tt(e))}function pt(e,t=new Set){const o=l.properties(e)||[],r=[];for(const n of o){const o=n+"",i=st(e,o);if(i?.schema){const n=dt(e,o,i.direction,t);if(n){r.push(...n);continue}}const a=lt(e,o,t);a&&r.push(a)}return r}function ut(e){return e.flatMap(e=>e.children&&e.children.length?ut(e.children):[e])}function ht(e){const t=tt(e),o=b.uiModelOf(t),r=at(t)||{},n=o?.tag||t.name,i=ct(t),a=((e,t)=>{const o=t.portGroups||[],r=new Map(o.map(e=>[e.property,e])),n=[],i=l.properties(e)||[];for(const t of i){const o=t+"",i=st(e,o);if(!i?.schema)continue;if(!nt(e,o,l.validationFor(e,o)))continue;const a=r.get(o);n.push(a?{...a,toggle:a.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,r),s=r.namespaces?.length?r.namespaces:(e=>{if(null==e)return[];let t,o=e;try{o=l.constr(e)}catch{o=e}try{t=l.get(o,"auth-namespace")}catch{t=void 0}return Ze(t)??[]})(t),d=s.length?s:void 0;return{name:t.name,tag:n,kind:r.kind||n,category:r.category,color:r.color,effectiveColor:Be(r.color,r.category),group:r.group,height:r.height,icon:r.icon,effectiveIcon:He(r.icon,r.category),labels:r.labels||[],maxChildren:r.maxChildren,minWidth:r.minWidth,width:r.width,shape:r.shape,cornerRadius:r.cornerRadius,sizeRules:r.sizeRules,props:o?.props,ui:o,graph:r,ports:i,portGroups:a,namespaces:d}}const gt=new Set,ft=new Set;function yt(e,t,o){return c.for(Le.NODE).define({decorator:(e,t,o)=>{const r={kind:t?.kind||e,...t};return t=>{const i=p(n(e,o),u(Le.NODE,r))(t);var a;return a=t,gt.add(a),i}},args:[e,t,o]}).apply()}function mt(e,t){return c.for(Le.PORT).define({decorator:(e,t)=>(o,r)=>{const n={direction:e,...t};return p(h(l.key(Le.PORT,r),n))(o,r)},args:[e,t]}).apply()}function bt(e){return mt(Me.INPUT,{...e,schema:!0})}function wt(e){return mt(Me.OUTPUT,{...e,schema:!0})}function vt(e){return mt(Me.CONNECTION,e)}r.prototype.renderAsNode=(e,t,...o)=>ht(e),l.nodes=(()=>[...gt]).bind(l),l.workflows=(()=>[...ft]).bind(l);const xt=["__proto__","prototype","constructor"];function It(e){return xt.includes(e)}function At(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function _t(e){return null===e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e}function Ot(e){return!!_t(e)||(Array.isArray(e)?e.every(e=>Ot(e)):!!At(e)&&Reflect.ownKeys(e).every(t=>"string"==typeof t&&!It(t)&&Ot(e[t])))}function Et(e){if(void 0===e)return!1;if("number"==typeof e)return Number.isFinite(e);if("function"==typeof e)return!1;if(Ot(e))return!0;if(Array.isArray(e))return e.every(e=>Et(e));if(At(e)){const t=Reflect.ownKeys(e);for(const o of t){if("string"!=typeof o)return!1;if(It(o))return!1;if(!Et(e[o]))return!1}return!0}return!1}function kt(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>kt(e));const t={};for(const[o,r]of Object.entries(e))t[o]=kt(r);return t}const St={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"},Rt={date:"date",datetime:"date-time","date-time":"date-time",duration:"duration"};function Ct(e){return e?St[e.toLowerCase()]??"any":"any"}function Nt(e,t){const o=e[t];if(o&&"object"==typeof o)return o.value}function Tt(e,t){const o=Nt(e,t);return"number"==typeof o&&Number.isFinite(o)?o:void 0}function Dt(e,t,o){const r=e??{},n=(e=>{const t=Nt(e,m.ENUM);if(Array.isArray(t)&&t.every(_t))return t})(r);if(n)return{type:"enum",values:n};const i=(e=>{const t=e[m.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(Ct(e)){case"string":{const t=(e=>{if(e)return Rt[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=Tt(t,m.MIN),n=Tt(t,m.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:Pt(e,t)},r=Tt(e,m.MIN),n=Tt(e,m.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 Pt(e,t){if((e=>{const t=e[m.LIST];return!!t?.clazz?.length})(e))return{type:"model",name:jt(e)};const o=Nt(e,m.TYPE);if("string"==typeof o){const e=Ct(o);return"model"===e?{type:"model",name:o}:{type:e}}if(t&&"array"!==t){const e=Ct(t);return"model"===e?{type:"model",name:t}:{type:e}}return{type:"any"}}function jt(e){const t=e[m.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 $t(e){return"workflow"===e.scope}function Lt(e){return"node"===e.scope}function Mt(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 Gt(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&&Ot(t)}return"expression"===t&&2===Object.keys(e).length&&"string"==typeof e.expression}const Ut=["any","string","number","boolean","array","object","enum","model"];function Ft(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(e=>Ut.includes(e))(e.type)}function Bt(e,t={seen:[]}){if(t.seen.includes(e))throw new E(`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 E("Document 'id' is required and must be a non-empty string");if("string"!=typeof e.name||!e.name)throw new E("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 E("Workflow port 'id' is required and must be a non-empty string");if(o.has(t.id))throw new E(`Workflow port '${t.id}' is declared more than once; workflow port ids must be unique`);if(void 0!==t.schema&&!Ft(t.schema))throw new E(`Workflow port '${t.id}' schema must be a valid GraphValueSchema`);o.add(t.id)}const r={seen:[...t.seen,e]},n=new Set;for(const t of e.nodes)Ht(t,n);for(const t of e.nodes)t.loop&&qt(t,t.loop,r),t.errorBoundary&&Wt(t,t.errorBoundary,r);const i=new Set;for(const t of e.edges)Vt(t,i);for(const t of e.edges)zt(t.source,0,o,n,`Edge '${t.id}' source`),zt(t.target,0,o,n,`Edge '${t.id}' target`);if(void 0!==e.settings&&!Et(e.settings))throw new E("Document settings must be JSON-safe (a map of JSON-safe values)");if(void 0!==e.metadata&&!Et(e.metadata))throw new E("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&&!Et(e.ui))throw new E("Document ui must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed")}function Ht(e,t){if("string"!=typeof e.id||!e.id)throw new E("Node 'id' is required and must be a non-empty string");if(t.has(e.id))throw new E(`Node id '${e.id}' is declared more than once; node ids must be unique`);if("string"!=typeof e.kind||!e.kind)throw new E(`Node '${e.id}' must declare a non-empty string 'kind'`);if(void 0===e.parameters||null===e.parameters)throw new E(`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(It(t))throw new E(`Node '${e.id}' input binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!Gt(o))throw new E(`Node '${e.id}' input binding for '${t}' must be a valid GraphInputBinding (edge, literal, or expression)`);if("literal"===o.mode&&!Et(o.value))throw new E(`Node '${e.id}' literal binding for '${t}' must contain JSON-safe values`);if("expression"===o.mode&&!o.expression)throw new E(`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(It(t))throw new E(`Node '${e.id}' output binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!o||"object"!=typeof o||Array.isArray(o))throw new E(`Node '${e.id}' output binding for '${t}' must be an object with enabled and alias settings`)}if(!Et(e.parameters))throw new E(`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 E(`Node '${e.id}' state must be an object when present`);if(!Et(e.state))throw new E(`Node '${e.id}' state must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}}function qt(e,t,o){if(!t.body||"object"!=typeof t.body)throw new E(`Node '${e.id}' loop configuration requires a body document`);if(Bt(t.body,o),!(void 0===t.maxIterations||Number.isFinite(t.maxIterations)&&t.maxIterations>0))throw new E(`Node '${e.id}' loop maxIterations must be a positive number`);if(void 0!==t.timeoutMs&&("number"!=typeof t.timeoutMs||0>=t.timeoutMs))throw new E(`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 E(`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(It(t))throw new E(`Node '${e.id}' loop mapping key '${t}' is not allowed (unsafe prototype-pollutant key)`);Kt(r,e.id,t)}}function Wt(e,t,o){if(!t.try||"object"!=typeof t.try)throw new E(`Node '${e.id}' error-boundary configuration requires a try body document`);Bt(t.try,o);for(const[r,n]of[["catch",t.catch],["finally",t.finally]])if(void 0!==n){if(!n||"object"!=typeof n)throw new E(`Node '${e.id}' error-boundary ${r} body must be a document`);Bt(n,o)}}function Kt(e,t,o){if(!e||"object"!=typeof e)throw new E(`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 E(`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 E(`Node '${t}' loop mapping '${o}' referencing a node must reference a node id and a port`);break;case"literal":if(!Et(e.value))throw new E(`Node '${t}' loop mapping '${o}' literal references must be JSON-safe values`);break;case"expression":if("string"!=typeof e.expression||!e.expression)throw new E(`Node '${t}' loop mapping '${o}' expression references must be non-empty expressions`);break;default:throw new E(`Node '${t}' loop mapping '${o}' must use a workflow, node, literal, or expression reference source`)}}function Vt(e,t){if("string"!=typeof e.id||!e.id)throw new E("Edge 'id' is required and must be a non-empty string");if(t.has(e.id))throw new E(`Edge id '${e.id}' is declared more than once; edge ids must be unique`);if(!Mt(e.source))throw new E(`Edge '${e.id}' source endpoint is not a valid GraphEndpoint`);if(!Mt(e.target))throw new E(`Edge '${e.id}' target endpoint is not a valid GraphEndpoint`);if("data"!==e.type&&"connection"!==e.type)throw new E(`Edge '${e.id}' type '${e.type+""}' is not a valid edge type (data or connection are allowed)`);if(t.add(e.id),!Et(e))throw new E(`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 zt(e,t,o,r,n){if($t(e)){if(!o.has(e.port))throw new E(`${n} references workflow port '${e.port}' which is not declared on the document`)}else if(Lt(e)){if(!r.has(e.nodeId))throw new E(`${n} references node '${e.nodeId}' which is not part of the document`);if("string"!=typeof e.port||!e.port)throw new E(n+" node endpoints must reference a non-empty port identifier")}}const Qt=["expression","template"],Jt=["javascript","typescript","json","text"];function Xt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return!(!(e=>Qt.includes(e))(t.mode)||"string"!=typeof t.expression||!t.expression||void 0!==t.language&&!(e=>Jt.includes(e))(t.language)||void 0!==t.metadata&&!Ot(t.metadata))}function Yt(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 Zt(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 eo=["trigger","loop","branching","stateful","retryable","cancellable","parallel","resource"];function to(e){return eo.includes(e)}function oo(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 ro(e){if(!oo(e))throw new E("Graph node manifest does not conform to the required shape");if(!Et(e))throw new E("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 no(e){return ro(e),kt(e)}function io(e){if(!oo(e))throw new E("Serialized graph node manifest does not conform to the required shape");return kt(e)}const ao=["loadOptions","listSearch","resourceLocator","resourceMapping","validateParameter","action"];function so(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.name&&(e=>ao.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 lo(e){const t=e.element?.props?.value,o=t??e.prop?.value??e.validation?.defaultValue;if(void 0!==o&&"function"!=typeof o&&Et(o))try{return JSON.parse(JSON.stringify(o))}catch{return}}function co(e){if(e.type&&e.type in Rt)return{type:"string",format:Rt[e.type]};const t=(e=>{for(const t of[e.graph?.type,e.element?.props?.type,e.prop?.type])if("string"==typeof t&&"any"!==Ct(t))return t})(e);return t?Dt((e=>{if(!e)return;const t=Object.entries(e).filter(([e])=>e!==m.TYPE);return Object.fromEntries(t)})(e.validation),t):Dt(e.validation,e.type,e.model)}function po(e){const t={};for(const[o,r]of Object.entries(e.graph?.metadata??{}))Et(r)&&(t[o]=JSON.parse(JSON.stringify(r)));return Object.keys(t).length?t:void 0}function uo(e){switch(e){case"output":return"output";case"connection":return"connection";default:return"input"}}function ho(e){const t=e.graph?.handle;return"connection"!==e.direction&&"string"==typeof t&&t?t:e.path??e.property}const go=["top","bottom","left","right"],fo=["start","center","end"];function yo(e,t){const o={id:ho(e),label:e.label,direction:uo(e.direction),schema:co(e)};e.required&&(o.required=!0),e.hidden&&(o.hidden=!0);const r=e.graph?.category;"string"==typeof r&&(o.category=r);const n=(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||!go.includes(r))return;const n={side:r},i=o.align;"string"==typeof i&&fo.includes(i)&&(n.align=i);const a=o.order;return"number"==typeof a&&Number.isFinite(a)&&(n.order=a),n})(e);n&&(o.zone=n),!0===e.graph?.userControlled&&(o.configurable=!0);const i=e.graph?.handle;"string"==typeof i&&(o.handle=i);const a=Eo(e.graph?.connectionRules)??t;a&&(o.connectionPolicy=a);const s=(e=>{const t=e.element;if(!t||!Et(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)?kt(r):{}}})(e);s&&(o.element=s);const d=po(e);return d&&(o.metadata=d),o}function mo(e){const t={type:"string",id:ho(e),label:e.label,required:e.required};if(e.hidden)return((e,t)=>{const o={...t,type:"hidden"},r=lo(e);return void 0!==r&&(o.defaultValue=r),bo(o)})(e,t);const o=lo(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 n=po(e);if(n&&(t.metadata=n),(e=>{const t=xo(e);return"code"===t||"code-editor"===t})(e))return bo({...t,type:"code",language:_o(e)});const i=co(e);switch(i.type){case"number":{const o={...t,type:"number",integer:i.integer,min:i.min,max:i.max},r=vo(e.validation?.step);return void 0!==r&&(o.step=r),bo(o)}case"boolean":return bo({...t,type:"boolean"});case"enum":return bo({...t,type:"options",options:i.values.map(e=>({value:e,label:e+""}))});case"array":{const e={...t,type:"collection"};return void 0!==i.maxItems&&(e.maxItems=i.maxItems),bo(e)}case"object":case"model":return bo({...t,type:"object"});default:return bo({...t,type:"string",multiline:!!Io(e)||void 0,pattern:wo(e.validation?.pattern),minLength:vo(e.validation?.minlength),maxLength:vo(e.validation?.maxlength)})}}function bo(e){const t=e;for(const e of Object.keys(t))void 0===t[e]&&delete t[e];return e}function wo(e){const t=e?.value;return"string"==typeof t?t:void 0}function vo(e){const t=e?.value;return"number"==typeof t&&Number.isFinite(t)?t:void 0}function xo(e){const t=e.element?.tag;return"string"==typeof t&&t?t:void 0}function Io(e){return"textarea"===xo(e)||"textarea"===(e=>{const t=e.element?.props?.type;return"string"==typeof t?t:void 0})(e)}const Ao=["javascript","typescript","json","text"];function _o(e){const t=e.element?.props?.language;return"string"==typeof t&&Ao.includes(t)?t:"javascript"}function Oo(e,t){const o={name:t.name??e.name},r=e.graph?.metadata?.description??void 0;"string"==typeof r&&r&&(o.description=r);const n=t.category??e.category;"string"==typeof n&&n&&(o.category=n),"string"==typeof e.group&&e.group&&(o.group=e.group),Array.isArray(e.labels)&&(o.labels=e.labels.slice());const i=((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 i&&(o.icon=i),"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 Eo(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 n=t.blockedKinds;Array.isArray(n)&&n.every(e=>"string"==typeof e)&&(o.blockedNodeKinds=n);const i=t.allowedPortCategories;Array.isArray(i)&&i.every(e=>"string"==typeof e)&&(o.allowedPortCategories=i);const a=t.maxConnections;return"number"==typeof a&&Number.isFinite(a)&&(o.maxConnections=a),Object.keys(o).length?o:void 0}function ko(e,t={}){const o="function"==typeof e?e:e.constructor;if(!at(o))throw new E(`Node '${o?.name??e+""}' is not decorated with @node and cannot produce a manifest`);const r=ht(o),n=ut(ct(o)),i=[],a=[],s=[],d=[],l=Eo(r.graph?.connectionRules);for(const e of n)("connection"===e.direction?s:"output"===e.direction?a:i).push(yo(e,l)),"input"===e.direction&&d.push(mo(e));const c={kind:t.kind??r.kind??r.name,display:Oo(r,t),inputs:i,outputs:a,parameters:d};return s.length&&(c.connections=s),r.namespaces?.length&&(c.namespaces=r.namespaces.slice()),ro(c),c}var So,Ro;(e=>{e.READABILITY="readability",e.COMPACTNESS="compactness",e.BALANCED="balanced"})(So||(So={})),(e=>{e.TIGHT="tight",e.NORMAL="normal",e.COMFORTABLE="comfortable"})(Ro||(Ro={})),Ro.TIGHT,Ro.NORMAL,Ro.COMFORTABLE,So.READABILITY,Ro.COMFORTABLE,So.COMPACTNESS,Ro.TIGHT,So.BALANCED,Ro.NORMAL;let Co=class extends j{constructor(e){super(e)}};R([N({type:String,generated:!1}),g("Unique graph run id"),i("ngx-decaf-crud-field",{label:"graph.run.id.label",readonly:!0}),C("design:type",String)],Co.prototype,"runId",void 0),R([T(),w(),D(),g("Workflow document id the run executes"),a("workflowId"),i("ngx-decaf-crud-field",{label:"graph.run.workflowId.label"}),C("design:type",String)],Co.prototype,"workflowId",void 0),R([T(),g("Owning user; absent for anonymous callers"),i("ngx-decaf-crud-field",{label:"graph.run.owner.label"}),C("design:type",String)],Co.prototype,"owner",void 0),R([T(),w(),v(String),D(),g("Current run lifecycle status"),a("status"),i("ngx-decaf-crud-field",{label:"graph.run.status.label",readonly:!0}),C("design:type",String)],Co.prototype,"status",void 0),R([T(),g("Fingerprint of the executed document"),i("ngx-decaf-crud-field",{label:"graph.run.fingerprint.label",readonly:!0}),C("design:type",String)],Co.prototype,"documentFingerprint",void 0),R([T(),f(),g("Workflow input values keyed by input port id"),C("design:type",Object)],Co.prototype,"inputs",void 0),R([T(),f(),g("Execution result, present on successful completion"),C("design:type",Object)],Co.prototype,"result",void 0),R([T(),f(),g("Structured error payload, present on failure"),C("design:type",Object)],Co.prototype,"error",void 0),R([x(),T(),g("Run creation timestamp"),C("design:type",Date)],Co.prototype,"createdAt",void 0),R([x(),T(),g("Execution start timestamp, once it has started"),C("design:type",Date)],Co.prototype,"startedAt",void 0),R([x(),T(),g("Terminal-state timestamp, once the run has finished"),C("design:type",Date)],Co.prototype,"finishedAt",void 0),Co=R([s("ngx-decaf-list-item",{icon:"ti-player-play"}),n("ngx-decaf-crud-form"),g("Persistable graph run lifecycle record"),P("graph_run"),I(),C("design:paramtypes",[Object])],Co);let No=class extends j{constructor(e){super(e)}};R([N({type:String,generated:!1}),C("design:type",String)],No.prototype,"workflowId",void 0),R([T(),C("design:type",String)],No.prototype,"name",void 0),R([T(),C("design:type",Object)],No.prototype,"document",void 0),R([T(),C("design:type",String)],No.prototype,"owner",void 0),R([T(),C("design:type",Object)],No.prototype,"snapshot",void 0),R([$(),C("design:type",Date)],No.prototype,"createdAt",void 0),No=R([P("graph_workflow"),I(),C("design:paramtypes",[Object])],No);let To=class extends j{constructor(e){super(e)}};R([N({type:String,generated:!1}),C("design:type",String)],To.prototype,"kind",void 0),R([T(),D(),C("design:type",String)],To.prototype,"name",void 0),R([T(),D(),C("design:type",String)],To.prototype,"category",void 0),R([T(),C("design:type",String)],To.prototype,"group",void 0),R([T(),C("design:type",String)],To.prototype,"description",void 0),R([T(),C("design:type",Object)],To.prototype,"manifest",void 0),R([$(),C("design:type",Date)],To.prototype,"createdAt",void 0),To=R([P("graph_node"),I(),C("design:paramtypes",[Object])],To),Fe("Trigger",{color:"#3b82f6",icon:"ti-bolt"}),Fe("Flow Control",{color:"#f59e0b",icon:"ti-arrows-split-2"}),Fe("Utility",{color:"#0d9488",icon:"ti-tool"}),Fe("Loop",{color:"#eab308",icon:"ti-repeat"}),Fe("Workflow",{color:"#f97316",icon:"ti-sitemap"}),Fe("Pipeline",{color:"#0ea5e9",icon:"ti-git-merge"}),Fe("Node",{color:"#8b5cf6",icon:"ti-point-filled"}),Fe("Agent",{color:"#7c3aed",icon:"ti-robot"}),Fe("Data",{color:"#8b5cf6",icon:"ti-table"}),Fe("IO",{color:"#0ea5e9",icon:"ti-world-www"}),Fe("Storage",{color:"#0f766e",icon:"ti-database"}),Fe("DevOps",{color:"#475569",icon:"ti-terminal-2"}),Fe("Comms",{color:"#d946ef",icon:"ti-message-circle"}),Fe("model",{color:"#3b82f6",icon:"ti-cpu"}),Fe("memory",{color:"#10b981",icon:"ti-database"}),Fe("workspace",{color:"#f59e0b",icon:"ti-folder"}),Fe("tools",{color:"#0ea5e9",icon:"ti-tools"}),Fe("hooks",{color:"#f97316",icon:"ti-webhook"}),Fe("skill",{color:"#8b5cf6",icon:"ti-bulb"}),Fe("sandbox",{color:"#14b8a6",icon:"ti-box"}),Fe("scorers",{color:"#ec4899",icon:"ti-star"}),Fe("embedding",{color:"#6366f1",icon:"ti-vector"});const Do=new Set;function Po(e,t){return e.config[t]}function jo(e){return Array.isArray(e)?e.map(e=>e+"").join(", "):e+""}(()=>{const t=[{key:ze.NODE_ID,shouldInclude:e=>null!=Po(e,ze.NODE_ID),render:e=>Po(e,ze.NODE_ID)+""},{key:ze.WORKFLOW_ID,shouldInclude:e=>null!=Po(e,ze.WORKFLOW_ID),render:e=>Po(e,ze.WORKFLOW_ID)+""},{key:ze.RUN_ID,shouldInclude:e=>null!=Po(e,ze.RUN_ID),render:e=>Po(e,ze.RUN_ID)+""},{key:ze.USER,shouldInclude:e=>null!=Po(e,ze.USER),render:e=>Po(e,ze.USER)+""},{key:ze.ROLES,shouldInclude(e){const t=Po(e,ze.ROLES);return Array.isArray(t)&&t.length>0},render:e=>jo(Po(e,ze.ROLES))},{key:ze.NAMESPACES,shouldInclude(e){const t=Po(e,ze.NAMESPACES);return Array.isArray(t)&&t.length>0},render:e=>jo(Po(e,ze.NAMESPACES))},{key:ze.ORGANIZATION,shouldInclude:e=>null!=Po(e,ze.ORGANIZATION),render:e=>Po(e,ze.ORGANIZATION)+""},{key:ze.IP,shouldInclude:e=>null!=Po(e,ze.IP),render:e=>Po(e,ze.IP)+""}];for(const o of t)Do.has(o.key)||(e.register(o),Do.add(o.key))})();const $o="$workflow",Lo="local",Mo="GRAPH_LOCAL_UNSUPPORTED_NODE_KIND",Go=4,Uo=100,Fo=1e3,Bo=1e3,Ho=1e4,qo=3e4,Wo=3e5,Ko=10485760,Vo=5,zo=6e4,Qo=3e4,Jo=1048576,Xo=10,Yo=1e3,Zo=1e4,er=1048576,tr=1e4,or="graph.pinnable";var rr,nr;(e=>{e.MANUAL="manual",e.AUTOMATIC="automatic",e.DISABLED="disabled"})(rr||(rr={})),(e=>{e.TRUTHY="truthy",e.FALSY="falsy",e.EQUALS="equals",e.NOT_EQUALS="notEquals",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.EXISTS="exists",e.CUSTOM="custom"})(nr||(nr={}));const ir={FOREACH:"core.loop.foreach",WHILE:"core.loop.while",UNTIL:"core.loop.until"};class ar extends k{constructor(e,t="GRAPH_EXECUTION_ERROR",o){super(e,ar.name,500),this.graphCode=t,this.details=o,this.name=this.constructor.name}}class sr extends ar{constructor(e){super("Graph workflow contains an unsupported cycle","GRAPH_CYCLE_ERROR",e)}}class dr extends ar{constructor(e,t){super(e,"GRAPH_INPUT_ERROR",t)}}class lr extends ar{constructor(e,t){super(e,"GRAPH_LOOP_LIMIT_ERROR",t)}}class cr extends ar{constructor(e,t){super(e,"GRAPH_PINNING_ERROR",t)}}class pr extends ar{constructor(e,t){super(e,"GRAPH_PORT_ERROR",t)}}class ur extends ar{constructor(e,t){super(e,"GRAPH_STORE_ERROR",t)}}class hr extends ar{constructor(e,t){super(e,"GRAPH_TOPOLOGY_ERROR",t)}}class gr extends ar{constructor(e){super("Break signal","GRAPH_BREAK_SIGNAL",{value:e}),this.isBreakSignal=!0,this.name="GraphBreakSignal"}}class fr extends ar{constructor(e){super(`Graph run '${e}' was cancelled`,"GRAPH_RUN_CANCELLED",{runId:e}),this.name=fr.name}}class yr extends E{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=yr.name,this.issues=e}}class mr{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 br{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 ar("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 wr(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(),n=o[2].trim(),i=o[1].split(",").map(e=>e.trim()).filter(e=>e.length>0);return r&&n&&0!==i.length?{organization:r,departments:i,role:n}:void 0}function vr(e){return`${e.organization}.${e.departments.join(",")}.${e.role}`}function xr(e){if(!e||"string"!=typeof e.namespace||!e.parts)return!1;const t=wr(e.namespace);return!!t&&vr(t)===vr(e.parts)}function Ir(e,t){const o="string"==typeof e?e.trim():"";if(o){if(t)for(const e of t)if(e&&e.namespace===o&&xr(e))return e.parts;return wr(o)}}function Ar(e,t,o={},r){const n=Ir(e,r),i=Ir(t,r);return!(!n||!i)&&n.organization===i.organization&&n.role===i.role&&("exact"===(o.mode??"inherit")?n.departments.length===i.departments.length&&n.departments.every((e,t)=>e===i.departments[t]):n.departments.length<=i.departments.length&&n.departments.every((e,t)=>e===i.departments[t]))}function _r(e,t,o={},r){return e.filter(e=>!t.some(t=>Ar(t,e,o,r)))}function Or(e){return e.filter(e=>void 0===wr(e))}function Er(e,t){const o=new Set;for(const r of e){const e=Ir(r,t);e&&o.add(e.role)}return[...o]}function kr(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function Sr(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 Rr(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 n=e.ip;"string"==typeof n&&n&&(t.ip=n);const i=kr(e.roles);i&&(t.roles=i);const a=kr(e.namespaces);return a&&(t.namespaces=a,t.namespaceCache=Nr(a)),t}function Cr(e){return e?Rr({user:Sr(e,"user"),organization:Sr(e,"organization"),ip:Sr(e,"ip"),roles:Sr(e,"roles"),namespaces:Sr(e,"namespaces")}):{}}function Nr(e){const t=[];for(const o of e){const e=wr(o);e&&t.push({namespace:o,parts:e})}return t}function Tr(...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??Nr(o.namespaces):void 0!==o.namespaceCache&&(t.namespaceCache=o.namespaceCache));return t}class Dr{constructor(e={}){this.options=e}get enabled(){return!0===this.options.enabled}validate(e,o,r,n){if(!this.enabled)return;const i=n??this.options.logger??t.for("GraphAuth"),a=e.id||e.name||o.workflowId,s=et(e.metadata);this.assertGranted(`workflow '${a}'`,s?.namespaces??[],r,s?.roles??[],i);for(const e of o.nodes)this.assertGranted(`node '${e.id}'`,e.manifest.namespaces??[],r,[],i)}validateWorkflowRead(e,o,r){if(!this.enabled)return;const n=r??this.options.logger??t.for("GraphAuth"),i=et(e.metadata);this.assertGranted(`workflow '${e.id||e.name}'`,i?.namespaces??[],o,i?.roles??[],n)}assertGranted(e,t,o,r,n){const i=o.namespaces??[],a=_r(t,i,this.options.match,o.namespaceCache),s=Er(i,o.namespaceCache),d=r.filter(e=>!s.includes(e));if(0===a.length&&0===d.length)return;const l=[...new Set([...Or(t),...Or(i)])],c=[];throw a.length&&c.push("namespace(s) "+a.join(", ")),d.length&&c.push("role(s) "+d.join(", ")),n.warn(`Graph access denied for ${e} for user ${o.user??"anonymous"}: missing ${c.join(" and ")}${l.length?`; malformed namespace(s) ${l.join(", ")} failed closed`:""}`),new L(`Access to ${e} requires ${c.join(" and ")}`)}}class Pr{constructor(e){this.services=e}async resolve(e,t,o,r,n){if(!e){if(o)throw new ar(`${r} node requires a credential of type '${t}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:t});return}if(e.credentialType&&e.credentialType!==t)throw new ar(`${r} node credential has type '${e.credentialType}' but requires '${t}'`,"GRAPH_CREDENTIAL_TYPE_MISMATCH",{credentialId:e.credentialId,credentialType:e.credentialType});let i;try{i=await this.services.credentialService.getCredential(e.credentialId,n)}catch(t){throw new ar(`${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===i.enabled)throw new ar(`${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})(i.expiresAt))throw new ar(`${r} node credential '${e.credentialId}' has expired`,"GRAPH_CREDENTIAL_EXPIRED",{credentialId:e.credentialId});if(i.credentialType&&i.credentialType!==t)throw new ar(`${r} node credential '${e.credentialId}' has type '${i.credentialType}' but requires '${t}'`,"GRAPH_CREDENTIAL_TYPE_MISMATCH",{credentialId:e.credentialId,credentialType:i.credentialType});const a=this.secretServiceFor(i.provider,r),s=await a.retrieve(i.secretName,{},n);return await(this.services.credentialService.markCredentialUsed?.(e.credentialId,n).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})(s)}secretServiceFor(e,t){if("model"===e)return this.services.modelSecretService;if("filesystem"===e){if(!this.services.fsSecretService)throw new ar(`${t} node credential provider '${e}' requires a configured filesystem secret service`,"GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{provider:e});return this.services.fsSecretService}throw new ar(`${t} node credential provider '${e}' is not supported`,"GRAPH_CREDENTIAL_PROVIDER_UNSUPPORTED",{provider:e})}}async function jr(e,t,o,r,n,i="credentialRef"){const a=t?.[i];if(!a){if(!r)return;throw new ar(`${n} node requires a credential of type '${o}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:o})}const s=e?.engine,d=s?.nodeCredentials;if(!d)throw new ar(n+" node requires ctx-bound credential services, but the engine has none configured","GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{node:n,credentialType:o});return d.resolve(a,o,r,n,e)}class $r{constructor(e){this.baseOptions=e,this.inner=t.for("GraphRun").for(this.attributeConfig(e))}attributeConfig(e){return{[ze.NODE_ID]:e.nodeId,[ze.WORKFLOW_ID]:e.workflowId,[ze.RUN_ID]:e.runId,[ze.USER]:e.user??null,[ze.ROLES]:e.roles,[ze.NAMESPACES]:e.namespaces,[ze.ORGANIZATION]:e.organization,[ze.IP]:e.ip}}emit(e,t,o){const r="string"==typeof t?t:t instanceof Error?t.message:t+"",n={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&&(n.roles=this.baseOptions.roles),void 0!==this.baseOptions.namespaces&&(n.namespaces=this.baseOptions.namespaces),void 0!==this.baseOptions.organization&&(n.organization=this.baseOptions.organization),void 0!==this.baseOptions.ip&&(n.ip=this.baseOptions.ip),void 0!==o&&(n.payload=o),this.baseOptions.forward({type:Qe.GRAPH_RUN_LOG,payload:n}).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 Lr(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}class Mr extends M{constructor(e,t,o,r,n,i,a,s,d={},l,c,p){super(),this.runId=e,this.parentRunId=t,this.workflowId=o,this.document=r,this.node=n,this.manifest=i,this.path=a,this.emitFn=s,this.metadata=d,this.engine=l,this.abortSignal=c,this.limits=p;const u=Rr(d);this.accumulate({...u,operation:"execute"});const h="string"==typeof d?.user?d.user:null;this.runLogger=new $r({runId:e,workflowId:o,nodeId:n.id,user:h,roles:Lr(d?.roles),namespaces:Lr(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 Cr(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:Qe.NODE_OUTPUT,payload:e})}async log(e,t){await this.emit({type:Qe.NODE_OUTPUT,payload:{message:e,payload:t}})}}class Gr{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 Ur(e,t,o,r,n){const i=e.valueStore.getWorkflowValues(),a={};for(const[t,o]of e.nodeResults)a[t]=o;const s=[...e.events];return{runId:e.runId,workflowId:t.id||t.name,status:r,document:t,inputs:{...o},outputs:i,nodeResults:a,events:s,startedAt:e.startedAt,finishedAt:e.finishedAt,metadata:n}}class Fr{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:Qe.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 Br(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 Hr{static{this._cache={}}static register(e,t){return Hr._cache[e]=t,t}static get(e){const t=e??Hr._currentFlavour;if(t)return Hr._cache[t]}static getOrFail(e){const t=Hr.get(e);if(!t)throw new ar(`No graph execution backend registered under '${e}'`,"GRAPH_EXECUTION_BACKEND_NOT_REGISTERED");return t}static get current(){return Hr.get()}static get currentFlavour(){return Hr._currentFlavour??Lo}static setCurrent(e){Hr._currentFlavour=e}static list(){return Object.entries(Hr._cache).map(([e,t])=>({flavour:e,backend:t}))}static unregister(e){e&&(delete Hr._cache[e],Hr._currentFlavour===e&&(Hr._currentFlavour=void 0))}static clear(){for(const e of Object.keys(Hr._cache))delete Hr._cache[e];Hr._currentFlavour=void 0}}class qr{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 ar(`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 ar("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 Wr(e){return"object"==typeof e&&null!==e&&"type"in e&&"code"===e.type}function Kr(e){return"object"==typeof e&&null!==e&&"op"in e&&"string"==typeof e.op}async function Vr(e,t,o){const r=o.engine?.codeSandboxEvaluator;if(!r)throw new ar("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 n=o.metadata;return!!await r.evaluate({code:e.code,language:e.language,input:t,vars:n?.vars??void 0,item:n?.item,index:n?.index,nodes:n?.nodes??void 0,logger:o.logger,abortSignal:o.abortSignal})}function zr(e,t,o){if(Kr(e))return(new qr).evaluate(e,t);throw((e,t)=>new ar(`Unknown ${t??"flow"} condition type \u2014 must be ConditionExpression (op) or CodeCondition (type: 'code')`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e}))(e,o)}async function Qr(e,t,o){return Wr(e)?Vr(e,t.input,o):zr(e,t.state,t.label)}function Jr(e,t,o,r){if(e&&"object"==typeof e&&!r.has(e))if(r.add(e),Wr(e))o.push({nodeId:t,kind:"code-condition"});else if(Xt(e))o.push({nodeId:t,kind:"value-template"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"expression"===t.source&&"string"==typeof t.expression})(e))o.push({nodeId:t,kind:"expression-binding"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.name&&Array.isArray(t.nodes)&&Array.isArray(t.edges)})(e))Yr(e,o,r);else if(Array.isArray(e))for(const n of e)Jr(n,t,o,r);else for(const n of Object.keys(e))Jr(e[n],t,o,r)}function Xr(e,t,o){const r=e.id;"core.utility.code"===e.kind&&t.push({nodeId:r,kind:"code-node",detail:e.kind});const n=e.inputBindings??{};for(const[e,o]of Object.entries(n))o&&"expression"===o.mode&&t.push({nodeId:r,kind:"expression-binding",detail:e});Jr(e.parameters,r,t,o),Jr(e.metadata,r,t,o),Jr(e.state,r,t,o),Jr(e.loop,r,t,o)}function Yr(e,t,o){for(const r of e.nodes??[])Xr(r,t,o)}function Zr(e){const t=[];return Yr(e,t,new Set),t}function en(e){return Zr(e).length>0}const tn="core.agent";function on(e,t){if(!t)return{valid:!0};switch(t.type){case"any":default:return{valid:!0};case"string":return"string"!=typeof e?rn("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}:rn("number");case"boolean":return"boolean"!=typeof e?rn("boolean"):{valid:!0};case"array":if(!Array.isArray(e))return rn("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=on(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 rn(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=on(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 rn(e){return{valid:!1,message:`expected a ${e} value`}}function nn(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 an=new Set(["loop"]),sn=["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 dn{validate(e,t,o,r,n){this.validateParameters(e,t,o,r,n),this.validateMetadataKeys(e,t,o,r),this.validateDisabledBehavior(e,o,r),this.validateBindingShapes(e,t,o,r)}validateParameters(e,t,o,r,n){const i=!0===t.policies?.allowUndeclaredParameters,a=new Map(t.parameters.map(e=>[e.id,e]));for(const[n,s]of Object.entries(e.parameters??{})){const d=a.get(n);if(!d){i||o.push({code:"parameter.undeclared",path:`${r}.parameters.${n}`,message:`Node '${e.id}' sets parameter '${n}' 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:`${r}.parameters.${n}`,message:`Node '${e.id}' parameter '${n}' must not be undefined`,nodeId:e.id});continue}const l=this.checkParameterValue(s,d);l.valid||o.push({code:"parameter.type-mismatch",path:`${r}.parameters.${n}`,message:`Node '${e.id}' parameter '${n}' is invalid: ${l.message}`,nodeId:e.id,details:{expectedType:d.type}})}for(const i of t.parameters)void 0===(e.parameters??{})[i.id]&&(this.isParameterSatisfiedByInput(e,i.id,n)||(!0===i.required||(i.validation??[]).some(e=>"required"===e.kind))&&void 0===i.defaultValue&&o.push({code:"parameter.required-missing",path:`${r}.parameters.${i.id}`,message:`Node '${e.id}' is missing required parameter '${i.id}' declared by kind '${t.kind}'`,nodeId:e.id}))}isParameterSatisfiedByInput(e,t,o){return void 0!==(e.inputBindings??{})[t]||!0===o?.has(t)}checkParameterValue(e,t){if(Xt(e))return{valid:!0};switch(t.type){case"string":case"code":case"expression":return"string"!=typeof e?rn("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?{valid:!0}:rn("number");case"boolean":return"boolean"!=typeof e?rn("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}:rn("array");case"object":case"resourceLocator":return null===e||"object"!=typeof e||Array.isArray(e)?rn("object"):{valid:!0};case"credential":return nn(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 n=t.metadata?.allowedInstanceMetadataKeys;for(const i of Object.keys(e.metadata??{}))an.has(i)?o.push({code:"metadata.key-not-allowed",path:`${r}.metadata.${i}`,message:`Node '${e.id}' metadata key '${i}' is reserved and must not be set directly`,nodeId:e.id}):Array.isArray(n)&&!n.includes(i)&&o.push({code:"metadata.key-not-allowed",path:`${r}.metadata.${i}`,message:`Node '${e.id}' metadata key '${i}' 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||We(r)||t.push({code:"disabled.invalid-behavior",path:o+".metadata.disabledBehavior",message:`Node '${e.id}' disabled behavior '${r+""}' is not one of: ${qe.join(", ")}`,nodeId:e.id})}validateBindingShapes(e,t,o,r){for(const[n,i]of Object.entries(e.inputBindings??{})){if("literal"===i.mode){const a=t.inputs.find(e=>e.id===n);if(a?.schema){const t=on(i.value,a.schema);t.valid||o.push({code:"binding.literal-invalid",path:`${r}.inputBindings.${n}`,message:`Node '${e.id}' literal binding for '${n}' is schema-invalid: ${t.message}`,nodeId:e.id})}}"expression"!==i.mode||"string"==typeof i.expression&&i.expression.trim()||o.push({code:"binding.expression-invalid",path:`${r}.inputBindings.${n}`,message:`Node '${e.id}' expression binding for '${n}' must contain a non-empty expression`,nodeId:e.id})}}validateBindingSatisfaction(e,t,o,r,n,i={}){const a=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 a){const o=(e.inputBindings??{})[t];o&&"literal"===o.mode&&!0!==i.allowLiteralAndEdgeBindings&&r.push({code:"binding.conflict",path:`${n}.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&&(a.has(o.id)||s.has(o.id)||void 0===(e.parameters??{})[o.id]&&r.push({code:"topology.required-input-unsatisfiable",path:n+".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(We(o))return o;const r=t?.disabledBehavior;return We(r)?r:"skip"}}let ln=class extends j{constructor(e){super(e)}};function cn(e){return[e.namespace??"default",e.workflowId,e.nodeId,e.version??"default",e.fingerprint].join(":")}function pn(e){return new ln({id:cn(e.key),workflowId:e.key.workflowId,nodeId:e.key.nodeId,fingerprint:e.key.fingerprint,...void 0!==e.key.namespace?{namespace:e.key.namespace}:{},...void 0!==e.key.version?{version:e.key.version}:{},pinned:e.pinned,outputs:e.outputs,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),...e.expiresAt?{expiresAt:new Date(e.expiresAt)}:{},...e.metadata?{metadata:e.metadata}:{}})}function un(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}:{}}}R([N({type:String,generated:!1}),C("design:type",String)],ln.prototype,"id",void 0),R([T(),D(),C("design:type",String)],ln.prototype,"workflowId",void 0),R([T(),D(),C("design:type",String)],ln.prototype,"nodeId",void 0),R([T(),C("design:type",String)],ln.prototype,"fingerprint",void 0),R([T(),C("design:type",String)],ln.prototype,"namespace",void 0),R([T(),C("design:type",String)],ln.prototype,"version",void 0),R([T(),C("design:type",Boolean)],ln.prototype,"pinned",void 0),R([T(),C("design:type",Object)],ln.prototype,"outputs",void 0),R([T(),C("design:type",Date)],ln.prototype,"createdAt",void 0),R([T(),C("design:type",Date)],ln.prototype,"updatedAt",void 0),R([T(),C("design:type",Date)],ln.prototype,"expiresAt",void 0),R([T(),C("design:type",Object)],ln.prototype,"metadata",void 0),ln=R([P("graph_value"),I(),C("design:paramtypes",[Object])],ln);let hn=class extends U{constructor(e){super(e,ln,!0),this.runtimeValues=new Map}seedWorkflowInputs(e){this.runtimeValues.set($o,{...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($o)??{};o[e]=t,this.runtimeValues.set($o,o)}getWorkflowValues(){return{...this.runtimeValues.get($o)??{}}}snapshot(){return Object.fromEntries(this.runtimeValues.entries())}async readCached(e,...t){try{return un(await this.read(cn(e),...t))}catch{return}}async writeCached(e,t,...o){const r=cn(e);let n;try{n=await this.read(r,...o)}catch{n=void 0}n?await this.update(Object.assign(n,pn(t)),...o):await this.create(pn(t),...o)}async deleteCached(e,...t){try{await this.delete(cn(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=>un(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}};function gn(e){return new(0,U.forModel(ln,e.alias).constructor)(e)}hn=R([G(ln,y),C("design:paramtypes",[Function])],hn);class fn{static upstreamNodes(e,t,o=!1){const r=new Set,n=[e];for(;n.length;){const e=n.pop(),i=t.get(e)??[];for(const e of i)!o&&this.isBoundary(e.sourceNodeId)||r.has(e.sourceNodeId)||(r.add(e.sourceNodeId),n.push(e.sourceNodeId))}return r}static downstreamNodes(e,t,o=!1){const r=new Set,n=[e];for(;n.length;){const e=n.pop(),i=t.get(e)??[];for(const e of i)!o&&this.isBoundary(e.targetNodeId)||r.has(e.targetNodeId)||(r.add(e.targetNodeId),n.push(e.targetNodeId))}return r}static isBoundary(e){return"$workflow"===e}}class yn{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 cr(`Node '${e}' not found in plan`);if(!this.policy.canPin(o))throw new cr(`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),n=e.result.nodeResults[o];if(!n||!n.outputs)throw new cr(`Node '${o}' has no completed output to pin`);const i=n.inputs??{},a=this.dependencyFingerprints(t,o,e.result),s=this.createValueKey(e.document.id,r,i,a),d=(new Date).toISOString(),l={key:s,outputs:n.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,r,n){const i=this.createValueKey(e,t,o,r,n),a=await this.store.readCached(i);if(a&&a.pinned){if(a.expiresAt&&new Date(a.expiresAt)<new Date)return;return a}}createValueKey(e,t,o,r,n){return{workflowId:e,nodeId:t.id,fingerprint:this.computeFingerprint(e,t,o,r),namespace:n}}computeFingerprint(e,t,o,r){const n={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)},i=this.stableSerialize(n);return this.simpleHash(i)}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,n=i=>{if(r.has(i))return;r.add(i);const a=fn.upstreamNodes(i,e.incomingByNode,!1);for(const e of a)t.has(e)&&n(e);o.push(i)};for(const e of t)n(e);return o}dependencyFingerprints(e,t,o){const r=this.dependencyResolver.getDependencies(e,t),n={};for(const t of r){const r=e.nodes.find(e=>e.id===t);if(r){const i=o.nodeResults[t],a=i?.inputs??{},s=this.dependencyFingerprints(e,t,o);n[t]=this.computeFingerprint(e.workflowId,r,a,s)}}return n}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 mn={enabled:!0,strategy:"manual",includeDependencies:!0};function bn(e){return!0===e?.enabled&&"disabled"!==e.strategy}class wn{canPin(e){return bn(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?{...mn,...t}:{...mn,enabled:!1}}}class vn{getDependencies(e,t){return fn.upstreamNodes(t,e.incomingByNode,!1)}getPinSet(e,t){const o=this.getDependencies(e,t);return o.add(t),o}}class xn{constructor(){this.local=!0,this.codeMode="hostSide",Hr.register(Lo,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 ar("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 ar("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=>Cr((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 ar("LocalGraphExecutionBackend has no writable workflowStore configured; workflow seeding is not supported","GRAPH_BACKEND_SEED_NOT_SUPPORTED");const n=[];for(const i of e)null!==await r.call(o,i.id,i,...t)&&n.push({id:i.id,...void 0!==i.name?{name:i.name}:{}});return n}async execute(e){const{document:t,plan:o,inputs:r,options:n,events:i}=e,a=i,s=a.frame;if(!s)throw new ar("LocalGraphExecutionBackend requires the frame-bound event sink created by GraphExecutionEngine","GRAPH_EXECUTION_FRAME_MISSING");const d=s.valueStore,l=s.runId,c=n.path??[],p=async e=>{await a.emit(e)};try{for(const e of o.layers)this.assertNotAborted(n),await this.executeLayer(s,o,e.nodes,n,p);this.assertNotAborted(n);const e=[...s.nodeResults.values()].find(e=>e.status===Ke.FAILED);if(e?.error)throw new ar(e.error.message,e.error.code??"GRAPH_EXECUTION_ERROR",e.error.details);return s.finish(),await a.emit({type:Qe.WORKFLOW_COMPLETED,runId:l,parentRunId:n.parentRunId,workflowId:o.workflowId,path:c,status:Ke.SUCCEEDED,payload:{outputs:d.getWorkflowValues()}}),Ur(s,t,r,Ke.SUCCEEDED,n.metadata)}catch(e){if(e instanceof gr)throw s.finish(),e;s.finish();const i=this.toErrorPayload(e);return e instanceof fr||!0===n.abortSignal?.aborted?(await a.emit({type:Qe.WORKFLOW_CANCELLED,runId:l,parentRunId:n.parentRunId,workflowId:o.workflowId,path:c,status:Ke.CANCELLED,error:i}),Ur(s,t,r,Ke.CANCELLED,n.metadata)):(await a.emit({type:Qe.WORKFLOW_FAILED,runId:l,parentRunId:n.parentRunId,workflowId:o.workflowId,path:c,status:Ke.FAILED,error:i}),Ur(s,t,r,Ke.FAILED,n.metadata))}}async executeLayer(e,t,o,r,n){const i=Math.max(1,r.concurrency??4),a=[...o];for(;a.length>0;){const o=a.splice(0,i);await Promise.all(o.map(o=>this.executeNode(e,t,o,r,n)))}}async executeNode(e,t,o,r,n){if(this.assertNotAborted(r),!this.isNodeActivated(e,t,o))return void await this.skipInactiveNode(e,t,o,r,n);if(!0===o.instance.disabled)return void await this.executeDisabledNode(e,t,o,r,n);const i=new Date,a=[...r.path??[],o.id];await n({type:Qe.NODE_STARTED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.RUNNING}),this.emitNodeStateChanged(e,t,o,a,Ve.RUNNING,Ke.RUNNING,n);const s=await this.resolveNodeInputs(e,t,o,r);if(r.usePinnedValues){const r=await this.tryPinnedValue(e,t,o,s);if(r){e.valueStore.setNodeOutputs(o.id,r.outputs),this.routeOutgoingEdges(e,t,o,r.outputs,n);const d=new Date,l={nodeId:o.id,status:Ke.CACHED,inputs:s,outputs:r.outputs,startedAt:i,finishedAt:d,fromCache:!0,pinned:!0,events:[]};return e.recordNodeResult(l),await n({type:Qe.NODE_CACHE_HIT,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.CACHED,payload:{outputs:r.outputs}}),await n({type:Qe.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.SUCCEEDED,payload:{outputs:r.outputs,fromCache:!0}}),void this.emitNodeStateChanged(e,t,o,a,Ve.SUCCEEDED,Ke.SUCCEEDED,n)}}try{const d=new Mr(e.runId,r.parentRunId,t.workflowId,t.resolved.document,o.instance,o.manifest,a,n,r.metadata,this.engine,r.abortSignal,this.executionLimits(r)),l=await this.resolveNodeParameters(o,s,r),c={nodeId:o.id,kind:o.kind,inputs:s,parameters:l,credentials:this.collectCredentials(o),metadata:o.instance.metadata},p=await this.invokeExecutor(o,c,d),u=this.validateNodeOutputs(o,p??{});e.valueStore.setNodeOutputs(o.id,u),this.routeOutgoingEdges(e,t,o,u,n);const h=new Date,g={nodeId:o.id,status:Ke.SUCCEEDED,inputs:s,outputs:u,startedAt:i,finishedAt:h,events:[]};e.recordNodeResult(g),await n({type:Qe.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.SUCCEEDED,payload:{outputs:u}}),this.emitNodeStateChanged(e,t,o,a,Ve.SUCCEEDED,Ke.SUCCEEDED,n)}catch(d){if(d instanceof gr)throw d;const l=new Date,c=this.toErrorPayload(d),p={nodeId:o.id,status:Ke.FAILED,inputs:s,error:c,startedAt:i,finishedAt:l,events:[]};if(e.recordNodeResult(p),await n({type:Qe.NODE_FAILED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.FAILED,error:c}),this.emitNodeStateChanged(e,t,o,a,Ve.FAILED,Ke.FAILED,n),r.failFast??!0)throw d}}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===$o||e.isDataEdgeActive(t.id))}async skipInactiveNode(e,t,o,r,n){const i=new Date,a=[...r.path??[],o.id];await n({type:Qe.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.SKIPPED,payload:{reason:"branchNotSelected"}});const s={nodeId:o.id,status:Ke.SKIPPED,inputs:{},startedAt:i,finishedAt:new Date,events:[]};e.recordNodeResult(s),this.emitNodeStateChanged(e,t,o,a,Ve.SKIPPED,Ke.SKIPPED,n)}async executeDisabledNode(e,t,o,r,n){const i=new Date,a=[...r.path??[],o.id],s=dn.disabledBehaviorOf(o.instance,t.resolved.document.settings);if(await n({type:Qe.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.SKIPPED,payload:{disabled:!0,behavior:s}}),"skip"===s){const r={nodeId:o.id,status:Ke.SKIPPED,inputs:{},startedAt:i,finishedAt:new Date,events:[]};return e.recordNodeResult(r),void this.emitNodeStateChanged(e,t,o,a,Ve.SKIPPED,Ke.SKIPPED,n)}const d=await this.resolveNodeInputs(e,t,o,r);let l;if("passThroughFirstInput"===s){const r=(t.incomingByNode.get(o.id)??[]).find(e=>"data"===e.type),n=o.manifest.outputs[0]?.id??"value",i=r?e.valueStore.getPort(r.sourceNodeId,r.sourcePort):Object.values(d)[0];l={[n]:i}}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,n);const c={nodeId:o.id,status:Ke.SUCCEEDED,inputs:d,outputs:l,startedAt:i,finishedAt:new Date,events:[]};e.recordNodeResult(c),this.emitNodeStateChanged(e,t,o,a,Ve.SUCCEEDED,Ke.SUCCEEDED,n)}async invokeExecutor(e,t,o){if((r=e.kind)===tn||r.startsWith(tn+"."))throw new ar(`Node '${e.id}' of kind '${e.kind}' requires the mastra engine, which the local backend does not provide`,Mo,{nodeId:e.id,kind:e.kind,backend:Lo});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)),n=Object.keys(t).filter(e=>!r.has(e));if(n.length>0)throw new ar(`Node '${e.id}' of kind '${e.kind}' produced unknown output(s): ${n.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,unknownOutputs:n});const i=o.outputs.filter(e=>!0===e.required&&!(e.id in t)).map(e=>e.id);if(i.length>0)throw new ar(`Node '${e.id}' of kind '${e.kind}' did not produce required output(s): ${i.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,missingRequired:i});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??""}:nn(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:""}:nn(o)&&(t[e]={credentialId:o.credentialId,credentialType:o.credentialType})}return t}async resolveNodeInputs(e,t,o,r){const n={},i=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type),a=new Map;for(const e of i){const t=a.get(e.targetPort)??[];t.push(e),a.set(e.targetPort,t)}for(const[t,o]of a)if(1===o.length)n[t]=e.valueStore.getPort(o[0].sourceNodeId,o[0].sourcePort);else{let r,i=!1;for(const t of o){const o=e.valueStore.getPort(t.sourceNodeId,t.sourcePort);n[t.sourcePort]=o,void 0!==o&&(r=o,i=!0)}i&&void 0===n[t]&&(n[t]=r)}const s=o.instance.inputBindings??{};for(const e of o.manifest.inputs){const t=s[e.id];if("literal"===t?.mode)n[e.id]=t.value;else if("expression"===t?.mode)n[e.id]=await this.evaluateExpressionBinding(o,t.expression,n,r);else if(void 0===n[e.id]){const t=e.metadata?.defaultValue;void 0!==t&&(n[e.id]=t)}}return n}async resolveNodeParameters(e,t,o){const r=e.instance.parameters??{},n={};for(const[i,a]of Object.entries(r))n[i]=Xt(a)?await this.evaluateValueTemplate(a,e,t,o):a;return n}async evaluateValueTemplate(e,t,o,r){const n=this.codeSandboxEvaluator;if(!n)throw new ar(`Value template on node '${t.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`,"GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{nodeId:t.id});const i=e.language??("expression"===e.mode?"javascript":"text"),a="template"===e.mode?(e=>`\`${e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(e,t)=>`\${${t}}`)}\``)(e.expression):e.expression,s=r.metadata;return await n.evaluate({code:a,language:"typescript"===i?"typescript":"javascript",input:o,vars:s?.vars??void 0,item:s?.item,index:s?.index,abortSignal:r.abortSignal})}async evaluateExpressionBinding(e,t,o,r){const n=this.codeSandboxEvaluator;if(!n)throw new ar(`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 i=r.metadata;return await n.evaluate({code:t,language:"javascript",input:o,vars:i?.vars??void 0,item:i?.item,index:i?.index,abortSignal:r.abortSignal})}async tryPinnedValue(e,t,o,r){if(!(new wn).shouldUsePinnedValue(o))return;const n=this.createPinningService(e),i=this.computeDependencyFingerprints(e,t,o.id);return n.readPinnedValue(t.workflowId,o,r,i)}computeDependencyFingerprints(e,t,o){const r=this.createPinningService(e),n=(new vn).getDependencies(t,o),i={};for(const o of n){const n=t.nodes.find(e=>e.id===o);if(n){const a=e.nodeResults.get(o),s=a?.inputs??{},d=this.computeDependencyFingerprints(e,t,o);i[o]=r.computeFingerprint(t.workflowId,n,s,d)}}return i}routeOutgoingEdges(e,t,o,r,n){const i=(t.outgoingByNode.get(o.id)??[]).filter(e=>"data"===e.type);for(const a of i){if(!Object.prototype.hasOwnProperty.call(r,a.sourcePort))continue;const i=r[a.sourcePort];e.activateDataEdge(a.id),a.targetNodeId===$o&&e.valueStore.setWorkflowOutput(a.targetPort,i),this.emitEdgeStateChanged(e,t,o,a,Ve.SUCCEEDED,Ke.SUCCEEDED,n),n({type:Qe.EDGE_VALUE_ROUTED,runId:e.runId,workflowId:t.workflowId,edgeId:a.id,nodeId:o.id,path:[],payload:{edge:a,value:i}}).catch(()=>{})}}emitNodeStateChanged(e,t,o,r,n,i,a){a({type:Qe.NODE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:r,status:i,payload:{nodeId:o.id,state:n,runId:e.runId,workflowId:t.workflowId,status:i}}).catch(()=>{})}emitEdgeStateChanged(e,t,o,r,n,i,a){a({type:Qe.EDGE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,edgeId:r.id,nodeId:o.id,path:[],status:i,payload:{edgeId:r.id,state:n,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,status:i}}).catch(()=>{})}createPinningService(e){const t=gn(e.valueStore.getAdapter()??this.valueAdapter);return new yn(t,new wn,new vn)}executionLimits(e){return{maxLoopIterations:e.maxLoopIterations??Bo,maxForeachIterations:e.maxForeachIterations??Ho}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new fr(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 In{constructor(e){this.catalogue=e}async resolveNodes(e,t,o,...r){const n=new Map;for(const[i,a]of e.entries()){const e=`nodes[${i}]`;if(this.catalogue.has(a.kind,...r))try{const e=await this.catalogue.resolveManifest(a.kind,a,o,...r),t=this.catalogue.getExecutor(a.kind,...r);n.set(a.id,{instance:a,manifest:e,executor:t})}catch(o){t.push({code:"kind.resolution-failed",path:e+".kind",message:`Node '${a.id}' kind '${a.kind}' failed to resolve: ${o.message}`,nodeId:a.id,details:{kind:a.kind}})}else t.push({code:"kind.unknown",path:e+".kind",message:`Node '${a.id}' references kind '${a.kind}' which is not registered in the backend catalogue`,nodeId:a.id,details:{kind:a.kind}})}return n}validateEffectivePorts(e,t,o,r){const n=!0===t.policies?.allowUndeclaredParameters,i=new Set(t.inputs.map(e=>e.id)),a=new Set(t.outputs.map(e=>e.id));for(const a of Object.keys(e.inputBindings??{}))n||i.has(a)||o.push({code:"binding.unknown-port",path:`${r}.inputBindings.${a}`,message:`Node '${e.id}' input binding '${a}' does not refer to an effective input port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveInputs:[...i]}});for(const i of Object.keys(e.outputBindings??{}))n||a.has(i)||o.push({code:"binding.unknown-port",path:`${r}.outputBindings.${i}`,message:`Node '${e.id}' output binding '${i}' does not refer to an effective output port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveOutputs:[...a]}})}}function An(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 n of e.nodes){r.has(n.id)||t.push({code:"topology.loose-node",path:`${o}.nodes[${n.id}]`,message:`Node '${n.id}' is connected to nothing; every node must participate in at least one edge`,nodeId:n.id});const e=n.loop?.body;e&&An(e,t,`${o}.nodes[${n.id}].loop.body`)}}class _n{resolveEdges(e,t,o){const r=new Set(e.inputs.map(e=>e.id)),n=new Set(e.outputs.map(e=>e.id)),i=[];for(const[a,s]of(e.edges??[]).entries()){const e=`edges[${a}]`,d=this.resolveEndpoint(s,"source",t,r,n,o,e),l=this.resolveEndpoint(s,"target",t,r,n,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),i.push(c)}return i}resolveEndpoint(e,t,o,r,n,i,a){const s=e[t];return $t(s)?("source"===t?r.has(s.port):n.has(s.port))?{nodeId:$o,port:s.port}:void i.push({code:"edge.unknown-port",path:`${a}.${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}}):Lt(s)?o.get(s.nodeId)?{nodeId:s.nodeId,port:s.port}:void i.push({code:"edge.unknown-node",path:`${a}.${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 i.push({code:"edge.invalid-endpoint",path:`${a}.${t}`,message:`Edge '${e.id}' ${t} endpoint is not a valid GraphEndpoint`,edgeId:e.id})}validateDirectionAndType(e,t,o,r,n,i){let a=!0;const s=t.nodeId===$o?void 0:r.get(t.nodeId),d=o.nodeId===$o?void 0:r.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,n,i),a=!1),!d||l(d)||this.hasPortDirection(d,o.port,"input")||(this.pushPortIssue(e,"target",o,d,n,i),a=!1);else{if(!s||!d)return n.push({code:"edge.boundary-routing",path:i,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 n.push({code:"edge.type-mismatch",path:i,message:`Connection edge '${e.id}' endpoints must both be connection ports`,edgeId:e.id,details:{sourcePort:t.port,targetPort:o.port}}),!1}return a}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,n,i){const a="source"===t?"output":"input";n.push({code:"data"===e.type?"edge.invalid-direction":"edge.type-mismatch",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} port '${o.port}' on node '${o.nodeId}' is not an ${a} port of kind '${r.manifest.kind}'`,edgeId:e.id,nodeId:o.nodeId,details:{port:o.port,expected:a}})}}class On{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}`,n=o.get(e);n?t.push({code:"connection.duplicate-edge",path:`edges[${r.id}]`,message:`Edge '${r.id}' duplicates the routing of edge '${n.id}' (${e})`,edgeId:r.id,details:{duplicateOf:n.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),n=r?.manifest.connections?.find(e=>e.id===o.targetPort)?.connectionPolicy;this.validateEdgePolicy(o,e.nodeById,n,t),this.validateCategoryMatch(o,e.nodeById,t)}for(const[r,n]of o){const o=r.lastIndexOf(":"),i=r.slice(0,o),a=r.slice(o+1),s=e.nodeById.get(i),d=s?.manifest.connections?.find(e=>e.id===a)?.connectionPolicy;if(!d)continue;const l=void 0!==d.maxConnections?d.maxConnections:!1===d.allowMultiple?1:1/0;n.length>l&&t.push({code:"connection.max-connections",path:`edges[${n[n.length-1].id}]`,message:`Connection port '${a}' on node '${i}' accepts at most ${l} connection(s) but has ${n.length}`,nodeId:i,edgeId:n[n.length-1].id,details:{port:a,max:l,actual:n.length}})}}validateCategoryMatch(e,t,o){const r=t.get(e.sourceNodeId),n=t.get(e.targetNodeId),i=r?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category,a=n?.manifest.connections?.find(t=>t.id===e.targetPort)?.category;i&&a&&i!==a&&o.push({code:"connection.category-mismatch",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' joins source port '${e.sourcePort}' (category '${i}') to target port '${e.targetPort}' (category '${a}'); connection categories must match`,edgeId:e.id,nodeId:e.sourceNodeId,details:{sourceCategory:i,targetCategory:a}})}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 n=t.get(e.sourceNodeId),i=n?.manifest.kind;if(!o.allowedNodeKinds?.length||i&&o.allowedNodeKinds.includes(i)||r.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${i??"unknown"}' is not in the allowed node kinds of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedNodeKinds:o.allowedNodeKinds}}),i&&o.blockedNodeKinds?.includes(i)&&r.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${i}' is blocked by target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{blockedNodeKinds:o.blockedNodeKinds}}),o.allowedPortCategories?.length){const t=n?.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 En{constructor(e){this.authorizer=e}async validate(e,t,o,r){const n=this.collectReferences(e,t);for(const i of t.credentials??[]){const a=n.find(e=>void 0===e.credentialType||e.credentialType===i.type);if(a){if(this.checkType(a,i))o.push({code:"credential.type-mismatch",path:r,message:`Node '${e.id}' credential '${a.credentialId}' has type '${a.credentialType}' but kind '${t.kind}' requires '${i.type}'`,nodeId:e.id,details:{credentialType:a.credentialType??"",requiredType:i.type}});else if(this.authorizer){if(!await this.authorizer.hasCredential(a)){o.push({code:"credential.not-found",path:r,message:`Node '${e.id}' references credential '${a.credentialId}' which does not exist`,nodeId:e.id,details:{credentialId:a.credentialId}});continue}await this.authorizer.authorize(a,i)||o.push({code:"credential.unauthorized",path:r,message:`Node '${e.id}' is not authorized to use credential '${a.credentialId}'`,nodeId:e.id,details:{credentialId:a.credentialId}})}}else!1!==i.required&&o.push({code:"credential.missing",path:r,message:`Node '${e.id}' does not provide the required credential of type '${i.type}'`,nodeId:e.id,details:{credentialType:i.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];nn(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))nn(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(sn.map(e=>e.toLowerCase()));for(const[n,i]of Object.entries(e.parameters??{}))this.scanPlainSecretValue(i,[n],e,o+".parameters",r,t);for(const[n,i]of Object.entries(e.metadata??{}))this.scanPlainSecretValue(i,[n],e,o+".metadata",r,t)}scanPlainSecretValue(e,t,o,r,n,i,a=0){const s=t[t.length-1];if(n.has(s.toLowerCase()))i.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>a&&null!==e)if(Array.isArray(e))for(const s of e)this.scanPlainSecretValue(s,[...t,"[]"],o,r,n,i,a+1);else if("object"==typeof e)for(const[s,d]of Object.entries(e))this.scanPlainSecretValue(d,[...t,s],o,r,n,i,a+1)}}class kn extends E{constructor(e,t=[]){super(e),this.issues=t,this.name=kn.name}}class Sn extends E{constructor(e,t){super(e),this.edgeId=t,this.name=Sn.name}}class Rn extends F{constructor(e){super(e),this.name=Rn.name}}const Cn={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},Nn=["node","definition","executor","execute","ports","component"];function Tn(e){if(!e||"object"!=typeof e)return!1;const t=e;return Yt(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 Dn(e,t){const o=[];for(const r of Object.keys(e))Nn.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 Pn{constructor(e){this.options=e,this.parameterValidator=new dn,this.edgeValidator=new _n,this.connectionPolicyValidator=new On,this.nodeValidator=new In(e.catalogue),this.credentialValidator=new En(e.credentialAuthorizer)}async validateOrThrow(e,...t){const o=await this.validate(e,0,...t);if(!o.valid||!o.resolved)throw new kn(`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=[],n={...Cn,...this.options.limits};if(!await this.validateStructure(e,n,t,r,...o))return{valid:!1,issues:r};const i=await this.nodeValidator.resolveNodes(e.nodes,r,this.options.resolutionContext,...o),a=e.nodes.filter(e=>i.has(e.id)).map(e=>i.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 r=t.get(e.nodeId)??new Set;r.add(e.port),t.set(e.nodeId,r)}return t})(e);for(const e of a)this.parameterValidator.validate(e.instance,e.manifest,r,`nodes[${e.instance.id}]`,s.get(e.instance.id));for(const e of a)this.nodeValidator.validateEffectivePorts(e.instance,e.manifest,r,`nodes[${e.instance.id}]`);const d=this.edgeValidator.resolveEdges(e,i,r),l=new Map,c=new Map;for(const e of d){if(e.targetNodeId!==$o){const t=l.get(e.targetNodeId)??[];t.push(e),l.set(e.targetNodeId,t)}if(e.sourceNodeId!==$o){const t=c.get(e.sourceNodeId)??[];t.push(e),c.set(e.sourceNodeId,t)}}this.connectionPolicyValidator.validate({edges:d,nodeById:i},r),this.validateAcyclicity(a,d,e,r),An(e,r);for(const e of a)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 a)await this.credentialValidator.validate(e.instance,e.manifest,r,`nodes[${e.instance.id}]`);return this.validateCapabilities(a,r),r.length>0?{valid:!1,issues:r}:{valid:!0,issues:r,resolved:{document:e,nodes:a,edges:d,nodeById:i,incomingByNode:l,outgoingByNode:c}}}async validateStructure(e,t,o,r,...n){if(!Yt(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"}),!Et(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(...Dn(e,"$"));for(const t of[...e.inputs,...e.outputs])r.push(...Dn(t,"ports"));for(const t of e.nodes)r.push(...Dn(t,`nodes[${t.id}]`));for(const t of e.edges)r.push(...Dn(t,`edges[${t.id}]`));this.validateUniqueIds(e,r),this.validateLimits(e,t,o,r);try{Bt(e)}catch(e){r.push({code:"document.structure",path:"$",message:e instanceof Error?e.message:e+""})}return await this.validateNestedBodies(e,o,r,...n),!0}validateUniqueIds(e,t){const o=new Set,r=new Set;for(const[n,i]of[["input",e.inputs],["output",e.outputs]]){const e="input"===n?o:r;for(const o of i)e.has(o.id)?t.push({code:"document.duplicate-port-id",path:`${"input"===n?"inputs":"outputs"}[${o.id}]`,message:`Workflow ${n} port '${o.id}' is declared more than once; workflow port ids must be unique`}):e.add(o.id)}const n=new Set;for(const o of e.nodes)n.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}):n.add(o.id);const i=new Set;for(const o of e.edges)i.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}):i.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 n=Buffer.byteLength(JSON.stringify(e),"utf8");n>t.maxDocumentBytes&&r.push({code:"document.limit.size",path:"$",message:`Document serializes to ${n} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,details:{bytes:n,limit:t.maxDocumentBytes}})}async validateNestedBodies(e,t,o,...r){for(const n of e.nodes){const e=[["loop.body",n.loop?.body],["errorBoundary.try",n.errorBoundary?.try],["errorBoundary.catch",n.errorBoundary?.catch],["errorBoundary.finally",n.errorBoundary?.finally]];for(const[i,a]of e){if(!a)continue;const e=await this.validate(a,t+1,...r);for(const t of e.issues)o.push({...t,path:`nodes[${n.id}].${i}.${t.path}`,nodeId:t.nodeId??n.id})}}}validateAcyclicity(e,t,o,r){const n=new Set(e.map(e=>e.instance.id)),i=new Map(e.map(e=>[e.instance.id,0]));for(const e of t)n.has(e.sourceNodeId)&&i.has(e.targetNodeId)&&i.set(e.targetNodeId,(i.get(e.targetNodeId)??0)+1);const a=[...i.entries()].filter(([,e])=>0===e).map(([e])=>e),s=[];for(;a.length>0;){const e=a.shift();s.push(e);for(const o of t){if(o.sourceNodeId!==e)continue;if(!i.has(o.targetNodeId))continue;const t=(i.get(o.targetNodeId)??1)-1;i.set(o.targetNodeId,t),0===t&&a.push(o.targetNodeId)}}if(s.length!==i.size){const e=[...i.keys()].filter(e=>!s.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===$o&&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??[])to(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}))}}}let jn=class extends H{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"}'`),!Tn(e))throw new hr("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 n=this.buildPlanNodes(e),i=this.buildPlanEdges(e),a=this.buildIncomingMap(i),s=this.buildOutgoingMap(i),d=this.topologicalLayers(n,i);return{resolved:e,workflowId:e.document.id||e.document.name,nodes:n,edges:i,layers:d,incomingByNode:a,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===$o)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===$o)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!==$o),r=new Set(o.map(e=>e.id)),n=t.filter(e=>r.has(e.sourceNodeId)&&r.has(e.targetNodeId)),i=new Map;for(const e of o)i.set(e.id,0);for(const e of n)i.set(e.targetNodeId,(i.get(e.targetNodeId)??0)+1);const a=[],s=new Set;let d=o.filter(e=>0===(i.get(e.id)??0)),l=0;for(;d.length>0;){const e={index:l++,nodes:d};a.push(e);const t=[];for(const e of d){s.add(e.id);const r=n.filter(t=>t.sourceNodeId===e.id);for(const e of r){const r=(i.get(e.targetNodeId)??1)-1;if(i.set(e.targetNodeId,r),0===r&&!s.has(e.targetNodeId)){const r=o.find(t=>t.id===e.targetNodeId);r&&t.push(r)}}}d=t}if(s.size!==o.length){const e=o.filter(e=>!s.has(e.id)).map(e=>e.id);throw new sr({unplannedNodes:e,workflowId:o[0]?.manifest.kind})}return a}};jn=R([B(),C("design:paramtypes",[])],jn);class $n{constructor(){this.pending=new Map}register(e,t){return this.cancel(e),new Promise((o,r)=>{const n={resolve:o};void 0!==t&&Number.isFinite(t)&&t>0&&(n.timer=setTimeout(()=>{this.pending.delete(e),r(new ar(`No webhook response was produced for run '${e}' within ${t}ms`,"GRAPH_WEBHOOK_RESPONSE_TIMEOUT",{runId:e,timeoutMs:t}))},t),n.timer.unref?.()),this.pending.set(e,n)})}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)}}let Ln=class extends j{constructor(e){super(e)}};R([N({type:String,generated:!1}),C("design:type",String)],Ln.prototype,"id",void 0),R([T(),D(),C("design:type",String)],Ln.prototype,"tableName",void 0),R([T(),D(),C("design:type",String)],Ln.prototype,"rowId",void 0),R([T(),C("design:type",Object)],Ln.prototype,"data",void 0),R([T(),C("design:type",Date)],Ln.prototype,"createdAt",void 0),R([T(),C("design:type",Date)],Ln.prototype,"updatedAt",void 0),Ln=R([P("graph_data_table"),I(),C("design:paramtypes",[Object])],Ln);const Mn=/^[A-Za-z0-9_.-]+$/;function Gn(e,t){return`${e}:${t}`}function Un(e){if(!e||e.length>128||!Mn.test(e))throw new ar(`Data table name '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_NAME",{tableName:e})}function Fn(e){if(!e||e.length>256)throw new ar(`Data table row id '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_ROW_ID",{rowId:e})}function Bn(e){let t;try{t=JSON.stringify(e)}catch{throw new ar("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:er})}if(void 0===t)throw new ar("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:er});const o=Buffer.byteLength(t,"utf8");if(o>er)throw new ar("Data table row payload exceeds the 1048576-byte limit","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{bytes:o,limitBytes:er})}function Hn(e){return{...e.data,id:e.rowId}}let qn=class extends U{constructor(e){super(e,Ln,!0)}async insertRow(e,t,o,...r){Un(e),Fn(t),Bn(o),await this.assertRowCapacity(e,...r);const n=new Date,i=new Ln({id:Gn(e,t),tableName:e,rowId:t,data:{...o},createdAt:n,updatedAt:n});return Hn(await this.create(i,...r))}async upsertRow(e,t,o,...r){if(Un(e),Fn(t),Bn(o),!await this.readRow(e,t,...r))return this.insertRow(e,t,o,...r);const n=await this.read(Gn(e,t),...r);return n.data={...o},n.updatedAt=new Date,Hn(await this.update(n,...r))}async readRow(e,t,...o){Un(e),Fn(t);try{return Hn(await this.read(Gn(e,t),...o))}catch{return}}async listRows(e,t,...o){Un(e);const r=void 0!==t&&Number.isFinite(t)&&t>=0?Math.floor(t):tr;if(0===r)return[];const n=Math.min(r,tr);return(await this.select().where(q.attr("tableName").eq(e)).orderBy("rowId",W.ASC).limit(n).execute(...o)).map(Hn)}async assertRowCapacity(e,...t){if((await this.listRows(e,Zo,...t)).length>=Zo)throw new ar(`Data table '${e}' reached the 10000-row limit`,"GRAPH_DATA_TABLE_ROW_LIMIT_EXCEEDED",{tableName:e,limit:Zo})}async deleteRow(e,t,...o){Un(e),Fn(t);try{return await this.delete(Gn(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}};function Wn(e){return new(0,U.forModel(Ln,e.alias).constructor)(e)}qn=R([G(Ln,y),C("design:paramtypes",[Function])],qn);const Kn=new Set(["engine","valueAdapter","codeSandboxEvaluator","workflowStore"]);function Vn(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 Cr(o)}return{}}function zn(e,t){const o={};for(const[r,n]of Object.entries(e??{}))Kn.has(r)&&!t.has(r)||(o[r]=n);return o}class Qn extends K{constructor(){super(),this.webhookResponseRegistry=new $n,this.runSubWorkflowDepth=new Map,this.runRootId=new Map,this.rootChildRunCounts=new Map}async initialize(...e){const t=e[0];if(!t||"object"!=typeof t||!t.registry)return this._config=void 0,this._client=void 0,{config:void 0,client:void 0};const o=t.catalogue??t.registry.catalog,r=t.valueAdapter??V.current;if(!r)throw new ar("GraphExecutionEngine requires a Decaf adapter for cached/pinned values: pass `valueAdapter` or configure one via `Adapter.setCurrent(...)`","GRAPH_VALUE_ADAPTER_MISSING");const n=t.backend??Hr.current??new xn,i={registry:t.registry,catalogue:o,planner:t.planner??new jn,backend:n,valueAdapter:r,eventEmitter:t.eventEmitter??new mr,documentValidator:t.documentValidator??new Pn({catalogue:o,limits:t.documentLimits,credentialAuthorizer:t.credentialAuthorizer}),authValidator:new Dr({enabled:!0===t.authEnabled,...t.authMatch?{match:t.authMatch}:{}}),...t.codeSandboxEvaluator?{codeSandboxEvaluator:t.codeSandboxEvaluator}:{},...t.nodeCredentials?{nodeCredentials:new Pr(t.nodeCredentials)}:{}};this._config=t,this._client=i;const a=new Set(["engine","valueAdapter"]);t.codeSandboxEvaluator&&a.add("codeSandboxEvaluator"),t.workflowStore&&a.add("workflowStore");const s=zn(n.config,a);if(await n.initialize({...s,valueAdapter:r,...t.codeSandboxEvaluator?{codeSandboxEvaluator:t.codeSandboxEvaluator}:{},...t.workflowStore?{workflowStore:t.workflowStore}:{},engine:this}),t.seedWorkflows&&t.seedWorkflows.length>0){const o=n.seedWorkflows;if("function"!=typeof o)throw new ar(`Graph execution backend '${n.constructor?.name??"GraphExecutionBackend"}' does not support workflow seeding`,"GRAPH_BACKEND_SEED_NOT_SUPPORTED",{backend:n.constructor?.name??"GraphExecutionBackend"});await o.call(n,t.seedWorkflows,...e.slice(1))}return await(t.onEngineCreated?.(this)),{config:t,client:i}}get codeSandboxEvaluator(){return this.client.codeSandboxEvaluator}get nodeCredentials(){return this.client.nodeCredentials}get dataTableStore(){return this.dataTableRepository||(this.dataTableRepository=Wn(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:n,ctx:i}=(await this.logCtx(r,"execute",!0)).for(this.execute);n.debug(`Executing workflow '${e.id||e.name}'`);const a=this.mergeOptions(o);this.assertNotAborted(a);const s=Tr(Cr(i),a.auth);a.auth=s,a.metadata={...a.metadata??{},...s};const d=a.runId??this.generateRunId();a.runId=d;const l=a.path??[];this.enterExecutionBudget(d,a);try{const o=new br,c=gn(this.valueAdapter);c.seedWorkflowInputs(this.withWorkflowInputDefaults(e,t));const p=new Fr(this.emitter,o,{runId:d,parentRunId:a.parentRunId,workflowId:e.id||e.name,path:l,engine:this,...this.codeSandboxEvaluator?{codeSandboxEvaluator:this.codeSandboxEvaluator}:{}});await p.emit({type:Qe.VALIDATION_STARTED,status:Ke.PLANNING});const u=await this.documentValidator.validate(e,0,i);if(!u.valid||!u.resolved)throw await p.emit({type:Qe.VALIDATION_FAILED,status:Ke.FAILED,payload:{issues:u.issues}}),new kn(`Graph workflow document '${e.id}' failed validation with ${u.issues.length} issue(s)`,u.issues);await p.emit({type:Qe.VALIDATION_COMPLETED,status:Ke.PLANNING,payload:{issues:u.issues.length}}),this.assertNotAborted(a);const h=await this.planner.plan(u.resolved);this.client.authValidator.validate(e,h,s,n),n.debug(`Authorized workflow '${e.id||e.name}' for user ${s.user??"anonymous"}`),this.assertCodeModeSupported(e);const g=new Gr(d,h,c,o);return p.bindFrame(g),await p.emit({type:Qe.WORKFLOW_STARTED,runId:d,parentRunId:a.parentRunId,workflowId:h.workflowId,path:l,status:Ke.RUNNING,payload:{inputs:t}}),await p.emit({type:Qe.WORKFLOW_PLANNED,runId:d,parentRunId:a.parentRunId,workflowId:h.workflowId,path:l,status:Ke.PLANNING,payload:{layers:h.layers.length,nodes:h.nodes.length}}),await this.client.backend.execute({document:e,plan:h,inputs:t,options:a,events:p},...r)}finally{this.releaseExecutionBudget(d)}}get backend(){return this.client.backend}get backendCapabilities(){return Br(this.client.backend)}async listWorkflows(...e){const t=this.client.backend;if("supported"!==Br(t).workflows.list||"function"!=typeof t.listWorkflows)throw new ar(`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"!==Br(o).workflows.get||"function"!=typeof o.getWorkflow)throw new ar(`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,Vn(t)),r}assertWorkflowReadAccess(e,t,o){this.client.authValidator.validateWorkflowRead(e,t,o)}async listEngineWorkflows(e,...t){const o=Hr.getOrFail(e);if("supported"!==Br(o).workflows.list||"function"!=typeof o.listWorkflows)throw new ar(`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=Hr.getOrFail(e);if("supported"!==Br(r).workflows.get||"function"!=typeof r.getWorkflow)throw new ar(`Graph execution backend '${e}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e,workflowId:t});const n=await r.getWorkflow(t,...o);return this.assertWorkflowReadAccess(n,Vn(o)),n}get backendName(){return this.client.backend.constructor?.name??"GraphExecutionBackend"}assertCodeModeSupported(e){const t=this.client.backend;if(t.local)return;const o=Zr(e);if(0!==o.length){if("unsupported"===t.codeMode)throw new ar(`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 ar("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,Qe.NODE_PINNED)}async unpinNode(e){const t=this.createPinningService();await t.unpinNode(e),await this.emitPinningEvent(e.nodeId,Qe.NODE_UNPINNED)}createPinningService(){const e=gn(this.valueAdapter);return new yn(e,new wn,new vn)}async emitPinningEvent(e,t){const o=(new br).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:Bo,maxForeachIterations:Ho,usePinnedValues:!0,writeThroughCache:!1,path:[],metadata:{},...this.defaultOptions,...e}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new fr(e.runId??"unknown")}enterExecutionBudget(e,t){const o=t.parentRunId,r=t.path??[],n="subworkflow"===r[r.length-1],i=r.filter(e=>"subworkflow"===e).length,a=o?this.runSubWorkflowDepth.get(o)??Math.max(0,i-(n?1:0)):0,s=o?a+(n?1:0):0,d=t.maxSubWorkflowDepth??10;if(s>d)throw new ar(`Graph run '${e}' exceeds the maximum sub-workflow depth of ${d}`,"GRAPH_SUB_WORKFLOW_DEPTH_EXCEEDED",{runId:e,parentRunId:o,depth:s,maxDepth:d});if(!o)return this.runSubWorkflowDepth.set(e,s),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(n){if(p+=1,p>c)throw new ar(`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,s),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 ar("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 Jn=new Set(["process","require","module","exports","global","globalThis","Function","eval","fetch","XMLHttpRequest","WebSocket","Worker","Deno","Bun","__dispatch"]);class Xn extends K{constructor(){super()}async initialize(...e){const t=e[0]??{},o=t&&"object"==typeof t?t:{};return this._config=o,this._client=Q,{config:o,client:Q}}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 ar("Code sandbox received empty code","GRAPH_CODE_SANDBOX_EMPTY_CODE");const r=((e,t)=>"javascript"===t?e:Y.transpileModule(e,{compilerOptions:{target:Y.ScriptTarget.ES2022,module:Y.ModuleKind.None,strict:!0,noEmitHelpers:!0,importHelpers:!1}}).outputText.replace(/^"use strict";\s*/,""))(o,e.language??"javascript");(e=>{if(e.length>1e5)throw new ar("Code exceeds the maximum length of 100000 characters","GRAPH_CODE_SANDBOX_CODE_TOO_LONG",{length:e.length});let t;try{t=J.parse(`async function __validate() {\n${e}\n}`,{ecmaVersion:"latest",sourceType:"script"})}catch{try{t=J.parse(e,{ecmaVersion:"latest",sourceType:"module"})}catch(t){throw new ar("Code failed to parse: "+t.message,"GRAPH_CODE_SANDBOX_PARSE_ERROR",{code:e,error:t.message})}}X.full(t,e=>{const t=e;if("ImportDeclaration"===t.type)throw new ar("Imports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"import"});if("ExportNamedDeclaration"===t.type||"ExportDefaultDeclaration"===t.type)throw new ar("Exports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"export"});if("Identifier"===t.type&&"string"==typeof t.name&&Jn.has(t.name))throw new ar(`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 ar("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 ar("eval() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"eval"})})})(r);const n=!(e=>/\breturn\b[\s;]/.test(e))(r),i=n?r.replace(/[\s;]+$/,""):r,a={$input:e.input??{},$vars:e.vars??{},$item:e.item,$index:e.index,$node:e.nodes??{},$output:void 0},s=Object.keys(a),d=n?`return (${i});`:i,l=`"use strict";\nasync function __userFunction(${s.join(", ")}) {\n${d}\n}\n__userFunction(${s.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`,c=new Q.Isolate({memoryLimit:this.defaultMemoryMb}),p=await c.createContext();try{const t=p.global;e.logger&&await this.injectConsole(p,e.logger);for(const[e,o]of Object.entries(a))await t.set(e,new Q.ExternalCopy(void 0===o?null:o).copyInto());let o;try{o=await c.compileScript(l,{filename:"graph-code-node.js"})}catch(e){if(!n)throw new ar("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:r,error:e.message});{const e=i,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 c.compileScript(t,{filename:"graph-code-node.js"})}catch(e){throw new ar("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:r,error:e.message})}}}const d=e.timeoutMs??this.defaultTimeoutMs;let u;try{u=await this.runBounded(o,p,d,e.abortSignal)}catch(e){if(e instanceof ar)throw e;const t=e.message;if(t.includes("timed out")||t.includes("timeout"))throw new ar(`Code execution timed out after ${d} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:d});if(t.includes("memory")||t.includes("heap"))throw new ar(`Code exceeded the memory limit of ${this.defaultMemoryMb} MB`,"GRAPH_CODE_SANDBOX_MEMORY_LIMIT",{memoryMb:this.defaultMemoryMb});throw new ar("Code execution failed: "+t,"GRAPH_CODE_SANDBOX_RUNTIME_ERROR",{code:r,error:t})}if("string"!=typeof u)throw new ar("Code sandbox returned an unexpected non-string result","GRAPH_CODE_SANDBOX_UNEXPECTED_RESULT",{result:u});return JSON.parse(u).v}finally{p.release(),c.dispose()}}async runBounded(e,t,o,r){const n=e.run(t,{timeout:o,promise:!0});n.catch(()=>{});const i=[n];let a,s;try{return i.push(new Promise((e,t)=>{a=setTimeout(()=>{t(new ar(`Code execution timed out after ${o} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:o}))},o+100)})),r&&i.push(new Promise((e,t)=>{const n=()=>{const e="timeout"===r.reason;t(new ar(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?n():(r.addEventListener("abort",n,{once:!0}),s=()=>r.removeEventListener("abort",n))})),await Promise.race(i)}finally{a&&clearTimeout(a),s?.()}}async injectConsole(e,t){const o=new Q.Reference((e,o)=>{let r;try{r=JSON.parse(o)}catch{r=[o]}const n=r.map(e=>"string"==typeof e?e:JSON.stringify(e)).join(" "),i=1===r.length?r[0]:r;switch(e){case"log":case"info":default:t.info(n,i);break;case"warn":t.warn(n,i);break;case"error":t.error(n,i);break;case"debug":case"dir":case"dirxml":case"table":t.debug(n,i);break;case"trace":t.trace(n,i);break;case"group":case"groupCollapsed":t.debug("[group] "+n,i);break;case"groupEnd":t.debug("[groupEnd]",void 0);break;case"time":case"timeEnd":case"timeLog":case"count":case"countReset":t.debug(`[${e}] ${n}`,i);break;case"assert":r[0]||t.error("Assertion failed: "+n,i);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 Yn extends k{constructor(e){super(e,Yn.name,500)}}class Zn extends S{constructor(e){super(e),this.name=Zn.name}}class ei extends S{constructor(e){super(e),this.name=ei.name}}class ti{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 Yn(`Method declaration for kind '${this.kind}' is missing a name`);if(this.declarations.has(e.name))throw new Yn(`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 Yn(`Method implementation '${e}' for kind '${this.kind}' is not a function`);if(!this.declarations.has(e))throw new Yn(`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 Yn(`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 ei(`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 oi(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 ri(e,t,o){const r=oi(t,e.itemIdPath),n=e.itemLabelPath?oi(t,e.itemLabelPath):void 0;return{id:"string"==typeof r&&r||"number"==typeof r&&Number.isFinite(r)&&r+""||o+"",label:"string"==typeof n?n:void 0}}function ni(e,t){switch(t){case"input":return e.inputs;case"output":return e.outputs;default:return e.connections}}function ii(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))},n=(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 i=ni(o,r.direction);e.forEach((e,t)=>{const{id:o,label:a}=ri(r,e,t),s=(d={id:o,index:t,label:a??o},r.portIdTemplate.replaceAll("${id}",d.id).replaceAll("${index}",d.index+"").replaceAll("${label}",d.label));var d;if(!n(r.direction,s))return;const l=r.defaultPort?kt(r.defaultPort):{id:s,label:a??s,direction:r.direction};l.id=s,l.direction=r.direction,a&&(l.label=a),i.push(l)})}else if("togglePort"===r.type){if(t[r.parameter]!==r.equals)continue;const e=kt(r.port);if(!n(e.direction,e.id))continue;ni(o,e.direction).push(e)}return o}function ai(e,t){const o=ii(e,t),r={kind:e.kind,display:e.display,inputs:[...e.inputs,...o.inputs],outputs:[...e.outputs,...o.outputs],parameters:e.parameters},n=[...e.connections??[],...o.connections];return n.length&&(r.connections=n),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),kt(r)}class si{async resolve(e,t,o,r,n){if(o){const i=await o(r,n);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)})(i))throw new Yn(`resolveManifest provider for kind '${e}' returned a value that does not conform to GraphResolvedNodeManifest`);if(!Et(i))throw new Yn(`resolveManifest provider for kind '${e}' returned a non-JSON-safe resolved manifest`);const a=kt(i);return!a.namespaces?.length&&t.namespaces?.length&&(a.namespaces=t.namespaces.slice()),a}return ai(t,r.parameters??{})}}const di=["edge","literal","expression"];function li(e){return di.includes(e)}function ci(e,t,o){if("string"!=typeof o||!o)throw new Yn(`Manifest for kind '${e}' has a ${t} with an empty port id`);if(It(o))throw new Yn(`Manifest for kind '${e}' has a ${t} with unsafe port id '${o}'`)}let pi=class extends H{constructor(){super(),this.entries=new Map,this.resolver=new si,this.fallbackContext=new M}withContext(e){return e[e.length-1]instanceof M?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 Yn("Graph node registration is required");if(!e.manifest||"object"!=typeof e.manifest)throw new Yn("Graph node registration is missing a manifest");if(!e.executor||"function"!=typeof e.executor.execute)throw new Yn(`Graph node registration for kind '${e.manifest?.kind+""}' is missing an executor`)})(e);const n=e.manifest;if("string"!=typeof n.kind||!n.kind.trim())throw new Yn("Graph node manifest kind is required and must be a non-empty string");const i=n.kind;if(this.entries.has(i)&&!t.replace)throw new Yn(`Graph node kind '${i}' is already registered; pass { replace: true } to replace it`);try{ro(n)}catch(e){throw new Yn(`Manifest for kind '${i}' 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 n of r){if(ci(e,t+" port",n?.id),o.has(n.id))throw new Yn(`Manifest for kind '${e}' declares duplicate static ${t} port id '${n.id}'`);if(o.add(n.id),void 0!==n.defaultMode&&!li(n.defaultMode))throw new Yn(`Manifest for kind '${e}' declares invalid default binding mode '${n.defaultMode+""}' on ${t} port '${n.id}'`)}}})(i,n);const a=((e,t)=>{const o=new Set;for(const r of t.parameters){const t=r?.id;if("string"!=typeof t||!t)throw new Yn(`Manifest for kind '${e}' has a parameter with an empty id`);if(It(t))throw new Yn(`Manifest for kind '${e}' has a parameter with unsafe id '${t}'`);if(o.has(t))throw new Yn(`Manifest for kind '${e}' declares duplicate parameter id '${t}'`);o.add(t)}return o})(i,n);((e,t,o)=>{for(const r of t.dynamicPorts??[]){if(!r||"string"!=typeof r.parameter||!r.parameter)throw new Yn(`Manifest for kind '${e}' has a dynamic-port rule without a parameter reference`);if(!o.has(r.parameter))throw new Yn(`Manifest for kind '${e}' has a dynamic-port rule referencing missing parameter '${r.parameter}'`);if("togglePort"===r.type){if(!r.port)throw new Yn(`Manifest for kind '${e}' has a togglePort rule without a port`);ci(e,"togglePort rule port",r.port.id)}if("repeatFromParameter"===r.type&&"string"!=typeof r.portIdTemplate)throw new Yn(`Manifest for kind '${e}' has a repeatFromParameter rule without a portIdTemplate`)}})(i,n,a),((e,t)=>{for(const o of t.credentials??[]){if(!Zt(o))throw new Yn(`Manifest for kind '${e}' has a malformed credential requirement`);if(!o.type)throw new Yn(`Manifest for kind '${e}' has a credential requirement with an empty type`)}})(i,n),((e,t)=>{for(const o of t.methods??[])if(!so(o))throw new Yn(`Manifest for kind '${e}' has a malformed method declaration`)})(i,n);const s=new ti(i,n.methods??[],e.methods??{});return this.entries.set(i,{registration:e,methods:s,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 Yn("Graph executor kind is required");if(!t||"function"!=typeof t.execute)throw new Yn(`Executor registered for kind '${e}' is missing an execute method`);const n=this.entries.get(e);if(n)return n.registration={...n.registration,executor:t},this;const i={kind:e,display:{name:e},inputs:[],outputs:[],parameters:[],policies:{allowUndeclaredParameters:!0,allowUnknownOutputs:!0}};return this.entries.set(e,{registration:{manifest:i,executor:t},methods:new ti(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 Zn(`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),kt(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,n=e?.kinds?.length?new Set(e.kinds):void 0,i=[];for(const e of o){if(n&&!n.has(e))continue;const o=this.getManifest(e,...t);r&&!r.has(o.display.category??"")||i.push(o)}return i}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 n=this.entry(e);return this.resolver.resolve(e,n.registration.manifest,n.registration.resolveManifest,t,o)}};pi=R([B(),C("design:paramtypes",[])],pi);let ui=class extends H{constructor(e=new pi){super(),this.catalogue=e}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 ar("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 Zn)throw new ar(`No graph executor registered for kind '${e}'`,"GRAPH_EXECUTOR_NOT_FOUND",{kind:e});throw t}}};ui=R([B(),C("design:paramtypes",[pi])],ui);let hi=class extends H{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)}};function gi(e){return e}function fi(e){return e.methods??[]}function yi(e){if(!e)return;const t={...e.metadata??{},...e.parameters??{},...e.state??{}};return e.loop&&(t.loop=e.loop),t}hi=R([B(),C("design:paramtypes",[Function,Object])],hi);class mi extends b{constructor(e){super(),b.fromModel(this,e)}execute(e,t){throw new ar(`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)}}let bi=class extends mi{execute(e,t){throw new gr(e.inputs.value)}};function wi(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+""}}R([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.break.fields.value.label",placeholder:"graph.node.flow_control.break.fields.value.placeholder",type:"textarea"}),bt({handle:"value"}),C("design:type",Object)],bi.prototype,"value",void 0),bi=R([yt("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"}}),I()],bi);let vi=class extends mi{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 ar("errorBoundary node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");try{const n=await r.execute(o.try,e.inputs,{parentRunId:t.runId,path:[...t.path,"try"]}),i=Object.values(n.nodeResults).find(e=>e.status===Ke.FAILED);if(i)throw new ar(i.error?.message??"error boundary try body failed",i.error?.code??"GRAPH_ERROR_BOUNDARY",i.error?.details);return{result:n.outputs.result??n.outputs}}catch(n){let i=n;if(o.catch){const a=await r.execute(o.catch,{...e.inputs,error:wi(n)},{parentRunId:t.runId,path:[...t.path,"catch"]});i=a.outputs.error??a.outputs}return{error:i}}finally{o.finally&&await r.execute(o.finally,e.inputs,{parentRunId:t.runId,path:[...t.path,"finally"]})}}};R([w(),i("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"}),bt({handle:"value"}),C("design:type",Object)],vi.prototype,"value",void 0),R([wt({handle:"result"}),C("design:type",Object)],vi.prototype,"result",void 0),R([wt({handle:"error"}),C("design:type",Object)],vi.prototype,"error",void 0),vi=R([yt("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}}),I()],vi);let xi=class extends mi{execute(e){const t=e.inputs.value??e.inputs;return!1===this.approved?{rejected:t}:{approved:t}}};R([w(),bt({handle:"value"}),C("design:type",Object)],xi.prototype,"value",void 0),R([i("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"}),bt({handle:"message",userControlled:!0}),C("design:type",String)],xi.prototype,"message",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.approved.label",type:"checkbox"}),bt({handle:"approved",userControlled:!0}),C("design:type",Boolean)],xi.prototype,"approved",void 0),R([wt({handle:"approved"}),C("design:type",Object)],xi.prototype,"approvedOut",void 0),R([wt({handle:"rejected"}),C("design:type",Object)],xi.prototype,"rejectedOut",void 0),xi=R([yt("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}}),I()],xi);let Ii=class extends mi{execute(e,t){const o=e.inputs,r=o.value??o;if(!this.condition)throw new ar("If node has no condition configured","GRAPH_IF_NO_CONDITION",{input:o});if(Wr(this.condition))return Vr(this.condition,o,t).then(e=>this.route(e,r));const n=zr(this.condition,((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(o,r),"if");return this.route(n,r)}route(e,t){if(e)return{then:t};if(!0===this.else)return{else:t};throw new ar("If node condition evaluated to false and the else branch is disabled","GRAPH_IF_ELSE_DISABLED",{condition:this.condition})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.value.label",placeholder:"graph.node.flow_control.if.fields.value.placeholder",type:"textarea"}),bt({handle:"value"}),C("design:type",Object)],Ii.prototype,"value",void 0),R([w(),wt({handle:"then"}),C("design:type",Object)],Ii.prototype,"then",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.condition.label",placeholder:"graph.node.flow_control.if.fields.condition.placeholder",type:"code"}),bt({handle:"condition",userControlled:!0,type:"object"}),C("design:type",Object)],Ii.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.else.label",type:"checkbox"}),bt({handle:"else",userControlled:!0}),C("design:type",Boolean)],Ii.prototype,"else",void 0),Ii=R([yt("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"}}),I()],Ii);let Ai=class extends mi{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,n=e.inputs,i=n.value??n,a=((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(n,i);for(const e of r)if(await Qr(e.condition,{input:n,state:a,label:"switch case"},t))return{[e.outputPort]:i};if(!0!==o.hasDefault)throw new ar("No switch case matched and default port is not enabled","GRAPH_SWITCH_NO_MATCH",{cases:r.map(e=>e.id)});const s=o.defaultPort??"default";return{[s]:i}}static applyMetadata(e){const t=ht(this),o=e.defaultPort??"default",r=!0===e.hasDefault,n=t.ports.filter(t=>!e.cases.some(e=>e.outputPort===t.property)),i=n.filter(e=>e.property!==o),a=n.find(e=>e.property===o),s=[...i,...e.cases.map(e=>({property:e.outputPort,name:e.label,direction:Me.OUTPUT,label:e.label,required:!1,hidden:!1,path:e.outputPort}))];return r&&a&&s.push(a),{ports:s,size:Ue(t,{cases:e.cases.length}),dataPatch:{switchMetadata:e}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.value.label",placeholder:"graph.node.flow_control.switch.fields.value.placeholder",type:"textarea"}),bt({handle:"value"}),C("design:type",Object)],Ai.prototype,"value",void 0),R([w(),wt({handle:"default"}),C("design:type",Object)],Ai.prototype,"default",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.cases.label",type:"collection"}),C("design:type",Object)],Ai.prototype,"cases",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.hasDefault.label",type:"checkbox"}),C("design:type",Boolean)],Ai.prototype,"hasDefault",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.defaultPort.label",type:"text"}),C("design:type",String)],Ai.prototype,"defaultPort",void 0),Ai=R([yt("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"}}),I()],Ai);const _i={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},Oi=o.accumulate({graph:{workflows:{limits:{..._i},allowAnonymousAccess:!1},execution:{maxCodeTimeoutMs:qo}}}),Ei=1e3;function ki(e,t){const o="number"==typeof t?t:Number(t),r=Number.isFinite(o)&&o>0?o:qo,n="number"==typeof e?e:Number(e);return Number.isFinite(n)&&n>0?Math.min(Math.floor(n),r):1e3}const Si=["javascript","typescript"],Ri="javascript";let Ci=class extends b{constructor(){super(...arguments),this.language=Ri}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.language.label",type:"select"}),A([...Si]),v(String),C("design:type",String)],Ci.prototype,"language",void 0),R([w(),i("code-editor",{label:"graph.node.utility.code.fields.code.label",placeholder:"graph.node.utility.code.fields.code.placeholder"}),bt({handle:"code"}),C("design:type",String)],Ci.prototype,"code",void 0),R([d(),bt({handle:"data"}),C("design:type",Object)],Ci.prototype,"data",void 0),Ci=R([I()],Ci);let Ni=class extends mi{async execute(e,t){const o=e.inputs,r=this.input,n=o.code??e.parameters?.code??r?.code??this.defaultCode,i=r?.language??Ri;if(!n||"string"!=typeof n||0===n.trim().length)throw new dr("Code node has no code to execute (input.code is empty)",{input:o});const a=t.engine?.codeSandboxEvaluator;if(!a)throw new ar("Code node execution requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:n});const s=Oi.graph.execution?.maxCodeTimeoutMs,d="number"==typeof s&&Number.isFinite(s)&&s>0?s:qo,l=ki(this.timeoutMs,d),c=t.metadata,p={code:n,language:i,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:i,length:n.length,timeoutMs:l});const u=await a.evaluate(p);return await t.log("Code node executed",{hasResult:void 0!==u}),{result:u}}};R([w(),bt({handle:"input",model:Ci}),C("design:type",Ci)],Ni.prototype,"input",void 0),R([_(1),O(qo),i("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs"}),C("design:type",Number)],Ni.prototype,"timeoutMs",void 0),R([i("code-editor",{label:"graph.node.utility.code.fields.defaultCode.label",placeholder:"graph.node.utility.code.fields.defaultCode.placeholder"}),bt({handle:"defaultCode",userControlled:!0}),C("design:type",String)],Ni.prototype,"defaultCode",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Ni.prototype,"result",void 0),Ni=R([yt("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"}}),I()],Ni);let Ti=class extends mi{execute(e){return{value:e.inputs.value??e.inputs}}};R([w(),bt({handle:"value"}),C("design:type",Object)],Ti.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.delay.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs"}),C("design:type",Number)],Ti.prototype,"timeoutMs",void 0),R([w(),wt({handle:"value"}),C("design:type",Object)],Ti.prototype,"valueOut",void 0),Ti=R([yt("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"}}),I()],Ti);let Di=class extends mi{execute(e,t){const o=e.inputs.value,r=this.level??"info";return t.logger[r](this.message??"Log node",{value:o}),{value:o}}};R([w(),bt({handle:"value"}),C("design:type",Object)],Di.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.message.label",placeholder:"graph.node.utility.log.fields.message.placeholder",type:"textarea"}),bt({handle:"message"}),C("design:type",String)],Di.prototype,"message",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.level.label",placeholder:"graph.node.utility.log.fields.level.placeholder",type:"text"}),bt({handle:"level",userControlled:!0}),C("design:type",String)],Di.prototype,"level",void 0),R([w(),wt({handle:"value"}),C("design:type",Object)],Di.prototype,"valueOut",void 0),Di=R([yt("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"}}),I()],Di);let Pi=class extends mi{execute(e){return{result:{mapped:e.inputs.value??e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.utility.map.fields.value.label",placeholder:"graph.node.utility.map.fields.value.placeholder",type:"textarea"}),bt({handle:"value"}),C("design:type",Object)],Pi.prototype,"value",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Pi.prototype,"result",void 0),Pi=R([yt("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:{}}}),I()],Pi);let ji=class extends mi{execute(e,t){const o=e.inputs.value,r=this.level??"info";return t.logger[r](this.message??"Log node",{value:o}),{value:o}}};R([w(),bt({handle:"value"}),C("design:type",Object)],ji.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.message.label",placeholder:"graph.node.utility.utility_log.fields.message.placeholder",type:"textarea"}),bt({handle:"message"}),C("design:type",String)],ji.prototype,"message",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.level.label",placeholder:"graph.node.utility.utility_log.fields.level.placeholder"}),bt({handle:"level",userControlled:!0,type:"string"}),C("design:type",String)],ji.prototype,"level",void 0),R([w(),wt({handle:"value"}),C("design:type",Object)],ji.prototype,"valueOut",void 0),ji=R([yt("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"}}),I()],ji);const $i=new Set(["__proto__","constructor","prototype"]);function Li(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Mi(e){return null==e?[]:(Array.isArray(e)?e:[e]).filter(e=>null!=e)}function Gi(e,t){if($i.has(t))throw new ar(`Graph data path '${e}' contains the reserved segment '${t}'`,"GRAPH_DATA_UNSAFE_PATH",{path:e,segment:t})}function Ui(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)Gi(e,o);return t})(e):(Gi(e,e),[e])}function Fi(e,t,o=!0){if(!t)return e;const r=Ui(t,o);let n=e;for(const e of r){if(!Li(n))return;n=n[e]}return n}function Bi(e,t,o,r=!0){const n=Ui(t,r);if(0===n.length)return;let i=e;for(let e=0;e<n.length-1;e++){const t=n[e],o=i[t];if(Li(o))i=o;else{const e={};i[t]=e,i=e}}i[n[n.length-1]]=o}function Hi(e,t,o=!0){const r=Ui(t,o);if(0===r.length)return;let n=e;for(let e=0;e<r.length-1;e++){const t=n[r[e]];if(!Li(t))return;n=t}delete n[r[r.length-1]]}function qi(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 ar(`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 Li(e)?e:{};default:if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}}function Wi(e,t,o="auto"){const r=null==e,n=null==t;return r&&n?0:r?1:n?-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 Ki(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 Vi(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 zi(e){if(e instanceof Date){if(Number.isNaN(e.getTime()))throw new ar("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 ar("Date & Time node requires a valid date value","GRAPH_DATA_INVALID_DATE",{value:e})}function Qi(e){return"undefined"!=typeof Buffer&&Buffer.isBuffer(e)||e instanceof Uint8Array||e instanceof ArrayBuffer}let Ji=class extends mi{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=Vi(zi(e),this.amount??0,this.unit??"days");break;case"subtract":t=Vi(zi(e),-(this.amount??0),this.unit??"days");break;case"parse":case"format":t=zi(e);break;default:throw new ar(`Unsupported Date & Time operation '${this.operation+""}'`,"GRAPH_DATE_TIME_UNSUPPORTED_OPERATION",{operation:this.operation})}return{result:Ki(t,this.format),iso:t.toISOString(),timestamp:t.getTime()}}};R([bt({handle:"value"}),C("design:type",Object)],Ji.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Ji.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.format.label",placeholder:"graph.node.data.date_time.fields.format.placeholder",type:"text"}),bt({handle:"format",userControlled:!0}),C("design:type",String)],Ji.prototype,"format",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.amount.label",type:"number"}),bt({handle:"amount",userControlled:!0}),C("design:type",Number)],Ji.prototype,"amount",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.unit.label",type:"select"}),bt({handle:"unit",userControlled:!0}),C("design:type",String)],Ji.prototype,"unit",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Ji.prototype,"result",void 0),R([wt({handle:"iso"}),C("design:type",String)],Ji.prototype,"iso",void 0),R([wt({handle:"timestamp"}),C("design:type",Number)],Ji.prototype,"timestamp",void 0),Ji=R([yt("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"}}),I()],Ji);let Xi=class extends mi{constructor(){super(...arguments),this.operation="insert",this.tableName="default"}async execute(e,t){const o=t.engine?.dataTableStore;if(!o)throw new ar("Data table node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");if(!this.tableName)throw new ar("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 ar("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 ar("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 ar(`Unsupported data table operation '${this.operation+""}'`,"GRAPH_DATA_TABLE_UNSUPPORTED_OPERATION",{operation:this.operation})}}rowsOf(e){const t=Mi(e.inputs.value).filter(Li);return t.length>0?t:Li(this.row)?[this.row]:[]}async insertRows(e,t,o){const r=this.rowsOf(e),n=[];for(const e of r){const r=this.rowId??this.rowIdOf(e)??Z();n.push(await t.insertRow(this.tableName,r,e,o))}return n}async upsertRows(e,t,o){const r=this.rowsOf(e),n=[];for(const e of r){const r=this.rowId??this.rowIdOf(e)??Z();n.push(await t.upsertRow(this.tableName,r,e,o))}return n}rowIdOf(e){const t=e[this.rowIdField||"id"];return"string"==typeof t&&t.length>0?t:"number"==typeof t?t+"":void 0}};function Yi(e,t){return Li(t)?{...e,...t,item:t}:{...e,item:t}}R([bt({handle:"value"}),C("design:type",Object)],Xi.prototype,"value",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Xi.prototype,"operation",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.tableName.label",placeholder:"graph.node.data.data_table.fields.tableName.placeholder",type:"text"}),bt({handle:"tableName",userControlled:!0}),C("design:type",String)],Xi.prototype,"tableName",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.rowId.label",placeholder:"graph.node.data.data_table.fields.rowId.placeholder",type:"text"}),bt({handle:"rowId",userControlled:!0}),C("design:type",String)],Xi.prototype,"rowId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.rowIdField.label",placeholder:"graph.node.data.data_table.fields.rowIdField.placeholder",type:"text"}),bt({handle:"rowIdField",userControlled:!0}),C("design:type",String)],Xi.prototype,"rowIdField",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.row.label",type:"json"}),bt({handle:"row",userControlled:!0,type:"object"}),C("design:type",Object)],Xi.prototype,"row",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Xi.prototype,"limit",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Xi.prototype,"result",void 0),R([wt({handle:"count"}),C("design:type",Number)],Xi.prototype,"count",void 0),Xi=R([yt("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"}}),I()],Xi);let Zi=class extends mi{constructor(){super(...arguments),this.negate=!1}async execute(e,t){if(!this.condition)throw new ar("Filter node has no condition configured","GRAPH_FILTER_NO_CONDITION");const o=Mi(e.inputs.value),r=[];for(let n=0;n<o.length;n++){const i=o[n];await Qr(this.condition,{input:{...e.inputs,item:i,index:n},state:Yi(e.inputs,i),label:"filter"},t)!==(!0===this.negate)&&r.push(i)}return{result:r}}};R([w(),bt({handle:"value"}),C("design:type",Object)],Zi.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.filter.fields.condition.label",placeholder:"graph.node.data.filter.fields.condition.placeholder",type:"code"}),bt({handle:"condition",userControlled:!0,type:"object"}),C("design:type",Object)],Zi.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.filter.fields.negate.label",type:"checkbox"}),bt({handle:"negate",userControlled:!0}),C("design:type",Boolean)],Zi.prototype,"negate",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],Zi.prototype,"result",void 0),Zi=R([yt("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"}}),I()],Zi);let ea=class extends mi{constructor(){super(...arguments),this.maxItems=1,this.keep="firstItems"}execute(e){const t=Mi(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}}};function ta(e,t,o){const r={...e};for(const[e,n]of Object.entries(t))"keepFirst"===o&&Object.prototype.hasOwnProperty.call(r,e)||(r[e]=n);return r}R([w(),bt({handle:"value"}),C("design:type",Object)],ea.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.limit.fields.maxItems.label",type:"number"}),bt({handle:"maxItems",userControlled:!0}),C("design:type",Number)],ea.prototype,"maxItems",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.limit.fields.keep.label",type:"select"}),bt({handle:"keep",userControlled:!0}),C("design:type",String)],ea.prototype,"keep",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],ea.prototype,"result",void 0),ea=R([yt("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"}}),I()],ea);let oa=class extends mi{constructor(){super(...arguments),this.mode="append",this.combineBy="position",this.joinMode="inner",this.clashHandling="keepFirst"}execute(e){const t=Mi(e.inputs.input),o=Mi(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),n=[];for(let e=0;r>e;e++){if(e>=t.length){if("inner"===this.joinMode||"left"===this.joinMode)continue;n.push(o[e]);continue}if(e>=o.length){if("inner"===this.joinMode||"right"===this.joinMode)continue;n.push(t[e]);continue}const r=t[e],i=o[e];Li(r)&&Li(i)?n.push(ta(r,i,this.clashHandling)):n.push([r,i])}return{result:n}}mergeByFields(e,t){const o=this.joinField;if(!o)throw new ar("Merge node in 'fields' mode requires a join field","GRAPH_MERGE_JOIN_FIELD_REQUIRED");const r=new Map;for(const e of t){if(!Li(e))continue;const t=Fi(e,o);if(null==t)continue;const n=r.get(t);r.set(t,n?ta(n,e,this.clashHandling):e)}const n=[],i=new Set;for(const t of e){if(!Li(t)){"inner"!==this.joinMode&&"right"!==this.joinMode&&n.push(t);continue}const e=Fi(t,o),a=r.get(e);a?(i.add(e),n.push(ta(t,a,this.clashHandling))):"inner"!==this.joinMode&&"right"!==this.joinMode&&n.push(t)}if("right"===this.joinMode||"outer"===this.joinMode)for(const[e,t]of r)i.has(e)||n.push(t);return n}};function ra(e,t,o){const r={...e};for(const e of t){if(!e||!e.from||!e.to||e.from===e.to)continue;const t=Fi(r,e.from,o);void 0!==t&&(Hi(r,e.from,o),Bi(r,e.to,t,o))}return r}R([w(),bt({handle:"input"}),C("design:type",Object)],oa.prototype,"input",void 0),R([bt({handle:"input2"}),C("design:type",Object)],oa.prototype,"input2",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.mode.label",type:"select"}),bt({handle:"mode",userControlled:!0}),C("design:type",String)],oa.prototype,"mode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.combineBy.label",type:"select"}),bt({handle:"combineBy",userControlled:!0}),C("design:type",String)],oa.prototype,"combineBy",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.joinMode.label",type:"select"}),bt({handle:"joinMode",userControlled:!0}),C("design:type",String)],oa.prototype,"joinMode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.joinField.label",placeholder:"graph.node.data.merge.fields.joinField.placeholder",type:"text"}),bt({handle:"joinField",userControlled:!0}),C("design:type",String)],oa.prototype,"joinField",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.clashHandling.label",type:"select"}),bt({handle:"clashHandling",userControlled:!0}),C("design:type",String)],oa.prototype,"clashHandling",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],oa.prototype,"result",void 0),oa=R([yt("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"}}),I()],oa);let na=class extends mi{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=>Li(e)?ra(e,t,r):e)}:Li(o)?{result:ra(o,t,r)}:{result:Mi(o)}}};R([w(),bt({handle:"value"}),C("design:type",Object)],na.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.rename_keys.fields.renames.label",placeholder:"graph.node.data.rename_keys.fields.renames.placeholder",type:"collection"}),bt({handle:"renames",userControlled:!0,type:"array"}),C("design:type",Array)],na.prototype,"renames",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.rename_keys.fields.dotNotation.label",type:"checkbox"}),bt({handle:"dotNotation",userControlled:!0}),C("design:type",Boolean)],na.prototype,"dotNotation",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],na.prototype,"result",void 0),na=R([yt("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"}}),I()],na);let ia=class extends mi{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?Li(e)?{...e}:void 0===e?{}:{value:e}:{};for(const e of this.assignments??[]){if(!e||"string"!=typeof e.name)continue;const o=qi(e.value,e.type??"json");null!=o&&Bi(t,e.name,o,!1!==this.dotNotation)}return t}};R([w(),bt({handle:"value"}),C("design:type",Object)],ia.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.assignments.label",placeholder:"graph.node.data.set.fields.assignments.placeholder",type:"collection"}),bt({handle:"assignments",userControlled:!0,type:"array"}),C("design:type",Array)],ia.prototype,"assignments",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.includeOtherFields.label",type:"checkbox"}),bt({handle:"includeOtherFields",userControlled:!0}),C("design:type",Boolean)],ia.prototype,"includeOtherFields",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.dotNotation.label",type:"checkbox"}),bt({handle:"dotNotation",userControlled:!0}),C("design:type",Boolean)],ia.prototype,"dotNotation",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],ia.prototype,"result",void 0),ia=R([yt("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"}}),I()],ia);let aa=class extends mi{constructor(){super(...arguments),this.sortFields=[],this.valueType="auto",this.dotNotation=!0}execute(e){const t=[...Mi(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=Wi(Fi(e,r.field,!1!==this.dotNotation),Fi(t,r.field,!1!==this.dotNotation),this.valueType??"auto");if(0!==o)return"desc"===r.direction?-o:o}return 0}),{result:t}}};R([w(),bt({handle:"value"}),C("design:type",Object)],aa.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.sortFields.label",placeholder:"graph.node.data.sort.fields.sortFields.placeholder",type:"collection"}),bt({handle:"sortFields",userControlled:!0,type:"array"}),C("design:type",Array)],aa.prototype,"sortFields",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.valueType.label",type:"select"}),bt({handle:"valueType",userControlled:!0}),C("design:type",String)],aa.prototype,"valueType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.dotNotation.label",type:"checkbox"}),bt({handle:"dotNotation",userControlled:!0}),C("design:type",Boolean)],aa.prototype,"dotNotation",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],aa.prototype,"result",void 0),aa=R([yt("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"}}),I()],aa);let sa=class extends mi{constructor(){super(...arguments),this.field="",this.include="noOtherFields"}execute(e){if(!this.field)throw new ar("Split Out node requires a field name","GRAPH_SPLIT_OUT_FIELD_REQUIRED");const t=Mi(e.inputs.value),o=[];for(const e of t){const t=Fi(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,n=Li(e)?{...e}:{};Hi(n,this.field,!0),Bi(n,r,t,!0),o.push(n)}}return{result:o}}};function da(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(Qi(e))return(Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e)).toString("utf8");if(Li(e)){if("string"==typeof e.data)return da(e.data,t);if("string"==typeof e.content)return da(e.content,t);throw new ar("Extract from File node received an object without file content","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT")}throw new ar("Extract from File node requires a file payload","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT",{valueType:typeof e})}R([w(),bt({handle:"value"}),C("design:type",Object)],sa.prototype,"value",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.field.label",placeholder:"graph.node.data.split_out.fields.field.placeholder",type:"text"}),bt({handle:"field",userControlled:!0}),C("design:type",String)],sa.prototype,"field",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.include.label",type:"select"}),bt({handle:"include",userControlled:!0}),C("design:type",String)],sa.prototype,"include",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.destinationField.label",placeholder:"graph.node.data.split_out.fields.destinationField.placeholder",type:"text"}),bt({handle:"destinationField",userControlled:!0}),C("design:type",String)],sa.prototype,"destinationField",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],sa.prototype,"result",void 0),sa=R([yt("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"}}),I()],sa);let la=class extends mi{constructor(){super(...arguments),this.format="json",this.encoding="utf8",this.delimiter=",",this.headerRow=!0}execute(e){const t=da(e.inputs.value,this.encoding??"utf8");switch(this.format){case"json":try{return{result:JSON.parse(t)}}catch(e){throw new ar("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=[],n="",i=!1;for(let a=0;a<e.length;a++){const s=e[a];i?'"'===s?'"'===e[a+1]?(n+='"',a++):i=!1:n+=s:'"'!==s?s!==t?"\n"!==s?"\r"!==s&&(n+=s):(r.push(n),o.push(r),r=[],n=""):(r.push(n),n=""):i=!0}return(n.length>0||r.length>0)&&(r.push(n),o.push(r)),o.filter(e=>e.length>1||(e[0]??"").trim().length>0)})(e,t);if(0===r.length)return[];const n=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<n.length;o++)t[n[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 ar(`Unsupported file extraction format '${this.format+""}'`,"GRAPH_EXTRACT_FROM_FILE_UNSUPPORTED_FORMAT",{format:this.format})}}};R([w(),bt({handle:"value"}),C("design:type",Object)],la.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.format.label",type:"select"}),bt({handle:"format",userControlled:!0}),C("design:type",String)],la.prototype,"format",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],la.prototype,"encoding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.delimiter.label",type:"text"}),bt({handle:"delimiter",userControlled:!0}),C("design:type",String)],la.prototype,"delimiter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.headerRow.label",type:"checkbox"}),bt({handle:"headerRow",userControlled:!0}),C("design:type",Boolean)],la.prototype,"headerRow",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],la.prototype,"result",void 0),R([wt({handle:"rows"}),C("design:type",Number)],la.prototype,"rows",void 0),la=R([yt("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"}}),I()],la);const ca=new Set(["http:","https:"]);let pa=class extends mi{constructor(){super(...arguments),this.url="",this.method="GET",this.responseFormat="json",this.failOnError=!1}async execute(e,t){if(!this.url)throw new ar("HTTP Request node requires a URL","GRAPH_HTTP_URL_REQUIRED");let o;try{o=new URL(this.url)}catch{throw new ar(`HTTP Request node URL '${this.url}' is invalid`,"GRAPH_HTTP_INVALID_URL",{url:this.url})}if(!ca.has(o.protocol))throw new ar(`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",n={};for(const[e,t]of Object.entries(this.headers??{}))"string"==typeof t&&e.trim().length>0&&(n[e.trim()]=t);const i=this.resolveBody(e,r);void 0!==i&&void 0===n["content-type"]&&(n["content-type"]="application/json");const a=this.resolveTimeoutMs(),s=new AbortController,d=setTimeout(()=>s.abort(),a);d.unref?.();const l=()=>s.abort();t.abortSignal?.addEventListener("abort",l,{once:!0});try{const{response:e,url:t}=await this.fetchFollowingRedirects(o,{method:r,headers:n,body:i,signal:s.signal}),a=await this.readCappedResponseText(e),d=Object.fromEntries(e.headers.entries()),l="text"===this.responseFormat?a:this.parseResponse(a);if(!0===this.failOnError&&!e.ok)throw new ar("HTTP Request node received status "+e.status,"GRAPH_HTTP_REQUEST_FAILED",{status:e.status,url:t.toString()});return{result:l,status:e.status,headers:d}}catch(e){if(e instanceof ar)throw e;if(s.signal.aborted)throw new ar(`HTTP Request node timed out after ${a}ms`,"GRAPH_HTTP_REQUEST_TIMEOUT",{url:o.toString(),timeoutMs:a});throw new ar("HTTP Request node failed: "+(e instanceof Error?e.message:e+""),"GRAPH_HTTP_REQUEST_FAILED",{url:o.toString()})}finally{clearTimeout(d),t.abortSignal?.removeEventListener("abort",l)}}resolveTimeoutMs(){const e=Number(this.timeoutMs);return Number.isFinite(e)&&e>0?Math.min(e,Wo):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 n=t.headers.get("location");if(!n)return{response:t,url:o};if(5===e)throw await this.discardResponseBody(t),new ar("HTTP Request node exceeded the maximum of 5 redirects","GRAPH_HTTP_TOO_MANY_REDIRECTS",{url:o.toString(),maxRedirects:5});let i;try{i=new URL(n,o)}catch{throw await this.discardResponseBody(t),new ar(`HTTP Request node redirect target '${n}' is invalid`,"GRAPH_HTTP_INVALID_URL",{location:n})}if(!ca.has(i.protocol))throw await this.discardResponseBody(t),new ar(`HTTP Request node redirect protocol '${i.protocol}' is not allowed`,"GRAPH_HTTP_PROTOCOL_NOT_ALLOWED",{protocol:i.protocol,url:i.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=i}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:n}=await t.read();if(e)break;if(n){if(r+=n.byteLength,r>Ko){try{await t.cancel()}catch{}throw new ar("HTTP Request node response body exceeds the 10485760-byte limit","GRAPH_HTTP_RESPONSE_TOO_LARGE",{limitBytes:Ko})}o.push(n)}}}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}}};function ua(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(Li(e)){const o=e.data??e.content;if(void 0!==o)return ua(o,t)}if(Qi(e))return Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e);throw new ar("Read PDF node requires a PDF file payload","GRAPH_READ_PDF_INVALID_INPUT",{valueType:typeof e})}R([bt({handle:"value"}),C("design:type",Object)],pa.prototype,"value",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.url.label",placeholder:"graph.node.io.http_request.fields.url.placeholder",type:"text"}),bt({handle:"url",userControlled:!0}),C("design:type",String)],pa.prototype,"url",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.method.label",type:"select"}),bt({handle:"method",userControlled:!0}),C("design:type",String)],pa.prototype,"method",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.headers.label",type:"json"}),bt({handle:"headers",userControlled:!0,type:"object"}),C("design:type",Object)],pa.prototype,"headers",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.query.label",type:"json"}),bt({handle:"query",userControlled:!0,type:"object"}),C("design:type",Object)],pa.prototype,"query",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.body.label",type:"json"}),bt({handle:"body",userControlled:!0,type:"object"}),C("design:type",Object)],pa.prototype,"body",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.responseFormat.label",type:"select"}),bt({handle:"responseFormat",userControlled:!0}),C("design:type",String)],pa.prototype,"responseFormat",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs",userControlled:!0}),C("design:type",Number)],pa.prototype,"timeoutMs",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.failOnError.label",type:"checkbox"}),bt({handle:"failOnError",userControlled:!0}),C("design:type",Boolean)],pa.prototype,"failOnError",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],pa.prototype,"result",void 0),R([wt({handle:"status"}),C("design:type",Number)],pa.prototype,"status",void 0),R([wt({handle:"headers"}),C("design:type",Object)],pa.prototype,"headersOut",void 0),pa=R([yt("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"}}),I()],pa);let ha=class extends mi{constructor(){super(...arguments),this.encoding="utf8"}async execute(e){const t=ua(e.inputs.value,this.encoding??"utf8");let o;try{o=await(import("pdf-parse"))}catch(e){throw new ar("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 ar("Read PDF node could not resolve the PDF parser","GRAPH_READ_PDF_DEPENDENCY_MISSING");const n=new r({data:t,...this.password?{password:this.password}:{}});try{const e=await n.getText(),t=e.text??"",o=(e.pages??[]).map((e,t)=>({pageNumber:t+1,text:e.text??""}));return{result:t,pages:o}}catch(e){throw new ar("Read PDF node failed to extract text: "+(e instanceof Error?e.message:e+""),"GRAPH_READ_PDF_FAILED")}finally{await(n.destroy?.())}}};R([w(),bt({handle:"value"}),C("design:type",Object)],ha.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_pdf.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],ha.prototype,"encoding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_pdf.fields.password.label",placeholder:"graph.node.io.read_pdf.fields.password.placeholder",type:"password"}),bt({handle:"password",userControlled:!0}),C("design:type",String)],ha.prototype,"password",void 0),R([w(),wt({handle:"result"}),C("design:type",String)],ha.prototype,"result",void 0),R([wt({handle:"pages"}),C("design:type",Array)],ha.prototype,"pages",void 0),ha=R([yt("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"}}),I()],ha);const ga=new Set(["workdocs"]);function fa(){return["/etc","/proc","/root",oe(ae(),".ssh")]}function ya(e,t){const o=re(e,t);return""===o||!o.startsWith("..")&&!ie(o)}function ma(e,t,o){if(!ya(e,t))throw new ar(`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 fa())if(ya(e,t))throw new ar(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o});const r=re(e,t).split(ne).filter(Boolean);for(const e of r)if(ga.has(e.toLowerCase()))throw new ar(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o,segment:e})}async function ba(e){let t=e;for(;;)try{return await de(t)}catch{const e=te(t);if(e===t)return;t=e}}let wa=class extends mi{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 ar("Read/Write Files from Disk node requires a path","GRAPH_READ_WRITE_FILE_PATH_REQUIRED");if(this.path.includes("\0"))throw new ar("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=oe(e&&e.length>0?e:process.cwd());try{return se(t)}catch{return t}})();(e=>{if(!ie(e))return;const t=oe(e);for(const o of fa())if(ya(o,t))throw new ar(`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=oe(t,o);return ma(t,r,e),{base:t,candidate:r}})(this.path);if("read"===this.operation){let e;try{e=await de(o)}catch{throw new ar(`Read/Write Files from Disk node path '${this.path}' does not exist`,"GRAPH_READ_WRITE_FILE_INVALID_PATH",{path:this.path})}ma(t,e,this.path);const r=await le(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 ar("Read/Write Files from Disk node requires content to write","GRAPH_READ_WRITE_FILE_CONTENT_REQUIRED");const n="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"),i=await ba(o);i&&ma(t,i,this.path),this.createDirectories&&await ce(te(o),{recursive:!0}),ma(t,await de(te(o)),this.path);const a=await ba(o);return a&&ma(t,a,this.path),this.append?await pe(o,n):await ue(o,n),{result:{path:this.path,bytes:n.byteLength},bytes:n.byteLength}}};R([bt({handle:"value"}),C("design:type",Object)],wa.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],wa.prototype,"operation",void 0),R([w(),i("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"}),bt({handle:"path",userControlled:!0}),C("design:type",String)],wa.prototype,"path",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],wa.prototype,"encoding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.content.label",type:"textarea"}),bt({handle:"content",userControlled:!0}),C("design:type",String)],wa.prototype,"content",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.append.label",type:"checkbox"}),bt({handle:"append",userControlled:!0}),C("design:type",Boolean)],wa.prototype,"append",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.createDirectories.label",type:"checkbox"}),bt({handle:"createDirectories",userControlled:!0}),C("design:type",Boolean)],wa.prototype,"createDirectories",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],wa.prototype,"result",void 0),R([wt({handle:"bytes"}),C("design:type",Number)],wa.prototype,"bytes",void 0),wa=R([yt("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"}}),I()],wa);let va=class extends mi{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 n={statusCode:this.responseCode??200,headers:r,body:o,runId:t.runId,respondedAt:(new Date).toISOString()},i=t.engine?.webhookResponses.deliver(t.runId,n)??!1;return await t.progress({...n,delivered:i}),{response:n,delivered:i}}resolveBody(e){const t=e.inputs.value;switch(this.respondWith){case"noData":return null;case"allIncomingItems":return Mi(t);case"firstIncomingItem":return Mi(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}}};function xa(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:void 0}function Ia(e){return"string"==typeof e&&e.trim().length>0?e.trim():void 0}function Aa(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 _a(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 Oa(e){return Array.isArray(e)?e:void 0}function Ea(e,t){try{const t=xa(e);if(t)return t;const o=xa(JSON.parse(e));if(!o)throw Error("not an object");return o}catch{throw new ar(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}function ka(e,t){if(e){if("string"!=typeof e)return Array.isArray(e)?void 0:e;if(e.trim().startsWith("{"))try{const t=xa(JSON.parse(e));if(!t)throw Error("not an object");return t}catch{throw new ar(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}}function Sa(e,t,o){const r=ka(e,o);return r?Ia(r[t]):"token"===t&&"string"==typeof e?Ia(e):void 0}function Ra(e,t){return Sa(e,"token",t)}function Ca(e,t,o){if("string"==typeof e)return Ia(e);const r=ka(e,o);if(r)for(const e of Array.isArray(t)?t:[t]){const t=Ia(r[e]);if(t)return t}}R([bt({handle:"value"}),C("design:type",Object)],va.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.respondWith.label",type:"select"}),bt({handle:"respondWith",userControlled:!0}),C("design:type",String)],va.prototype,"respondWith",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseCode.label",type:"number"}),bt({handle:"responseCode",userControlled:!0}),C("design:type",Number)],va.prototype,"responseCode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseHeaders.label",type:"json"}),bt({handle:"responseHeaders",userControlled:!0,type:"object"}),C("design:type",Object)],va.prototype,"responseHeaders",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseBody.label",type:"json"}),bt({handle:"responseBody",userControlled:!0,type:"object"}),C("design:type",Object)],va.prototype,"responseBody",void 0),R([w(),wt({handle:"response"}),C("design:type",Object)],va.prototype,"response",void 0),R([wt({handle:"delivered"}),C("design:type",Boolean)],va.prototype,"delivered",void 0),va=R([yt("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"}}),I()],va);const Na={postgres:5432,mysql:3306,mssql:1433};class Ta extends mi{constructor(){super(...arguments),this.ssl=!1,this.acceptSelfSigned=!1}dataSourceOptions(e,t,o,r,n){const i=Aa(this.ssl,!1),a=Aa(this.acceptSelfSigned,!1),s={host:e,port:t,database:o,username:r,password:n,entities:[],synchronize:!1};return"postgres"===this.driver?{...s,type:"postgres",ssl:!!i&&{rejectUnauthorized:!a}}:"mysql"===this.driver?{...s,type:"mysql",ssl:i?{}:void 0}:{...s,type:"mssql",options:{encrypt:i,trustServerCertificate:!i}}}async execute(e,t){const o=this.constructor.name,r=this.sql?.trim();if(!r)throw new ar(o+" node requires a SQL statement","GRAPH_DATABASE_SQL_REQUIRED");const n=this.host?.trim(),i=this.database?.trim(),a=this.username?.trim();if(!n||!i||!a)throw new ar(o+" node requires host, database, and username","GRAPH_DATABASE_CONNECTION_REQUIRED");const s=Ca(await jr(t,e.credentials,this.credentialType,!1,o),["password","secret","token"],o),d=Oa(this.parameters)??(Array.isArray(e.inputs.value)?e.inputs.value:[]),l=`as-graph-${this.driver}-${Date.now()}-${Math.random().toString(36).slice(2)}`,c=new he(this.dataSourceOptions(n,_a(this.port)??Na[this.driver],i,a,s),l),p=new M;try{await c.initialize(p);const e=await c.raw({query:r,values:d},!0,p),{rows:t,rowCount:o}=(e=>{if(Array.isArray(e))return{rows:e,rowCount:e.length};const t=xa(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:_a(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:_a(t.count)??e.length}}return{rows:[],rowCount:_a(t.affectedRows)??0}})(e);return{result:t,rows:t,rowCount:o}}catch(e){if(e instanceof ar)throw e;throw new ar(`${o} node query failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_DATABASE_QUERY_FAILED",{driver:this.driver})}finally{await c.shutdown().catch(()=>{}),V.unregister(l)}}}R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.host.label",type:"string"}),bt({handle:"host",userControlled:!0}),C("design:type",String)],Ta.prototype,"host",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.port.label",type:"number"}),bt({handle:"port",userControlled:!0}),C("design:type",Number)],Ta.prototype,"port",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.database.label",type:"string"}),bt({handle:"database",userControlled:!0}),C("design:type",String)],Ta.prototype,"database",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.username.label",type:"string"}),bt({handle:"username",userControlled:!0}),C("design:type",String)],Ta.prototype,"username",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.ssl.label",type:"boolean"}),bt({handle:"ssl",userControlled:!0}),C("design:type",Boolean)],Ta.prototype,"ssl",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.acceptSelfSigned.label",type:"boolean"}),bt({handle:"acceptSelfSigned",userControlled:!0}),C("design:type",Boolean)],Ta.prototype,"acceptSelfSigned",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sql.label",type:"textarea"}),bt({handle:"sql",userControlled:!0}),C("design:type",String)],Ta.prototype,"sql",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.parameters.label",type:"array"}),bt({handle:"parameters",userControlled:!0}),C("design:type",Array)],Ta.prototype,"parameters",void 0),R([bt({handle:"value"}),C("design:type",Object)],Ta.prototype,"value",void 0),R([w(),wt({handle:"result",type:"array"}),C("design:type",Array)],Ta.prototype,"result",void 0),R([wt({handle:"rows",type:"array"}),C("design:type",Array)],Ta.prototype,"rows",void 0),R([wt({handle:"rowCount",type:"number"}),C("design:type",Number)],Ta.prototype,"rowCount",void 0);let Da=class extends Ta{constructor(){super(...arguments),this.driver="postgres",this.credentialType="postgres"}};Da=R([yt("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"}}),I()],Da);let Pa=class extends Ta{constructor(){super(...arguments),this.driver="mysql",this.credentialType="mysql"}};Pa=R([yt("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"}}),I()],Pa);let ja=class extends Ta{constructor(){super(...arguments),this.driver="mssql",this.credentialType="mssql"}};ja=R([yt("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"}}),I()],ja);const $a=["get","set","delete","incr","keys","llen","lpop","rpop","lpush","rpush","publish","info"];function La(e){if(null===e)return null;try{return JSON.parse(e)}catch{return e}}function Ma(e){return"string"==typeof e?e:null==e?"":JSON.stringify(e)}let Ga=class extends mi{constructor(){super(...arguments),this.operation="get",this.tls=!1}async execute(e,t){const o=$a.includes(this.operation)?this.operation:"get",r=Ca(await jr(t,e.credentials,"redis",!1,"Redis"),["password","secret","token"],"Redis"),n=Ia(this.host)??"localhost",i=_a(this.port)??6379,a=Ia(this.key),s=Ia(this.prefix),d=e=>s?`${s}:${e}`:e,l=Ia(this.pattern),c=Ia(this.channel),p=this.value??e.inputs.value;if(!("info"===o||a||"keys"===o&&l||"publish"===o&&c))throw new ar(`Redis node operation '${o}' requires a key`,"GRAPH_REDIS_KEY_REQUIRED",{operation:o});const u=`as-graph-redis-${Date.now()}-${Math.random().toString(36).slice(2)}`,h=new ge({host:n,port:i,username:Ia(this.username),password:r,database:_a(this.database),tls:!!this.tls||void 0},u);try{await h.initialize();const e=h.client;switch(o){case"get":return{result:La(await e.get(d(a)))};case"set":{const t=_a(this.ttlSeconds);return{result:await e.set(d(a),Ma(p),t&&t>0?{EX:Math.floor(t)}:void 0)}}case"delete":{const t=await e.del(d(a));return{result:t,count:t}}case"incr":{const t=await e.incr(d(a));return{result:t,count:t}}case"keys":{const t=await e.keys(d(l??a??"*"));return{result:t,count:t.length}}case"llen":{const t=await e.lLen(d(a));return{result:t,count:t}}case"lpop":return{result:La(await e.lPop(d(a)))};case"rpop":return{result:La(await e.rPop(d(a)))};case"lpush":{const t=await e.lPush(d(a),Ma(p));return{result:t,count:t}}case"rpush":{const t=await e.rPush(d(a),Ma(p));return{result:t,count:t}}case"publish":{const t=await e.publish(c??a,Ma(p));return{result:t,count:t}}default:return{result:await e.info(Ia(this.section))}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Redis node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_REDIS_OPERATION_FAILED",{operation:o})}finally{await h.shutdown().catch(()=>{}),V.unregister(u)}}};R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Ga.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.host.label",type:"string"}),bt({handle:"host",userControlled:!0}),C("design:type",String)],Ga.prototype,"host",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.port.label",type:"number"}),bt({handle:"port",userControlled:!0}),C("design:type",Number)],Ga.prototype,"port",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.username.label",type:"string"}),bt({handle:"username",userControlled:!0}),C("design:type",String)],Ga.prototype,"username",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.database.label",type:"number"}),bt({handle:"database",userControlled:!0}),C("design:type",Number)],Ga.prototype,"database",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.tls.label",type:"boolean"}),bt({handle:"tls",userControlled:!0}),C("design:type",Boolean)],Ga.prototype,"tls",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.prefix.label",type:"string"}),bt({handle:"prefix",userControlled:!0}),C("design:type",String)],Ga.prototype,"prefix",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.key.label",type:"string"}),bt({handle:"key",userControlled:!0}),C("design:type",String)],Ga.prototype,"key",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.value.label",type:"textarea"}),bt({handle:"value",userControlled:!0}),C("design:type",Object)],Ga.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.ttlSeconds.label",type:"number"}),bt({handle:"ttlSeconds",userControlled:!0}),C("design:type",Number)],Ga.prototype,"ttlSeconds",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.pattern.label",type:"string"}),bt({handle:"pattern",userControlled:!0}),C("design:type",String)],Ga.prototype,"pattern",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.channel.label",type:"string"}),bt({handle:"channel",userControlled:!0}),C("design:type",String)],Ga.prototype,"channel",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.section.label",type:"string"}),bt({handle:"section",userControlled:!0}),C("design:type",String)],Ga.prototype,"section",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Ga.prototype,"result",void 0),R([wt({handle:"value"}),C("design:type",Object)],Ga.prototype,"valueOutput",void 0),R([wt({handle:"count",type:"number"}),C("design:type",Number)],Ga.prototype,"count",void 0),Ga=R([yt("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"}}),I()],Ga);const Ua=["put","get","delete","list","stat","has","url","copy"];class Fa extends mi{constructor(){super(...arguments),this.operation="get",this.encoding="utf8",this.urlOperation="get"}async execute(e,t){const o=this.constructor.name,r=Ua.includes(this.operation)?this.operation:"get",n=Ia(this.key);if("list"!==r&&!n)throw new ar(`${o} node operation '${r}' requires a key`,"GRAPH_BLOB_KEY_REQUIRED",{operation:r});const i=await jr(t,e.credentials,this.credentialType,!1,o),a=await this.createService(i);try{switch(r){case"put":{const t=this.content??e.inputs.value,r=xa(this.metadataValues),i=await a.put(n,((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 ar(o+" node cannot encode the blob payload","GRAPH_BLOB_INVALID_PAYLOAD")}})(t,this.encoding,o),{contentType:Ia(this.contentType),metadata:r?Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t+""])):void 0});return{result:i}}case"get":{const e=await a.get(n),t=await fe(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 a.delete(n),{result:{key:n,deleted:!0}};case"list":{const e=_a(this.limit);return{result:await a.list({prefix:Ia(this.prefix),limit:void 0===e?void 0:Math.max(0,Math.floor(e)),cursor:Ia(this.cursor)})}}case"stat":return{result:await a.stat(n)};case"has":return{result:await a.has(n)};case"url":{const e=_a(this.expiresInSeconds);return{result:await a.url(n,{operation:this.urlOperation,expiresInSeconds:void 0===e?void 0:Math.max(0,Math.floor(e)),contentType:Ia(this.contentType)})}}case"copy":{const e=Ia(this.targetKey);if(!e)throw new ar(o+" node copy operation requires a targetKey","GRAPH_BLOB_TARGET_KEY_REQUIRED");return{result:await a.copy(n,e,{contentType:Ia(this.contentType)})}}default:throw new ar(`${o} node operation '${r}' is not supported`,"GRAPH_BLOB_OPERATION_NOT_SUPPORTED",{operation:r})}}catch(e){if(e instanceof ar)throw e;throw new ar(`${o} node operation '${r}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_BLOB_OPERATION_FAILED",{operation:r})}finally{await a.shutdown().catch(()=>{})}}}R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Fa.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.key.label",type:"string"}),bt({handle:"key",userControlled:!0}),C("design:type",String)],Fa.prototype,"key",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.targetKey.label",type:"string"}),bt({handle:"targetKey",userControlled:!0}),C("design:type",String)],Fa.prototype,"targetKey",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.content.label",type:"textarea"}),bt({handle:"content",userControlled:!0}),C("design:type",Object)],Fa.prototype,"content",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.contentType.label",type:"string"}),bt({handle:"contentType",userControlled:!0}),C("design:type",String)],Fa.prototype,"contentType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],Fa.prototype,"encoding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.metadataValues.label",type:"object"}),bt({handle:"metadataValues",userControlled:!0}),C("design:type",Object)],Fa.prototype,"metadataValues",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.prefix.label",type:"string"}),bt({handle:"prefix",userControlled:!0}),C("design:type",String)],Fa.prototype,"prefix",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.cursor.label",type:"string"}),bt({handle:"cursor",userControlled:!0}),C("design:type",String)],Fa.prototype,"cursor",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Fa.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.urlOperation.label",type:"select"}),bt({handle:"urlOperation",userControlled:!0}),C("design:type",String)],Fa.prototype,"urlOperation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.expiresInSeconds.label",type:"number"}),bt({handle:"expiresInSeconds",userControlled:!0}),C("design:type",Number)],Fa.prototype,"expiresInSeconds",void 0),R([bt({handle:"value"}),C("design:type",Object)],Fa.prototype,"value",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Fa.prototype,"result",void 0),R([wt({handle:"value"}),C("design:type",String)],Fa.prototype,"valueOutput",void 0),R([wt({handle:"contentLength",type:"number"}),C("design:type",Number)],Fa.prototype,"contentLength",void 0),R([wt({handle:"contentType"}),C("design:type",String)],Fa.prototype,"contentTypeOutput",void 0);class Ba extends Fa{constructor(){super(...arguments),this.credentialType="s3",this.forcePathStyle=!1}async createService(e){const t=Ia(this.bucket);if(!t)throw new ar("S3 node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o=new ye;return await me(o,((e,t)=>{const o=e?Ea(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:Ia(o.sessionToken)}:void 0}})(e,{bucket:t,sourceId:Ia(this.sourceId)??"graph",region:Ia(this.region),endpoint:Ia(this.endpoint),prefix:Ia(this.prefix),forcePathStyle:this.forcePathStyle})),o}}R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),bt({handle:"bucket",userControlled:!0}),C("design:type",String)],Ba.prototype,"bucket",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),bt({handle:"sourceId",userControlled:!0}),C("design:type",String)],Ba.prototype,"sourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.region.label",type:"string"}),bt({handle:"region",userControlled:!0}),C("design:type",String)],Ba.prototype,"region",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.endpoint.label",type:"string"}),bt({handle:"endpoint",userControlled:!0}),C("design:type",String)],Ba.prototype,"endpoint",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.forcePathStyle.label",type:"boolean"}),bt({handle:"forcePathStyle",userControlled:!0}),C("design:type",Boolean)],Ba.prototype,"forcePathStyle",void 0);let Ha=class extends Ba{};Ha=R([yt("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"}}),I()],Ha);let qa=class extends Ba{};qa=R([yt("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"}}),I()],qa);let Wa=class extends Fa{constructor(){super(...arguments),this.credentialType="gcs"}async createService(e){const t=Ia(this.bucket);if(!t)throw new ar("Google Cloud Storage node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o={provider:"gcs",bucket:t,sourceId:Ia(this.sourceId)??"graph",projectId:Ia(this.projectId),apiEndpoint:Ia(this.apiEndpoint),prefix:Ia(this.prefix),credentials:e?Ea(e,"Google Cloud Storage"):void 0},r=new be;return await me(r,o),r}};function Ka(e){if(!e)return;if("string"!=typeof e)return Ia(e.connectionString);const t=e.trim();return t.startsWith("{")?Ia(Ea(t,"Azure Storage").connectionString):t}R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),bt({handle:"bucket",userControlled:!0}),C("design:type",String)],Wa.prototype,"bucket",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),bt({handle:"sourceId",userControlled:!0}),C("design:type",String)],Wa.prototype,"sourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.projectId.label",type:"string"}),bt({handle:"projectId",userControlled:!0}),C("design:type",String)],Wa.prototype,"projectId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.apiEndpoint.label",type:"string"}),bt({handle:"apiEndpoint",userControlled:!0}),C("design:type",String)],Wa.prototype,"apiEndpoint",void 0),Wa=R([yt("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"}}),I()],Wa);let Va=class extends Fa{constructor(){super(...arguments),this.credentialType="azure-blob"}async createService(e){const t=Ia(this.container);if(!t)throw new ar("Azure Storage node requires a container","GRAPH_BLOB_CONTAINER_REQUIRED");const o={provider:"azure-blob",container:t,sourceId:Ia(this.sourceId)??"graph",accountName:Ia(this.accountName),endpoint:Ia(this.endpoint),prefix:Ia(this.prefix),connectionString:Ka(e)},r=new we;return await me(r,o),r}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.container.label",type:"string"}),bt({handle:"container",userControlled:!0}),C("design:type",String)],Va.prototype,"container",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),bt({handle:"sourceId",userControlled:!0}),C("design:type",String)],Va.prototype,"sourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.accountName.label",type:"string"}),bt({handle:"accountName",userControlled:!0}),C("design:type",String)],Va.prototype,"accountName",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.endpoint.label",type:"string"}),bt({handle:"endpoint",userControlled:!0}),C("design:type",String)],Va.prototype,"endpoint",void 0),Va=R([yt("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"}}),I()],Va);const za=["postMessage","listConversations","getConversation","getUser"];let Qa=class extends mi{constructor(){super(...arguments),this.operation="postMessage"}async execute(e,t){const o=za.includes(this.operation)?this.operation:"postMessage";if(!this.operation)throw new ar("Slack node requires an operation","GRAPH_SLACK_OPERATION_REQUIRED");const r=Ra(await jr(t,e.credentials,"slack",!1,"Slack"),"Slack"),n=new ve;try{switch(await me(n,{token:r,baseUrl:this.baseUrl}),o){case"postMessage":{const t=this.channel,o=this.text??(e.inputs.value??"")+"";if(!t||!o)throw new ar("Slack postMessage requires a channel and text","GRAPH_SLACK_MESSAGE_REQUIRED");const r=await n.postMessage({channel:t,text:o,blocks:Oa(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 n.listConversations({limit:_a(this.limit),cursor:this.cursor,types:this.types,excludeArchived:this.excludeArchived})};case"getConversation":{if(!this.channel)throw new ar("Slack getConversation requires a channel","GRAPH_SLACK_CHANNEL_REQUIRED");const e=await n.getConversation(this.channel);return{result:e,channel:e.id}}default:if(!this.userId)throw new ar("Slack getUser requires a user ID","GRAPH_SLACK_USER_REQUIRED");return{result:await n.getUser(this.userId)}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Slack node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SLACK_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Qa.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.channel.label",type:"string"}),bt({handle:"channel",userControlled:!0}),C("design:type",String)],Qa.prototype,"channel",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],Qa.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.blocks.label",type:"json"}),bt({handle:"blocks",userControlled:!0}),C("design:type",Array)],Qa.prototype,"blocks",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.threadTs.label",type:"string"}),bt({handle:"threadTs",userControlled:!0}),C("design:type",String)],Qa.prototype,"threadTs",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Qa.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.cursor.label",type:"string"}),bt({handle:"cursor",userControlled:!0}),C("design:type",String)],Qa.prototype,"cursor",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.types.label",type:"string"}),bt({handle:"types",userControlled:!0}),C("design:type",String)],Qa.prototype,"types",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.userId.label",type:"string"}),bt({handle:"userId",userControlled:!0}),C("design:type",String)],Qa.prototype,"userId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Qa.prototype,"baseUrl",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.excludeArchived.label",type:"boolean"}),bt({handle:"excludeArchived",userControlled:!0}),C("design:type",Boolean)],Qa.prototype,"excludeArchived",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.replyBroadcast.label",type:"boolean"}),bt({handle:"replyBroadcast",userControlled:!0}),C("design:type",Boolean)],Qa.prototype,"replyBroadcast",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.unfurlLinks.label",type:"boolean"}),bt({handle:"unfurlLinks",userControlled:!0}),C("design:type",Boolean)],Qa.prototype,"unfurlLinks",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.unfurlMedia.label",type:"boolean"}),bt({handle:"unfurlMedia",userControlled:!0}),C("design:type",Boolean)],Qa.prototype,"unfurlMedia",void 0),R([wt({handle:"result"}),C("design:type",Object)],Qa.prototype,"result",void 0),R([wt({handle:"channel",type:"string"}),C("design:type",String)],Qa.prototype,"resultChannel",void 0),R([wt({handle:"ts",type:"string"}),C("design:type",String)],Qa.prototype,"resultTs",void 0),Qa=R([yt("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"}}),I()],Qa);const Ja=["sendMessage","getMe","getUpdates","sendChatAction"];let Xa=class extends mi{constructor(){super(...arguments),this.operation="sendMessage"}async execute(e,t){if(!this.operation)throw new ar("Telegram node requires an operation","GRAPH_TELEGRAM_OPERATION_REQUIRED");const o=Ja.includes(this.operation)?this.operation:"sendMessage",r=Ra(await jr(t,e.credentials,"telegram",!1,"Telegram"),"Telegram"),n=new xe;try{switch(await me(n,{token:r,baseUrl:this.baseUrl}),o){case"sendMessage":{const t=this.chatId,o=this.text??(e.inputs.value??"")+"";if(null==t||!o)throw new ar("Telegram sendMessage requires a chat ID and text","GRAPH_TELEGRAM_MESSAGE_REQUIRED");const r=await n.sendMessage({chatId:t,text:o,parseMode:this.parseMode,disableNotification:this.disableNotification,disablePreview:this.disablePreview,replyToMessageId:_a(this.replyToMessageId),messageThreadId:_a(this.messageThreadId)});return{result:r,messageId:_a(r?.message_id)}}case"getMe":return{result:await n.getMe()};case"getUpdates":return{result:await n.getUpdates({offset:_a(this.offset),limit:_a(this.limit),timeoutSeconds:_a(this.timeoutSeconds)})};default:if(void 0===this.chatId||null===this.chatId)throw new ar("Telegram sendChatAction requires a chat ID","GRAPH_TELEGRAM_CHAT_REQUIRED");return{result:await n.sendChatAction(this.chatId,this.action??"typing")}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Telegram node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TELEGRAM_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Xa.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.chatId.label",type:"string"}),bt({handle:"chatId",userControlled:!0}),C("design:type",Object)],Xa.prototype,"chatId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],Xa.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.parseMode.label",type:"select"}),bt({handle:"parseMode",userControlled:!0}),C("design:type",String)],Xa.prototype,"parseMode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.disableNotification.label",type:"boolean"}),bt({handle:"disableNotification",userControlled:!0}),C("design:type",Boolean)],Xa.prototype,"disableNotification",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.disablePreview.label",type:"boolean"}),bt({handle:"disablePreview",userControlled:!0}),C("design:type",Boolean)],Xa.prototype,"disablePreview",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.replyToMessageId.label",type:"number"}),bt({handle:"replyToMessageId",userControlled:!0}),C("design:type",Number)],Xa.prototype,"replyToMessageId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.messageThreadId.label",type:"number"}),bt({handle:"messageThreadId",userControlled:!0}),C("design:type",Number)],Xa.prototype,"messageThreadId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.offset.label",type:"number"}),bt({handle:"offset",userControlled:!0}),C("design:type",Number)],Xa.prototype,"offset",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Xa.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.timeoutSeconds.label",type:"number"}),bt({handle:"timeoutSeconds",userControlled:!0}),C("design:type",Number)],Xa.prototype,"timeoutSeconds",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.action.label",type:"string"}),bt({handle:"action",userControlled:!0}),C("design:type",String)],Xa.prototype,"action",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Xa.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],Xa.prototype,"result",void 0),R([wt({handle:"messageId",type:"number"}),C("design:type",Number)],Xa.prototype,"messageId",void 0),Xa=R([yt("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"}}),I()],Xa);const Ya=["sendWebhook","sendChannelMessage","listTeams","listChannels"];let Za=class extends mi{constructor(){super(...arguments),this.operation="sendWebhook"}async execute(e,t){if(!this.operation)throw new ar("Microsoft Teams node requires an operation","GRAPH_TEAMS_OPERATION_REQUIRED");const o=Ya.includes(this.operation)?this.operation:"sendWebhook",r=await jr(t,e.credentials,"teams",!1,"Microsoft Teams"),n=new Ie;try{switch(await me(n,{token:Sa(r,"token","Microsoft Teams"),webhookUrl:Sa(r,"webhookUrl","Microsoft Teams"),baseUrl:this.baseUrl}),o){case"sendWebhook":{const t=this.text??(e.inputs.value??"")+"";if(!t)throw new ar("Microsoft Teams sendWebhook requires text","GRAPH_TEAMS_TEXT_REQUIRED");return{result:await n.sendWebhook({text:t,title:this.title,markdown:this.markdown})}}case"sendChannelMessage":if(!this.teamId||!this.channelId||!this.content)throw new ar("Microsoft Teams sendChannelMessage requires teamId, channelId, and content","GRAPH_TEAMS_CHANNEL_MESSAGE_REQUIRED");return{result:await n.sendChannelMessage({teamId:this.teamId,channelId:this.channelId,content:this.content,contentType:this.contentType})};case"listTeams":return{result:await n.listTeams(_a(this.limit))};default:if(!this.teamId)throw new ar("Microsoft Teams listChannels requires a teamId","GRAPH_TEAMS_TEAM_REQUIRED");return{result:await n.listChannels(this.teamId)}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Microsoft Teams node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TEAMS_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Za.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],Za.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.title.label",type:"string"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],Za.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.markdown.label",type:"boolean"}),bt({handle:"markdown",userControlled:!0}),C("design:type",Boolean)],Za.prototype,"markdown",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.teamId.label",type:"string"}),bt({handle:"teamId",userControlled:!0}),C("design:type",String)],Za.prototype,"teamId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.channelId.label",type:"string"}),bt({handle:"channelId",userControlled:!0}),C("design:type",String)],Za.prototype,"channelId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.content.label",type:"textarea"}),bt({handle:"content",userControlled:!0}),C("design:type",String)],Za.prototype,"content",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.contentType.label",type:"select"}),bt({handle:"contentType",userControlled:!0}),C("design:type",String)],Za.prototype,"contentType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Za.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Za.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],Za.prototype,"result",void 0),Za=R([yt("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"}}),I()],Za);const es=["send","list","get","labels"];let ts=class extends mi{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new ar("Gmail node requires an operation","GRAPH_GMAIL_OPERATION_REQUIRED");const o=es.includes(this.operation)?this.operation:"send",r=await jr(t,e.credentials,"gmail",!1,"Gmail"),n=new Ae;try{switch(await me(n,{token:Ra(r,"Gmail"),userId:this.userId??Sa(r,"userId","Gmail"),baseUrl:this.baseUrl}),o){case"send":{const t=this.from??Sa(r,"from","Gmail");if(!t||!this.to||!this.subject)throw new ar("Gmail send requires from, to, and subject","GRAPH_GMAIL_MESSAGE_REQUIRED");const o=await n.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 n.listMessages({query:this.query,maxResults:_a(this.maxResults),pageToken:this.pageToken,labelIds:Oa(this.labelIds)?.map(String)})};case"get":if(!this.messageId)throw new ar("Gmail get requires a message ID","GRAPH_GMAIL_MESSAGE_ID_REQUIRED");return{result:await n.getMessage(this.messageId,this.format??"full")};default:return{result:await n.listLabels()}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Gmail node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GMAIL_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],ts.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.userId.label",type:"string"}),bt({handle:"userId",userControlled:!0}),C("design:type",String)],ts.prototype,"userId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.from.label",type:"string"}),bt({handle:"from",userControlled:!0}),C("design:type",String)],ts.prototype,"from",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.to.label",type:"string"}),bt({handle:"to",userControlled:!0}),C("design:type",Object)],ts.prototype,"to",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.cc.label",type:"string"}),bt({handle:"cc",userControlled:!0}),C("design:type",Object)],ts.prototype,"cc",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.bcc.label",type:"string"}),bt({handle:"bcc",userControlled:!0}),C("design:type",Object)],ts.prototype,"bcc",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.subject.label",type:"string"}),bt({handle:"subject",userControlled:!0}),C("design:type",String)],ts.prototype,"subject",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],ts.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.html.label",type:"textarea"}),bt({handle:"html",userControlled:!0}),C("design:type",String)],ts.prototype,"html",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.replyTo.label",type:"string"}),bt({handle:"replyTo",userControlled:!0}),C("design:type",String)],ts.prototype,"replyTo",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.query.label",type:"string"}),bt({handle:"query",userControlled:!0}),C("design:type",String)],ts.prototype,"query",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.maxResults.label",type:"number"}),bt({handle:"maxResults",userControlled:!0}),C("design:type",Number)],ts.prototype,"maxResults",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.pageToken.label",type:"string"}),bt({handle:"pageToken",userControlled:!0}),C("design:type",String)],ts.prototype,"pageToken",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.labelIds.label",type:"json"}),bt({handle:"labelIds",userControlled:!0}),C("design:type",Array)],ts.prototype,"labelIds",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.messageId.label",type:"string"}),bt({handle:"messageId",userControlled:!0}),C("design:type",String)],ts.prototype,"messageId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.format.label",type:"select"}),bt({handle:"format",userControlled:!0}),C("design:type",String)],ts.prototype,"format",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],ts.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],ts.prototype,"result",void 0),R([wt({handle:"id",type:"string"}),C("design:type",String)],ts.prototype,"id",void 0),ts=R([yt("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"}}),I()],ts);const os=["send","listInbox","listImap"];let rs=class extends mi{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new ar("Email Send node requires an operation","GRAPH_EMAIL_OPERATION_REQUIRED");const o=os.includes(this.operation)?this.operation:"send",r=await jr(t,e.credentials,"email",!1,"Email"),n=ka(r,"Email"),i=r&&!n?r:void 0,a=new _e;try{switch(await me(a,{provider:this.provider??n?.provider,host:this.host??this.asCredentialString(n,"host"),port:_a(this.port)??_a(n?.port),secure:this.secure??Aa(n?.secure,!1),username:this.username??this.asCredentialString(n,"username"),password:this.asCredentialString(n,"password"),from:this.from??this.asCredentialString(n,"from"),token:i??this.asCredentialString(n,"token"),graphBaseUrl:this.graphBaseUrl??this.asCredentialString(n,"graphBaseUrl"),baseUrl:this.baseUrl}),o){case"send":{if(!this.to||!this.subject)throw new ar("Email Send send requires to and subject","GRAPH_EMAIL_MESSAGE_REQUIRED");const t=await a.send({from:this.from??this.asCredentialString(n,"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 a.listInbox({mailbox:this.mailbox,limit:_a(this.limit),since:this.since,subject:this.subjectFilter})};default:return{result:await a.listImapMessages({mailbox:this.mailbox,limit:_a(this.limit),since:this.since,subject:this.subjectFilter})}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Email node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_EMAIL_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}asCredentialString(e,t){const o=e?.[t];return"string"==typeof o&&o.trim().length>0?o.trim():void 0}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],rs.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.provider.label",type:"select"}),bt({handle:"provider",userControlled:!0}),C("design:type",String)],rs.prototype,"provider",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.host.label",type:"string"}),bt({handle:"host",userControlled:!0}),C("design:type",String)],rs.prototype,"host",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.port.label",type:"number"}),bt({handle:"port",userControlled:!0}),C("design:type",Number)],rs.prototype,"port",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.secure.label",type:"boolean"}),bt({handle:"secure",userControlled:!0}),C("design:type",Boolean)],rs.prototype,"secure",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.username.label",type:"string"}),bt({handle:"username",userControlled:!0}),C("design:type",String)],rs.prototype,"username",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.from.label",type:"string"}),bt({handle:"from",userControlled:!0}),C("design:type",String)],rs.prototype,"from",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.to.label",type:"string"}),bt({handle:"to",userControlled:!0}),C("design:type",Object)],rs.prototype,"to",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.cc.label",type:"string"}),bt({handle:"cc",userControlled:!0}),C("design:type",Object)],rs.prototype,"cc",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.bcc.label",type:"string"}),bt({handle:"bcc",userControlled:!0}),C("design:type",Object)],rs.prototype,"bcc",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.subject.label",type:"string"}),bt({handle:"subject",userControlled:!0}),C("design:type",String)],rs.prototype,"subject",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],rs.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.html.label",type:"textarea"}),bt({handle:"html",userControlled:!0}),C("design:type",String)],rs.prototype,"html",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.replyTo.label",type:"string"}),bt({handle:"replyTo",userControlled:!0}),C("design:type",String)],rs.prototype,"replyTo",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.mailbox.label",type:"string"}),bt({handle:"mailbox",userControlled:!0}),C("design:type",String)],rs.prototype,"mailbox",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],rs.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.since.label",type:"string"}),bt({handle:"since",userControlled:!0}),C("design:type",String)],rs.prototype,"since",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.subjectFilter.label",type:"string"}),bt({handle:"subjectFilter",userControlled:!0}),C("design:type",String)],rs.prototype,"subjectFilter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.graphBaseUrl.label",type:"string"}),bt({handle:"graphBaseUrl",userControlled:!0}),C("design:type",String)],rs.prototype,"graphBaseUrl",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],rs.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],rs.prototype,"result",void 0),R([wt({handle:"messageId",type:"string"}),C("design:type",String)],rs.prototype,"messageId",void 0),rs=R([yt("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"}}),I()],rs);const ns=["get","update","append","clear","create"];let is=class extends mi{constructor(){super(...arguments),this.operation="get"}async execute(e,t){if(!this.operation)throw new ar("Google Sheets node requires an operation","GRAPH_GOOGLE_SHEETS_OPERATION_REQUIRED");const o=ns.includes(this.operation)?this.operation:"get",r=await jr(t,e.credentials,"google-sheets",!1,"Google Sheets"),n=new Oe;try{switch(await me(n,{token:Sa(r,"token","Google Sheets"),apiKey:Sa(r,"apiKey","Google Sheets"),baseUrl:this.baseUrl}),o){case"get":{const e=await n.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 n.updateValues(t):await n.appendValues(t);return{result:r,values:r.values,spreadsheetId:r.spreadsheetId,range:r.range}}case"clear":{const e=await n.clearValues(this.requireSpreadsheet(),this.requireRange());return{result:e,spreadsheetId:e.spreadsheetId,range:e.clearedRange}}default:{if(!this.title)throw new ar("Google Sheets create requires a title","GRAPH_GOOGLE_SHEETS_TITLE_REQUIRED");const e=await n.createSpreadsheet(this.title);return{result:e,spreadsheetId:e.spreadsheetId}}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Google Sheets node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GOOGLE_SHEETS_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}requireSpreadsheet(){if(!this.spreadsheetId)throw new ar("Google Sheets node requires a spreadsheet ID","GRAPH_GOOGLE_SHEETS_SPREADSHEET_REQUIRED");return this.spreadsheetId}requireRange(){if(!this.range)throw new ar("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 ar("Google Sheets node requires values as an array of rows","GRAPH_GOOGLE_SHEETS_VALUES_REQUIRED");return this.values}};R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],is.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.spreadsheetId.label",type:"string"}),bt({handle:"spreadsheetId",userControlled:!0}),C("design:type",String)],is.prototype,"spreadsheetId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.range.label",type:"string"}),bt({handle:"range",userControlled:!0}),C("design:type",String)],is.prototype,"range",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.values.label",type:"json"}),bt({handle:"values",userControlled:!0}),C("design:type",Array)],is.prototype,"values",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.valueInputOption.label",type:"select"}),bt({handle:"valueInputOption",userControlled:!0}),C("design:type",String)],is.prototype,"valueInputOption",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.title.label",type:"string"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],is.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],is.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],is.prototype,"result",void 0),R([wt({handle:"values",type:"array"}),C("design:type",Array)],is.prototype,"outputValues",void 0),R([wt({handle:"spreadsheetId",type:"string"}),C("design:type",String)],is.prototype,"outputSpreadsheetId",void 0),R([wt({handle:"range",type:"string"}),C("design:type",String)],is.prototype,"outputRange",void 0),is=R([yt("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"}}),I()],is);const as=["list","get","create","update","delete"];let ss=class extends mi{constructor(){super(...arguments),this.operation="list"}async execute(e,t){if(!this.operation)throw new ar("Airtable node requires an operation","GRAPH_AIRTABLE_OPERATION_REQUIRED");const o=as.includes(this.operation)?this.operation:"list",r=await jr(t,e.credentials,"airtable",!1,"Airtable"),n=new Ee;try{switch(await me(n,{token:Sa(r,"token","Airtable"),baseId:this.baseId??Sa(r,"baseId","Airtable"),baseUrl:this.baseUrl}),o){case"list":{const e=await n.listRecords({table:this.requireTable(),view:this.view,filterByFormula:this.filterByFormula,maxRecords:_a(this.maxRecords),pageSize:_a(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 n.getRecord(this.requireTable(),this.requireRecordId());return{result:e,records:[e]}}case"create":{const e=await n.createRecord({table:this.requireTable(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}case"update":{const e=await n.updateRecord({table:this.requireTable(),recordId:this.requireRecordId(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}default:return{result:await n.deleteRecord(this.requireTable(),this.requireRecordId())}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Airtable node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_AIRTABLE_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}requireTable(){if(!this.table)throw new ar("Airtable node requires a table","GRAPH_AIRTABLE_TABLE_REQUIRED");return this.table}requireRecordId(){if(!this.recordId)throw new ar("Airtable node requires a record ID","GRAPH_AIRTABLE_RECORD_REQUIRED");return this.recordId}requireRecordFields(){const e=xa(this.recordFields);if(!e)throw new ar("Airtable node requires recordFields as an object","GRAPH_AIRTABLE_FIELDS_REQUIRED");return e}};R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],ss.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.baseId.label",type:"string"}),bt({handle:"baseId",userControlled:!0}),C("design:type",String)],ss.prototype,"baseId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.table.label",type:"string"}),bt({handle:"table",userControlled:!0}),C("design:type",String)],ss.prototype,"table",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.recordId.label",type:"string"}),bt({handle:"recordId",userControlled:!0}),C("design:type",String)],ss.prototype,"recordId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.recordFields.label",type:"json"}),bt({handle:"recordFields",userControlled:!0}),C("design:type",Object)],ss.prototype,"recordFields",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.typecast.label",type:"boolean"}),bt({handle:"typecast",userControlled:!0}),C("design:type",Boolean)],ss.prototype,"typecast",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.view.label",type:"string"}),bt({handle:"view",userControlled:!0}),C("design:type",String)],ss.prototype,"view",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.filterByFormula.label",type:"string"}),bt({handle:"filterByFormula",userControlled:!0}),C("design:type",String)],ss.prototype,"filterByFormula",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.fields.label",type:"json"}),bt({handle:"fields",userControlled:!0}),C("design:type",Array)],ss.prototype,"fields",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.sortField.label",type:"string"}),bt({handle:"sortField",userControlled:!0}),C("design:type",String)],ss.prototype,"sortField",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.sortDirection.label",type:"select"}),bt({handle:"sortDirection",userControlled:!0}),C("design:type",String)],ss.prototype,"sortDirection",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.maxRecords.label",type:"number"}),bt({handle:"maxRecords",userControlled:!0}),C("design:type",Number)],ss.prototype,"maxRecords",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.pageSize.label",type:"number"}),bt({handle:"pageSize",userControlled:!0}),C("design:type",Number)],ss.prototype,"pageSize",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.offset.label",type:"string"}),bt({handle:"offset",userControlled:!0}),C("design:type",String)],ss.prototype,"offset",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],ss.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],ss.prototype,"result",void 0),R([wt({handle:"records",type:"array"}),C("design:type",Array)],ss.prototype,"records",void 0),R([wt({handle:"offset",type:"string"}),C("design:type",String)],ss.prototype,"nextOffset",void 0),ss=R([yt("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"}}),I()],ss);const ds=["parse","write"];let ls=class extends mi{constructor(){super(...arguments),this.spreadsheets=new ke,this.operation="parse"}async execute(e){const t=ds.includes(this.operation)?this.operation:"parse";try{if("parse"===t){const t=this.content??e.inputs.value;if("string"!=typeof t)throw new ar("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 ar("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:Oa(this.header)?.map(String)});return{result:r,content:r}}catch(e){if(e instanceof ar)throw e;throw new ar(`Spreadsheet File node operation '${t}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SPREADSHEET_OPERATION_FAILED",{operation:t})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],ls.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.format.label",type:"select"}),bt({handle:"format",userControlled:!0}),C("design:type",String)],ls.prototype,"format",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.delimiter.label",type:"string"}),bt({handle:"delimiter",userControlled:!0}),C("design:type",String)],ls.prototype,"delimiter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.content.label",type:"textarea"}),bt({handle:"content",userControlled:!0}),C("design:type",String)],ls.prototype,"content",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.rows.label",type:"json"}),bt({handle:"rows",userControlled:!0}),C("design:type",Array)],ls.prototype,"rows",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.header.label",type:"json"}),bt({handle:"header",userControlled:!0}),C("design:type",Array)],ls.prototype,"header",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.hasHeader.label",type:"boolean"}),bt({handle:"hasHeader",userControlled:!0}),C("design:type",Boolean)],ls.prototype,"hasHeader",void 0),R([wt({handle:"result"}),C("design:type",Object)],ls.prototype,"result",void 0),R([wt({handle:"content",type:"string"}),C("design:type",String)],ls.prototype,"outputContent",void 0),R([wt({handle:"rows",type:"array"}),C("design:type",Array)],ls.prototype,"outputRows",void 0),R([wt({handle:"header",type:"array"}),C("design:type",Array)],ls.prototype,"outputHeader",void 0),ls=R([yt("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"}}),I()],ls);const cs=["query","mutation"];let ps=class extends mi{constructor(){super(...arguments),this.operation="query"}async execute(e,t){if(!this.operation)throw new ar("GraphQL node requires an operation","GRAPH_GRAPHQL_OPERATION_REQUIRED");const o=cs.includes(this.operation)?this.operation:"query",r=this.query??(e.inputs.value??"")+"";if(!r)throw new ar("GraphQL node requires a query document","GRAPH_GRAPHQL_QUERY_REQUIRED");const n=await jr(t,e.credentials,"graphql",!1,"GraphQL"),i=new Se;try{await me(i,{endpoint:this.endpoint??Sa(n,"endpoint","GraphQL"),token:Sa(n,"token","GraphQL")});const e=await i.request({query:r,variables:xa(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 ar)throw e;throw new ar(`GraphQL node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GRAPHQL_OPERATION_FAILED",{operation:o})}finally{await i.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],ps.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.endpoint.label",type:"string"}),bt({handle:"endpoint",userControlled:!0}),C("design:type",String)],ps.prototype,"endpoint",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.query.label",type:"textarea"}),bt({handle:"query",userControlled:!0}),C("design:type",String)],ps.prototype,"query",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.variables.label",type:"json"}),bt({handle:"variables",userControlled:!0}),C("design:type",Object)],ps.prototype,"variables",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.operationName.label",type:"string"}),bt({handle:"operationName",userControlled:!0}),C("design:type",String)],ps.prototype,"operationName",void 0),R([wt({handle:"result"}),C("design:type",Object)],ps.prototype,"result",void 0),R([wt({handle:"errors",type:"array"}),C("design:type",Array)],ps.prototype,"errors",void 0),ps=R([yt("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"}}),I()],ps);const us=["getRepo","listIssues","createIssue","commentIssue","listPullRequests"];let hs=class extends mi{constructor(){super(...arguments),this.operation="getRepo"}async execute(e,t){if(!this.operation)throw new ar("GitHub node requires an operation","GRAPH_GITHUB_OPERATION_REQUIRED");const o=us.includes(this.operation)?this.operation:"getRepo",r=await jr(t,e.credentials,"github",!1,"GitHub"),n=new Re;try{switch(await me(n,{token:Ra(r,"GitHub"),owner:this.owner,repo:this.repo,baseUrl:this.baseUrl}),o){case"getRepo":return{result:await n.getRepository({owner:this.owner,repo:this.repo})};case"listIssues":return{result:await n.listIssues({owner:this.owner,repo:this.repo,state:this.state,limit:_a(this.limit),page:_a(this.page),labels:this.labels?.join(",")})};case"createIssue":{if(!this.title)throw new ar("GitHub createIssue requires a title","GRAPH_GITHUB_TITLE_REQUIRED");const t=await n.createIssue({owner:this.owner,repo:this.repo,title:this.title,body:this.body??(e.inputs.value??"")+"",labels:Oa(this.labels)?.map(String),assignees:Oa(this.assignees)?.map(String)});return{result:t,number:t.number,url:t.htmlUrl}}case"commentIssue":{const e=_a(this.number);if(!e||!this.body)throw new ar("GitHub commentIssue requires an issue number and body","GRAPH_GITHUB_COMMENT_REQUIRED");const t=await n.commentOnIssue({owner:this.owner,repo:this.repo,number:e,body:this.body});return{result:t,number:e,url:t.htmlUrl}}default:return{result:await n.listPullRequests({owner:this.owner,repo:this.repo,state:this.state,limit:_a(this.limit),page:_a(this.page)})}}}catch(e){if(e instanceof ar)throw e;throw new ar(`GitHub node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITHUB_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],hs.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.owner.label",type:"string"}),bt({handle:"owner",userControlled:!0}),C("design:type",String)],hs.prototype,"owner",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.repo.label",type:"string"}),bt({handle:"repo",userControlled:!0}),C("design:type",String)],hs.prototype,"repo",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.number.label",type:"number"}),bt({handle:"number",userControlled:!0}),C("design:type",Number)],hs.prototype,"number",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.title.label",type:"string"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],hs.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.body.label",type:"textarea"}),bt({handle:"body",userControlled:!0}),C("design:type",String)],hs.prototype,"body",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.labels.label",type:"json"}),bt({handle:"labels",userControlled:!0}),C("design:type",Array)],hs.prototype,"labels",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.assignees.label",type:"json"}),bt({handle:"assignees",userControlled:!0}),C("design:type",Array)],hs.prototype,"assignees",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.state.label",type:"select"}),bt({handle:"state",userControlled:!0}),C("design:type",String)],hs.prototype,"state",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],hs.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.page.label",type:"number"}),bt({handle:"page",userControlled:!0}),C("design:type",Number)],hs.prototype,"page",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],hs.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],hs.prototype,"result",void 0),R([wt({handle:"number",type:"number"}),C("design:type",Number)],hs.prototype,"issueNumber",void 0),R([wt({handle:"url",type:"string"}),C("design:type",String)],hs.prototype,"url",void 0),hs=R([yt("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"}}),I()],hs);const gs=["getProject","listIssues","createIssue","commentIssue","listMergeRequests"];let fs=class extends mi{constructor(){super(...arguments),this.operation="getProject"}async execute(e,t){if(!this.operation)throw new ar("GitLab node requires an operation","GRAPH_GITLAB_OPERATION_REQUIRED");const o=gs.includes(this.operation)?this.operation:"getProject",r=await jr(t,e.credentials,"gitlab",!1,"GitLab"),n=new Ce;try{switch(await me(n,{token:Ra(r,"GitLab"),projectId:this.projectId,baseUrl:this.baseUrl}),o){case"getProject":return{result:await n.getProject(this.projectId)};case"listIssues":return{result:await n.listIssues({projectId:this.projectId,state:this.state,limit:_a(this.limit),page:_a(this.page),labels:Oa(this.labels)?.map(String).join(","),search:this.search})};case"createIssue":{if(!this.title)throw new ar("GitLab createIssue requires a title","GRAPH_GITLAB_TITLE_REQUIRED");const t=await n.createIssue({projectId:this.projectId,title:this.title,description:this.body??(e.inputs.value??"")+"",labels:Oa(this.labels)?.map(String).join(","),assigneeIds:Oa(this.assigneeIds)?.map(Number)});return{result:t,iid:t.iid,url:t.webUrl}}case"commentIssue":{const e=_a(this.iid);if(!e||!this.body)throw new ar("GitLab commentIssue requires an issue IID and body","GRAPH_GITLAB_COMMENT_REQUIRED");const t=await n.commentOnIssue({projectId:this.projectId,iid:e,body:this.body});return{result:t,iid:e,url:t.webUrl}}default:return{result:await n.listMergeRequests({projectId:this.projectId,state:this.state,limit:_a(this.limit),page:_a(this.page),search:this.search})}}}catch(e){if(e instanceof ar)throw e;throw new ar(`GitLab node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITLAB_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],fs.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.projectId.label",type:"string"}),bt({handle:"projectId",userControlled:!0}),C("design:type",String)],fs.prototype,"projectId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.iid.label",type:"number"}),bt({handle:"iid",userControlled:!0}),C("design:type",Number)],fs.prototype,"iid",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.title.label",type:"string"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],fs.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.body.label",type:"textarea"}),bt({handle:"body",userControlled:!0}),C("design:type",String)],fs.prototype,"body",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.labels.label",type:"json"}),bt({handle:"labels",userControlled:!0}),C("design:type",Array)],fs.prototype,"labels",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.assigneeIds.label",type:"json"}),bt({handle:"assigneeIds",userControlled:!0}),C("design:type",Array)],fs.prototype,"assigneeIds",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.state.label",type:"select"}),bt({handle:"state",userControlled:!0}),C("design:type",String)],fs.prototype,"state",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.search.label",type:"string"}),bt({handle:"search",userControlled:!0}),C("design:type",String)],fs.prototype,"search",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],fs.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.page.label",type:"number"}),bt({handle:"page",userControlled:!0}),C("design:type",Number)],fs.prototype,"page",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],fs.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],fs.prototype,"result",void 0),R([wt({handle:"iid",type:"number"}),C("design:type",Number)],fs.prototype,"issueIid",void 0),R([wt({handle:"url",type:"string"}),C("design:type",String)],fs.prototype,"url",void 0),fs=R([yt("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"}}),I()],fs);const ys={MD5:"md5",SHA1:"sha1",SHA256:"sha256",SHA384:"sha384",SHA512:"sha512","SHA3-256":"sha3-256","SHA3-384":"sha3-384","SHA3-512":"sha3-512"},ms=["hash","hmac","encrypt","decrypt","sign","verify","generate"];let bs=class extends mi{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 n=Ca(await jr(t,e.credentials,"crypto",!0,o),r,o);if(!n)throw new ar(o+" node credential must contain the required key material","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:o});return n},n=ms.includes(this.operation)?this.operation:"hash",i=ys[this.algorithm]??ys.SHA256,a="base64"===this.encoding?"base64":"hex",s=()=>((e,t)=>{if("string"==typeof e)return e;if(null==e)throw new ar(t+" node requires a payload","GRAPH_CRYPTO_PAYLOAD_REQUIRED");try{return JSON.stringify(e)}catch{throw new ar(t+" node cannot serialize the payload","GRAPH_CRYPTO_INVALID_PAYLOAD")}})(this.payload??e.inputs.value,o),d=new Ne;await d.boot();const l=d.client;try{switch(n){case"hash":return{result:l.createHash(i).update(s()).digest(a)};case"hmac":{const e=await r(["secret","key","password","token"]);return{result:l.createHmac(i,e).update(s()).digest(a)}}case"encrypt":{const e=await r(["secret","key","password","token"]);return{result:await d.encrypt(s(),e),encodings:["base64"]}}case"decrypt":{const e=await r(["secret","key","password","token"]),t=Ia(this.encryptedData);if(!t)throw new ar("Crypto node decrypt requires encryptedData","GRAPH_CRYPTO_ENCRYPTED_DATA_REQUIRED");const o=Ia(this.salt);if(!o)throw new ar("Crypto node decrypt requires the encryption salt","GRAPH_CRYPTO_SALT_REQUIRED");return{result:await d.decrypt(t,e,o)}}case"sign":{const e=await r(["privateKey","key","secret","token"]);return{result:l.createSign(i).update(s()).sign(e,a)}}case"verify":{const e=Ia(this.publicKey)??await r(["publicKey","key","secret","token"]),t=Ia(this.signature);if(!t)throw new ar("Crypto node verify requires a signature","GRAPH_CRYPTO_SIGNATURE_REQUIRED");return{result:l.createVerify(i).update(s()).verify(e,t,a)}}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:Ia(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 ar(`Crypto node operation '${n}' is not supported`,"GRAPH_CRYPTO_OPERATION_NOT_SUPPORTED",{operation:n})}}catch(e){if(e instanceof ar)throw e;throw new ar(`Crypto node operation '${n}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_CRYPTO_OPERATION_FAILED",{operation:n})}finally{await d.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],bs.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.algorithm.label",type:"select"}),bt({handle:"algorithm",userControlled:!0}),C("design:type",String)],bs.prototype,"algorithm",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],bs.prototype,"encoding",void 0),R([bt({handle:"value"}),C("design:type",Object)],bs.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.payload.label",type:"textarea"}),bt({handle:"payload",userControlled:!0}),C("design:type",Object)],bs.prototype,"payload",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.encryptedData.label",type:"textarea"}),bt({handle:"encryptedData",userControlled:!0}),C("design:type",String)],bs.prototype,"encryptedData",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.salt.label",type:"string"}),bt({handle:"salt",userControlled:!0}),C("design:type",String)],bs.prototype,"salt",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.publicKey.label",type:"textarea"}),bt({handle:"publicKey",userControlled:!0}),C("design:type",String)],bs.prototype,"publicKey",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.signature.label",type:"textarea"}),bt({handle:"signature",userControlled:!0}),C("design:type",String)],bs.prototype,"signature",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.keyType.label",type:"select"}),bt({handle:"keyType",userControlled:!0}),C("design:type",String)],bs.prototype,"keyType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.modulusLength.label",type:"number"}),bt({handle:"modulusLength",userControlled:!0}),C("design:type",Number)],bs.prototype,"modulusLength",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.namedCurve.label",type:"string"}),bt({handle:"namedCurve",userControlled:!0}),C("design:type",String)],bs.prototype,"namedCurve",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],bs.prototype,"result",void 0),R([wt({handle:"encodings",type:"array"}),C("design:type",Array)],bs.prototype,"encodings",void 0),bs=R([yt("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"}}),I()],bs);const ws=["sign","verify","decode"];let vs=class extends mi{constructor(){super(...arguments),this.operation="decode"}async execute(e,t){const o=ws.includes(this.operation)?this.operation:"decode",r=Ia(this.token)??Ia(e.inputs.value);if("sign"!==o&&!r)throw new ar(`JWT node operation '${o}' requires a token`,"GRAPH_JWT_TOKEN_REQUIRED",{operation:o});try{if("sign"===o){const o=await jr(t,e.credentials,"jwt",!0,"JWT"),r=(e=>{if("string"==typeof e&&e.trim().startsWith("{"))try{return xa(JSON.parse(e))??{}}catch{throw new ar("JWT node claims must be a JSON object","GRAPH_JWT_INVALID_CLAIMS")}const t=xa(e);if(!t)throw new ar("JWT node sign operation requires claims","GRAPH_JWT_CLAIMS_REQUIRED");return t})(this.claims??e.inputs.value),n={secret:o,expiry:Ia(this.expiry)??"1h"},i=await Te(r,n);return{result:i,token:i}}if("verify"===o){const o=await jr(t,e.credentials,"jwt",!1,"JWT"),n=Ia(this.verifyUrl);if(!o&&!n)throw new ar("JWT node verify requires a secret credential or verifyUrl","GRAPH_JWT_VERIFICATION_NOT_CONFIGURED");const i=await De(r,{secret:"string"==typeof o?o:Ia(o?.secret),verifyUrl:n,clockToleranceSeconds:_a(this.clockToleranceSeconds)});return{result:i,payload:i}}const n=Pe(r);return{result:n??null,payload:n??null}}catch(e){if(e instanceof ar)throw e;throw new ar(`JWT node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_JWT_OPERATION_FAILED",{operation:o})}}};function xs(e,t="utf8"){const o=Buffer.isBuffer(e)?e:Buffer.from(e??"",t);return o.length>Jo?{value:o.subarray(0,Jo).toString(t),truncated:!0}:{value:o.toString(t),truncated:!1}}R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],vs.prototype,"operation",void 0),R([bt({handle:"value"}),C("design:type",Object)],vs.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.token.label",type:"textarea"}),bt({handle:"token",userControlled:!0}),C("design:type",String)],vs.prototype,"token",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.claims.label",type:"object"}),bt({handle:"claims",userControlled:!0}),C("design:type",Object)],vs.prototype,"claims",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.expiry.label",type:"string"}),bt({handle:"expiry",userControlled:!0}),C("design:type",String)],vs.prototype,"expiry",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.verifyUrl.label",type:"string"}),bt({handle:"verifyUrl",userControlled:!0}),C("design:type",String)],vs.prototype,"verifyUrl",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.clockToleranceSeconds.label",type:"number"}),bt({handle:"clockToleranceSeconds",userControlled:!0}),C("design:type",Number)],vs.prototype,"clockToleranceSeconds",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],vs.prototype,"result",void 0),R([wt({handle:"token"}),C("design:type",String)],vs.prototype,"tokenOutput",void 0),R([wt({handle:"payload"}),C("design:type",Object)],vs.prototype,"payload",void 0),vs=R([yt("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"}}),I()],vs);let Is=class extends mi{constructor(){super(...arguments),this.failOnError=!1}async execute(e,t){const o=Ia(this.command);if(!o)throw new ar("Execute Command node requires a command","GRAPH_EXECUTE_COMMAND_REQUIRED");const r=Math.min(6e4,Math.max(1,Math.floor(_a(this.timeoutMs)??3e4))),n=await new Promise(e=>{je(o,{timeout:r,maxBuffer:Jo,cwd:Ia(this.cwd),shell:Ia(this.shell),signal:t.abortSignal,windowsHide:!0},(t,o,r)=>{const n=xs(o),i=xs(r),a=t?.code;e({stdout:n.value,stderr:i.value,exitCode:"number"==typeof a?a:t?null:0,error:t??void 0,truncated:n.truncated||i.truncated})})});if(n.error&&this.failOnError)throw new ar("Execute Command node command failed: "+n.error.message,"GRAPH_EXECUTE_COMMAND_FAILED",{exitCode:n.exitCode});return{result:{stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode,truncated:n.truncated},stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.command.label",type:"textarea"}),bt({handle:"command",userControlled:!0}),C("design:type",String)],Is.prototype,"command",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.cwd.label",type:"string"}),bt({handle:"cwd",userControlled:!0}),C("design:type",String)],Is.prototype,"cwd",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.shell.label",type:"string"}),bt({handle:"shell",userControlled:!0}),C("design:type",String)],Is.prototype,"shell",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs",userControlled:!0}),C("design:type",Number)],Is.prototype,"timeoutMs",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.failOnError.label",type:"boolean"}),bt({handle:"failOnError",userControlled:!0}),C("design:type",Boolean)],Is.prototype,"failOnError",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Is.prototype,"result",void 0),R([wt({handle:"stdout"}),C("design:type",String)],Is.prototype,"stdout",void 0),R([wt({handle:"stderr"}),C("design:type",String)],Is.prototype,"stderr",void 0),R([wt({handle:"exitCode",type:"number"}),C("design:type",Object)],Is.prototype,"exitCode",void 0),Is=R([yt("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"}}),I()],Is);const As=["list","download","delete"];function _s(e){if(!e)return{};if("string"!=typeof e)return{password:Ia(e.password),privateKey:Ia(e.privateKey),passphrase:Ia(e.passphrase)};if(!e.trim().startsWith("{"))return{password:e};const t=Ea(e,"FTP");return{password:Ia(t.password),privateKey:Ia(t.privateKey),passphrase:Ia(t.passphrase)}}let Os=class extends mi{constructor(){super(...arguments),this.operation="list",this.encoding="utf8"}async execute(e,t){const o=Ia(this.host),r=Ia(this.username);if(!o||!r)throw new ar("FTP node requires host and username","GRAPH_FTP_CONNECTION_REQUIRED");const n=As.includes(this.operation)?this.operation:"list",i=Ia(this.path);if("list"!==n&&!i)throw new ar(`FTP node operation '${n}' requires a path`,"GRAPH_FTP_PATH_REQUIRED",{operation:n});const a=await jr(t,e.credentials,"sftp",!1,"FTP"),s={provider:"ssh2",sourceId:Ia(this.sourceId)??"graph",host:o,port:_a(this.port)??22,username:r,remotePath:Ia(this.remotePath),..._s(a)},d=new $e;try{if(await d.initialize(s),"list"===n)return{result:await d.list(i)};if("delete"===n)return await d.delete(i),{result:{path:i,deleted:!0}};const e=await d.fetch(i);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 ar)throw e;throw new ar(`FTP node operation '${n}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_FTP_OPERATION_FAILED",{operation:n})}finally{await d.close().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Os.prototype,"operation",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.host.label",type:"string"}),bt({handle:"host",userControlled:!0}),C("design:type",String)],Os.prototype,"host",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.port.label",type:"number"}),bt({handle:"port",userControlled:!0}),C("design:type",Number)],Os.prototype,"port",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.username.label",type:"string"}),bt({handle:"username",userControlled:!0}),C("design:type",String)],Os.prototype,"username",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.sourceId.label",type:"string"}),bt({handle:"sourceId",userControlled:!0}),C("design:type",String)],Os.prototype,"sourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.remotePath.label",type:"string"}),bt({handle:"remotePath",userControlled:!0}),C("design:type",String)],Os.prototype,"remotePath",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.path.label",type:"string"}),bt({handle:"path",userControlled:!0}),C("design:type",String)],Os.prototype,"path",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],Os.prototype,"encoding",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Os.prototype,"result",void 0),R([wt({handle:"content"}),C("design:type",String)],Os.prototype,"content",void 0),R([wt({handle:"size",type:"number"}),C("design:type",Number)],Os.prototype,"size",void 0),Os=R([yt("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"}}),I()],Os);let Es=class extends mi{constructor(){super(...arguments),this.mode="once",this.inputPort="value"}async execute(e,t){const o=t.engine;if(!o)throw new ar("Execute Sub-workflow node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const r=await this.documentOf(o,t),n=this.inputPort||"value",i=e.inputs.value??e.inputs.input;if("perItem"===this.mode){const e=[];let a,s;for(const d of Mi(i)){const i=await o.execute(r,{[n]:d},{parentRunId:t.runId,path:[...t.path,"subworkflow"],auth:t.auth,metadata:{...t.metadata,item:d}},t);e.push(i.outputs.result??i.outputs),a=i.outputs,s=i.runId}return{result:e,outputs:a,childRunId:s}}const a=await o.execute(r,{[n]:i},{parentRunId:t.runId,path:[...t.path,"subworkflow"],auth:t.auth,metadata:t.metadata},t);return{result:a.outputs.result??a.outputs,outputs:a.outputs,childRunId:a.runId}}async documentOf(e,t){if(Li(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 ar("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 ar(`Execute Sub-workflow node could not resolve workflow '${r}': ${e instanceof Error?e.message:e+""}`,"GRAPH_SUB_WORKFLOW_NOT_FOUND",{workflowId:r})}}};R([bt({handle:"value"}),C("design:type",Object)],Es.prototype,"value",void 0),R([i("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"}),bt({handle:"workflowId",userControlled:!0}),C("design:type",String)],Es.prototype,"workflowId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.workflow.label",type:"json"}),bt({handle:"workflow",userControlled:!0,type:"object"}),C("design:type",Object)],Es.prototype,"workflow",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.mode.label",type:"select"}),bt({handle:"mode",userControlled:!0}),C("design:type",String)],Es.prototype,"mode",void 0),R([i("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"}),bt({handle:"inputPort",userControlled:!0}),C("design:type",String)],Es.prototype,"inputPort",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Es.prototype,"result",void 0),R([wt({handle:"outputs"}),C("design:type",Object)],Es.prototype,"outputs",void 0),R([wt({handle:"childRunId"}),C("design:type",String)],Es.prototype,"childRunId",void 0),Es=R([yt("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"}}),I()],Es);let ks=class extends mi{execute(e){const t=e.inputs.payload;return{result:void 0!==t?t:e.inputs.value??e.inputs}}};R([bt({handle:"payload"}),C("design:type",Object)],ks.prototype,"payload",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.trigger.execute_workflow.fields.schema.label",placeholder:"graph.node.trigger.execute_workflow.fields.schema.placeholder",type:"json"}),bt({handle:"schema",userControlled:!0,type:"object"}),C("design:type",Object)],ks.prototype,"schema",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],ks.prototype,"result",void 0),ks=R([yt("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"}}}),I()],ks);let Ss=class extends mi{execute(e){return{message:e.inputs.message??null,sessionId:e.inputs.sessionId??null,userId:e.inputs.userId??null}}};R([w(),wt({handle:"message"}),C("design:type",String)],Ss.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",String)],Ss.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",String)],Ss.prototype,"userId",void 0),Ss=R([yt("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"}}}),I()],Ss);let Rs=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),wt({handle:"payload"}),C("design:type",Object)],Rs.prototype,"payload",void 0),Rs=R([yt("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"}}}),I()],Rs);let Cs=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),bt({handle:"schema"}),i("ngx-decaf-model-builder",{label:"graph.node.trigger.form.fields.schema.label",placeholder:"graph.node.trigger.form.fields.schema.placeholder"}),C("design:type",Object)],Cs.prototype,"schema",void 0),R([w(),wt({handle:"payload"}),C("design:type",Object)],Cs.prototype,"payload",void 0),Cs=R([yt("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:[]}}}),I()],Cs);let Ns=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),wt({handle:"payload"}),C("design:type",Object)],Ns.prototype,"payload",void 0),Ns=R([yt("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:{}}}}),I()],Ns);let Ts=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),bt({handle:"cron"}),i("app-cron-selector-field",{label:"graph.node.trigger.schedule.fields.cron.label",placeholder:"graph.node.trigger.schedule.fields.cron.placeholder"}),C("design:type",String)],Ts.prototype,"cron",void 0),R([w(),wt({handle:"payload"}),C("design:type",Object)],Ts.prototype,"payload",void 0),Ts=R([yt("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"}}}),I()],Ts);let Ds=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),bt({handle:"schema"}),i("ngx-decaf-model-builder",{label:"graph.node.trigger.webhook.fields.schema.label",placeholder:"graph.node.trigger.webhook.fields.schema.placeholder"}),C("design:type",Object)],Ds.prototype,"schema",void 0),R([w(),wt({handle:"payload"}),C("design:type",Object)],Ds.prototype,"payload",void 0),Ds=R([yt("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"}}}),I()],Ds);const Ps={memory:"memory",scorers:"scorers",embedding:"embedding",hooks:"hooks",sandbox:"sandbox",tools:"tools",skill:"skill",inputProcessors:"inputProcessors",outputProcessors:"outputProcessors"},js=["memory","scorers","embedding","hooks","sandbox","tools","skill","inputProcessors","outputProcessors"];let $s=class extends mi{execute(e){throw new ar("Node kind 'core.agent' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.prompt.label",placeholder:"graph.node.agent.agent.fields.prompt.placeholder",type:"textarea"}),bt({handle:"prompt"}),C("design:type",String)],$s.prototype,"prompt",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.name.label",placeholder:"graph.node.agent.agent.fields.name.placeholder",type:"text"}),bt({handle:"name",userControlled:!0}),C("design:type",String)],$s.prototype,"name",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.description.label",type:"textarea"}),bt({handle:"description",userControlled:!0}),C("design:type",String)],$s.prototype,"description",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.instructions.label",placeholder:"graph.node.agent.agent.fields.instructions.placeholder",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],$s.prototype,"instructions",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.skillsFormat.label",type:"select"}),bt({handle:"skillsFormat",userControlled:!0}),C("design:type",String)],$s.prototype,"skillsFormat",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.maxRetries.label",type:"number"}),bt({handle:"maxRetries",userControlled:!0}),C("design:type",Number)],$s.prototype,"maxRetries",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],$s.prototype,"modelAdapter",void 0),R([i("ngx-decaf-model-builder",{label:"graph.node.agent.agent.fields.structuredOutput.label"}),bt({handle:"structuredOutput",userControlled:!0,type:"object"}),C("design:type",Object)],$s.prototype,"structuredOutput",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.agentOptions.label",type:"object"}),bt({handle:"agentOptions",userControlled:!0,type:"object"}),C("design:type",Object)],$s.prototype,"agentOptions",void 0),R([w(),wt({handle:"response"}),C("design:type",String)],$s.prototype,"response",void 0),R([w(),wt({handle:"actions"}),C("design:type",Array)],$s.prototype,"actions",void 0),R([vt({category:"memory",handle:"memory",zone:{side:"bottom",align:"start",order:0}}),C("design:type",Object)],$s.prototype,"memory",void 0),R([vt({category:"scorers",handle:"scorers",zone:{side:"top",align:"end",order:0}}),C("design:type",Object)],$s.prototype,"scorers",void 0),R([vt({category:"embedding",handle:"embedding",zone:{side:"bottom",align:"end",order:0}}),C("design:type",Object)],$s.prototype,"embedding",void 0),R([vt({category:"hooks",handle:"hooks",zone:{side:"top",align:"center",order:0}}),C("design:type",Object)],$s.prototype,"hooks",void 0),R([vt({category:"sandbox",handle:"sandbox",zone:{side:"top",align:"center",order:1}}),C("design:type",Object)],$s.prototype,"sandbox",void 0),R([vt({category:"tools",handle:"tools",zone:{side:"bottom",align:"center",order:0}}),C("design:type",Object)],$s.prototype,"tools",void 0),R([vt({category:"skill",handle:"skill",zone:{side:"bottom",align:"center",order:1}}),C("design:type",Object)],$s.prototype,"skill",void 0),R([vt({category:"inputProcessors",handle:"inputProcessors",zone:{side:"top",align:"center",order:2}}),C("design:type",Object)],$s.prototype,"inputProcessors",void 0),R([vt({category:"outputProcessors",handle:"outputProcessors",zone:{side:"bottom",align:"center",order:2}}),C("design:type",Object)],$s.prototype,"outputProcessors",void 0),R([vt({category:"model",handle:"model",zone:{side:"bottom",align:"start",order:1}}),C("design:type",Object)],$s.prototype,"model",void 0),R([vt({category:"workspace",handle:"workspace",zone:{side:"bottom",align:"start",order:2}}),C("design:type",Object)],$s.prototype,"workspace",void 0),$s=R([yt("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"}}),I()],$s);const Ls=[$s];let Ms=class extends mi{execute(e){return{resource:{type:"mastra.tool",toolId:this.toolId,description:this.description,input:e.inputs}}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool.fields.toolId.label",placeholder:"graph.node.agent.tool.fields.toolId.placeholder",type:"text"}),bt({handle:"toolId",userControlled:!0}),C("design:type",String)],Ms.prototype,"toolId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool.fields.description.label",type:"textarea"}),bt({handle:"description",userControlled:!0}),C("design:type",String)],Ms.prototype,"description",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Ms.prototype,"resource",void 0),R([vt({category:"tools",handle:"tool"}),C("design:type",Object)],Ms.prototype,"tool",void 0),Ms=R([yt("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"}}),I()],Ms);const Gs=[Ms];let Us=class extends mi{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}}};R([bt({handle:"decision"}),C("design:type",Object)],Us.prototype,"decision",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool_selector.fields.tools.label",type:"text"}),bt({handle:"tools",userControlled:!0}),C("design:type",Array)],Us.prototype,"tools",void 0),R([wt({handle:"selected"}),C("design:type",Object)],Us.prototype,"selectedOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Us.prototype,"resource",void 0),R([vt({category:"tools",handle:"tool"}),C("design:type",Object)],Us.prototype,"tool",void 0),Us=R([yt("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"}}),I()],Us);const Fs=[Us];let Bs=class extends mi{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}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.hook.fields.phase.label",type:"select"}),bt({handle:"phase",userControlled:!0}),C("design:type",String)],Bs.prototype,"phase",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.hook.fields.toolName.label",type:"text"}),bt({handle:"toolName",userControlled:!0}),C("design:type",String)],Bs.prototype,"toolName",void 0),R([w(),bt({handle:"value"}),C("design:type",Object)],Bs.prototype,"value",void 0),R([w(),wt({handle:"toolName"}),C("design:type",Object)],Bs.prototype,"toolNameOut",void 0),R([wt({handle:"input"}),C("design:type",Object)],Bs.prototype,"inputOut",void 0),R([wt({handle:"output"}),C("design:type",Object)],Bs.prototype,"outputOut",void 0),R([wt({handle:"error"}),C("design:type",Object)],Bs.prototype,"errorOut",void 0),R([wt({handle:"value"}),C("design:type",Object)],Bs.prototype,"valueOut",void 0),R([vt({category:"hooks",handle:"hook"}),C("design:type",Object)],Bs.prototype,"hook",void 0),Bs=R([yt("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"}}),I()],Bs);const Hs=[Bs];let qs=class extends mi{execute(e){const t=e.inputs.value;return{proceed:!1,denied:!0,reason:this.reason,value:this.replacement??t}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool_deny.fields.replacement.label",type:"textarea"}),bt({handle:"replacement",userControlled:!0}),C("design:type",Object)],qs.prototype,"replacement",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool_deny.fields.reason.label",type:"text"}),bt({handle:"reason",userControlled:!0}),C("design:type",String)],qs.prototype,"reason",void 0),R([bt({handle:"value"}),C("design:type",Object)],qs.prototype,"value",void 0),R([wt({handle:"proceed"}),C("design:type",Boolean)],qs.prototype,"proceedOut",void 0),R([wt({handle:"value"}),C("design:type",Object)],qs.prototype,"valueOut",void 0),R([wt({handle:"denied"}),C("design:type",Boolean)],qs.prototype,"deniedOut",void 0),R([wt({handle:"reason"}),C("design:type",Object)],qs.prototype,"reasonOut",void 0),qs=R([yt("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"}}),I()],qs);const Ws=[qs];let Ks=class extends mi{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}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.delegation_hook.fields.phase.label",type:"select"}),bt({handle:"phase",userControlled:!0}),C("design:type",String)],Ks.prototype,"phase",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.delegation_hook.fields.subAgentId.label",type:"text"}),bt({handle:"subAgentId",userControlled:!0}),C("design:type",String)],Ks.prototype,"subAgentId",void 0),R([w(),bt({handle:"value"}),C("design:type",Object)],Ks.prototype,"value",void 0),R([wt({handle:"fromAgentId"}),C("design:type",Object)],Ks.prototype,"fromAgentIdOut",void 0),R([wt({handle:"toAgentId"}),C("design:type",Object)],Ks.prototype,"toAgentIdOut",void 0),R([wt({handle:"input"}),C("design:type",Object)],Ks.prototype,"inputOut",void 0),R([wt({handle:"output"}),C("design:type",Object)],Ks.prototype,"outputOut",void 0),R([wt({handle:"error"}),C("design:type",Object)],Ks.prototype,"errorOut",void 0),R([wt({handle:"value"}),C("design:type",Object)],Ks.prototype,"valueOut",void 0),R([vt({category:"hooks",handle:"hook"}),C("design:type",Object)],Ks.prototype,"hook",void 0),Ks=R([yt("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"}}),I()],Ks);const Vs=[Ks];let zs=class extends mi{execute(e){return{resource:{type:"mastra.skill",name:this.name,description:this.description,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.name.label",type:"text"}),bt({handle:"name",userControlled:!0}),C("design:type",String)],zs.prototype,"name",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.description.label",type:"textarea"}),bt({handle:"description",userControlled:!0}),C("design:type",String)],zs.prototype,"description",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.instructions.label",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],zs.prototype,"instructions",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],zs.prototype,"resource",void 0),R([vt({category:"skill",handle:"skill"}),C("design:type",Object)],zs.prototype,"skill",void 0),zs=R([yt("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"}}),I()],zs);const Qs=[zs];let Js=class extends mi{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}}};R([bt({handle:"decision"}),C("design:type",Object)],Js.prototype,"decision",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.skill_selector.fields.skills.label",type:"text"}),bt({handle:"skills",userControlled:!0}),C("design:type",Array)],Js.prototype,"skills",void 0),R([wt({handle:"selected"}),C("design:type",Object)],Js.prototype,"selectedOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Js.prototype,"resource",void 0),R([vt({category:"skill",handle:"skill"}),C("design:type",Object)],Js.prototype,"skill",void 0),Js=R([yt("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"}}),I()],Js);const Xs=[Js];function Ys(e){const t=Oi.graph.execution?.maxCodeTimeoutMs;return ki(e,"number"==typeof t&&Number.isFinite(t)&&t>0?t:qo)}let Zs=class extends mi{execute(e){return{resource:{type:"mastra.sandbox",workingDirectory:this.workingDirectory,isolation:this.isolation,timeoutMs:Ys(this.timeoutMs),input:e.inputs}}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.workingDirectory.label",type:"text"}),bt({handle:"workingDirectory",userControlled:!0}),C("design:type",String)],Zs.prototype,"workingDirectory",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.isolation.label",type:"select"}),bt({handle:"isolation",userControlled:!0}),C("design:type",String)],Zs.prototype,"isolation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs",userControlled:!0}),C("design:type",Number)],Zs.prototype,"timeoutMs",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Zs.prototype,"resource",void 0),R([vt({category:"sandbox",handle:"sandbox"}),C("design:type",Object)],Zs.prototype,"sandbox",void 0),Zs=R([yt("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"}}),I()],Zs);const ed=[Zs];let td=class extends mi{execute(e){return{resource:{type:"mastra.scorer",id:this.scorerId,description:this.description,scorerType:this.scorerType,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.scorerId.label",type:"text"}),bt({handle:"scorerId",userControlled:!0}),C("design:type",String)],td.prototype,"scorerId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.description.label",type:"textarea"}),bt({handle:"description",userControlled:!0}),C("design:type",String)],td.prototype,"description",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.scorerType.label",type:"select"}),bt({handle:"scorerType",userControlled:!0}),C("design:type",String)],td.prototype,"scorerType",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],td.prototype,"resource",void 0),R([vt({category:"scorers",handle:"scorer"}),C("design:type",Object)],td.prototype,"scorer",void 0),td=R([yt("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"}}),I()],td);const od=[td];let rd=class extends mi{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}}};R([bt({handle:"decision"}),C("design:type",Object)],rd.prototype,"decision",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer_selector.fields.scorers.label",type:"text"}),bt({handle:"scorers",userControlled:!0}),C("design:type",Array)],rd.prototype,"scorers",void 0),R([wt({handle:"selected"}),C("design:type",Object)],rd.prototype,"selectedOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],rd.prototype,"resource",void 0),R([vt({category:"scorers",handle:"scorer"}),C("design:type",Object)],rd.prototype,"scorer",void 0),rd=R([yt("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"}}),I()],rd);const nd=[rd];o.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 id=[...sn,"connectionString","dsn","pwd","passphrase","authToken"];function ad(e,t,o,r=0){if(8>=r&&null!==e)if(Array.isArray(e))for(const n of e)ad(n,t,o,r+1);else if("object"==typeof e)for(const[n,i]of Object.entries(e)){const e=[...t,n];if(id.includes(n))throw new ar(`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:n,path:e.join(".")});ad(i,e,o,r+1)}}function sd(e,t){ad(e,[],t)}const dd=["memory","libsql","pg","mongodb","upstash","cloud","d1","dynamodb","convex","astra","redis"];function ld(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}let cd=class extends mi{execute(e){return{resource:ld(this.configOf(e))}}configOf(e){const t=this.provider??"memory";if(!dd.includes(t))throw new ar(`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 n="string"==typeof o&&o.trim().length>0?o:this.workingMemoryTemplate;return"string"==typeof n&&n.trim().length>0&&(r.workingMemoryTemplate=n),r}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.provider.label",type:"select"}),bt({handle:"provider",userControlled:!0}),C("design:type",String)],cd.prototype,"provider",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.memoryId.label",type:"text"}),bt({handle:"memoryId",userControlled:!0}),C("design:type",String)],cd.prototype,"memoryId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.threadId.label",placeholder:"graph.node.agent.memory.fields.threadId.placeholder",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],cd.prototype,"threadId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.resourceId.label",type:"text"}),bt({handle:"resourceId",userControlled:!0}),C("design:type",String)],cd.prototype,"resourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.lastMessages.label",type:"number"}),bt({handle:"lastMessages",userControlled:!0}),C("design:type",Number)],cd.prototype,"lastMessages",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.semanticRecall.label",type:"select"}),bt({handle:"semanticRecall",userControlled:!0}),C("design:type",Boolean)],cd.prototype,"semanticRecall",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.workingMemoryTemplate.label",placeholder:"graph.node.agent.memory.fields.workingMemoryTemplate.placeholder",type:"textarea"}),bt({handle:"workingMemoryTemplate",userControlled:!0}),C("design:type",String)],cd.prototype,"workingMemoryTemplate",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.generateTitle.label",type:"select"}),bt({handle:"generateTitle",userControlled:!0}),C("design:type",Boolean)],cd.prototype,"generateTitle",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.memoryOptions.label",type:"object"}),bt({handle:"memoryOptions",userControlled:!0,type:"object"}),C("design:type",Object)],cd.prototype,"memoryOptions",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.connection.label",type:"object"}),bt({handle:"connection",userControlled:!0,type:"object"}),C("design:type",Object)],cd.prototype,"connection",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.credentialRef.label",type:"text"}),bt({handle:"credentialKey",userControlled:!0}),C("design:type",String)],cd.prototype,"credentialKey",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.credentialRef.label",type:"object"}),bt({handle:"credentialRef",userControlled:!0,type:"object"}),C("design:type",Object)],cd.prototype,"credentialRef",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],cd.prototype,"resource",void 0),R([vt({category:"memory",handle:"memory"}),C("design:type",Object)],cd.prototype,"memory",void 0),cd=R([yt("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"}}),I()],cd);let pd=class extends mi{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}}};R([bt({handle:"decision"}),C("design:type",Object)],pd.prototype,"decision",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory_selector.fields.memories.label",type:"text"}),bt({handle:"memories",userControlled:!0}),C("design:type",Array)],pd.prototype,"memories",void 0),R([wt({handle:"selected"}),C("design:type",Object)],pd.prototype,"selectedOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],pd.prototype,"resource",void 0),R([vt({category:"memory",handle:"memory"}),C("design:type",Object)],pd.prototype,"memory",void 0),pd=R([yt("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"}}),I()],pd);const ud=[pd];let hd=class extends mi{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}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],hd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.dimension.label",type:"number"}),bt({handle:"dimension",userControlled:!0}),C("design:type",Number)],hd.prototype,"dimension",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.batchSize.label",type:"number"}),bt({handle:"batchSize",userControlled:!0}),C("design:type",Number)],hd.prototype,"batchSize",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],hd.prototype,"resource",void 0),R([vt({category:"embedding",handle:"embedding"}),C("design:type",Object)],hd.prototype,"embedding",void 0),hd=R([yt("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"}}),I()],hd);const gd=[hd];let fd=class extends mi{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&&(sd(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??[]}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.provider.label",type:"select"}),bt({handle:"provider",userControlled:!0}),C("design:type",String)],fd.prototype,"provider",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.storeId.label",type:"text"}),bt({handle:"storeId",userControlled:!0}),C("design:type",String)],fd.prototype,"storeId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.indexName.label",type:"text"}),bt({handle:"indexName",userControlled:!0}),C("design:type",String)],fd.prototype,"indexName",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.dimension.label",type:"number"}),bt({handle:"dimension",userControlled:!0}),C("design:type",Number)],fd.prototype,"dimension",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.metric.label",type:"select"}),bt({handle:"metric",userControlled:!0}),C("design:type",String)],fd.prototype,"metric",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.modelAdapter.label",type:"object"}),bt({handle:"embedding",userControlled:!0,type:"object"}),C("design:type",Object)],fd.prototype,"embedding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.connection.label",type:"object"}),bt({handle:"connection",userControlled:!0,type:"object"}),C("design:type",Object)],fd.prototype,"connection",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.credentialRef.label",type:"text"}),bt({handle:"credentialKey",userControlled:!0}),C("design:type",String)],fd.prototype,"credentialKey",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.credentialRef.label",type:"object"}),bt({handle:"credentialRef",userControlled:!0,type:"object"}),C("design:type",Object)],fd.prototype,"credentialRef",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],fd.prototype,"resource",void 0),R([wt({handle:"inserted"}),C("design:type",Object)],fd.prototype,"insertedOut",void 0),R([wt({handle:"documents"}),C("design:type",Object)],fd.prototype,"documentsOut",void 0),fd=R([yt("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"}}),I()],fd);const yd=[fd];let md=class extends mi{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}}}};R([w(),bt({handle:"store"}),C("design:type",Object)],md.prototype,"store",void 0),R([w(),bt({handle:"query"}),C("design:type",Object)],md.prototype,"query",void 0),R([bt({handle:"queryVector"}),C("design:type",Object)],md.prototype,"queryVector",void 0),R([bt({handle:"filter",type:"object"}),C("design:type",Object)],md.prototype,"filter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.retriever.fields.topK.label",type:"number"}),bt({handle:"topK",userControlled:!0}),C("design:type",Number)],md.prototype,"topK",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.retriever.fields.indexName.label",type:"text"}),bt({handle:"indexName",userControlled:!0}),C("design:type",String)],md.prototype,"indexName",void 0),R([w(),wt({handle:"documents"}),C("design:type",Object)],md.prototype,"documents",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],md.prototype,"resource",void 0),md=R([yt("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"}}),I()],md);const bd=[md],wd=1e3,vd=200;function xd(e,t,o){if("number"!=typeof e||!Number.isFinite(e))return t;const r=Math.floor(e);return o>r?t:r}function Id(e,t,o){if(e.length<=t)return e.length?[e]:[];const r=Math.max(1,t-o),n=[];for(let o=0;o<e.length;o+=r){const r=Math.min(o+t,e.length);if(n.push(e.slice(o,r)),r>=e.length)break}return n}function Ad(e,t={}){if("string"!=typeof e||0===e.length)return[];const o=t.strategy??"recursive",r=xd(t.chunkSize,1e3,1),n=xd(t.chunkOverlap,200,0),i=Math.min(n,Math.max(0,r-1));if("character"===o)return Id(e,r,i);if("token"===o){const t=e.split(/\s+/).filter(e=>e.length>0);if(0===t.length)return[];const o=Math.max(1,r-i),n=[];for(let e=0;e<t.length&&(n.push(t.slice(e,e+r).join(" ")),e+r<t.length);e+=o);return n}const a="markdown"===o?"\n#":t.separator??"\n\n",s=e.split(a),d=[];return s.forEach(e=>{const t=e.trim();t&&(t.length>r?d.push(...Id(t,r,i)):d.push(t))}),d.length?d:Id(e,r,i)}function _d(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}let Od=class extends mi{execute(e){const t=_d(e.inputs),o={strategy:this.strategy,chunkSize:this.chunkSize,chunkOverlap:this.chunkOverlap,separator:this.separator},r=t.flatMap(e=>Ad(e,o));return{chunks:r,count:r.length}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.strategy.label",type:"select"}),bt({handle:"strategy",userControlled:!0}),C("design:type",String)],Od.prototype,"strategy",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.chunkSize.label",type:"number"}),bt({handle:"chunkSize",userControlled:!0}),C("design:type",Number)],Od.prototype,"chunkSize",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.chunkOverlap.label",type:"number"}),bt({handle:"chunkOverlap",userControlled:!0}),C("design:type",Number)],Od.prototype,"chunkOverlap",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.separator.label",type:"text"}),bt({handle:"separator",userControlled:!0}),C("design:type",String)],Od.prototype,"separator",void 0),R([w(),wt({handle:"chunks"}),C("design:type",Object)],Od.prototype,"chunks",void 0),R([wt({handle:"count"}),C("design:type",Object)],Od.prototype,"countOut",void 0),Od=R([yt("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"}}),I()],Od);const Ed=[Od];let kd=class extends mi{execute(e){const t=e.inputs.documents,o=Array.isArray(t)?t:[],r="number"==typeof this.topN&&this.topN>0?this.topN:void 0,n=this.modelAdapter??{};return{documents:void 0!==r?o.slice(0,r):o,resource:{type:"mastra.rerank",provider:n.provider,modelId:n.modelId,topN:r}}}};R([w(),bt({handle:"documents"}),C("design:type",Object)],kd.prototype,"documents",void 0),R([bt({handle:"query"}),C("design:type",Object)],kd.prototype,"query",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.rerank.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],kd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.rerank.fields.topN.label",type:"number"}),bt({handle:"topN",userControlled:!0}),C("design:type",Number)],kd.prototype,"topN",void 0),R([w(),wt({handle:"documents"}),C("design:type",Object)],kd.prototype,"documentsOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],kd.prototype,"resource",void 0),kd=R([yt("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"}}),I()],kd);const Sd=[kd];let Rd=class extends mi{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}}}};R([w(),bt({handle:"query"}),C("design:type",Object)],Rd.prototype,"query",void 0),R([bt({handle:"context"}),C("design:type",Object)],Rd.prototype,"context",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Rd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.promptTemplate.label",type:"textarea"}),bt({handle:"promptTemplate",userControlled:!0}),C("design:type",String)],Rd.prototype,"promptTemplate",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.returnSourceDocuments.label",type:"boolean"}),bt({handle:"returnSourceDocuments",userControlled:!0}),C("design:type",Boolean)],Rd.prototype,"returnSourceDocuments",void 0),R([w(),wt({handle:"text"}),C("design:type",Object)],Rd.prototype,"text",void 0),R([wt({handle:"sourceDocuments"}),C("design:type",Object)],Rd.prototype,"sourceDocumentsOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Rd.prototype,"resource",void 0),Rd=R([yt("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"}}),I()],Rd);const Cd=[Rd];let Nd=class extends mi{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}}}};R([w(),bt({handle:"input"}),C("design:type",Object)],Nd.prototype,"input",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.basic.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Nd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.basic.fields.promptTemplate.label",type:"textarea"}),bt({handle:"promptTemplate",userControlled:!0}),C("design:type",String)],Nd.prototype,"promptTemplate",void 0),R([w(),wt({handle:"text"}),C("design:type",Object)],Nd.prototype,"text",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Nd.prototype,"resource",void 0),Nd=R([yt("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"}}),I()],Nd);const Td=[Nd];let Dd=class extends mi{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}}}};R([w(),bt({handle:"documents"}),C("design:type",Object)],Dd.prototype,"documents",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Dd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.strategy.label",type:"select"}),bt({handle:"strategy",userControlled:!0}),C("design:type",String)],Dd.prototype,"strategy",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.instructions.label",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],Dd.prototype,"instructions",void 0),R([w(),wt({handle:"text"}),C("design:type",Object)],Dd.prototype,"text",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Dd.prototype,"resource",void 0),Dd=R([yt("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"}}),I()],Dd);const Pd=[Dd];function jd(e){if("string"!=typeof e||0===e.trim().length)return null;try{return JSON.parse(e)}catch{return null}}let $d=class extends mi{execute(e){return{object:jd(e.inputs.text??e.inputs.input),resource:{type:"mastra.structuredOutputParser",strict:this.strict??!1,hasSchema:void 0!==this.structuredOutput}}}};R([w(),bt({handle:"text"}),C("design:type",Object)],$d.prototype,"text",void 0),R([i("ngx-decaf-model-builder",{label:"graph.node.agent.structured_output_parser.fields.structuredOutput.label"}),bt({handle:"structuredOutput",userControlled:!0,type:"object"}),C("design:type",Object)],$d.prototype,"structuredOutput",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.structured_output_parser.fields.strict.label",type:"boolean"}),bt({handle:"strict",userControlled:!0}),C("design:type",Boolean)],$d.prototype,"strict",void 0),R([w(),wt({handle:"object"}),C("design:type",Object)],$d.prototype,"object",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],$d.prototype,"resource",void 0),$d=R([yt("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"}}),I()],$d);const Ld=[$d];let Md=class extends mi{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}}}};R([w(),bt({handle:"text"}),C("design:type",Object)],Md.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.information_extractor.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Md.prototype,"modelAdapter",void 0),R([i("ngx-decaf-model-builder",{label:"graph.node.agent.information_extractor.fields.structuredOutput.label"}),bt({handle:"structuredOutput",userControlled:!0,type:"object"}),C("design:type",Object)],Md.prototype,"structuredOutput",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.information_extractor.fields.instructions.label",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],Md.prototype,"instructions",void 0),R([w(),wt({handle:"data"}),C("design:type",Object)],Md.prototype,"data",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Md.prototype,"resource",void 0),Md=R([yt("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"}}),I()],Md);const Gd=[Md];let Ud=class extends mi{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}}}};R([w(),bt({handle:"input"}),C("design:type",Object)],Ud.prototype,"input",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.code.label",type:"textarea"}),bt({handle:"code",userControlled:!0}),C("design:type",String)],Ud.prototype,"code",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.language.label",type:"select"}),bt({handle:"language",userControlled:!0}),C("design:type",String)],Ud.prototype,"language",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.mode.label",type:"select"}),bt({handle:"mode",userControlled:!0}),C("design:type",String)],Ud.prototype,"mode",void 0),R([wt({handle:"output"}),C("design:type",Object)],Ud.prototype,"outputOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Ud.prototype,"resource",void 0),Ud=R([yt("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"}}),I()],Ud);const Fd=[Ud],Bd=["unicodeNormalizer","languageDetector","piiDetector","promptInjectionDetector","systemPromptScrubber","tokenCostControl","modelSelection"],Hd=["tokenLimiter","toolCallFilter","regexFilter","responseCache","batchParts","providerHistoryCompat","cyberRefusalHandler","prefillErrorHandler","streamErrorRetry","unsupportedFileHandler"],qd=["moderation","piiDetector","promptInjectionDetector","regexFilter"];let Wd=class extends mi{execute(e){return{resource:{type:"mastra.inputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.processorType.label",type:"select"}),bt({handle:"processorType",userControlled:!0}),C("design:type",Object)],Wd.prototype,"processorType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.options.label",type:"object"}),bt({handle:"options",userControlled:!0,type:"object"}),C("design:type",Object)],Wd.prototype,"options",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Wd.prototype,"modelAdapter",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Wd.prototype,"resource",void 0),R([vt({category:"inputProcessors",handle:"processors"}),C("design:type",Object)],Wd.prototype,"processors",void 0),Wd=R([yt("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"}}),I()],Wd);const Kd=[Wd];let Vd=class extends mi{execute(e){return{resource:{type:"mastra.outputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.output_processor.fields.processorType.label",type:"select"}),bt({handle:"processorType",userControlled:!0}),C("design:type",Object)],Vd.prototype,"processorType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.output_processor.fields.options.label",type:"object"}),bt({handle:"options",userControlled:!0,type:"object"}),C("design:type",Object)],Vd.prototype,"options",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Vd.prototype,"resource",void 0),R([vt({category:"outputProcessors",handle:"processors"}),C("design:type",Object)],Vd.prototype,"processors",void 0),Vd=R([yt("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"}}),I()],Vd);const zd=[Vd];let Qd=class extends mi{execute(e){return{resource:{type:"mastra.guardrail",guardrailType:this.guardrailType,strategy:this.strategy,options:this.options,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.guardrailType.label",type:"select"}),bt({handle:"guardrailType",userControlled:!0}),C("design:type",Object)],Qd.prototype,"guardrailType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.strategy.label",type:"select"}),bt({handle:"strategy",userControlled:!0}),C("design:type",String)],Qd.prototype,"strategy",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.options.label",type:"object"}),bt({handle:"options",userControlled:!0,type:"object"}),C("design:type",Object)],Qd.prototype,"options",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Qd.prototype,"modelAdapter",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Qd.prototype,"resource",void 0),R([vt({category:"outputProcessors",handle:"guardrail"}),C("design:type",Object)],Qd.prototype,"guardrail",void 0),Qd=R([yt("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"}}),I()],Qd);const Jd=[Qd];let Xd=class extends mi{execute(e){throw new ar("Node kind 'core.agent.hitl' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.hitl",backend:"local"})}};R([w(),bt({handle:"value"}),C("design:type",Object)],Xd.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.hitl.fields.message.label",placeholder:"graph.node.agent.hitl.fields.message.placeholder",type:"textarea"}),bt({handle:"message",userControlled:!0}),C("design:type",String)],Xd.prototype,"message",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.hitl.fields.prompt.label",type:"textarea"}),bt({handle:"prompt",userControlled:!0}),C("design:type",String)],Xd.prototype,"prompt",void 0),R([w(),bt({handle:"resumeSchema"}),i("ngx-decaf-model-builder",{label:"graph.node.agent.hitl.fields.resumeSchema.label",placeholder:"graph.node.agent.hitl.fields.resumeSchema.placeholder"}),C("design:type",Object)],Xd.prototype,"resumeSchema",void 0),R([wt({handle:"approved"}),C("design:type",Object)],Xd.prototype,"approvedOut",void 0),R([wt({handle:"rejected"}),C("design:type",Object)],Xd.prototype,"rejectedOut",void 0),Xd=R([yt("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"}}),I()],Xd);const Yd=[Xd];let Zd=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.mcp' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.mcp",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.serverId.label",placeholder:"graph.node.agent.mcp_trigger.fields.serverId.placeholder",type:"text"}),bt({handle:"serverId",userControlled:!0}),C("design:type",String)],Zd.prototype,"serverId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.title.label",type:"text"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],Zd.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.instructions.label",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],Zd.prototype,"instructions",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.transport.label",type:"select"}),bt({handle:"transport",userControlled:!0}),C("design:type",String)],Zd.prototype,"transport",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.authMode.label",type:"select"}),bt({handle:"authMode",userControlled:!0}),C("design:type",String)],Zd.prototype,"authMode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.authCredentialRef.label",type:"object"}),bt({handle:"authCredentialRef",userControlled:!0,type:"object"}),C("design:type",Object)],Zd.prototype,"authCredentialRef",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.pendingCap.label",type:"number"}),bt({handle:"pendingCap",userControlled:!0}),C("design:type",Number)],Zd.prototype,"pendingCap",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.pendingTimeoutMs.label",type:"number"}),bt({handle:"pendingTimeoutMs",userControlled:!0}),C("design:type",Number)],Zd.prototype,"pendingTimeoutMs",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Zd.prototype,"resource",void 0),Zd=R([yt("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"}}),I()],Zd);const el=[Zd];let tl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.slack' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.slack",backend:"local"})}};R([w(),wt({handle:"message"}),C("design:type",Object)],tl.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",Object)],tl.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",Object)],tl.prototype,"userId",void 0),R([w(),wt({handle:"threadId"}),C("design:type",Object)],tl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],tl.prototype,"resource",void 0),tl=R([yt("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"}}),I()],tl);const ol=[tl];let rl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.discord' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.discord",backend:"local"})}};R([w(),wt({handle:"message"}),C("design:type",Object)],rl.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",Object)],rl.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",Object)],rl.prototype,"userId",void 0),R([w(),wt({handle:"threadId"}),C("design:type",Object)],rl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],rl.prototype,"resource",void 0),rl=R([yt("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"}}),I()],rl);const nl=[rl];let il=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.telegram' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.telegram",backend:"local"})}};R([w(),wt({handle:"message"}),C("design:type",Object)],il.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",Object)],il.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",Object)],il.prototype,"userId",void 0),R([w(),wt({handle:"threadId"}),C("design:type",Object)],il.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],il.prototype,"resource",void 0),il=R([yt("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"}}),I()],il);const al=[il];let sl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.teams' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.teams",backend:"local"})}};R([w(),wt({handle:"message"}),C("design:type",Object)],sl.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",Object)],sl.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",Object)],sl.prototype,"userId",void 0),R([w(),wt({handle:"threadId"}),C("design:type",Object)],sl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],sl.prototype,"resource",void 0),sl=R([yt("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"}}),I()],sl);const dl=[sl];let ll=class extends mi{execute(e){throw new ar("Node kind 'core.agent.response.slack' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.response.slack",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.slack_response.fields.response.label",type:"textarea"}),bt({handle:"response"}),C("design:type",Object)],ll.prototype,"response",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.slack_response.fields.threadId.label",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],ll.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],ll.prototype,"resource",void 0),ll=R([yt("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"}}),I()],ll);const cl=[ll];let pl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.response.discord' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.response.discord",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.discord_response.fields.response.label",type:"textarea"}),bt({handle:"response"}),C("design:type",Object)],pl.prototype,"response",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.discord_response.fields.threadId.label",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],pl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],pl.prototype,"resource",void 0),pl=R([yt("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"}}),I()],pl);const ul=[pl];let hl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.response.telegram' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.response.telegram",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.telegram_response.fields.response.label",type:"textarea"}),bt({handle:"response"}),C("design:type",Object)],hl.prototype,"response",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.telegram_response.fields.threadId.label",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],hl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],hl.prototype,"resource",void 0),hl=R([yt("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"}}),I()],hl);const gl=[hl];let fl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.response.teams' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.response.teams",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.teams_response.fields.response.label",type:"textarea"}),bt({handle:"response"}),C("design:type",Object)],fl.prototype,"response",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.teams_response.fields.threadId.label",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],fl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],fl.prototype,"resource",void 0),fl=R([yt("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"}}),I()],fl);const yl=[fl];let ml=class extends mi{execute(e){throw new ar("Node kind 'core.agent.voice' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.voice",backend:"local"})}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.speaker.label",type:"text"}),bt({handle:"speaker",userControlled:!0}),C("design:type",String)],ml.prototype,"speaker",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.speechModel.label",type:"object"}),bt({handle:"speechModel",userControlled:!0,type:"object"}),C("design:type",Object)],ml.prototype,"speechModel",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.listeningModel.label",type:"object"}),bt({handle:"listeningModel",userControlled:!0,type:"object"}),C("design:type",Object)],ml.prototype,"listeningModel",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],ml.prototype,"resource",void 0),ml=R([yt("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"}}),I()],ml);const bl=[ml];function wl(e,t,o,r){const n=t??o;if(null==e)return Math.min(o,n);const i=Number(e);if(!Number.isFinite(i)||0>=i)throw new dr(r+" loop maxIterations must be a positive finite number");return Math.min(Math.floor(i),n)}function vl(e,t,o){const r=t.node.loop,n=t.metadata?.loop;if(!r?.body&&!n?.body)throw new dr(o+" node is missing loop configuration (instance.loop.body)");const i=t=>{const o=e[t]??r?.[t]??n?.[t],i=Number(o);return void 0!==o&&Number.isFinite(i)?i:void 0},a=t=>{const o=e[t]??n?.[t];return"string"==typeof o?o:void 0};return{body:r?.body??n?.body,maxIterations:i("maxIterations"),timeoutMs:i("timeoutMs"),concurrency:i("concurrency"),condition:e.condition??n?.condition,inputPort:a("inputPort"),outputPort:a("outputPort"),itemPort:a("itemPort"),resultPort:a("resultPort"),statePort:a("statePort"),slice:i("slice")}}let xl=class extends mi{async execute(e,t){const o=vl(this,t,"foreach"),r=e.inputs,n=r.items,i=wl(o.maxIterations,t.limits?.maxForeachIterations,1e3,"foreach");if(!Array.isArray(n))throw new dr("foreach input 'items' must be an array");const a=t.engine;if(!a)throw new ar("foreach node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const s=Number(r.slice??o.slice??1),d=Number.isFinite(s)&&s>0?Math.floor(s):1,l=d>1?Math.ceil(n.length/d):n.length;if(l>i)throw new lr(`foreach exceeded max iterations (${l} > ${i})`);const c=o.itemPort??"item",p=o.resultPort??"result",u=o.statePort??"state",h=o.body,g=[];let f=r.state,y=!1;await t.emit({type:Qe.LOOP_STARTED});for(let e=0;l>e;e++){await t.emit({type:Qe.LOOP_ITERATION_STARTED,iteration:e});const o=d>1?n.slice(e*d,e*d+d):n[e],r={[c]:o,index:e};d>1&&(r.slice=o),void 0!==f&&(r[u]=f);try{const n=await a.execute(h,r,{parentRunId:t.runId,path:[...t.path,"iteration:"+e],metadata:{item:o,index:e,slice:d},auth:t.auth},t);g.push(n.outputs[p]),void 0!==n.outputs[u]&&(f=n.outputs[u])}catch(o){if(o instanceof gr){const r=o.details?.value;void 0!==r&&g.push(r),y=!0,await t.emit({type:Qe.LOOP_ITERATION_COMPLETED,iteration:e,metadata:{broken:!0}});break}throw o}await t.emit({type:Qe.LOOP_ITERATION_COMPLETED,iteration:e})}await t.emit({type:Qe.LOOP_COMPLETED,metadata:{broken:y}});const m={results:g,completed:g,iterations:g.length,broken:y};return void 0!==f&&(m[u]=f),m}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.items.label",placeholder:"graph.node.loop.foreach.fields.items.placeholder",type:"textarea"}),bt({handle:"items"}),C("design:type",Array)],xl.prototype,"items",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.slice.label",placeholder:"graph.node.loop.foreach.fields.slice.placeholder",type:"number"}),bt({handle:"slice"}),C("design:type",Number)],xl.prototype,"slice",void 0),R([w(),wt({handle:"item"}),C("design:type",Object)],xl.prototype,"item",void 0),R([w(),vt({handle:"loop",connectionRules:{allowSelf:!0,maxConnections:1}}),C("design:type",Object)],xl.prototype,"loop",void 0),R([w(),wt({handle:"completed"}),C("design:type",Array)],xl.prototype,"completed",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.maxIterations.label",type:"number"}),bt({handle:"maxIterations",userControlled:!0}),C("design:type",Number)],xl.prototype,"maxIterations",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.condition.label",type:"code"}),bt({handle:"condition",userControlled:!0}),C("design:type",Object)],xl.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.itemPort.label",type:"text"}),bt({handle:"itemPort",userControlled:!0}),C("design:type",String)],xl.prototype,"itemPort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.resultPort.label",type:"text"}),bt({handle:"resultPort",userControlled:!0}),C("design:type",String)],xl.prototype,"resultPort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.statePort.label",type:"text"}),bt({handle:"statePort",userControlled:!0}),C("design:type",String)],xl.prototype,"statePort",void 0),xl=R([yt("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}}}),I()],xl);class Il{constructor(){this.expressionEvaluator=new qr}evaluate(e,t){if(this.isConditionExpression(e))return this.expressionEvaluator.evaluate(e,t);const o=this.resolveValue(e.left,t),r=e.right;switch(e.type){case nr.TRUTHY:return!!o;case nr.FALSY:return!o;case nr.EQUALS:return o===r;case nr.NOT_EQUALS:return o!==r;case nr.GREATER_THAN:return Number(o)>Number(r);case nr.GREATER_THAN_OR_EQUAL:return Number(o)>=Number(r);case nr.LESS_THAN:return Number(r)>Number(o);case nr.LESS_THAN_OR_EQUAL:return Number(r)>=Number(o);case nr.EXISTS:return null!=o;case nr.CUSTOM:throw new ar("Custom condition evaluators are not supported in v1","GRAPH_CUSTOM_CONDITION_UNSUPPORTED");default:throw new ar(`Unknown condition type '${e.type}'`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e})}}async evaluateAsync(e,t,o,r){return Wr(e)?Vr(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}}let Al=class extends mi{async execute(e,t){const o=vl(this,t,"until"),r=e.inputs,n=wl(o.maxIterations,t.limits?.maxLoopIterations,100,"until"),i=o.condition;if(!i)throw new dr("until node is missing a condition");const a=o.statePort??"state",s=o.inputPort??a,d=o.outputPort??a,l=o.body,c=t.engine;if(!c)throw new ar("until node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=r.state,u=0;await t.emit({type:Qe.LOOP_STARTED});let h=!1;do{if(u>=n)throw await t.emit({type:Qe.LOOP_LIMIT_REACHED,iteration:u}),new lr(`until loop exceeded max iterations (${n})`);await t.emit({type:Qe.LOOP_ITERATION_STARTED,iteration:u}),p=(await c.execute(l,{[s]:p,iteration:u},{parentRunId:t.runId,path:[...t.path,"iteration:"+u],auth:t.auth},t)).outputs[d],await t.emit({type:Qe.LOOP_ITERATION_COMPLETED,iteration:u});const e=await(new Il).evaluateAsync(i,p,t,{...r,state:p});await t.emit({type:Qe.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:e}}),u++,h=e}while(!h);return await t.emit({type:Qe.LOOP_COMPLETED}),{state:p,iterations:u}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.state.label",placeholder:"graph.node.loop.until.fields.state.placeholder",type:"textarea"}),bt({handle:"state"}),C("design:type",Object)],Al.prototype,"state",void 0),R([w(),wt({handle:"state"}),C("design:type",Object)],Al.prototype,"stateOut",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.maxIterations.label",type:"number"}),bt({handle:"maxIterations",userControlled:!0}),C("design:type",Number)],Al.prototype,"maxIterations",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.condition.label",type:"code"}),bt({handle:"condition",userControlled:!0}),C("design:type",Object)],Al.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.statePort.label",type:"text"}),bt({handle:"statePort",userControlled:!0}),C("design:type",String)],Al.prototype,"statePort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.inputPort.label",type:"text"}),bt({handle:"inputPort",userControlled:!0}),C("design:type",String)],Al.prototype,"inputPort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.outputPort.label",type:"text"}),bt({handle:"outputPort",userControlled:!0}),C("design:type",String)],Al.prototype,"outputPort",void 0),Al=R([yt("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}}}}),I()],Al);let _l=class extends mi{async execute(e,t){const o=vl(this,t,"while"),r=e.inputs,n=wl(o.maxIterations,t.limits?.maxLoopIterations,100,"while"),i=o.condition;if(!i)throw new dr("while node is missing a condition");const a=o.statePort??"state",s=o.inputPort??a,d=o.outputPort??a,l=o.body,c=t.engine;if(!c)throw new ar("while node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=r.state,u=0;for(await t.emit({type:Qe.LOOP_STARTED});await(new Il).evaluateAsync(i,p,t,{...r,state:p});){if(u>=n)throw await t.emit({type:Qe.LOOP_LIMIT_REACHED,iteration:u}),new lr(`while loop exceeded max iterations (${n})`);await t.emit({type:Qe.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:!0}}),await t.emit({type:Qe.LOOP_ITERATION_STARTED,iteration:u}),p=(await c.execute(l,{[s]:p,iteration:u},{parentRunId:t.runId,path:[...t.path,"iteration:"+u],auth:t.auth},t)).outputs[d],await t.emit({type:Qe.LOOP_ITERATION_COMPLETED,iteration:u}),u++}return await t.emit({type:Qe.LOOP_COMPLETED}),{state:p,iterations:u}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.state.label",placeholder:"graph.node.loop.while.fields.state.placeholder",type:"textarea"}),bt({handle:"state"}),C("design:type",Object)],_l.prototype,"state",void 0),R([w(),wt({handle:"state"}),C("design:type",Object)],_l.prototype,"stateOut",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.maxIterations.label",type:"number"}),bt({handle:"maxIterations",userControlled:!0}),C("design:type",Number)],_l.prototype,"maxIterations",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.condition.label",type:"code"}),bt({handle:"condition",userControlled:!0}),C("design:type",Object)],_l.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.statePort.label",type:"text"}),bt({handle:"statePort",userControlled:!0}),C("design:type",String)],_l.prototype,"statePort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.inputPort.label",type:"text"}),bt({handle:"inputPort",userControlled:!0}),C("design:type",String)],_l.prototype,"inputPort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.outputPort.label",type:"text"}),bt({handle:"outputPort",userControlled:!0}),C("design:type",String)],_l.prototype,"outputPort",void 0),_l=R([yt("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}}}}),I()],_l);let Ol=class extends mi{execute(e){const t=e.inputs;return{value:t?.value??null}}};R([wt({handle:"value",connectionRules:{allowMultiple:!0}}),C("design:type",Object)],Ol.prototype,"value",void 0),Ol=R([yt("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"}}),I()],Ol);let El=class extends mi{execute(e){return{}}};function kl(e,t,o,r={}){return{id:e,label:t,direction:o,...r}}function Sl(e){const t=e,o=at(t),r=o?.metadata?.title;return ko(t,r?{name:r}:{})}function Rl(e,t){const o=e,r=at(o),n=r?.metadata?.title;return ko(o,{...n?{name:n}:{},icon:{type:"catalogue",name:t}})}function Cl(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}]}}R([w(),bt({handle:"value"}),C("design:type",Object)],El.prototype,"value",void 0),El=R([yt("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"}}),I()],El);const Nl={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:[kl("items","graph.node.loop.foreach.ports.input.items.label","input",{required:!0,schema:{type:"array",items:{type:"any"}}}),kl("slice","graph.node.loop.foreach.ports.input.slice.label","input",{schema:{type:"number",integer:!0,min:1}}),kl("state","graph.node.loop.foreach.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[kl("results","graph.node.loop.foreach.ports.output.results.label","output",{schema:{type:"array",items:{type:"any"}}}),kl("completed","graph.node.loop.foreach.ports.output.completed.label","output",{schema:{type:"array",items:{type:"any"}}}),kl("iterations","graph.node.loop.foreach.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}}),kl("broken","graph.node.loop.foreach.ports.output.broken.label","output",{schema:{type:"boolean"}}),kl("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}]},Tl={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:[kl("state","graph.node.loop.while.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[kl("state","graph.node.loop.while.ports.output.state.label","output",{schema:{type:"any"}}),kl("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"}]},Dl={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:[kl("state","graph.node.loop.until.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[kl("state","graph.node.loop.until.ports.output.state.label","output",{schema:{type:"any"}}),kl("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"}]},Pl=[Sl(Ol),Sl(El),Sl(Ji),Sl(Xi),Sl(Zi),Sl(ea),Sl(oa),Sl(na),Sl(ia),Sl(aa),Sl(sa),Sl(la),Sl(pa),Sl(ha),Sl(wa),Cl(Sl(Da),"postgres","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Pa),"mysql","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(ja),"mssql","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Ga),"redis","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Ha),"s3","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(qa),"s3","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Wa),"gcs","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Va),"azure-blob","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(bs),"crypto","graph.node.devops.common.fields.credentialRef.label"),Cl(Sl(vs),"jwt","graph.node.devops.common.fields.credentialRef.label"),(()=>{const e=Sl(Is);return{...e,metadata:{...e.metadata??{},danger:!0,requiresOptIn:!0,dangerReason:"Executes arbitrary shell commands with the host process privileges; expose only behind an explicit operator opt-in."}}})(),Cl(Sl(Os),"sftp","graph.node.devops.common.fields.credentialRef.label"),Cl(Sl(hs),"github","graph.node.devops.common.fields.credentialRef.label"),Cl(Sl(fs),"gitlab","graph.node.devops.common.fields.credentialRef.label"),Cl(Sl(Qa),"slack","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(Xa),"telegram","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(Za),"teams","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(ts),"gmail","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(rs),"email","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(is),"google-sheets","graph.node.io.common.fields.credentialRef.label"),Cl(Sl(ss),"airtable","graph.node.io.common.fields.credentialRef.label"),Cl(Sl(ps),"graphql","graph.node.io.common.fields.credentialRef.label"),Sl(ls),Sl(va),Sl(Es),Sl(ks),Sl(Ns),Sl(Ds),Sl(Ts),Sl(Rs),Sl(Cs),Sl(Ss),(jl=Sl(Ii),{...jl,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"}}}]}))(Sl(Ai)),Sl(Pi),Sl(Ti),Sl(vi),Sl(xi),Sl(Ni),Sl(Di),Sl(ji),Sl(bi),Sl($s),Sl(Ms),Sl(Us),Sl(Bs),Sl(qs),Sl(Ks),Sl(zs),Sl(Js),Sl(Zs),Sl(td),Sl(rd),Sl(cd),Sl(pd),Sl(hd),Sl(fd),Sl(md),Sl(Od),Sl(kd),Sl(Rd),Sl(Nd),Sl(Dd),Sl($d),Sl(Md),Sl(Ud),Sl(Wd),Sl(Vd),Sl(Qd),Sl(Xd),Sl(Zd),Rl(tl,"ti-brand-slack"),Rl(rl,"ti-brand-discord"),Rl(il,"ti-brand-telegram"),Rl(sl,"ti-brand-teams"),Rl(ll,"ti-brand-slack"),Rl(pl,"ti-brand-discord"),Rl(hl,"ti-brand-telegram"),Rl(fl,"ti-brand-teams"),Rl(ml,"ti-volume-2"),Nl,Tl,Dl];var jl;const $l=Object.fromEntries(Pl.map(e=>[e.kind,e])),Ll=[Ns,Ds,Ts,Rs,Cs,Ss],Ml=[Ii,Ai,Ti,vi,xi,Di,bi],Gl=[Ni,Pi,ji],Ul=[xl,_l,Al],Fl=[Ol,El],Bl=[Ms,Us,Bs,qs,Ks,zs,Js,Zs,td,rd],Hl=[cd,pd],ql=[hd,fd,md,Od,kd,Rd,Nd,Dd,$d,Md,Ud],Wl=[Wd,Vd,Qd],Kl=[Xd,Zd],Vl=[tl,rl,il,sl,ll,pl,hl,fl,ml],zl=[ia,oa,Zi,sa,Ji,Xi,ea,aa,na],Ql=[pa,va,la,ha,wa],Jl={value:Ol,result:El,"core.trigger.manual":Ns,"core.trigger.webhook":Ds,"core.trigger.schedule":Ts,"core.trigger.event":Rs,"core.trigger.form":Cs,"core.trigger.chat":Ss,"core.flow.if":Ii,"core.flow.switch":Ai,"core.utility.map":Pi,"core.flow.delay":Ti,"core.flow.errorBoundary":vi,"core.flow.humanApproval":xi,"core.utility.code":Ni,"core.flow.log":Di,"core.utility.log":ji,"core.flow.break":bi,"core.agent":$s,"core.agent.tool":Ms,"core.agent.toolSelector":Us,"core.agent.hook":Bs,"core.agent.toolDeny":qs,"core.agent.delegationHook":Ks,"core.agent.skill":zs,"core.agent.skillSelector":Js,"core.agent.sandbox":Zs,"core.agent.scorer":td,"core.agent.scorerSelector":rd,"core.agent.memory":cd,"core.agent.memorySelector":pd,"core.agent.embedding":hd,"core.agent.vectorStore":fd,"core.agent.retriever":md,"core.agent.chunking":Od,"core.agent.rerank":kd,"core.agent.chain.qa":Rd,"core.agent.chain.basic":Nd,"core.agent.chain.summarization":Dd,"core.agent.structuredOutputParser":$d,"core.agent.informationExtractor":Md,"core.agent.langchainCode":Ud,"core.agent.inputProcessor":Wd,"core.agent.outputProcessor":Vd,"core.agent.guardrail":Qd,"core.agent.hitl":Xd,"core.agent.trigger.mcp":Zd,"core.agent.trigger.slack":tl,"core.agent.trigger.discord":rl,"core.agent.trigger.telegram":il,"core.agent.trigger.teams":sl,"core.agent.response.slack":ll,"core.agent.response.discord":pl,"core.agent.response.telegram":hl,"core.agent.response.teams":fl,"core.agent.voice":ml,"core.data.set":ia,"core.data.merge":oa,"core.data.filter":Zi,"core.data.splitOut":sa,"core.data.dateTime":Ji,"core.data.dataTable":Xi,"core.data.limit":ea,"core.data.sort":aa,"core.data.renameKeys":na,"core.io.httpRequest":pa,"core.io.respondToWebhook":va,"core.io.extractFromFile":la,"core.io.readPDF":ha,"core.io.readWriteFile":wa,"core.storage.postgres":Da,"core.storage.mySql":Pa,"core.storage.microsoftSql":ja,"core.storage.redis":Ga,"core.storage.s3":Ha,"core.storage.awsS3":qa,"core.storage.googleCloudStorage":Wa,"core.storage.azureStorage":Va,"core.devops.crypto":bs,"core.devops.jwt":vs,"core.devops.executeCommand":Is,"core.devops.ftp":Os,"core.devops.github":hs,"core.devops.gitlab":fs,"core.comms.slack":Qa,"core.comms.telegram":Xa,"core.comms.teams":Za,"core.comms.gmail":ts,"core.comms.emailSend":rs,"core.io.googleSheets":is,"core.io.airtable":ss,"core.io.spreadsheetFile":ls,"core.io.graphql":ps,"core.flow.executeSubWorkflow":Es,"core.trigger.executeWorkflow":ks,"core.loop.foreach":xl,"core.loop.while":_l,"core.loop.until":Al};function Xl(e){return{execute:(t,o)=>e.instantiate({...yi(o.node),...t.parameters,...o.node.state??{}}).execute(t,o)}}function Yl(){const e=[];for(const[t,o]of Object.entries($l)){const r=Jl[t];r&&e.push(gi({manifest:o,executor:Xl(r)}))}return e}function Zl(e,...t){for(const o of Yl())e.register(o,{},...t);return e}class ec{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}}}class tc{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 dr(`Missing required ${o} port '${r.name}'`);if(e&&!this.resolver.resolve(r).validate(t[r.name]))throw new dr(`Invalid value for ${o} port '${r.name}'`)}}}const oc=["node","definition","executor","execute","ports","component"];function rc(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 nc(e,t){const o=[];for(const r of Object.keys(e))oc.includes(r)&&o.push(rc("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 ic(e,t){t.push(...nc(e,"$")),e.inputs.forEach((e,o)=>t.push(...nc(e,`inputs[${o}]`))),e.outputs.forEach((e,o)=>t.push(...nc(e,`outputs[${o}]`)));for(const o of e.nodes)t.push(...nc(o,`nodes[${o.id}]`)),o.loop&&(t.push(...nc(o.loop,`nodes[${o.id}].loop`)),ic(o.loop.body,t));for(const o of e.edges)t.push(...nc(o,`edges[${o.id}]`))}function ac(e,t){const o=[];e.nodes.length>t.maxNodes&&o.push(rc("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(rc("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=sc(e);r>t.maxNestingDepth&&o.push(rc("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 n=Buffer.byteLength(JSON.stringify(e),"utf8");return n>t.maxDocumentBytes&&o.push(rc("document.limit.size","$",`Document serializes to ${n} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,{details:{bytes:n,limit:t.maxDocumentBytes}})),o}function sc(e,t=0){let o=t;for(const r of e.nodes)r.loop?.body&&(o=Math.max(o,sc(r.loop.body,t+1)));return o}async function dc(e,t,...o){const r=[];for(const n of e.nodes)t.has(n.kind,...o)||r.push(rc("node.unknown-kind",`nodes[${n.id}].kind`,`Node '${n.id}' references kind '${n.kind}' which is not registered in the backend catalogue`,{nodeId:n.id,details:{kind:n.kind}})),n.loop?.body&&r.push(...await dc(n.loop.body,t,...o));return r}async function lc(e,t={},...o){const r={..._i,...t.limits},n=[];if(!Yt(e))return n.push(rc("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:n};if(!Et(e))return n.push(rc("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:n};ic(e,n),n.push(...(e=>{const t=[],o=new Set;for(const r of[...e.inputs,...e.outputs])o.has(r.id)?t.push(rc("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(rc("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 n=new Set;for(const o of e.edges)n.has(o.id)?t.push(rc("document.duplicate-edge-id",`edges[${o.id}]`,`Edge '${o.id}' is declared more than once; edge ids must be unique`,{edgeId:o.id})):n.add(o.id);return t})(e)),n.push(...ac(e,r)),An(e,n);try{Bt(e)}catch(e){const t=e instanceof E?e.message:e+"";n.push(rc("document.structure","$",t))}return t.catalogue&&n.push(...await dc(e,t.catalogue,...o)),{valid:0===n.length,issues:n}}class cc{constructor(e,t){this.iteration=e,this.metadata=t}}function pc(e,t,o={}){const r=e?.owner??null;return!r||r===t||(null==t||""===t)&&!0===o.allowAnonymousAccess}function uc(e,t){return(e?.owner??null)===(t??null)}function hc(e,t,o){if(!uc(e,t))throw new L(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function gc(e,t,o){if(!pc(e,t,o))throw new L(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function fc(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>fc(e)).join(",")}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${fc(t[e])}`).join(",")}}`}function yc(e){return ee("sha256").update(fc(e)).digest("hex")}class mc{constructor(e={}){this.events=new Map,this.listeners=new Map,this.limits={...Je,...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=>!Ye(e.type));if(-1===t)break;e.splice(t,1)}}}function bc(e){return new Co({runId:e.runId,workflowId:e.workflowId,...e.ownerUser?{owner:e.ownerUser}:{},status:e.status,...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{},...void 0!==e.result?{result:wc(e.result)}:{},...e.error?{error:wc(e.error)}:{},createdAt:new Date(e.createdAt),...e.startedAt?{startedAt:new Date(e.startedAt)}:{},...e.finishedAt?{finishedAt:new Date(e.finishedAt)}:{}})}function wc(e){if(null!=e)return JSON.parse(JSON.stringify(e))}class vc{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=>bc(e))}release(e){this.runs.delete(e)}}class xc{constructor(e,t={}){this.sequences=new Map,this.chains=new Map,this.store=e,this.limits={...Je,...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()},n=(this.chains.get(t)??Promise.resolve()).then(()=>this.store.append(r));return this.chains.set(t,n.catch(()=>{})),await n,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 Ic{constructor(e,t,o,r={},n={}){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={...Je,...n}}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 n=this.completions.get(e.runId);if(n)return n;const i=this.runExecution({...e},t,o,...r).catch(async t=>{const o=Ac(t);try{await this.emitTerminal({...e},Qe.WORKFLOW_FAILED,o)}catch{}return await this.finalize({...e},"failed",void 0,o,...r)});return this.completions.set(e.runId,i),i}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 n=e.runId;let i,a,s=!1;const d=this.engine.observe({refresh:async t=>{t.runId===n&&(t.error&&(i=t.error),Ye((await this.publisher.publish(this.envelopeOf(e,t))).type)?s=!0:t.type===Qe.WORKFLOW_STARTED&&"validating"===e.status&&(e.status="running",await this.persist(e,...r)))}});this.armTimeout(n);try{if(this.isAborted(n)){const t={name:"GraphRunCancelledError",message:`Graph run '${n}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return i=t,await this.emitTerminal(e,Qe.WORKFLOW_CANCELLED,t),s=!0,await this.finalize(e,"cancelled",void 0,t,...r)}let d,l;e.status="validating",e.startedAt=(new Date).toISOString(),await this.persist(e,...r);try{({document:d,fingerprint:l}=await t(...r)),e.documentFingerprint=l,await this.persist(e,...r)}catch(t){const o=Ac(t);return i=o,s||(await this.emitTerminal(e,Qe.WORKFLOW_FAILED,o),s=!0),await this.finalize(e,"failed",void 0,o,...r)}if(this.isAborted(n)){const t={name:"GraphRunCancelledError",message:`Graph run '${n}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return i=t,s||(await this.emitTerminal(e,Qe.WORKFLOW_CANCELLED,t),s=!0),await this.finalize(e,"cancelled",void 0,t,...r)}try{a=await this.engine.execute(d,o,{runId:n,abortSignal:this.controllers.get(n)?.signal,metadata:{documentFingerprint:l}},...r)}catch(e){i=Ac(e)}const c=this.abortReason(n);let p,u;return"timeout"===c?(p="failed",u=i??{name:"GraphRunTimeoutError",message:`Graph run '${n}' exceeded the configured execution timeout of ${this.limits.executionTimeoutMs}ms`,code:"GRAPH_RUN_TIMEOUT"}):"user"===c?(p="cancelled",u=i):a?.status===Ke.SUCCEEDED?p="succeeded":a?.status===Ke.CANCELLED?(p="cancelled",u=i):(p="failed",u=i??Ac(new ar(a?`Graph run '${n}' failed`:`Graph run '${n}' failed without a result`,"GRAPH_RUN_FAILED",{runId:n}))),s||await this.emitTerminal(e,"succeeded"===p?Qe.WORKFLOW_COMPLETED:"cancelled"===p?Qe.WORKFLOW_CANCELLED:Qe.WORKFLOW_FAILED,u),await this.finalize(e,p,a,u,...r)}finally{d();const e=this.timeouts.get(n);e&&(clearTimeout(e),this.timeouts.delete(n))}}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,...n){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,...n);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:Ot(t.payload)?t.payload:{nonSerializable:!0},error:t.error,parentRunId:t.parentRunId,path:t.path}}}function Ac(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 _c{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 xc(o,r.limits),this.executor=new Ic(e,t,this.publisher,{onRunCompleted:r.onRunCompleted},r.limits),this.options={...r,limits:{...Je,...r.limits}}}get limits(){return this.options.limits}async createRun(e,t,o,...r){this.validateCreateRequest(e);const n=e.workflowId??e.workflow?.id??"";if(!n)throw new E("Graph run request must carry a workflow document with an id or a saved workflowId");if(e.workflowId&&!this.options.documentResolver)throw new E("Graph run requests by workflowId require a document resolver");const i=o??t??"anonymous",a=this.activeByCaller.get(i)??new Set;if(a.size>=this.options.limits.maxConcurrentRuns)throw new E(`Graph run rejected: the configured limit of ${this.options.limits.maxConcurrentRuns} concurrent runs per caller is exhausted`);const s=this.generateRunId(),d={runId:s,workflowId:n,ownerUser:t,status:"queued",createdAt:(new Date).toISOString()};this.executor.begin(s),await this.runStore.saveRun({...d},...r);const l=this.documentProviderFor(e,t);return a.add(s),this.activeByCaller.set(i,a),this.callerKeysByRun.set(s,i),this.executor.schedule(d,l,e.inputs??{},...r).catch(()=>{}).finally(()=>this.finishActiveRun(s)),d}async getRun(e,t,...o){const r=await this.runStore.readRun(e,...o);if(!r)throw new S(`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=>pc({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 S(`No graph run found for runId '${e}'`);return this.assertWriteOwnership(r,t),"succeeded"===(n=r.status)||"failed"===n||"cancelled"===n||(this.executor.abort(e,"user"),r.status="cancelled",r.finishedAt=(new Date).toISOString(),await this.runStore.saveRun({...r},...o)),r;var n}async resumeRun(e,t,o,...r){const n=await this.runStore.readRun(e,...r);if(!n)throw new S(`No graph run found for runId '${e}'`);this.assertWriteOwnership(n,o);const i=this.engine.backend,a=i.resume;if("function"!=typeof a)throw new ar(`Graph execution backend '${i.constructor?.name??"GraphExecutionBackend"}' does not support resume`,"GRAPH_RESUME_UNSUPPORTED_BACKEND",{runId:e});let s;try{s=await a.call(i,e,t,...r)}catch(e){throw(d=e)instanceof ar?new ar(d.message,d.graphCode):d}var d;const l={...s,runId:e,caller:o};return await this.publisher.publish({runId:e,workflowId:n.workflowId,type:Qe.WORKFLOW_RESUMED,payload:l}),l}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 n=await this.createRun(e,t,o,...r);return this.waitForRun(n.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 E("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 E("Graph run request is ambiguous: supply either an unsaved workflow document or a saved workflowId, not both");if(!t&&!o)throw new E("Graph run request must supply either an unsaved workflow document or a saved workflowId");if(t&&!Yt(e.workflow))throw new E("Graph run request carries a payload that is not a canonical GraphWorkflowDocument");if(void 0!==e.inputs&&!Et(e.inputs))throw new E("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 E(`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:yc(t)})}const o=e.workflowId;return async(...e)=>{const r=this.options.documentResolver;if(!r)throw new E("Graph run requests by workflowId require a document resolver");const n=await r.resolve(o,t,...e);return{document:n,fingerprint:yc(n)}}}assertOwnership(e,t){gc({owner:e.ownerUser},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess,resourceKind:"Graph run",resourceId:e.runId})}assertWriteOwnership(e,t){hc({owner:e.ownerUser},t,{resourceKind:"Graph run",resourceId:e.runId})}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new ur("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime",{runtime:typeof globalThis.crypto});return e.randomUUID()}}function Oc(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 Ec(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&Yt(e.document)&&!Yt(e)}function kc(e){return JSON.parse(JSON.stringify(e))}function Sc(e){if(null==e)return 0;let t;try{t=e.getTime()}catch{return 0}return Number.isFinite(t)?t:0}let Rc=class extends z{constructor(e){super(No),this.catalogue=e}get limits(){return{..._i,...Oi.graph.workflows.limits??{}}}get allowAnonymousAccess(){return!0===Oi.graph.workflows.allowAnonymousAccess}async saveDocument(e,t,...o){const{ctx:r,ctxArgs:n}=(await this.logCtx(o,"saveDocument",!0)).for(this.saveDocument);if(!Yt(t))throw new E("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 E(`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 yr(i.issues);const a=Oc(r),s=await this.readExistingForWrite(e,n);s&&this.assertWriteOwnership(e,s,a);const d=new Date;if(s)return s.name=t.name,s.document=kc(t),s.updatedAt=d,this.update(s,...n);const l=new No({workflowId:e,name:t.name,document:kc(t),...a?{owner:a}:{},updatedAt:d});return this.create(l,...n)}async seedDocument(e,t,...o){const{log:r,ctxArgs:n}=(await this.logCtx(o,"seedDocument",!0)).for(this.seedDocument);try{return await this.saveDocument(e,t,...n)}catch(t){if(t instanceof L)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 n;try{n=await this.read(e,...r)}catch{n=null}if(!n)throw new S(`No graph workflow found for workflowId '${e}'`);if(this.assertOwnership(e,n,Oc(o)),n.document)return kc(n.document);throw new S(`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",W.ASC,...o),n=Oc(t);return r.filter(e=>pc(e,n,{allowAnonymousAccess:this.allowAnonymousAccess})).sort((e,t)=>Sc(t.updatedAt)-Sc(e.updatedAt))}async assertAccess(e,...t){const{ctx:o,ctxArgs:r}=(await this.logCtx(t,"assertAccess",!0)).for(this.assertAccess);let n;try{n=await this.read(e,...r)}catch{n=null}if(!n)throw new S(`No graph workflow found for workflowId '${e}'`);return this.assertOwnership(e,n,Oc(o)),n}async validateDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateDocument",!0)).for(this.validateDocument);return await lc(e,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o)}async saveSnapshot(e,t,...o){const{ctx:r,ctxArgs:n}=(await this.logCtx(o,"saveSnapshot",!0)).for(this.saveSnapshot);if(!Et(t))throw new E("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(!Ec(t))throw new E("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=Oc(r),a=await this.readExistingForWrite(e,n);a&&this.assertWriteOwnership(e,a,i);const s=new Date;if(a)return a.snapshot=t,await this.applyCanonicalWrapper(a,t,r),a.updatedAt=s,this.update(a,...n);const d=new No({workflowId:e,snapshot:t,...i?{owner:i}:{},updatedAt:s});return await this.applyCanonicalWrapper(d,t,r),this.create(d,...n)}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,Oc(o)),t}catch{return null}}async readExistingForWrite(e,t){try{return await this.read(e,...t)}catch(e){if(e instanceof S)return null;throw e}}assertOwnership(e,t,o){gc(t??null,o??null,{allowAnonymousAccess:this.allowAnonymousAccess,resourceKind:"Graph workflow",resourceId:e})}assertWriteOwnership(e,t,o){hc(t??null,o??null,{resourceKind:"Graph workflow",resourceId:e})}async applyCanonicalWrapper(e,t,o){if(!Ec(t))return;if(t.document.id!==e.workflowId)throw new E(`Document id '${t.document.id}' does not match the workflow id '${e.workflowId}' from the request path`);const r=await lc(t.document,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o);if(!r.valid)throw new yr(r.issues);e.document=kc(t.document),e.name=t.document.name}};Rc=R([B(No),C("design:paramtypes",[Function])],Rc);let Cc=class extends z{constructor(){super(Co)}async saveRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"saveRun",!0)).for(this.saveRun),r=bc(e);let n;try{n=await super.read(e.runId,...o)}catch{n=null}if(n)return n.workflowId=r.workflowId,n.owner=r.owner,n.status=r.status,n.documentFingerprint=r.documentFingerprint,n.result=r.result,n.error=r.error,n.startedAt=r.startedAt,n.finishedAt=r.finishedAt,void await this.update(n,...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)}};Cc=R([B(Co),C("design:paramtypes",[])],Cc);let Nc=class extends z{constructor(){super(To)}async upsertManifest(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"upsertManifest",!0)).for(this.upsertManifest),r=(e=>new To({kind:e.kind,name:e.display?.name,category:e.display?.category,group:e.display?.group,description:e.display?.description,manifest:io(no(e))}))(e);let n;try{n=await this.read(r.kind,...o)}catch{n=void 0}return n?(n.name=r.name,n.category=r.category,n.group=r.group,n.description=r.description,n.manifest=r.manifest,await this.update(n,...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),n=[];for(const e of r)n.push(await this.upsertManifest(e,...o));return n}async listNodes(...e){const{ctxArgs:t}=(await this.logCtx(e,"listNodes",!0)).for(this.listNodes);return await this.listBy("kind",W.ASC,...t)}async listManifests(...e){return(await this.listNodes(...e)).map(e=>(e=>{if(!e.manifest)throw new E(`Graph node row '${e.kind}' has no manifest to convert`);return io(no(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 S(`Graph node kind '${e}' is not registered`)}}};Nc=R([B(To),C("design:paramtypes",[])],Nc);class Tc{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:Ke.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}}}export{Nd as AgentBasicChainNode,Od as AgentChunkingNode,Ks as AgentDelegationHookNode,hd as AgentEmbeddingNode,Qd as AgentGuardrailNode,Xd as AgentHitlNode,Bs as AgentHookNode,Md as AgentInformationExtractorNode,Wd as AgentInputProcessorNode,Ud as AgentLangChainCodeNode,cd as AgentMemoryNode,pd as AgentMemorySelectorNode,$s as AgentNode,Vd as AgentOutputProcessorNode,Rd as AgentQaChainNode,kd as AgentRerankNode,md as AgentRetrieverNode,Zs as AgentSandboxNode,td as AgentScorerNode,rd as AgentScorerSelectorNode,zs as AgentSkillNode,Js as AgentSkillSelectorNode,$d as AgentStructuredOutputParserNode,Dd as AgentSummarizationChainNode,qs as AgentToolDenyNode,Ms as AgentToolNode,Us as AgentToolSelectorNode,fd as AgentVectorStoreNode,ml as AgentVoiceNode,ss as AirtableNode,qa as AwsS3StorageNode,Va as AzureStorageNode,bi as BreakFlowNode,Ss as ChatTriggerNode,Ci as CodeInputSchema,Ni as CodeNode,qr as ConditionExpressionEvaluator,bs as CryptoNode,_i as DEFAULT_GRAPH_WORKFLOW_DOCUMENT_LIMITS,Cn as DEFAULT_GRAPH_WORKFLOW_VALIDATION_LIMITS,mn as DEFAULT_PINNING_METADATA,vd as DEFAULT_RAG_CHUNK_OVERLAP,wd as DEFAULT_RAG_CHUNK_SIZE,Xi as DataTableNode,Ji as DateTimeNode,Ti as DelayFlowNode,pl as DiscordChannelResponseNode,rl as DiscordChannelTriggerNode,rs as EmailSendNode,vi as ErrorBoundaryFlowNode,Rs as EventTriggerNode,Is as ExecuteCommandNode,Es as ExecuteSubWorkflowNode,ks as ExecuteWorkflowTriggerNode,la as ExtractFromFileNode,Zi as FilterNode,Cs as FormTriggerNode,Os as FtpNode,Td as GRAPH_AGENT_BASIC_CHAIN_NODES,Ed as GRAPH_AGENT_CHUNKING_NODES,Vs as GRAPH_AGENT_DELEGATION_HOOK_NODES,ul as GRAPH_AGENT_DISCORD_RESPONSE_NODES,nl as GRAPH_AGENT_DISCORD_TRIGGER_NODES,gd as GRAPH_AGENT_EMBEDDING_NODES,Bl as GRAPH_AGENT_FAMILY_NODES,Jd as GRAPH_AGENT_GUARDRAIL_NODES,Yd as GRAPH_AGENT_HITL_NODES,Hs as GRAPH_AGENT_HOOK_NODES,Gd as GRAPH_AGENT_INFORMATION_EXTRACTOR_NODES,Kd as GRAPH_AGENT_INPUT_PROCESSOR_NODES,Fd as GRAPH_AGENT_LANGCHAIN_CODE_NODES,Kl as GRAPH_AGENT_M5_NODES,Vl as GRAPH_AGENT_M6_NODES,el as GRAPH_AGENT_MCP_TRIGGER_NODES,Hl as GRAPH_AGENT_MEMORY_NODES,ud as GRAPH_AGENT_MEMORY_SELECTOR_NODES,Ls as GRAPH_AGENT_NODES,zd as GRAPH_AGENT_OUTPUT_PROCESSOR_NODES,Wl as GRAPH_AGENT_PROCESSOR_NODES,Cd as GRAPH_AGENT_QA_CHAIN_NODES,ql as GRAPH_AGENT_RAG_NODES,Sd as GRAPH_AGENT_RERANK_NODES,bd as GRAPH_AGENT_RETRIEVER_NODES,ed as GRAPH_AGENT_SANDBOX_NODES,od as GRAPH_AGENT_SCORER_NODES,nd as GRAPH_AGENT_SCORER_SELECTOR_NODES,Qs as GRAPH_AGENT_SKILL_NODES,Xs as GRAPH_AGENT_SKILL_SELECTOR_NODES,cl as GRAPH_AGENT_SLACK_RESPONSE_NODES,ol as GRAPH_AGENT_SLACK_TRIGGER_NODES,Ld as GRAPH_AGENT_STRUCTURED_OUTPUT_PARSER_NODES,Pd as GRAPH_AGENT_SUMMARIZATION_CHAIN_NODES,yl as GRAPH_AGENT_TEAMS_RESPONSE_NODES,dl as GRAPH_AGENT_TEAMS_TRIGGER_NODES,gl as GRAPH_AGENT_TELEGRAM_RESPONSE_NODES,al as GRAPH_AGENT_TELEGRAM_TRIGGER_NODES,Ws as GRAPH_AGENT_TOOL_DENY_NODES,Gs as GRAPH_AGENT_TOOL_NODES,Fs as GRAPH_AGENT_TOOL_SELECTOR_NODES,yd as GRAPH_AGENT_VECTOR_STORE_NODES,bl as GRAPH_AGENT_VOICE_NODES,Fl as GRAPH_BOUNDARY_NODES,Jl as GRAPH_BUILT_IN_NODE_CLASSES_BY_KIND,Pl as GRAPH_BUILT_IN_NODE_MANIFESTS,$l as GRAPH_BUILT_IN_NODE_MANIFESTS_BY_KIND,Ri as GRAPH_CODE_DEFAULT_LANGUAGE,Ei as GRAPH_CODE_DEFAULT_TIMEOUT_MS,Si as GRAPH_CODE_LANGUAGES,qo as GRAPH_CODE_MAX_TIMEOUT_MS,zl as GRAPH_DATA_NODES,tr as GRAPH_DATA_TABLE_MAX_LIST_ROWS,Zo as GRAPH_DATA_TABLE_MAX_ROWS,er as GRAPH_DATA_TABLE_MAX_ROW_BYTES,Go as GRAPH_DEFAULT_CONCURRENCY,Fo as GRAPH_DEFAULT_MAX_FOREACH_ITERATIONS,Uo as GRAPH_DEFAULT_MAX_LOOP_ITERATIONS,Nn as GRAPH_DOCUMENT_FORBIDDEN_FIELD_KEYS,Qo as GRAPH_EXECUTE_COMMAND_DEFAULT_TIMEOUT_MS,Jo as GRAPH_EXECUTE_COMMAND_MAX_OUTPUT_BYTES,zo as GRAPH_EXECUTE_COMMAND_MAX_TIMEOUT_MS,Ml as GRAPH_FLOW_CONTROL_NODES,Vo as GRAPH_HTTP_MAX_REDIRECTS,Ko as GRAPH_HTTP_MAX_RESPONSE_BYTES,Wo as GRAPH_HTTP_MAX_TIMEOUT_MS,Ql as GRAPH_IO_NODES,Lo as GRAPH_LOCAL_EXECUTION_BACKEND,Mo as GRAPH_LOCAL_UNSUPPORTED_NODE_KIND,ir as GRAPH_LOOP_KIND,Ul as GRAPH_LOOP_NODES,Yo as GRAPH_MAX_CHILD_RUNS,Ho as GRAPH_MAX_FOREACH_ITERATIONS,Bo as GRAPH_MAX_LOOP_ITERATIONS,Xo as GRAPH_MAX_SUB_WORKFLOW_DEPTH,or as GRAPH_PINNING_METADATA_KEY,sn as GRAPH_PLAIN_SECRET_KEYS,Ll as GRAPH_TRIGGER_NODES,Gl as GRAPH_UTILITY_NODES,$o as GRAPH_WORKFLOW_BOUNDARY,oc as GRAPH_WORKFLOW_FORBIDDEN_FIELD_KEYS,hs as GithubNode,fs as GitlabNode,ts as GmailNode,Wa as GoogleCloudStorageNode,is as GoogleSheetsNode,Dr as GraphAuthValidator,gr as GraphBreakSignal,Il as GraphConditionEvaluator,nr as GraphConditionType,On as GraphConnectionPolicyValidator,Sn as GraphConnectionValidationError,Rn as GraphCredentialAuthorizationError,En as GraphCredentialReferenceValidator,sr as GraphCycleError,Ln as GraphDataTableModel,qn as GraphDataTableRepository,kn as GraphDocumentValidationError,_n as GraphEdgeInstanceValidator,Fr as GraphEngineEventSink,Oi as GraphEnvironment,Hr as GraphExecutionBackendRegistry,Mr as GraphExecutionContext,Qn as GraphExecutionEngine,ar as GraphExecutionError,mr as GraphExecutionEventEmitter,br as GraphExecutionEventFactory,Gr as GraphExecutionFrame,jn as GraphExecutionPlanner,Tc as GraphExecutionSnapshotMapper,xl as GraphForeachLoopNode,dr as GraphInputError,Ol as GraphInputValueNode,cc as GraphLoopExecutionContext,lr as GraphLoopLimitError,mi as GraphNode,pi as GraphNodeCatalogue,Pr as GraphNodeCredentialResolver,ui as GraphNodeExecutorRegistry,hi as GraphNodeExecutorResolver,In as GraphNodeInstanceValidator,si as GraphNodeManifestResolver,ei as GraphNodeMethodNotFoundError,ti as GraphNodeMethodRegistry,Nc as GraphNodeModelService,Zn as GraphNodeNotFoundError,Yn as GraphNodeRegistrationError,El as GraphOutputValueNode,dn as GraphParameterValidator,vn as GraphPinningDependencyResolver,cr as GraphPinningError,wn as GraphPinningPolicy,yn as GraphPinningService,rr as GraphPinningStrategy,pr as GraphPortError,ec as GraphPortSchemaResolver,fr as GraphRunCancelledError,xc as GraphRunEventPublisher,Ic as GraphRunExecutor,Cc as GraphRunModelService,_c as GraphRunService,ur as GraphStoreError,fn as GraphTopology,hr as GraphTopologyError,Al as GraphUntilLoopNode,ln as GraphValueModel,hn as GraphValueRepository,tc as GraphValueValidator,$n as GraphWebhookResponseRegistry,_l as GraphWhileLoopNode,yr as GraphWorkflowDocumentRejectedError,Pn as GraphWorkflowDocumentValidator,Rc as GraphWorkflowService,ps as GraphqlNode,pa as HttpRequestNode,xi as HumanApprovalFlowNode,Ii as IfFlowNode,mc as InMemoryGraphRunEventStore,vc as InMemoryGraphRunStore,Xn as IsolatedVmCodeSandboxEvaluator,vs as JwtNode,ea as LimitNode,xn as LocalGraphExecutionBackend,Di as LogFlowNode,Ps as MASTRA_AGENT_ZONE,js as MASTRA_AGENT_ZONES,qd as MASTRA_GUARDRAIL_TYPES,Bd as MASTRA_INPUT_PROCESSOR_TYPES,Hd as MASTRA_OUTPUT_PROCESSOR_TYPES,Ns as ManualTriggerNode,Pi as MapNode,Zd as McpServerTriggerNode,oa as MergeNode,ja as MicrosoftSqlNode,Pa as MySqlNode,Da as PostgresNode,ha as ReadPDFNode,wa as ReadWriteFileNode,Ga as RedisNode,na as RenameKeysNode,va as RespondToWebhookNode,Ba as S3Node,Ha as S3StorageNode,Ts as ScheduleTriggerNode,ia as SetNode,ll as SlackChannelResponseNode,tl as SlackChannelTriggerNode,Qa as SlackNode,aa as SortNode,sa as SplitOutNode,ls as SpreadsheetFileNode,Ai as SwitchFlowNode,fl as TeamsChannelResponseNode,sl as TeamsChannelTriggerNode,Za as TeamsNode,hl as TelegramChannelResponseNode,il as TelegramChannelTriggerNode,Xa as TelegramNode,ji as UtilityLogNode,Ds as WebhookTriggerNode,gc as assertGraphResourceOwnership,hc as assertGraphResourceWriteOwnership,Ur as buildGraphExecutionResult,Yl as builtInGraphNodeRegistrations,pc as canAccessGraphResource,uc as canAccessGraphResourcePayload,on as checkGraphValueAgainstSchema,Ad as chunkText,ki as clampGraphCodeTimeoutMs,Ys as clampSandboxTimeoutMs,An as collectLooseNodeIssues,vr as composeGraphNamespace,Wn as createGraphDataTableRepository,gn as createGraphValueRepository,fi as declaredGraphNodeMethods,wr as decomposeGraphNamespace,Nr as decomposeGraphNamespaces,gi as defineGraphNode,Zr as detectGraphCodeModeSurfaces,Vr as evaluateCodeCondition,Qr as evaluateCondition,zr as evaluateConditionSync,_d as extractChunkTexts,Or as findMalformedGraphNamespaces,_r as findUngrantedGraphNamespaces,Rr as graphAuthDataFromRecord,Cr as graphAuthDataOf,en as graphDocumentHasCodeMode,Ar as graphNamespaceCovers,Ir as graphNamespacePartsOf,yi as graphNodeConfig,Er as graphRolesFromNamespaces,yc as graphRunDocumentFingerprint,Oc as graphWorkflowOwnerOf,Wr as isCodeCondition,Kr as isConditionExpression,nn as isGraphCredentialReferenceLike,xr as isGraphNamespaceCacheEntryValid,Tn as isGraphResolvedWorkflow,bn as isPinnable,Tr as mergeGraphAuthData,Zl as registerBuiltInGraphNodes,Br as resolveGraphBackendCapabilities,ii as resolveGraphDynamicPorts,ai as resolveGraphNodeManifest,jr as resolveNodeCredential,cn as serializeGraphValueKey,zn as stripFacadeOwnedBackendConfig,lc as validateGraphWorkflowDocumentAtBoundary};
|
|
2
2
|
//# sourceMappingURL=as-graph.js.map
|