@codemation/core 0.0.1
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 +30 -0
- package/dist/EngineExecutionLimitsPolicy-8MEFIYx1.d.cts +160 -0
- package/dist/EngineExecutionLimitsPolicy-BWAXW9D6.d.cts +160 -0
- package/dist/EngineExecutionLimitsPolicy-Bp8PS1Ss.d.cts +159 -0
- package/dist/EngineExecutionLimitsPolicy-CLxcN-D2.d.ts +159 -0
- package/dist/EngineExecutionLimitsPolicy-DZXuix51.d.ts +160 -0
- package/dist/EngineExecutionLimitsPolicy-Gfz6ngFd.d.ts +160 -0
- package/dist/EngineFactory-CBnntY3J.cjs +3152 -0
- package/dist/EngineFactory-CBnntY3J.cjs.map +1 -0
- package/dist/EngineFactory-Cwn3R2YA.js +3087 -0
- package/dist/EngineFactory-Cwn3R2YA.js.map +1 -0
- package/dist/EngineFactory-DWCnNocp.js +3063 -0
- package/dist/EngineFactory-DWCnNocp.js.map +1 -0
- package/dist/EngineFactory-DhPFou4p.cjs +3188 -0
- package/dist/EngineFactory-DhPFou4p.cjs.map +1 -0
- package/dist/EngineFactory-l_9xmBtv.cjs +3190 -0
- package/dist/EngineFactory-l_9xmBtv.cjs.map +1 -0
- package/dist/EngineFactory-w-aOWuqh.js +3089 -0
- package/dist/EngineFactory-w-aOWuqh.js.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-1J9MHN_I.js +18 -0
- package/dist/InMemoryLiveWorkflowRepository-1J9MHN_I.js.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-BTzHpQ6e.cjs +151 -0
- package/dist/InMemoryLiveWorkflowRepository-BTzHpQ6e.cjs.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-BoLNnVLg.js +139 -0
- package/dist/InMemoryLiveWorkflowRepository-BoLNnVLg.js.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-CULNqv96.d.ts +1300 -0
- package/dist/InMemoryLiveWorkflowRepository-D6eiiXxF.d.cts +1168 -0
- package/dist/InMemoryLiveWorkflowRepository-D7l8cjdZ.d.cts +1130 -0
- package/dist/InMemoryLiveWorkflowRepository-DL7LmC9S.d.ts +1340 -0
- package/dist/InMemoryLiveWorkflowRepository-jnv-OnOP.d.ts +1300 -0
- package/dist/InMemoryLiveWorkflowRepository-xny1_Z6i.cjs +24 -0
- package/dist/InMemoryLiveWorkflowRepository-xny1_Z6i.cjs.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-xr7b4kvi.d.ts +1338 -0
- package/dist/InMemoryWorkflowCatalog-BIdFpwbK.d.ts +1205 -0
- package/dist/InMemoryWorkflowCatalog-BW00_3N3.d.cts +12 -0
- package/dist/InMemoryWorkflowCatalog-BiYHGoPw.cjs +24 -0
- package/dist/InMemoryWorkflowCatalog-BiYHGoPw.cjs.map +1 -0
- package/dist/InMemoryWorkflowCatalog-BrG0ApMO.d.cts +1115 -0
- package/dist/InMemoryWorkflowCatalog-BzrAr--Y.js +139 -0
- package/dist/InMemoryWorkflowCatalog-BzrAr--Y.js.map +1 -0
- package/dist/InMemoryWorkflowCatalog-C-EJlJ7y.d.cts +1120 -0
- package/dist/InMemoryWorkflowCatalog-C4482bpw.cjs +24 -0
- package/dist/InMemoryWorkflowCatalog-C4482bpw.cjs.map +1 -0
- package/dist/InMemoryWorkflowCatalog-CZ0kZpOv.d.ts +1289 -0
- package/dist/InMemoryWorkflowCatalog-C_ACeLyW.d.cts +1119 -0
- package/dist/InMemoryWorkflowCatalog-CiHWIu5E.d.cts +12 -0
- package/dist/InMemoryWorkflowCatalog-CkH7gkya.js +18 -0
- package/dist/InMemoryWorkflowCatalog-CkH7gkya.js.map +1 -0
- package/dist/InMemoryWorkflowCatalog-CnpZVJM9.d.ts +1205 -0
- package/dist/InMemoryWorkflowCatalog-Cu68S8YR.js +18 -0
- package/dist/InMemoryWorkflowCatalog-Cu68S8YR.js.map +1 -0
- package/dist/InMemoryWorkflowCatalog-D2w9nMj2.cjs +151 -0
- package/dist/InMemoryWorkflowCatalog-D2w9nMj2.cjs.map +1 -0
- package/dist/InMemoryWorkflowCatalog-D5eMxEf7.js +18 -0
- package/dist/InMemoryWorkflowCatalog-D5eMxEf7.js.map +1 -0
- package/dist/InMemoryWorkflowCatalog-D5nCp2yZ.d.ts +1267 -0
- package/dist/InMemoryWorkflowCatalog-DIq0bjqN.d.ts +12 -0
- package/dist/InMemoryWorkflowCatalog-DLgaEaw_.d.ts +1288 -0
- package/dist/InMemoryWorkflowCatalog-DNBFdK-x.d.cts +1120 -0
- package/dist/InMemoryWorkflowCatalog-DQBkCzb7.cjs +24 -0
- package/dist/InMemoryWorkflowCatalog-DQBkCzb7.cjs.map +1 -0
- package/dist/InMemoryWorkflowCatalog-DS4-eX6i.d.cts +1118 -0
- package/dist/InMemoryWorkflowCatalog-DdVfy8MY.d.ts +12 -0
- package/dist/InMemoryWorkflowCatalog-DeVZu3g8.d.ts +12 -0
- package/dist/InMemoryWorkflowCatalog-GxkQjvt5.d.ts +1200 -0
- package/dist/InMemoryWorkflowCatalog-qaVRn1Lc.d.cts +1115 -0
- package/dist/InMemoryWorkflowCatalog-z1aIT4TC.d.cts +12 -0
- package/dist/InMemoryWorkflowRegistry-BBuOovLL.d.ts +1007 -0
- package/dist/InMemoryWorkflowRegistry-BIFnSl3k.d.ts +1201 -0
- package/dist/InMemoryWorkflowRegistry-BnGilthz.d.ts +1137 -0
- package/dist/InMemoryWorkflowRegistry-CEp5I8No.d.ts +1146 -0
- package/dist/InMemoryWorkflowRegistry-CHyMB9jW.d.cts +976 -0
- package/dist/InMemoryWorkflowRegistry-CUN7K86m.d.cts +1061 -0
- package/dist/InMemoryWorkflowRegistry-CVfHyELh.d.cts +971 -0
- package/dist/InMemoryWorkflowRegistry-CXXJrwAr.d.cts +1052 -0
- package/dist/InMemoryWorkflowRegistry-DDGfPTJy.d.ts +1013 -0
- package/dist/InMemoryWorkflowRegistry-DnYSOoT5.d.ts +1120 -0
- package/dist/InMemoryWorkflowRegistry-Dp5GiFF2.d.cts +1035 -0
- package/dist/InMemoryWorkflowRegistry-DypDBeOw.d.cts +1116 -0
- package/dist/InMemoryWorkflowRegistry-SzwJCAxT.d.ts +1012 -0
- package/dist/InMemoryWorkflowRegistry-jupvqyGc.d.cts +977 -0
- package/dist/InMemoryWorkflowRegistry-rAdKVWYT.d.ts +1117 -0
- package/dist/InProcessRetryRunner-BBNPkXjy.d.cts +292 -0
- package/dist/PersistedWorkflowSnapshotFactory-7RkOL3Kg.d.ts +14 -0
- package/dist/PersistedWorkflowSnapshotFactory-BmANa46W.cjs +141 -0
- package/dist/PersistedWorkflowSnapshotFactory-BmANa46W.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Bwb_etSt.js +118 -0
- package/dist/PersistedWorkflowSnapshotFactory-Bwb_etSt.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-CRkKGNV6.js +123 -0
- package/dist/PersistedWorkflowSnapshotFactory-CRkKGNV6.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-CZolnGy5.js +101 -0
- package/dist/PersistedWorkflowSnapshotFactory-CZolnGy5.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Ca_oysOv.cjs +131 -0
- package/dist/PersistedWorkflowSnapshotFactory-Ca_oysOv.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-CqIcShnX.js +103 -0
- package/dist/PersistedWorkflowSnapshotFactory-CqIcShnX.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-D-tBk4_G.js +119 -0
- package/dist/PersistedWorkflowSnapshotFactory-D-tBk4_G.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-D4cXl2e2.cjs +131 -0
- package/dist/PersistedWorkflowSnapshotFactory-D4cXl2e2.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-DINoP12r.cjs +131 -0
- package/dist/PersistedWorkflowSnapshotFactory-DINoP12r.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-DJAwSuHU.js +103 -0
- package/dist/PersistedWorkflowSnapshotFactory-DJAwSuHU.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-DSUjVCcf.cjs +131 -0
- package/dist/PersistedWorkflowSnapshotFactory-DSUjVCcf.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-DdHuhkDb.cjs +107 -0
- package/dist/PersistedWorkflowSnapshotFactory-DdHuhkDb.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Dqc6NHis.js +119 -0
- package/dist/PersistedWorkflowSnapshotFactory-Dqc6NHis.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Dxa2dSrw.cjs +130 -0
- package/dist/PersistedWorkflowSnapshotFactory-Dxa2dSrw.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Ep79Ah1G.js +123 -0
- package/dist/PersistedWorkflowSnapshotFactory-Ep79Ah1G.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-GyLfRuiJ.js +119 -0
- package/dist/PersistedWorkflowSnapshotFactory-GyLfRuiJ.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-HTpBsBzn.js +102 -0
- package/dist/PersistedWorkflowSnapshotFactory-HTpBsBzn.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-LVmaaf3t.cjs +141 -0
- package/dist/PersistedWorkflowSnapshotFactory-LVmaaf3t.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-PZCpo2ZS.js +119 -0
- package/dist/PersistedWorkflowSnapshotFactory-PZCpo2ZS.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-UjQ1SJev.cjs +109 -0
- package/dist/PersistedWorkflowSnapshotFactory-UjQ1SJev.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Y8kCrhcy.cjs +109 -0
- package/dist/PersistedWorkflowSnapshotFactory-Y8kCrhcy.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Z_nB-fmB.cjs +108 -0
- package/dist/PersistedWorkflowSnapshotFactory-Z_nB-fmB.cjs.map +1 -0
- package/dist/RunIntentService-1EE6N8ZL.cjs +963 -0
- package/dist/RunIntentService-1EE6N8ZL.cjs.map +1 -0
- package/dist/RunIntentService-2ivFmNQh.cjs +3462 -0
- package/dist/RunIntentService-2ivFmNQh.cjs.map +1 -0
- package/dist/RunIntentService-B0sUL5q-.js +761 -0
- package/dist/RunIntentService-B0sUL5q-.js.map +1 -0
- package/dist/RunIntentService-BFVbsOcg.js +3131 -0
- package/dist/RunIntentService-BFVbsOcg.js.map +1 -0
- package/dist/RunIntentService-BsBOwpVN.cjs +1051 -0
- package/dist/RunIntentService-BsBOwpVN.cjs.map +1 -0
- package/dist/RunIntentService-CSk3ETyn.js +858 -0
- package/dist/RunIntentService-CSk3ETyn.js.map +1 -0
- package/dist/RunIntentService-Ckn3u3tA.d.cts +326 -0
- package/dist/RunIntentService-DEo6GTTo.d.cts +289 -0
- package/dist/RunIntentService-DKrGtL0B.js +782 -0
- package/dist/RunIntentService-DKrGtL0B.js.map +1 -0
- package/dist/RunIntentService-DNOJc1R7.cjs +942 -0
- package/dist/RunIntentService-DNOJc1R7.cjs.map +1 -0
- package/dist/RunIntentService-Dq3pV53j.d.cts +289 -0
- package/dist/RunIntentService-NKobsfMQ.d.cts +274 -0
- package/dist/WorkflowSnapshotCodec-C3fuuS_R.d.cts +22 -0
- package/dist/WorkflowSnapshotCodec-CUudUo6f.js +123 -0
- package/dist/WorkflowSnapshotCodec-CUudUo6f.js.map +1 -0
- package/dist/WorkflowSnapshotCodec-CuCPQZTc.cjs +129 -0
- package/dist/WorkflowSnapshotCodec-CuCPQZTc.cjs.map +1 -0
- package/dist/WorkflowSnapshotCodec-DLiXQNvV.d.cts +22 -0
- package/dist/WorkflowSnapshotCodec-DNtdrZ7l.d.cts +22 -0
- package/dist/WorkflowSnapshotCodec-DTdWkoW_.d.cts +22 -0
- package/dist/bootstrap/index.cjs +1028 -0
- package/dist/bootstrap/index.cjs.map +1 -0
- package/dist/bootstrap/index.d.cts +311 -0
- package/dist/bootstrap/index.d.ts +83 -0
- package/dist/bootstrap/index.js +994 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/credentialTypes-B5h3dI7r.d.cts +1107 -0
- package/dist/credentialTypes-B9okPCVo.d.cts +963 -0
- package/dist/credentialTypes-BFL70rgZ.d.cts +964 -0
- package/dist/credentialTypes-BGkh1O07.d.ts +1010 -0
- package/dist/credentialTypes-BNLi4Q7u.d.ts +1030 -0
- package/dist/credentialTypes-CeSoZGj3.d.cts +994 -0
- package/dist/credentialTypes-CpHc32Ig.d.cts +984 -0
- package/dist/credentialTypes-D0m7MQQl.d.cts +1107 -0
- package/dist/credentialTypes-D4nL2sUd.d.ts +1000 -0
- package/dist/credentialTypes-DBYK2Qbu.d.ts +999 -0
- package/dist/credentialTypes-DMJVy0r1.d.ts +1000 -0
- package/dist/credentialTypes-DhUAjYQp.d.ts +1020 -0
- package/dist/credentialTypes-gGITj5KL.d.cts +964 -0
- package/dist/credentialTypes-r3KVBJBE.d.cts +974 -0
- package/dist/diTokens-ClO27tjK.cjs +34 -0
- package/dist/diTokens-ClO27tjK.cjs.map +1 -0
- package/dist/diTokens-CoHBkwG6.js +28 -0
- package/dist/diTokens-CoHBkwG6.js.map +1 -0
- package/dist/index-6Doxmfnd.d.ts +857 -0
- package/dist/index-9g6Pfe9Z.d.ts +689 -0
- package/dist/index-AZ72Ej-K.d.ts +920 -0
- package/dist/index-BEk9V-q-.d.ts +667 -0
- package/dist/index-Bjt7_7oS.d.ts +1192 -0
- package/dist/index-CFGxsYXy.d.ts +708 -0
- package/dist/index-C_u8xFgn.d.ts +690 -0
- package/dist/index-CpbfsvOJ.d.ts +1192 -0
- package/dist/index-CsReNJN_.d.ts +859 -0
- package/dist/index-D5iNnXaW.d.ts +667 -0
- package/dist/index-DD_Eft1q.d.ts +708 -0
- package/dist/index-DiSYUe0G.d.ts +1192 -0
- package/dist/index-gIcH60sp.d.ts +674 -0
- package/dist/index.cjs +520 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +345 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +412 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime-BIvd-1JA.cjs +4112 -0
- package/dist/runtime-BIvd-1JA.cjs.map +1 -0
- package/dist/runtime-D3eWKSQK.cjs +3986 -0
- package/dist/runtime-D3eWKSQK.cjs.map +1 -0
- package/dist/runtime-Dvp4xAjg.js +3799 -0
- package/dist/runtime-Dvp4xAjg.js.map +1 -0
- package/dist/runtime-vc76SSAa.js +3685 -0
- package/dist/runtime-vc76SSAa.js.map +1 -0
- package/dist/runtimeTypes-BK0b8SaG.d.cts +884 -0
- package/dist/runtimeTypes-CoYZkYQq.d.cts +851 -0
- package/dist/runtimeTypes-D-Pm0Uas.d.cts +849 -0
- package/dist/testing.cjs +18 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +19 -0
- package/dist/testing.d.ts +18 -0
- package/dist/testing.js +16 -0
- package/dist/testing.js.map +1 -0
- package/dist/types-Cb5UK7Y6.d.ts +857 -0
- package/package.json +66 -0
- package/src/ai/AiHost.ts +115 -0
- package/src/binaries/DefaultExecutionBinaryServiceFactory.ts +37 -0
- package/src/binaries/DefaultNodeBinaryAttachmentServiceFactory.ts +120 -0
- package/src/binaries/UnavailableBinaryStorage.ts +19 -0
- package/src/binaries/index.ts +2 -0
- package/src/bootstrap/index.ts +46 -0
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +180 -0
- package/src/bootstrap/runtime/EngineRuntimeRegistration.types.ts +43 -0
- package/src/bootstrap/runtime/index.ts +6 -0
- package/src/browser.ts +8 -0
- package/src/contracts/Clock.ts +10 -0
- package/src/contracts/ExpRetryPolicy.ts +23 -0
- package/src/contracts/NoRetryPolicy.ts +5 -0
- package/src/contracts/RetryPolicy.ts +23 -0
- package/src/contracts/credentialTypes.ts +194 -0
- package/src/contracts/index.ts +6 -0
- package/src/contracts/retryPolicySpec.types.ts +30 -0
- package/src/contracts/runFinishedAtFactory.ts +19 -0
- package/src/contracts/runTypes.ts +314 -0
- package/src/contracts/runtimeTypes.ts +373 -0
- package/src/contracts/webhookTypes.ts +49 -0
- package/src/contracts/workflowActivationPolicy.ts +16 -0
- package/src/contracts/workflowTypes.ts +280 -0
- package/src/di/CoreTokens.ts +60 -0
- package/src/di/index.ts +24 -0
- package/src/events/EventPublishingWorkflowExecutionRepository.ts +67 -0
- package/src/events/InMemoryRunEventBusRegistry.ts +37 -0
- package/src/events/InMemoryRunEventSubscription.ts +9 -0
- package/src/events/NodeEventPublisher.ts +22 -0
- package/src/events/index.ts +4 -0
- package/src/events/runEvents.ts +54 -0
- package/src/execution/ActivationEnqueueService.ts +125 -0
- package/src/execution/CredentialResolverFactory.ts +39 -0
- package/src/execution/DefaultAsyncSleeper.ts +9 -0
- package/src/execution/DefaultExecutionContextFactory.ts +48 -0
- package/src/execution/InProcessRetryRunner.ts +115 -0
- package/src/execution/InProcessRetryRunnerFactory.ts +8 -0
- package/src/execution/NodeActivationRequestComposer.ts +113 -0
- package/src/execution/NodeExecutionSnapshotFactory.ts +152 -0
- package/src/execution/NodeExecutor.ts +43 -0
- package/src/execution/NodeExecutorFactory.ts +10 -0
- package/src/execution/NodeInputsByPortFactory.ts +14 -0
- package/src/execution/NodeInstanceFactory.ts +32 -0
- package/src/execution/NodeInstanceFactoryFactory.ts +9 -0
- package/src/execution/NodeRunStateWriter.ts +185 -0
- package/src/execution/NodeRunStateWriterFactory.ts +29 -0
- package/src/execution/PersistedRunStateTerminalBuilder.ts +25 -0
- package/src/execution/RunStateSemantics.ts +158 -0
- package/src/execution/WorkflowRunExecutionContextFactory.ts +45 -0
- package/src/execution/asyncSleeper.types.ts +3 -0
- package/src/execution/index.ts +26 -0
- package/src/index.ts +18 -0
- package/src/orchestration/Engine.ts +229 -0
- package/src/orchestration/EngineWaiters.ts +37 -0
- package/src/orchestration/RunContinuationService.ts +810 -0
- package/src/orchestration/RunStartService.ts +449 -0
- package/src/orchestration/TriggerRuntimeService.ts +260 -0
- package/src/orchestration/index.ts +5 -0
- package/src/planning/CurrentStateFrontierPlanner.ts +400 -0
- package/src/planning/EngineWorkflowPlanningFactory.ts +63 -0
- package/src/planning/RunQueuePlanner.ts +302 -0
- package/src/planning/WorkflowTopologyPlanner.ts +77 -0
- package/src/planning/index.ts +4 -0
- package/src/policies/WorkflowPolicyErrorServices.ts +38 -0
- package/src/policies/executionLimits/EngineExecutionLimitsPolicy.ts +66 -0
- package/src/policies/executionLimits/EngineExecutionLimitsPolicyFactory.ts +14 -0
- package/src/policies/index.ts +10 -0
- package/src/policies/storage/RunPolicySnapshotFactory.ts +23 -0
- package/src/policies/storage/RunTerminalPersistenceCoordinator.ts +29 -0
- package/src/policies/storage/WorkflowStoragePolicyEvaluator.ts +39 -0
- package/src/runStorage/BinaryBodyBufferReader.ts +57 -0
- package/src/runStorage/BinaryBodyReadableStreamFactory.ts +21 -0
- package/src/runStorage/InMemoryBinaryStorageRegistry.ts +53 -0
- package/src/runStorage/InMemoryRunData.ts +33 -0
- package/src/runStorage/InMemoryRunDataFactory.ts +8 -0
- package/src/runStorage/InMemoryWorkflowExecutionRepository.ts +95 -0
- package/src/runStorage/RunSummaryMapper.ts +17 -0
- package/src/runStorage/index.ts +7 -0
- package/src/runtime/EngineFactory.ts +151 -0
- package/src/runtime/EngineWorkflowRunnerService.ts +39 -0
- package/src/runtime/EngineWorkflowRunnerServiceFactory.ts +11 -0
- package/src/runtime/InMemoryLiveWorkflowRepository.ts +20 -0
- package/src/runtime/RunIntentService.ts +175 -0
- package/src/runtime/RunIntentServiceFactory.ts +11 -0
- package/src/runtime/WorkflowRepositoryWebhookTriggerMatcher.ts +144 -0
- package/src/runtime/WorkflowRepositoryWebhookTriggerMatcherFactory.ts +13 -0
- package/src/runtime/index.ts +9 -0
- package/src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts +25 -0
- package/src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts +46 -0
- package/src/runtime-types/PersistedRuntimeTypeNameResolver.ts +14 -0
- package/src/runtime-types/StackTraceCallSitePathResolver.ts +25 -0
- package/src/runtime-types/persistedRuntimeTypeModelRegistry.ts +33 -0
- package/src/runtime-types/runtimeTypeDecorators.types.ts +46 -0
- package/src/scheduler/ConfigDrivenOffloadPolicy.ts +28 -0
- package/src/scheduler/DefaultDrivingScheduler.ts +100 -0
- package/src/scheduler/HintOnlyOffloadPolicy.ts +9 -0
- package/src/scheduler/InlineDrivingScheduler.ts +145 -0
- package/src/scheduler/InlineDrivingSchedulerFactory.ts +9 -0
- package/src/scheduler/LocalOnlyScheduler.ts +7 -0
- package/src/serialization/ItemsInputNormalizer.ts +36 -0
- package/src/testing/RejectingCredentialSessionService.ts +15 -0
- package/src/testing.ts +6 -0
- package/src/types/index.ts +12 -0
- package/src/workflow/definition/ConnectionInvocationIdFactory.ts +17 -0
- package/src/workflow/definition/ConnectionNodeIdFactory.ts +42 -0
- package/src/workflow/definition/WorkflowExecutableNodeClassifier.ts +71 -0
- package/src/workflow/definition/WorkflowExecutableNodeClassifierFactory.ts +9 -0
- package/src/workflow/dsl/ChainCursorResolver.ts +103 -0
- package/src/workflow/dsl/WhenBuilder.ts +57 -0
- package/src/workflow/dsl/WorkflowBuilder.ts +55 -0
- package/src/workflow/dsl/workflowBuilderTypes.ts +63 -0
- package/src/workflow/graph/DefaultWorkflowGraphFactory.ts +8 -0
- package/src/workflow/graph/ExecutableGraph.ts +24 -0
- package/src/workflow/index.ts +11 -0
- package/src/workflowSnapshots/MissingRuntimeExecutionMarker.ts +5 -0
- package/src/workflowSnapshots/MissingRuntimeFallbacksFactory.ts +27 -0
- package/src/workflowSnapshots/MissingRuntimeNode.ts +12 -0
- package/src/workflowSnapshots/MissingRuntimeNodeConfig.ts +14 -0
- package/src/workflowSnapshots/MissingRuntimeNodeToken.ts +1 -0
- package/src/workflowSnapshots/MissingRuntimeTrigger.ts +16 -0
- package/src/workflowSnapshots/MissingRuntimeTriggerConfig.ts +14 -0
- package/src/workflowSnapshots/MissingRuntimeTriggerToken.ts +1 -0
- package/src/workflowSnapshots/PersistedRuntimeTypeIdFactory.ts +19 -0
- package/src/workflowSnapshots/PersistedWorkflowTokenRegistry.ts +89 -0
- package/src/workflowSnapshots/PersistedWorkflowTokenRegistryFactory.ts +2 -0
- package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +177 -0
- package/src/workflowSnapshots/WorkflowSnapshotResolver.ts +102 -0
- package/src/workflowSnapshots/index.ts +12 -0
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +10 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExecutionContextFactory,
|
|
3
|
+
Items,
|
|
4
|
+
JsonValue,
|
|
5
|
+
NodeDefinition,
|
|
6
|
+
NodeId,
|
|
7
|
+
NodeResolver,
|
|
8
|
+
RunDataFactory,
|
|
9
|
+
RunIdFactory,
|
|
10
|
+
TestableTriggerNode,
|
|
11
|
+
TriggerCleanupHandle,
|
|
12
|
+
TriggerInstanceId,
|
|
13
|
+
TriggerNode,
|
|
14
|
+
TriggerNodeConfig,
|
|
15
|
+
TriggerSetupContext,
|
|
16
|
+
TriggerSetupStateRepository,
|
|
17
|
+
TriggerRuntimeDiagnostics,
|
|
18
|
+
WorkflowActivationPolicy,
|
|
19
|
+
WorkflowDefinition,
|
|
20
|
+
WorkflowId,
|
|
21
|
+
WorkflowRepository,
|
|
22
|
+
} from "../types";
|
|
23
|
+
|
|
24
|
+
import { CredentialResolverFactory } from "../execution/CredentialResolverFactory";
|
|
25
|
+
import type { NodeRunStateWriterFactory } from "../execution/NodeRunStateWriterFactory";
|
|
26
|
+
import type { EngineExecutionLimitsPolicy } from "../policies/executionLimits/EngineExecutionLimitsPolicy";
|
|
27
|
+
|
|
28
|
+
export interface TriggerEmitHandler {
|
|
29
|
+
emit(workflow: WorkflowDefinition, triggerNodeId: NodeId, items: Items): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class TriggerRuntimeService {
|
|
33
|
+
private readonly credentialResolverFactory: CredentialResolverFactory;
|
|
34
|
+
private readonly triggerCleanupHandlesByKey = new Map<string, TriggerCleanupHandle[]>();
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
private readonly workflowRepository: WorkflowRepository,
|
|
38
|
+
private readonly workflowActivationPolicy: WorkflowActivationPolicy,
|
|
39
|
+
private readonly runIdFactory: RunIdFactory,
|
|
40
|
+
private readonly runDataFactory: RunDataFactory,
|
|
41
|
+
private readonly executionContextFactory: ExecutionContextFactory,
|
|
42
|
+
credentialResolverFactory: CredentialResolverFactory,
|
|
43
|
+
private readonly nodeExecutionStatePublisherFactory: NodeRunStateWriterFactory,
|
|
44
|
+
private readonly nodeResolver: NodeResolver,
|
|
45
|
+
private readonly triggerSetupStateRepository: TriggerSetupStateRepository,
|
|
46
|
+
private readonly emitHandler: TriggerEmitHandler,
|
|
47
|
+
private readonly executionLimitsPolicy: EngineExecutionLimitsPolicy,
|
|
48
|
+
private readonly diagnostics?: TriggerRuntimeDiagnostics,
|
|
49
|
+
) {
|
|
50
|
+
this.credentialResolverFactory = credentialResolverFactory;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async startTriggers(): Promise<void> {
|
|
54
|
+
for (const wf of this.workflowRepository.list()) {
|
|
55
|
+
if (!this.workflowActivationPolicy.isActive(wf.id)) {
|
|
56
|
+
const summaries = this.formatTriggerSummaries(wf);
|
|
57
|
+
if (summaries.length > 0) {
|
|
58
|
+
this.logInfo(
|
|
59
|
+
`Workflow "${wf.name}" (${wf.id}) is inactive; skipping trigger setup — ${summaries.join("; ")}.`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
await this.startTriggersForWorkflow(wf);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async syncWorkflowTriggersForActivation(workflowId: WorkflowId): Promise<void> {
|
|
69
|
+
const wf = this.workflowRepository.get(workflowId);
|
|
70
|
+
if (!wf) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const summaries = this.formatTriggerSummaries(wf);
|
|
74
|
+
if (summaries.length > 0) {
|
|
75
|
+
this.logInfo(`Workflow "${wf.name}" (${wf.id}): stopping triggers — ${summaries.join("; ")}.`);
|
|
76
|
+
}
|
|
77
|
+
await this.stopTriggersForWorkflow(wf);
|
|
78
|
+
if (this.workflowActivationPolicy.isActive(workflowId)) {
|
|
79
|
+
if (summaries.length > 0) {
|
|
80
|
+
this.logInfo(`Workflow "${wf.name}" (${wf.id}): activation on; starting triggers — ${summaries.join("; ")}.`);
|
|
81
|
+
}
|
|
82
|
+
await this.startTriggersForWorkflow(wf);
|
|
83
|
+
} else {
|
|
84
|
+
this.logInfo(`Workflow "${wf.name}" (${wf.id}): activation off; triggers not started.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async stop(): Promise<void> {
|
|
89
|
+
for (const workflow of this.workflowRepository.list()) {
|
|
90
|
+
await this.stopTriggersForWorkflow(workflow);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async createTriggerTestItems(args: { workflow: WorkflowDefinition; nodeId: NodeId }): Promise<Items | undefined> {
|
|
95
|
+
const definition = args.workflow.nodes.find((node) => node.id === args.nodeId);
|
|
96
|
+
if (!definition) {
|
|
97
|
+
throw new Error(`Unknown trigger nodeId: ${args.nodeId}`);
|
|
98
|
+
}
|
|
99
|
+
if (definition.kind !== "trigger") {
|
|
100
|
+
throw new Error(`Node ${args.nodeId} is not a trigger`);
|
|
101
|
+
}
|
|
102
|
+
const node = this.nodeResolver.resolve(definition.type) as TriggerNode;
|
|
103
|
+
if (!this.isTestableTriggerNode(node)) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
const data = this.runDataFactory.create();
|
|
107
|
+
const runId = this.runIdFactory.makeRunId();
|
|
108
|
+
const trigger = { workflowId: args.workflow.id, nodeId: definition.id } as const;
|
|
109
|
+
const previousState = await this.triggerSetupStateRepository.load(trigger);
|
|
110
|
+
return await node.getTestItems({
|
|
111
|
+
...this.createExecutionContext({
|
|
112
|
+
runId,
|
|
113
|
+
workflowId: args.workflow.id,
|
|
114
|
+
nodeId: definition.id,
|
|
115
|
+
data,
|
|
116
|
+
}),
|
|
117
|
+
trigger,
|
|
118
|
+
nodeId: definition.id,
|
|
119
|
+
config: definition.config as TriggerNodeConfig,
|
|
120
|
+
previousState: previousState?.state as never,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private async startTriggersForWorkflow(wf: WorkflowDefinition): Promise<void> {
|
|
125
|
+
for (const def of wf.nodes) {
|
|
126
|
+
if (def.kind !== "trigger") continue;
|
|
127
|
+
const node = this.nodeResolver.resolve(def.type) as TriggerNode;
|
|
128
|
+
const data = this.runDataFactory.create();
|
|
129
|
+
const triggerRunId = this.runIdFactory.makeRunId();
|
|
130
|
+
const trigger = { workflowId: wf.id, nodeId: def.id } as const;
|
|
131
|
+
await this.stopTrigger(trigger);
|
|
132
|
+
const previousState = await this.triggerSetupStateRepository.load(trigger);
|
|
133
|
+
let nextState: unknown;
|
|
134
|
+
try {
|
|
135
|
+
nextState = await node.setup({
|
|
136
|
+
...this.createExecutionContext({
|
|
137
|
+
runId: triggerRunId,
|
|
138
|
+
workflowId: wf.id,
|
|
139
|
+
nodeId: def.id,
|
|
140
|
+
data,
|
|
141
|
+
}),
|
|
142
|
+
trigger,
|
|
143
|
+
config: def.config as TriggerNodeConfig,
|
|
144
|
+
previousState: previousState?.state as never,
|
|
145
|
+
registerCleanup: (cleanup) => {
|
|
146
|
+
this.registerTriggerCleanupHandle(trigger, cleanup);
|
|
147
|
+
},
|
|
148
|
+
emit: async (items) => {
|
|
149
|
+
await this.emitHandler.emit(wf, def.id, items);
|
|
150
|
+
},
|
|
151
|
+
} satisfies TriggerSetupContext<TriggerNodeConfig>);
|
|
152
|
+
} catch (triggerError: unknown) {
|
|
153
|
+
await this.stopTrigger(trigger);
|
|
154
|
+
const message = triggerError instanceof Error ? triggerError.message : String(triggerError);
|
|
155
|
+
this.logWarn(`Skipping trigger setup for workflow ${wf.id} node ${def.id}: ${message}`);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (nextState === undefined) {
|
|
159
|
+
await this.triggerSetupStateRepository.delete(trigger);
|
|
160
|
+
} else {
|
|
161
|
+
await this.triggerSetupStateRepository.save({
|
|
162
|
+
trigger,
|
|
163
|
+
updatedAt: new Date().toISOString(),
|
|
164
|
+
state: nextState as JsonValue | undefined,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private async stopTriggersForWorkflow(workflow: WorkflowDefinition): Promise<void> {
|
|
171
|
+
for (const node of workflow.nodes) {
|
|
172
|
+
if (node.kind !== "trigger") {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
await this.stopTrigger({
|
|
176
|
+
workflowId: workflow.id,
|
|
177
|
+
nodeId: node.id,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private createExecutionContext(args: {
|
|
183
|
+
runId: ReturnType<RunIdFactory["makeRunId"]>;
|
|
184
|
+
workflowId: string;
|
|
185
|
+
nodeId: NodeId;
|
|
186
|
+
data: ReturnType<RunDataFactory["create"]>;
|
|
187
|
+
}) {
|
|
188
|
+
const nodeState = this.nodeExecutionStatePublisherFactory.create(args.runId, args.workflowId, undefined);
|
|
189
|
+
const rootLimits = this.executionLimitsPolicy.createRootExecutionOptions();
|
|
190
|
+
return this.executionContextFactory.create({
|
|
191
|
+
runId: args.runId,
|
|
192
|
+
workflowId: args.workflowId,
|
|
193
|
+
parent: undefined,
|
|
194
|
+
subworkflowDepth: rootLimits.subworkflowDepth ?? 0,
|
|
195
|
+
engineMaxNodeActivations: rootLimits.maxNodeActivations!,
|
|
196
|
+
engineMaxSubworkflowDepth: rootLimits.maxSubworkflowDepth!,
|
|
197
|
+
data: args.data,
|
|
198
|
+
nodeState,
|
|
199
|
+
getCredential: this.credentialResolverFactory.create(args.workflowId, args.nodeId),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private registerTriggerCleanupHandle(trigger: TriggerInstanceId, cleanup: TriggerCleanupHandle): void {
|
|
204
|
+
const key = this.toTriggerKey(trigger);
|
|
205
|
+
const cleanups = this.triggerCleanupHandlesByKey.get(key) ?? [];
|
|
206
|
+
cleanups.push(cleanup);
|
|
207
|
+
this.triggerCleanupHandlesByKey.set(key, cleanups);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private async stopTrigger(trigger: TriggerInstanceId): Promise<void> {
|
|
211
|
+
const key = this.toTriggerKey(trigger);
|
|
212
|
+
const cleanups = this.triggerCleanupHandlesByKey.get(key) ?? [];
|
|
213
|
+
this.triggerCleanupHandlesByKey.delete(key);
|
|
214
|
+
for (const cleanup of [...cleanups].reverse()) {
|
|
215
|
+
await cleanup.stop();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private toTriggerKey(trigger: TriggerInstanceId): string {
|
|
220
|
+
return `${trigger.workflowId}:${trigger.nodeId}`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private formatTriggerSummaries(wf: WorkflowDefinition): string[] {
|
|
224
|
+
const out: string[] = [];
|
|
225
|
+
for (const def of wf.nodes) {
|
|
226
|
+
if (def.kind !== "trigger") {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
out.push(this.describeTriggerNode(def));
|
|
230
|
+
}
|
|
231
|
+
return out;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private describeTriggerNode(def: NodeDefinition): string {
|
|
235
|
+
const label = def.name !== undefined && def.name.trim().length > 0 ? def.name.trim() : String(def.id);
|
|
236
|
+
const cfg = def.config as { endpointKey?: unknown };
|
|
237
|
+
if (typeof cfg.endpointKey === "string" && cfg.endpointKey.trim().length > 0) {
|
|
238
|
+
return `${label} (webhook "${cfg.endpointKey.trim()}")`;
|
|
239
|
+
}
|
|
240
|
+
return label;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private logInfo(message: string): void {
|
|
244
|
+
if (this.diagnostics) {
|
|
245
|
+
this.diagnostics.info(message);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private logWarn(message: string): void {
|
|
250
|
+
if (this.diagnostics) {
|
|
251
|
+
this.diagnostics.warn(message);
|
|
252
|
+
} else {
|
|
253
|
+
console.warn(`[engine] ${message}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
private isTestableTriggerNode(node: TriggerNode): node is TestableTriggerNode<TriggerNodeConfig> {
|
|
258
|
+
return typeof (node as Partial<TestableTriggerNode<TriggerNodeConfig>>).getTestItems === "function";
|
|
259
|
+
}
|
|
260
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Engine } from "./Engine";
|
|
2
|
+
export { EngineWaiters } from "./EngineWaiters";
|
|
3
|
+
export { RunContinuationService } from "./RunContinuationService";
|
|
4
|
+
export { RunStartService } from "./RunStartService";
|
|
5
|
+
export { TriggerRuntimeService } from "./TriggerRuntimeService";
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExecutionFrontierPlan,
|
|
3
|
+
InputPortKey,
|
|
4
|
+
Items,
|
|
5
|
+
NodeId,
|
|
6
|
+
NodeOutputs,
|
|
7
|
+
OutputPortKey,
|
|
8
|
+
RunCurrentState,
|
|
9
|
+
PersistedMutableNodeState,
|
|
10
|
+
RunQueueEntry,
|
|
11
|
+
RunStateResetRequest,
|
|
12
|
+
RunStopCondition,
|
|
13
|
+
ConnectionInvocationRecord,
|
|
14
|
+
} from "../types";
|
|
15
|
+
|
|
16
|
+
import { ConnectionNodeIdFactory } from "../workflow/definition/ConnectionNodeIdFactory";
|
|
17
|
+
import { WorkflowTopology } from "./WorkflowTopologyPlanner";
|
|
18
|
+
|
|
19
|
+
export class CurrentStateFrontierPlanner {
|
|
20
|
+
constructor(private readonly topology: WorkflowTopology) {}
|
|
21
|
+
|
|
22
|
+
/** Composition-root-friendly factory (avoids `new` at orchestration call sites under ESLint manual-DI rules). */
|
|
23
|
+
static createFromTopology(topology: WorkflowTopology): CurrentStateFrontierPlanner {
|
|
24
|
+
return new CurrentStateFrontierPlanner(topology);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
plan(args: {
|
|
28
|
+
currentState?: RunCurrentState;
|
|
29
|
+
stopCondition?: RunStopCondition;
|
|
30
|
+
reset?: RunStateResetRequest;
|
|
31
|
+
items?: Items;
|
|
32
|
+
}): ExecutionFrontierPlan {
|
|
33
|
+
const stopCondition = args.stopCondition ?? { kind: "workflowCompleted" as const };
|
|
34
|
+
const baseState = this.cloneCurrentState(args.currentState);
|
|
35
|
+
const normalizedState = this.overlayPinnedOutputs(baseState);
|
|
36
|
+
const resetResult = this.applyReset({ currentState: normalizedState, reset: args.reset });
|
|
37
|
+
const requiredNodeIds = this.collectRequiredNodeIds(stopCondition, resetResult.currentState);
|
|
38
|
+
const satisfiedNodeIds = this.collectSatisfiedNodeIds(resetResult.currentState);
|
|
39
|
+
const skippedNodeIds = [
|
|
40
|
+
...new Set([
|
|
41
|
+
...[...requiredNodeIds].filter((nodeId) => this.isNodeSatisfied(resetResult.currentState, nodeId)),
|
|
42
|
+
...resetResult.preservedPinnedNodeIds.filter((nodeId) => requiredNodeIds.has(nodeId)),
|
|
43
|
+
]),
|
|
44
|
+
];
|
|
45
|
+
const frontierNodeIds = this.collectFrontierNodeIds(requiredNodeIds, resetResult.currentState);
|
|
46
|
+
const rootNodeIds = frontierNodeIds.filter(
|
|
47
|
+
(nodeId) => (this.topology.incomingByNode.get(nodeId) ?? []).length === 0,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (rootNodeIds.length > 1) {
|
|
51
|
+
throw new Error(`Ambiguous execution frontier. Multiple root nodes require input: ${rootNodeIds.join(", ")}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (frontierNodeIds.length === 0) {
|
|
55
|
+
return {
|
|
56
|
+
queue: [],
|
|
57
|
+
currentState: resetResult.currentState,
|
|
58
|
+
stopCondition,
|
|
59
|
+
satisfiedNodeIds,
|
|
60
|
+
skippedNodeIds,
|
|
61
|
+
clearedNodeIds: resetResult.clearedNodeIds,
|
|
62
|
+
preservedPinnedNodeIds: resetResult.preservedPinnedNodeIds,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (rootNodeIds.length === 1) {
|
|
67
|
+
const rootNodeId = rootNodeIds[0]!;
|
|
68
|
+
const definition = this.topology.defsById.get(rootNodeId);
|
|
69
|
+
if (!definition) {
|
|
70
|
+
throw new Error(`Unknown frontier nodeId: ${rootNodeId}`);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
rootNodeId,
|
|
74
|
+
rootNodeInput: this.resolveRootNodeInput({ nodeKind: definition.kind, items: args.items }),
|
|
75
|
+
queue: [],
|
|
76
|
+
currentState: resetResult.currentState,
|
|
77
|
+
stopCondition,
|
|
78
|
+
satisfiedNodeIds,
|
|
79
|
+
skippedNodeIds,
|
|
80
|
+
clearedNodeIds: resetResult.clearedNodeIds,
|
|
81
|
+
preservedPinnedNodeIds: resetResult.preservedPinnedNodeIds,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const queue: RunQueueEntry[] = [];
|
|
86
|
+
for (const nodeId of frontierNodeIds) {
|
|
87
|
+
queue.push(...this.buildFrontierQueue(nodeId, resetResult.currentState));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
queue,
|
|
92
|
+
currentState: resetResult.currentState,
|
|
93
|
+
stopCondition,
|
|
94
|
+
satisfiedNodeIds,
|
|
95
|
+
skippedNodeIds,
|
|
96
|
+
clearedNodeIds: resetResult.clearedNodeIds,
|
|
97
|
+
preservedPinnedNodeIds: resetResult.preservedPinnedNodeIds,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private cloneCurrentState(currentState: RunCurrentState | undefined): RunCurrentState {
|
|
102
|
+
if (!currentState) {
|
|
103
|
+
return {
|
|
104
|
+
outputsByNode: {},
|
|
105
|
+
nodeSnapshotsByNodeId: {},
|
|
106
|
+
connectionInvocations: [],
|
|
107
|
+
mutableState: undefined,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
outputsByNode: { ...currentState.outputsByNode },
|
|
112
|
+
nodeSnapshotsByNodeId: { ...currentState.nodeSnapshotsByNodeId },
|
|
113
|
+
connectionInvocations: currentState.connectionInvocations ? [...currentState.connectionInvocations] : undefined,
|
|
114
|
+
mutableState: currentState.mutableState,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private overlayPinnedOutputs(currentState: RunCurrentState): RunCurrentState {
|
|
119
|
+
const outputsByNode: Record<NodeId, NodeOutputs> = { ...currentState.outputsByNode };
|
|
120
|
+
for (const [nodeId, nodeState] of Object.entries(currentState.mutableState?.nodesById ?? {}) as Array<
|
|
121
|
+
[NodeId, PersistedMutableNodeState]
|
|
122
|
+
>) {
|
|
123
|
+
const pinnedOutputs = nodeState.pinnedOutputsByPort;
|
|
124
|
+
if (!pinnedOutputs) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
outputsByNode[nodeId] = pinnedOutputs;
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
outputsByNode,
|
|
131
|
+
nodeSnapshotsByNodeId: { ...currentState.nodeSnapshotsByNodeId },
|
|
132
|
+
connectionInvocations: currentState.connectionInvocations,
|
|
133
|
+
mutableState: currentState.mutableState,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private applyReset(args: { currentState: RunCurrentState; reset?: RunStateResetRequest }): Readonly<{
|
|
138
|
+
currentState: RunCurrentState;
|
|
139
|
+
clearedNodeIds: ReadonlyArray<NodeId>;
|
|
140
|
+
preservedPinnedNodeIds: ReadonlyArray<NodeId>;
|
|
141
|
+
}> {
|
|
142
|
+
if (!args.reset) {
|
|
143
|
+
return {
|
|
144
|
+
currentState: args.currentState,
|
|
145
|
+
clearedNodeIds: [],
|
|
146
|
+
preservedPinnedNodeIds: [],
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const outputsByNode: Record<NodeId, NodeOutputs> = { ...args.currentState.outputsByNode };
|
|
151
|
+
const nodeSnapshotsByNodeId = { ...args.currentState.nodeSnapshotsByNodeId };
|
|
152
|
+
const clearedNodeIds: NodeId[] = [];
|
|
153
|
+
const preservedPinnedNodeIds: NodeId[] = [];
|
|
154
|
+
const descendants = this.collectDescendants(args.reset.clearFromNodeId);
|
|
155
|
+
const runtimeDescendants = this.collectRuntimeDescendants(args.currentState, descendants);
|
|
156
|
+
const clearedIdSet = new Set<NodeId>([...descendants, ...runtimeDescendants]);
|
|
157
|
+
|
|
158
|
+
for (const nodeId of [...descendants, ...runtimeDescendants]) {
|
|
159
|
+
const pinnedOutputs = this.getPinnedOutputs(args.currentState, nodeId);
|
|
160
|
+
if (pinnedOutputs) {
|
|
161
|
+
outputsByNode[nodeId] = pinnedOutputs;
|
|
162
|
+
delete nodeSnapshotsByNodeId[nodeId];
|
|
163
|
+
preservedPinnedNodeIds.push(nodeId);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
delete outputsByNode[nodeId];
|
|
167
|
+
delete nodeSnapshotsByNodeId[nodeId];
|
|
168
|
+
clearedNodeIds.push(nodeId);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
currentState: {
|
|
173
|
+
outputsByNode,
|
|
174
|
+
nodeSnapshotsByNodeId,
|
|
175
|
+
connectionInvocations: this.filterConnectionInvocations(args.currentState.connectionInvocations, clearedIdSet),
|
|
176
|
+
mutableState: args.currentState.mutableState,
|
|
177
|
+
},
|
|
178
|
+
clearedNodeIds,
|
|
179
|
+
preservedPinnedNodeIds,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private collectSatisfiedNodeIds(currentState: RunCurrentState): ReadonlyArray<NodeId> {
|
|
184
|
+
const satisfiedNodeIds: NodeId[] = [];
|
|
185
|
+
for (const nodeId of this.topology.defsById.keys()) {
|
|
186
|
+
if (this.isNodeSatisfied(currentState, nodeId)) {
|
|
187
|
+
satisfiedNodeIds.push(nodeId);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return satisfiedNodeIds;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private collectFrontierNodeIds(
|
|
194
|
+
requiredNodeIds: ReadonlySet<NodeId>,
|
|
195
|
+
currentState: RunCurrentState,
|
|
196
|
+
): ReadonlyArray<NodeId> {
|
|
197
|
+
const frontierNodeIds: NodeId[] = [];
|
|
198
|
+
for (const nodeId of this.topology.defsById.keys()) {
|
|
199
|
+
if (!requiredNodeIds.has(nodeId) || this.isNodeSatisfied(currentState, nodeId)) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const incomingEdges = this.topology.incomingByNode.get(nodeId) ?? [];
|
|
203
|
+
const isFrontier = incomingEdges.every((edge) => this.isEdgeSatisfied(currentState, nodeId, edge.input));
|
|
204
|
+
if (isFrontier) {
|
|
205
|
+
frontierNodeIds.push(nodeId);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return frontierNodeIds;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private collectRequiredNodeIds(stopCondition: RunStopCondition, currentState: RunCurrentState): ReadonlySet<NodeId> {
|
|
212
|
+
const requiredNodeIds = new Set<NodeId>();
|
|
213
|
+
if (stopCondition.kind === "workflowCompleted") {
|
|
214
|
+
for (const nodeId of this.topology.defsById.keys()) {
|
|
215
|
+
if (!this.isNodeSatisfied(currentState, nodeId)) {
|
|
216
|
+
this.collectRequiredNode(requiredNodeIds, currentState, nodeId);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return requiredNodeIds;
|
|
220
|
+
}
|
|
221
|
+
if (!this.topology.defsById.has(stopCondition.nodeId)) {
|
|
222
|
+
throw new Error(`Unknown stop nodeId: ${stopCondition.nodeId}`);
|
|
223
|
+
}
|
|
224
|
+
this.collectRequiredNode(requiredNodeIds, currentState, stopCondition.nodeId);
|
|
225
|
+
return requiredNodeIds;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private collectRequiredNode(requiredNodeIds: Set<NodeId>, currentState: RunCurrentState, nodeId: NodeId): void {
|
|
229
|
+
if (requiredNodeIds.has(nodeId)) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (this.isNodeSatisfied(currentState, nodeId) && !this.isNodeSatisfiedByOutputsOnly(currentState, nodeId)) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
requiredNodeIds.add(nodeId);
|
|
236
|
+
for (const edge of this.topology.incomingByNode.get(nodeId) ?? []) {
|
|
237
|
+
if (
|
|
238
|
+
!this.isEdgeSatisfied(currentState, nodeId, edge.input) ||
|
|
239
|
+
this.isNodeSatisfiedByOutputsOnly(currentState, edge.from.nodeId)
|
|
240
|
+
) {
|
|
241
|
+
this.collectRequiredNode(requiredNodeIds, currentState, edge.from.nodeId);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private buildFrontierQueue(nodeId: NodeId, currentState: RunCurrentState): ReadonlyArray<RunQueueEntry> {
|
|
247
|
+
const incomingEdges = this.topology.incomingByNode.get(nodeId) ?? [];
|
|
248
|
+
if (incomingEdges.length === 0) {
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
const expectedInputs = this.topology.expectedInputsByNode.get(nodeId) ?? [];
|
|
252
|
+
const usesCollect = expectedInputs.length !== 1 || expectedInputs[0] !== "in";
|
|
253
|
+
if (usesCollect) {
|
|
254
|
+
const received: Record<InputPortKey, Items> = {};
|
|
255
|
+
for (const input of expectedInputs) {
|
|
256
|
+
received[input] = this.resolveInput(currentState, nodeId, input);
|
|
257
|
+
}
|
|
258
|
+
return [
|
|
259
|
+
{
|
|
260
|
+
nodeId,
|
|
261
|
+
input: [],
|
|
262
|
+
batchId: "batch_1",
|
|
263
|
+
collect: {
|
|
264
|
+
expectedInputs,
|
|
265
|
+
received,
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
const input = expectedInputs[0] ?? "in";
|
|
271
|
+
const incomingEdge = incomingEdges.find((edge) => edge.input === input);
|
|
272
|
+
return [
|
|
273
|
+
{
|
|
274
|
+
nodeId,
|
|
275
|
+
input: this.resolveInput(currentState, nodeId, input),
|
|
276
|
+
toInput: input,
|
|
277
|
+
batchId: "batch_1",
|
|
278
|
+
from: incomingEdge?.from,
|
|
279
|
+
},
|
|
280
|
+
];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private resolveRootNodeInput(args: { nodeKind: "node" | "trigger"; items?: Items }): Items {
|
|
284
|
+
if (args.items) {
|
|
285
|
+
return args.items;
|
|
286
|
+
}
|
|
287
|
+
if (args.nodeKind === "trigger") {
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
return [{ json: {} }];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private isNodeSatisfied(currentState: RunCurrentState, nodeId: NodeId): boolean {
|
|
294
|
+
return this.hasOutputs(currentState, nodeId) || this.hasCompletedSnapshot(currentState, nodeId);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
private isNodeSatisfiedByOutputsOnly(currentState: RunCurrentState, nodeId: NodeId): boolean {
|
|
298
|
+
return this.hasOutputs(currentState, nodeId) && !this.hasCompletedSnapshot(currentState, nodeId);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private isEdgeSatisfied(currentState: RunCurrentState, nodeId: NodeId, input: InputPortKey): boolean {
|
|
302
|
+
const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);
|
|
303
|
+
if (!incomingEdge) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
return this.hasOutputPort(currentState, incomingEdge.from.nodeId, incomingEdge.from.output);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private resolveInput(currentState: RunCurrentState, nodeId: NodeId, input: InputPortKey): Items {
|
|
310
|
+
const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);
|
|
311
|
+
if (!incomingEdge) {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
return this.resolveOutputItems(currentState, incomingEdge.from.nodeId, incomingEdge.from.output);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
private hasOutputs(currentState: RunCurrentState, nodeId: NodeId): boolean {
|
|
318
|
+
return Object.prototype.hasOwnProperty.call(currentState.outputsByNode, nodeId);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private hasCompletedSnapshot(currentState: RunCurrentState, nodeId: NodeId): boolean {
|
|
322
|
+
const snapshot = currentState.nodeSnapshotsByNodeId[nodeId];
|
|
323
|
+
return snapshot?.status === "completed" || snapshot?.status === "skipped";
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
private hasOutputPort(currentState: RunCurrentState, nodeId: NodeId, output: OutputPortKey): boolean {
|
|
327
|
+
const outputs = currentState.outputsByNode[nodeId];
|
|
328
|
+
if (!outputs) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
return Object.prototype.hasOwnProperty.call(outputs, output);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private resolveOutputItems(currentState: RunCurrentState, nodeId: NodeId, output: OutputPortKey): Items {
|
|
335
|
+
return currentState.outputsByNode[nodeId]?.[output] ?? [];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
private getPinnedOutputs(currentState: RunCurrentState, nodeId: NodeId): NodeOutputs | undefined {
|
|
339
|
+
return currentState.mutableState?.nodesById?.[nodeId]?.pinnedOutputsByPort;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
private filterConnectionInvocations(
|
|
343
|
+
invocations: ReadonlyArray<ConnectionInvocationRecord> | undefined,
|
|
344
|
+
clearedIdSet: ReadonlySet<NodeId>,
|
|
345
|
+
): ReadonlyArray<ConnectionInvocationRecord> | undefined {
|
|
346
|
+
if (!invocations || invocations.length === 0) {
|
|
347
|
+
return invocations;
|
|
348
|
+
}
|
|
349
|
+
const kept = invocations.filter(
|
|
350
|
+
(invocation) => !clearedIdSet.has(invocation.parentAgentNodeId) && !clearedIdSet.has(invocation.connectionNodeId),
|
|
351
|
+
);
|
|
352
|
+
return kept.length === invocations.length ? invocations : kept;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private collectDescendants(startNodeId: NodeId): ReadonlyArray<NodeId> {
|
|
356
|
+
const pendingNodeIds: NodeId[] = [startNodeId];
|
|
357
|
+
const descendants = new Set<NodeId>();
|
|
358
|
+
while (pendingNodeIds.length > 0) {
|
|
359
|
+
const nodeId = pendingNodeIds.pop();
|
|
360
|
+
if (!nodeId || descendants.has(nodeId)) {
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
descendants.add(nodeId);
|
|
364
|
+
for (const edge of this.topology.outgoingByNode.get(nodeId) ?? []) {
|
|
365
|
+
pendingNodeIds.push(edge.to.nodeId);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return [...descendants];
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
private collectRuntimeDescendants(
|
|
372
|
+
currentState: RunCurrentState,
|
|
373
|
+
descendantNodeIds: ReadonlyArray<NodeId>,
|
|
374
|
+
): ReadonlyArray<NodeId> {
|
|
375
|
+
const descendantSet = new Set(descendantNodeIds);
|
|
376
|
+
const runtimeNodeIds = new Set<NodeId>();
|
|
377
|
+
for (const nodeId of [
|
|
378
|
+
...Object.keys(currentState.outputsByNode),
|
|
379
|
+
...Object.keys(currentState.nodeSnapshotsByNodeId),
|
|
380
|
+
...Object.keys(currentState.mutableState?.nodesById ?? {}),
|
|
381
|
+
] as NodeId[]) {
|
|
382
|
+
if (this.isRuntimeDescendant(nodeId, descendantSet)) {
|
|
383
|
+
runtimeNodeIds.add(nodeId);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return [...runtimeNodeIds];
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
private isRuntimeDescendant(nodeId: NodeId, descendantNodeIds: ReadonlySet<NodeId>): boolean {
|
|
390
|
+
for (const descendantNodeId of descendantNodeIds) {
|
|
391
|
+
if (nodeId === descendantNodeId) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
if (ConnectionNodeIdFactory.isConnectionOwnedDescendantOf(descendantNodeId, nodeId)) {
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
}
|