@codemation/host 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.
Files changed (358) hide show
  1. package/README.md +75 -0
  2. package/dist/CodemationConfig-XCkSV2dj.d.ts +168 -0
  3. package/dist/CodemationConsumerConfigLoader-Dmm2TzAA.d.ts +61 -0
  4. package/dist/CodemationConsumerConfigLoader-scS_RQMy.js +334 -0
  5. package/dist/CodemationConsumerConfigLoader-scS_RQMy.js.map +1 -0
  6. package/dist/CodemationFrontendBootstrapRequest-CE6DjOWJ.js +5768 -0
  7. package/dist/CodemationFrontendBootstrapRequest-CE6DjOWJ.js.map +1 -0
  8. package/dist/CodemationPluginListMerger-BNmaoXQL.js +49 -0
  9. package/dist/CodemationPluginListMerger-BNmaoXQL.js.map +1 -0
  10. package/dist/CodemationPluginListMerger-BRYqEk0y.d.ts +793 -0
  11. package/dist/CodemationWhitelabelConfig-DgbjgtrR.d.ts +48 -0
  12. package/dist/ConsoleLogger-ClPU7jtc.js +35 -0
  13. package/dist/ConsoleLogger-ClPU7jtc.js.map +1 -0
  14. package/dist/CredentialServices-BKBGe7l3.js +1030 -0
  15. package/dist/CredentialServices-BKBGe7l3.js.map +1 -0
  16. package/dist/CredentialServices-DpDpm8mL.d.ts +291 -0
  17. package/dist/LogLevelPolicy-4cq9z0TI.d.ts +37 -0
  18. package/dist/PrismaMigrationDeployer-B1E_gYz7.js +8212 -0
  19. package/dist/PrismaMigrationDeployer-B1E_gYz7.js.map +1 -0
  20. package/dist/ServerLoggerFactory-BRHxIDS7.js +340 -0
  21. package/dist/ServerLoggerFactory-BRHxIDS7.js.map +1 -0
  22. package/dist/WorkflowViewContracts-DCLpTn25.d.ts +47 -0
  23. package/dist/chunk-7V6ThxGB.js +39 -0
  24. package/dist/client-Yh7-CQud.d.ts +21995 -0
  25. package/dist/client.d.ts +12 -0
  26. package/dist/client.js +15 -0
  27. package/dist/client.js.map +1 -0
  28. package/dist/consumer.d.ts +5 -0
  29. package/dist/consumer.js +7 -0
  30. package/dist/credentials.d.ts +50 -0
  31. package/dist/credentials.js +11 -0
  32. package/dist/credentials.js.map +1 -0
  33. package/dist/decorate-B-N_5S4p.js +10 -0
  34. package/dist/decorateParam-BTcc3KNk.js +15 -0
  35. package/dist/devServerSidecar.d.ts +52 -0
  36. package/dist/devServerSidecar.js +131 -0
  37. package/dist/devServerSidecar.js.map +1 -0
  38. package/dist/index-Bs4F1IsC.d.ts +1044 -0
  39. package/dist/index.d.ts +19 -0
  40. package/dist/index.js +14 -0
  41. package/dist/nextServer.d.ts +89 -0
  42. package/dist/nextServer.js +127 -0
  43. package/dist/nextServer.js.map +1 -0
  44. package/dist/persistenceServer-K5eqlZm3.d.ts +36 -0
  45. package/dist/persistenceServer-W9uRw0dJ.js +19 -0
  46. package/dist/persistenceServer-W9uRw0dJ.js.map +1 -0
  47. package/dist/persistenceServer.d.ts +6 -0
  48. package/dist/persistenceServer.js +6 -0
  49. package/dist/server-BBdsATju.d.ts +132 -0
  50. package/dist/server-BiHSuA13.js +175 -0
  51. package/dist/server-BiHSuA13.js.map +1 -0
  52. package/dist/server.d.ts +9 -0
  53. package/dist/server.js +13 -0
  54. package/package.json +152 -0
  55. package/playwright.config.ts +74 -0
  56. package/prisma/migrations/20260315063514_init/migration.sql +16 -0
  57. package/prisma/migrations/20260316090000_workflow_debugger_overlay/migration.sql +9 -0
  58. package/prisma/migrations/20260317120000_trigger_state_store/migration.sql +3 -0
  59. package/prisma/migrations/20260317153000_trigger_setup_state/migration.sql +8 -0
  60. package/prisma/migrations/20260318110000_credentials_v2/migration.sql +49 -0
  61. package/prisma/migrations/20260319110000_credential_oauth2_material/migration.sql +28 -0
  62. package/prisma/migrations/20260319200000_codemation_auth_tables/migration.sql +56 -0
  63. package/prisma/migrations/20260320140000_user_invites_account_status/migration.sql +20 -0
  64. package/prisma/migrations/20260325120000_workflow_activation/migration.sql +8 -0
  65. package/prisma/migrations/migration_lock.toml +3 -0
  66. package/prisma/schema.prisma +179 -0
  67. package/prisma.config.ts +12 -0
  68. package/scripts/ensure-prisma-runtime-sourcemaps.mjs +42 -0
  69. package/scripts/integration-database-global-setup.mjs +30 -0
  70. package/src/application/ApplicationRequestError.ts +12 -0
  71. package/src/application/auth/AuthenticatedPrincipal.ts +5 -0
  72. package/src/application/auth/SessionVerifier.ts +5 -0
  73. package/src/application/binary/OverlayPinnedBinaryUploadService.ts +119 -0
  74. package/src/application/binary/RunBinaryAttachmentLookupService.ts +139 -0
  75. package/src/application/binary/RunStateBinaryStorageKeysCollector.ts +57 -0
  76. package/src/application/bus/Command.ts +3 -0
  77. package/src/application/bus/CommandBus.ts +5 -0
  78. package/src/application/bus/CommandHandler.ts +5 -0
  79. package/src/application/bus/DomainEvent.ts +1 -0
  80. package/src/application/bus/DomainEventBus.ts +5 -0
  81. package/src/application/bus/DomainEventHandler.ts +5 -0
  82. package/src/application/bus/Query.ts +3 -0
  83. package/src/application/bus/QueryBus.ts +5 -0
  84. package/src/application/bus/QueryHandler.ts +5 -0
  85. package/src/application/commands/AcceptUserInviteCommand.ts +10 -0
  86. package/src/application/commands/AcceptUserInviteCommandHandler.ts +19 -0
  87. package/src/application/commands/CopyRunToWorkflowDebuggerCommand.ts +14 -0
  88. package/src/application/commands/CopyRunToWorkflowDebuggerCommandHandler.ts +56 -0
  89. package/src/application/commands/CreateCredentialInstanceCommand.ts +9 -0
  90. package/src/application/commands/CreateCredentialInstanceCommandHandler.ts +28 -0
  91. package/src/application/commands/CredentialCommandHandlers.ts +10 -0
  92. package/src/application/commands/DeleteCredentialInstanceCommand.ts +7 -0
  93. package/src/application/commands/DeleteCredentialInstanceCommandHandler.ts +27 -0
  94. package/src/application/commands/HandleWebhookInvocationCommand.ts +12 -0
  95. package/src/application/commands/HandleWebhookInvocationCommandHandler.ts +42 -0
  96. package/src/application/commands/InviteUserCommand.ts +12 -0
  97. package/src/application/commands/InviteUserCommandHandler.ts +22 -0
  98. package/src/application/commands/RegenerateUserInviteCommand.ts +12 -0
  99. package/src/application/commands/RegenerateUserInviteCommandHandler.ts +24 -0
  100. package/src/application/commands/ReplaceMutableRunWorkflowSnapshotCommand.ts +12 -0
  101. package/src/application/commands/ReplaceMutableRunWorkflowSnapshotCommandHandler.ts +47 -0
  102. package/src/application/commands/ReplaceWorkflowDebuggerOverlayCommand.ts +14 -0
  103. package/src/application/commands/ReplaceWorkflowDebuggerOverlayCommandHandler.ts +35 -0
  104. package/src/application/commands/ReplayWorkflowNodeCommand.ts +12 -0
  105. package/src/application/commands/ReplayWorkflowNodeCommandHandler.ts +164 -0
  106. package/src/application/commands/SetPinnedNodeInputCommand.ts +13 -0
  107. package/src/application/commands/SetPinnedNodeInputCommandHandler.ts +50 -0
  108. package/src/application/commands/SetWorkflowActivationCommand.ts +10 -0
  109. package/src/application/commands/SetWorkflowActivationCommandHandler.ts +39 -0
  110. package/src/application/commands/StartWorkflowRunCommand.ts +8 -0
  111. package/src/application/commands/StartWorkflowRunCommandHandler.ts +286 -0
  112. package/src/application/commands/TestCredentialInstanceCommand.ts +9 -0
  113. package/src/application/commands/TestCredentialInstanceCommandHandler.ts +28 -0
  114. package/src/application/commands/UpdateCredentialInstanceCommand.ts +12 -0
  115. package/src/application/commands/UpdateCredentialInstanceCommandHandler.ts +28 -0
  116. package/src/application/commands/UpdateUserAccountStatusCommand.ts +12 -0
  117. package/src/application/commands/UpdateUserAccountStatusCommandHandler.ts +24 -0
  118. package/src/application/commands/UploadOverlayPinnedBinaryCommand.ts +16 -0
  119. package/src/application/commands/UploadOverlayPinnedBinaryCommandHandler.ts +31 -0
  120. package/src/application/commands/UpsertCredentialBindingCommand.ts +11 -0
  121. package/src/application/commands/UpsertCredentialBindingCommandHandler.ts +28 -0
  122. package/src/application/commands/UpsertLocalBootstrapUserCommand.ts +12 -0
  123. package/src/application/commands/UpsertLocalBootstrapUserCommandHandler.ts +24 -0
  124. package/src/application/commands/UserAccountCommandHandlers.ts +10 -0
  125. package/src/application/contracts/CredentialContractsRegistry.ts +88 -0
  126. package/src/application/contracts/RunContracts.ts +41 -0
  127. package/src/application/contracts/WorkflowDebuggerContracts.ts +12 -0
  128. package/src/application/contracts/WorkflowViewContracts.ts +40 -0
  129. package/src/application/contracts/WorkflowWebsocketMessage.ts +8 -0
  130. package/src/application/contracts/userDirectoryContracts.types.ts +60 -0
  131. package/src/application/dev/BootRuntimeSnapshotHolder.ts +19 -0
  132. package/src/application/dev/BootRuntimeSummary.types.ts +11 -0
  133. package/src/application/dev/DevBootstrapSummaryAssembler.ts +84 -0
  134. package/src/application/dev/DevBootstrapSummaryJson.types.ts +9 -0
  135. package/src/application/logging/LogFilter.ts +7 -0
  136. package/src/application/logging/Logger.ts +10 -0
  137. package/src/application/mapping/DataMapper.ts +3 -0
  138. package/src/application/mapping/WorkflowDefinitionMapper.ts +171 -0
  139. package/src/application/mapping/WorkflowPolicyUiPresentationFactory.ts +39 -0
  140. package/src/application/queries/CredentialQueryHandlers.ts +12 -0
  141. package/src/application/queries/GetCredentialFieldEnvStatusQuery.ts +5 -0
  142. package/src/application/queries/GetCredentialFieldEnvStatusQueryHandler.ts +52 -0
  143. package/src/application/queries/GetCredentialInstanceQuery.ts +9 -0
  144. package/src/application/queries/GetCredentialInstanceQueryHandler.ts +27 -0
  145. package/src/application/queries/GetCredentialInstanceWithSecretsQuery.ts +9 -0
  146. package/src/application/queries/GetCredentialInstanceWithSecretsQueryHandler.ts +27 -0
  147. package/src/application/queries/GetRunBinaryAttachmentQuery.ts +11 -0
  148. package/src/application/queries/GetRunBinaryAttachmentQueryHandler.ts +23 -0
  149. package/src/application/queries/GetRunStateQuery.ts +8 -0
  150. package/src/application/queries/GetRunStateQueryHandler.ts +21 -0
  151. package/src/application/queries/GetWorkflowCredentialHealthQuery.ts +9 -0
  152. package/src/application/queries/GetWorkflowCredentialHealthQueryHandler.ts +27 -0
  153. package/src/application/queries/GetWorkflowDebuggerOverlayQuery.ts +8 -0
  154. package/src/application/queries/GetWorkflowDebuggerOverlayQueryHandler.ts +28 -0
  155. package/src/application/queries/GetWorkflowDetailQuery.ts +8 -0
  156. package/src/application/queries/GetWorkflowDetailQueryHandler.ts +24 -0
  157. package/src/application/queries/GetWorkflowOverlayBinaryAttachmentQuery.ts +11 -0
  158. package/src/application/queries/GetWorkflowOverlayBinaryAttachmentQueryHandler.ts +23 -0
  159. package/src/application/queries/GetWorkflowSummariesQuery.ts +4 -0
  160. package/src/application/queries/GetWorkflowSummariesQueryHandler.ts +23 -0
  161. package/src/application/queries/ListCredentialInstancesQuery.ts +5 -0
  162. package/src/application/queries/ListCredentialInstancesQueryHandler.ts +27 -0
  163. package/src/application/queries/ListCredentialTypesQuery.ts +5 -0
  164. package/src/application/queries/ListCredentialTypesQueryHandler.ts +28 -0
  165. package/src/application/queries/ListUserAccountsQuery.ts +5 -0
  166. package/src/application/queries/ListUserAccountsQueryHandler.ts +22 -0
  167. package/src/application/queries/ListWorkflowRunsQuery.ts +8 -0
  168. package/src/application/queries/ListWorkflowRunsQueryHandler.ts +21 -0
  169. package/src/application/queries/UserAccountQueryHandlers.ts +4 -0
  170. package/src/application/queries/VerifyUserInviteQuery.ts +9 -0
  171. package/src/application/queries/VerifyUserInviteQueryHandler.ts +21 -0
  172. package/src/application/runs/WorkflowRunRetentionPruneScheduler.ts +98 -0
  173. package/src/application/websocket/WorkflowRunEventWebsocketRelay.ts +36 -0
  174. package/src/application/websocket/WorkflowWebsocketPublisher.ts +5 -0
  175. package/src/application/workflows/WebhookEndpointPathValidator.ts +35 -0
  176. package/src/application/workflows/WorkflowDebuggerOverlayStateFactory.ts +122 -0
  177. package/src/applicationTokens.ts +72 -0
  178. package/src/bootstrap/CodemationBootstrapRequest.ts +27 -0
  179. package/src/bootstrap/CodemationContainerFactory.ts +310 -0
  180. package/src/bootstrap/CodemationContainerRegistration.ts +23 -0
  181. package/src/bootstrap/CodemationContainerRegistrationRegistrar.ts +42 -0
  182. package/src/bootstrap/CodemationFrontendBootstrapRequest.ts +16 -0
  183. package/src/bootstrap/CodemationWorkerBootstrapRequest.ts +19 -0
  184. package/src/bootstrap/PreparedCodemationRuntime.ts +37 -0
  185. package/src/bootstrap/PreparedCodemationRuntimeFactory.ts +308 -0
  186. package/src/bootstrap/boot/CliRuntimeBootService.ts +27 -0
  187. package/src/bootstrap/boot/FrontendRuntimeBootService.ts +86 -0
  188. package/src/bootstrap/boot/WorkerRuntimeBootService.ts +64 -0
  189. package/src/bootstrap/runtime/AppConfigFactory.ts +57 -0
  190. package/src/bootstrap/runtime/ResolvedImplementationSelectionFactory.ts +118 -0
  191. package/src/client.ts +3 -0
  192. package/src/codemationApplication.ts +311 -0
  193. package/src/consumer.ts +4 -0
  194. package/src/credentials.ts +24 -0
  195. package/src/devServerSidecar.ts +10 -0
  196. package/src/domain/credentials/CredentialBindingService.ts +139 -0
  197. package/src/domain/credentials/CredentialFieldEnvOverlayService.ts +60 -0
  198. package/src/domain/credentials/CredentialInstanceService.ts +391 -0
  199. package/src/domain/credentials/CredentialMaterialResolver.ts +55 -0
  200. package/src/domain/credentials/CredentialRuntimeMaterialService.ts +39 -0
  201. package/src/domain/credentials/CredentialSecretCipher.ts +70 -0
  202. package/src/domain/credentials/CredentialServices.ts +145 -0
  203. package/src/domain/credentials/CredentialSessionServiceImpl.ts +119 -0
  204. package/src/domain/credentials/CredentialTestService.ts +73 -0
  205. package/src/domain/credentials/CredentialTypeRegistryImpl.ts +29 -0
  206. package/src/domain/credentials/OAuth2ConnectServiceFactory.ts +396 -0
  207. package/src/domain/credentials/OAuth2ProviderRegistry.ts +75 -0
  208. package/src/domain/credentials/WorkflowCredentialNodeResolver.ts +246 -0
  209. package/src/domain/runs/WorkflowRunRepository.ts +11 -0
  210. package/src/domain/users/UserAccountServiceRegistry.ts +315 -0
  211. package/src/domain/users/userLoginMethodLabels.types.ts +29 -0
  212. package/src/domain/workflows/WorkflowActivationPreflight.ts +32 -0
  213. package/src/domain/workflows/WorkflowActivationPreflightRules.ts +77 -0
  214. package/src/domain/workflows/WorkflowActivationRepository.ts +9 -0
  215. package/src/domain/workflows/WorkflowDebuggerOverlayRepository.ts +7 -0
  216. package/src/domain/workflows/WorkflowDebuggerOverlayState.ts +8 -0
  217. package/src/domain/workflows/WorkflowDefinitionRepository.ts +11 -0
  218. package/src/index.ts +58 -0
  219. package/src/infrastructure/auth/AuthJsSessionVerifier.ts +26 -0
  220. package/src/infrastructure/auth/DevelopmentSessionBypassVerifier.ts +12 -0
  221. package/src/infrastructure/binary/BinaryBodyNodeReadableFactory.ts +22 -0
  222. package/src/infrastructure/binary/CountingSha256Transform.ts +26 -0
  223. package/src/infrastructure/binary/LocalFilesystemBinaryStorageRegistry.ts +86 -0
  224. package/src/infrastructure/config/CodemationPluginRegistrar.ts +44 -0
  225. package/src/infrastructure/credentials/FrameworkBuiltinCredentialTypesRegistrar.ts +21 -0
  226. package/src/infrastructure/credentials/OpenAiApiKeyCredentialHealthTester.ts +89 -0
  227. package/src/infrastructure/credentials/OpenAiApiKeyCredentialShapes.types.ts +15 -0
  228. package/src/infrastructure/credentials/OpenAiApiKeyCredentialTypeFactory.ts +47 -0
  229. package/src/infrastructure/di/HandlesCommandRegistry.ts +24 -0
  230. package/src/infrastructure/di/HandlesDomainEventRegistry.ts +24 -0
  231. package/src/infrastructure/di/HandlesQueryRegistry.ts +24 -0
  232. package/src/infrastructure/di/InMemoryCommandBus.ts +47 -0
  233. package/src/infrastructure/di/InMemoryDomainEventBus.ts +47 -0
  234. package/src/infrastructure/di/InMemoryQueryBus.ts +45 -0
  235. package/src/infrastructure/ids/CodemationIdFactory.ts +12 -0
  236. package/src/infrastructure/logging/BrowserLogger.ts +1 -0
  237. package/src/infrastructure/logging/BrowserLoggerFactory.ts +14 -0
  238. package/src/infrastructure/logging/ConsoleLogger.ts +41 -0
  239. package/src/infrastructure/logging/FilteringLogger.ts +38 -0
  240. package/src/infrastructure/logging/LogLevelPolicy.ts +148 -0
  241. package/src/infrastructure/logging/LogLevelPolicyFactory.ts +16 -0
  242. package/src/infrastructure/logging/PerformanceLogPolicy.ts +10 -0
  243. package/src/infrastructure/logging/PerformanceLogPolicyFactory.ts +14 -0
  244. package/src/infrastructure/logging/ServerLogger.ts +1 -0
  245. package/src/infrastructure/logging/ServerLoggerFactory.ts +28 -0
  246. package/src/infrastructure/persistence/CodemationPostgresPrismaClientFactory.ts +9 -0
  247. package/src/infrastructure/persistence/CredentialPersistenceStore.ts +139 -0
  248. package/src/infrastructure/persistence/DatabasePersistenceResolver.ts +91 -0
  249. package/src/infrastructure/persistence/InMemoryTriggerSetupStateRepository.ts +23 -0
  250. package/src/infrastructure/persistence/InMemoryWorkflowActivationRepository.ts +18 -0
  251. package/src/infrastructure/persistence/InMemoryWorkflowDebuggerOverlayRepository.ts +16 -0
  252. package/src/infrastructure/persistence/InMemoryWorkflowRunRepository.ts +94 -0
  253. package/src/infrastructure/persistence/PrismaClientFactory.ts +26 -0
  254. package/src/infrastructure/persistence/PrismaCredentialStore.ts +368 -0
  255. package/src/infrastructure/persistence/PrismaMigrationDeployer.ts +184 -0
  256. package/src/infrastructure/persistence/PrismaTriggerSetupStateRepository.ts +68 -0
  257. package/src/infrastructure/persistence/PrismaWorkflowActivationRepository.ts +36 -0
  258. package/src/infrastructure/persistence/PrismaWorkflowDebuggerOverlayRepository.ts +65 -0
  259. package/src/infrastructure/persistence/PrismaWorkflowRunRepository.ts +243 -0
  260. package/src/infrastructure/persistence/RuntimeWorkflowActivationPolicy.ts +27 -0
  261. package/src/infrastructure/persistence/SchedulerPersistenceCompatibilityValidator.ts +20 -0
  262. package/src/infrastructure/persistence/WorkflowDefinitionRepositoryAdapter.ts +31 -0
  263. package/src/infrastructure/persistence/WorkflowRunRepository.ts +46 -0
  264. package/src/infrastructure/persistence/generated/prisma/client.d.ts +1 -0
  265. package/src/infrastructure/persistence/generated/prisma/default.d.ts +1 -0
  266. package/src/infrastructure/persistence/generated/prisma/edge.d.ts +1 -0
  267. package/src/infrastructure/persistence/generated/prisma/index.d.ts +4766 -0
  268. package/src/infrastructure/persistence/generated/prisma/package.json +144 -0
  269. package/src/infrastructure/persistence/generated/prisma/query_compiler_fast_bg.wasm +0 -0
  270. package/src/infrastructure/persistence/generated/prisma/runtime/client.d.ts +3358 -0
  271. package/src/infrastructure/persistence/generated/prisma/runtime/index-browser.d.ts +90 -0
  272. package/src/infrastructure/persistence/generated/prisma/schema.prisma +35 -0
  273. package/src/infrastructure/persistence/generated/prisma/wasm-edge-light-loader.mjs +5 -0
  274. package/src/infrastructure/persistence/generated/prisma/wasm-worker-loader.mjs +5 -0
  275. package/src/infrastructure/persistence/generated/prisma-client/client.d.ts +1 -0
  276. package/src/infrastructure/persistence/generated/prisma-client/client.js +5 -0
  277. package/src/infrastructure/persistence/generated/prisma-client/default.d.ts +1 -0
  278. package/src/infrastructure/persistence/generated/prisma-client/default.js +5 -0
  279. package/src/infrastructure/persistence/generated/prisma-client/edge.d.ts +1 -0
  280. package/src/infrastructure/persistence/generated/prisma-client/edge.js +299 -0
  281. package/src/infrastructure/persistence/generated/prisma-client/index-browser.js +325 -0
  282. package/src/infrastructure/persistence/generated/prisma-client/index.d.ts +21623 -0
  283. package/src/infrastructure/persistence/generated/prisma-client/index.js +299 -0
  284. package/src/infrastructure/persistence/generated/prisma-client/package.json +144 -0
  285. package/src/infrastructure/persistence/generated/prisma-client/query_compiler_fast_bg.js +2 -0
  286. package/src/infrastructure/persistence/generated/prisma-client/query_compiler_fast_bg.wasm +0 -0
  287. package/src/infrastructure/persistence/generated/prisma-client/query_compiler_fast_bg.wasm-base64.js +2 -0
  288. package/src/infrastructure/persistence/generated/prisma-client/runtime/client.d.ts +3358 -0
  289. package/src/infrastructure/persistence/generated/prisma-client/runtime/client.js +86 -0
  290. package/src/infrastructure/persistence/generated/prisma-client/runtime/client.js.map +1 -0
  291. package/src/infrastructure/persistence/generated/prisma-client/runtime/index-browser.d.ts +90 -0
  292. package/src/infrastructure/persistence/generated/prisma-client/runtime/index-browser.js +6 -0
  293. package/src/infrastructure/persistence/generated/prisma-client/runtime/index-browser.js.map +1 -0
  294. package/src/infrastructure/persistence/generated/prisma-client/runtime/wasm-compiler-edge.js +76 -0
  295. package/src/infrastructure/persistence/generated/prisma-client/runtime/wasm-compiler-edge.js.map +1 -0
  296. package/src/infrastructure/persistence/generated/prisma-client/schema.prisma +179 -0
  297. package/src/infrastructure/persistence/generated/prisma-client/wasm-edge-light-loader.mjs +5 -0
  298. package/src/infrastructure/persistence/generated/prisma-client/wasm-worker-loader.mjs +5 -0
  299. package/src/infrastructure/runtime/LiveWorkflowRepository.ts +14 -0
  300. package/src/infrastructure/runtime/WorkerRuntimeScheduler.ts +35 -0
  301. package/src/infrastructure/server/http/ServerHttpRouteParams.ts +1 -0
  302. package/src/infrastructure/webhooks/RequestToWebhookItemMapper.ts +128 -0
  303. package/src/nextServer.ts +31 -0
  304. package/src/persistenceServer.ts +5 -0
  305. package/src/presentation/config/AppConfig.ts +25 -0
  306. package/src/presentation/config/CodemationAppContext.ts +19 -0
  307. package/src/presentation/config/CodemationApplicationFacade.ts +5 -0
  308. package/src/presentation/config/CodemationAuthConfig.ts +31 -0
  309. package/src/presentation/config/CodemationClassToken.ts +3 -0
  310. package/src/presentation/config/CodemationConfig.ts +86 -0
  311. package/src/presentation/config/CodemationConfigNormalizer.ts +179 -0
  312. package/src/presentation/config/CodemationLogConfig.ts +22 -0
  313. package/src/presentation/config/CodemationPackageManifest.ts +9 -0
  314. package/src/presentation/config/CodemationPlugin.ts +20 -0
  315. package/src/presentation/config/CodemationPluginListMerger.ts +46 -0
  316. package/src/presentation/config/CodemationWhitelabelConfig.ts +9 -0
  317. package/src/presentation/config/CodemationWorkflowDiscovery.ts +3 -0
  318. package/src/presentation/http/ApiPaths.ts +165 -0
  319. package/src/presentation/http/CodemationServerGatewayFactory.ts +120 -0
  320. package/src/presentation/http/HttpRequestJsonBodyReader.ts +12 -0
  321. package/src/presentation/http/ServerHttpErrorResponseFactory.ts +33 -0
  322. package/src/presentation/http/ServerHttpRouteParams.ts +1 -0
  323. package/src/presentation/http/hono/CodemationHonoApiAppFactory.ts +64 -0
  324. package/src/presentation/http/hono/HonoApiRouteRegistrar.ts +5 -0
  325. package/src/presentation/http/hono/HonoHttpAnonymousRoutePolicyRegistry.ts +27 -0
  326. package/src/presentation/http/hono/registrars/BinaryHonoApiRouteRegistrar.ts +21 -0
  327. package/src/presentation/http/hono/registrars/CredentialHonoApiRouteRegistrar.ts +34 -0
  328. package/src/presentation/http/hono/registrars/DevHonoApiRouteRegistrar.ts +17 -0
  329. package/src/presentation/http/hono/registrars/OAuth2HonoApiRouteRegistrar.ts +18 -0
  330. package/src/presentation/http/hono/registrars/RunHonoApiRouteRegistrar.ts +31 -0
  331. package/src/presentation/http/hono/registrars/UserHonoApiRouteRegistrar.ts +24 -0
  332. package/src/presentation/http/hono/registrars/WebhookHonoApiRouteRegistrar.ts +23 -0
  333. package/src/presentation/http/hono/registrars/WhitelabelHonoApiRouteRegistrar.ts +18 -0
  334. package/src/presentation/http/hono/registrars/WorkflowHonoApiRouteRegistrar.ts +33 -0
  335. package/src/presentation/http/routeHandlers/BinaryHttpRouteHandlerFactory.ts +101 -0
  336. package/src/presentation/http/routeHandlers/CredentialHttpRouteHandler.ts +129 -0
  337. package/src/presentation/http/routeHandlers/DevBootstrapSummaryHttpRouteHandler.ts +21 -0
  338. package/src/presentation/http/routeHandlers/OAuth2HttpRouteHandlerFactory.ts +129 -0
  339. package/src/presentation/http/routeHandlers/RunHttpRouteHandler.ts +82 -0
  340. package/src/presentation/http/routeHandlers/UserHttpRouteHandlerFactory.ts +109 -0
  341. package/src/presentation/http/routeHandlers/WebhookHttpRouteHandler.ts +42 -0
  342. package/src/presentation/http/routeHandlers/WhitelabelLogoHttpRouteHandler.ts +96 -0
  343. package/src/presentation/http/routeHandlers/WorkflowHttpRouteHandler.ts +104 -0
  344. package/src/presentation/server/CodemationConsumerAppResolver.ts +82 -0
  345. package/src/presentation/server/CodemationConsumerConfigExportsResolver.ts +33 -0
  346. package/src/presentation/server/CodemationConsumerConfigLoader.ts +270 -0
  347. package/src/presentation/server/CodemationPluginDiscovery.ts +151 -0
  348. package/src/presentation/server/CodemationTsyringeParamInfoReader.ts +26 -0
  349. package/src/presentation/server/CodemationTsyringeTypeInfoRegistrar.ts +121 -0
  350. package/src/presentation/server/DevelopmentRuntimeRouteGuard.ts +59 -0
  351. package/src/presentation/server/DiscoveredWorkflowsEmptyMessageFactory.ts +11 -0
  352. package/src/presentation/server/WorkflowDefinitionExportsResolver.ts +24 -0
  353. package/src/presentation/server/WorkflowDiscoveryPathSegmentsComputer.ts +53 -0
  354. package/src/presentation/server/WorkflowModulePathFinder.ts +47 -0
  355. package/src/presentation/websocket/WorkflowWebsocketServer.ts +169 -0
  356. package/src/server.ts +14 -0
  357. package/tsconfig.json +10 -0
  358. package/vitest.shared.ts +45 -0
@@ -0,0 +1,1044 @@
1
+ import "reflect-metadata";
2
+ import { ReadableStream } from "node:stream/web";
3
+ import { DependencyContainer as Container, InjectionToken as TypeToken } from "tsyringe";
4
+
5
+ //#region ../core/src/contracts/Clock.d.ts
6
+ /** Port for time; inject `SystemClock` in production and a fake/test clock in tests. */
7
+ interface Clock {
8
+ now(): Date;
9
+ }
10
+ //#endregion
11
+ //#region ../core/src/contracts/retryPolicySpec.types.d.ts
12
+ /**
13
+ * In-process retry policy for runnable nodes. Serialized configs use the same
14
+ * `kind` discriminator (`JSON.stringify` / persisted workflows).
15
+ *
16
+ * `maxAttempts` is the total number of tries including the first (e.g. 3 means up to 2 delays after failures).
17
+ */
18
+ type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
19
+ interface NoneRetryPolicySpec {
20
+ readonly kind: "none";
21
+ }
22
+ interface FixedRetryPolicySpec {
23
+ readonly kind: "fixed";
24
+ /** Total attempts including the first execution. Must be >= 1. */
25
+ readonly maxAttempts: number;
26
+ readonly delayMs: number;
27
+ }
28
+ interface ExponentialRetryPolicySpec {
29
+ readonly kind: "exponential";
30
+ /** Total attempts including the first execution. Must be >= 1. */
31
+ readonly maxAttempts: number;
32
+ readonly initialDelayMs: number;
33
+ readonly multiplier: number;
34
+ readonly maxDelayMs?: number;
35
+ /** When true, each delay is multiplied by a random factor in [1, 1.2). */
36
+ readonly jitter?: boolean;
37
+ }
38
+ //#endregion
39
+ //#region ../core/src/contracts/runTypes.d.ts
40
+ interface RunExecutionOptions {
41
+ /** Run-intent override: force the inline scheduler and bypass node-level offload decisions. */
42
+ localOnly?: boolean;
43
+ /** Marks runs started from webhook handling so orchestration can apply webhook-specific continuation rules. */
44
+ webhook?: boolean;
45
+ mode?: "manual" | "debug";
46
+ sourceWorkflowId?: WorkflowId;
47
+ sourceRunId?: RunId;
48
+ derivedFromRunId?: RunId;
49
+ isMutable?: boolean;
50
+ /** Set by the engine for this run: 0 = root, 1 = first child subworkflow, … */
51
+ subworkflowDepth?: number;
52
+ /** Effective cap after engine policy merge (successful node completions per run). */
53
+ maxNodeActivations?: number;
54
+ /** Effective cap after engine policy merge (subworkflow nesting). */
55
+ maxSubworkflowDepth?: number;
56
+ }
57
+ /** Engine-owned counters persisted with the run (worker-safe). */
58
+ interface EngineRunCounters {
59
+ completedNodeActivations: number;
60
+ }
61
+ type RunStopCondition = Readonly<{
62
+ kind: "workflowCompleted";
63
+ }> | Readonly<{
64
+ kind: "nodeCompleted";
65
+ nodeId: NodeId;
66
+ }>;
67
+ interface RunStateResetRequest {
68
+ clearFromNodeId: NodeId;
69
+ }
70
+ interface PersistedRunControlState {
71
+ stopCondition?: RunStopCondition;
72
+ }
73
+ interface PersistedWorkflowSnapshotNode {
74
+ id: NodeId;
75
+ kind: NodeKind;
76
+ name?: string;
77
+ nodeTokenId: PersistedTokenId;
78
+ configTokenId: PersistedTokenId;
79
+ tokenName?: string;
80
+ configTokenName?: string;
81
+ config: unknown;
82
+ }
83
+ interface PersistedWorkflowSnapshot {
84
+ id: WorkflowId;
85
+ name: string;
86
+ nodes: ReadonlyArray<PersistedWorkflowSnapshotNode>;
87
+ edges: ReadonlyArray<Edge>;
88
+ /** When the snapshot was built from a live workflow definition that configured a workflow error handler. */
89
+ workflowErrorHandlerConfigured?: boolean;
90
+ /** Connection metadata for child nodes not in the execution graph (e.g. AI agent attachments). */
91
+ connections?: ReadonlyArray<WorkflowNodeConnection>;
92
+ }
93
+ type PinnedNodeOutputsByPort = Readonly<Record<OutputPortKey, Items>>;
94
+ interface PersistedMutableNodeState {
95
+ pinnedOutputsByPort?: PinnedNodeOutputsByPort;
96
+ lastDebugInput?: Items;
97
+ }
98
+ interface PersistedMutableRunState {
99
+ nodesById: Readonly<Record<NodeId, PersistedMutableNodeState>>;
100
+ }
101
+ type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
102
+ interface RunQueueEntry {
103
+ nodeId: NodeId;
104
+ input: Items;
105
+ toInput?: InputPortKey;
106
+ batchId?: string;
107
+ from?: Readonly<{
108
+ nodeId: NodeId;
109
+ output: OutputPortKey;
110
+ }>;
111
+ collect?: Readonly<{
112
+ expectedInputs: ReadonlyArray<InputPortKey>;
113
+ received: Readonly<Record<InputPortKey, Items>>;
114
+ }>;
115
+ }
116
+ type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
117
+ interface NodeExecutionError {
118
+ message: string;
119
+ name?: string;
120
+ stack?: string;
121
+ }
122
+ interface NodeExecutionSnapshot {
123
+ runId: RunId;
124
+ workflowId: WorkflowId;
125
+ nodeId: NodeId;
126
+ activationId?: NodeActivationId;
127
+ parent?: ParentExecutionRef;
128
+ status: NodeExecutionStatus;
129
+ usedPinnedOutput?: boolean;
130
+ queuedAt?: string;
131
+ startedAt?: string;
132
+ finishedAt?: string;
133
+ updatedAt: string;
134
+ inputsByPort?: NodeInputsByPort;
135
+ outputs?: NodeOutputs;
136
+ error?: NodeExecutionError;
137
+ }
138
+ /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
139
+ type ConnectionInvocationId = string;
140
+ /**
141
+ * One logical LLM or tool call under an owning workflow node (e.g. AI agent).
142
+ * The owning node defines what {@link managedInput} and {@link managedOutput} contain.
143
+ */
144
+ interface ConnectionInvocationRecord {
145
+ readonly invocationId: ConnectionInvocationId;
146
+ readonly runId: RunId;
147
+ readonly workflowId: WorkflowId;
148
+ readonly connectionNodeId: NodeId;
149
+ readonly parentAgentNodeId: NodeId;
150
+ readonly parentAgentActivationId: NodeActivationId;
151
+ readonly status: NodeExecutionStatus;
152
+ readonly managedInput?: JsonValue;
153
+ readonly managedOutput?: JsonValue;
154
+ readonly error?: NodeExecutionError;
155
+ readonly queuedAt?: string;
156
+ readonly startedAt?: string;
157
+ readonly finishedAt?: string;
158
+ readonly updatedAt: string;
159
+ }
160
+ /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
161
+ type ConnectionInvocationAppendArgs = Readonly<{
162
+ invocationId: ConnectionInvocationId;
163
+ connectionNodeId: NodeId;
164
+ parentAgentNodeId: NodeId;
165
+ parentAgentActivationId: NodeActivationId;
166
+ status: NodeExecutionStatus;
167
+ managedInput?: JsonValue;
168
+ managedOutput?: JsonValue;
169
+ error?: NodeExecutionError;
170
+ queuedAt?: string;
171
+ startedAt?: string;
172
+ finishedAt?: string;
173
+ }>;
174
+ interface RunCurrentState {
175
+ outputsByNode: Record<NodeId, NodeOutputs>;
176
+ nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
177
+ /** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
178
+ connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
179
+ mutableState?: PersistedMutableRunState;
180
+ }
181
+ interface CurrentStateExecutionRequest {
182
+ workflow: WorkflowDefinition;
183
+ items?: Items;
184
+ parent?: ParentExecutionRef;
185
+ executionOptions?: RunExecutionOptions;
186
+ workflowSnapshot?: PersistedWorkflowSnapshot;
187
+ mutableState?: PersistedMutableRunState;
188
+ currentState?: RunCurrentState;
189
+ stopCondition?: RunStopCondition;
190
+ reset?: RunStateResetRequest;
191
+ }
192
+ type RunStatus = "running" | "pending" | "completed" | "failed";
193
+ interface RunSummary {
194
+ runId: RunId;
195
+ workflowId: WorkflowId;
196
+ startedAt: string;
197
+ status: RunStatus;
198
+ /** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
199
+ finishedAt?: string;
200
+ parent?: ParentExecutionRef;
201
+ executionOptions?: RunExecutionOptions;
202
+ }
203
+ interface PendingNodeExecution {
204
+ runId: RunId;
205
+ activationId: NodeActivationId;
206
+ workflowId: WorkflowId;
207
+ nodeId: NodeId;
208
+ itemsIn: number;
209
+ inputsByPort: NodeInputsByPort;
210
+ receiptId: string;
211
+ queue?: string;
212
+ batchId?: string;
213
+ enqueuedAt: string;
214
+ }
215
+ interface PersistedRunState {
216
+ runId: RunId;
217
+ workflowId: WorkflowId;
218
+ startedAt: string;
219
+ parent?: ParentExecutionRef;
220
+ executionOptions?: RunExecutionOptions;
221
+ control?: PersistedRunControlState;
222
+ workflowSnapshot?: PersistedWorkflowSnapshot;
223
+ mutableState?: PersistedMutableRunState;
224
+ /** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
225
+ policySnapshot?: PersistedRunPolicySnapshot;
226
+ /** Successful node completions so far (for activation budget). */
227
+ engineCounters?: EngineRunCounters;
228
+ status: RunStatus;
229
+ pending?: PendingNodeExecution;
230
+ queue: RunQueueEntry[];
231
+ outputsByNode: Record<NodeId, NodeOutputs>;
232
+ nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
233
+ /** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
234
+ connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
235
+ }
236
+ interface WorkflowExecutionRepository {
237
+ createRun(args: {
238
+ runId: RunId;
239
+ workflowId: WorkflowId;
240
+ startedAt: string;
241
+ parent?: ParentExecutionRef;
242
+ executionOptions?: RunExecutionOptions;
243
+ control?: PersistedRunControlState;
244
+ workflowSnapshot?: PersistedWorkflowSnapshot;
245
+ mutableState?: PersistedMutableRunState;
246
+ policySnapshot?: PersistedRunPolicySnapshot;
247
+ engineCounters?: EngineRunCounters;
248
+ }): Promise<void>;
249
+ load(runId: RunId): Promise<PersistedRunState | undefined>;
250
+ save(state: PersistedRunState): Promise<void>;
251
+ deleteRun?(runId: RunId): Promise<void>;
252
+ }
253
+ type RunResult = {
254
+ runId: RunId;
255
+ workflowId: WorkflowId;
256
+ startedAt: string;
257
+ status: "completed";
258
+ outputs: Items;
259
+ } | {
260
+ runId: RunId;
261
+ workflowId: WorkflowId;
262
+ startedAt: string;
263
+ status: "pending";
264
+ pending: PendingNodeExecution;
265
+ } | {
266
+ runId: RunId;
267
+ workflowId: WorkflowId;
268
+ startedAt: string;
269
+ status: "failed";
270
+ error: {
271
+ message: string;
272
+ };
273
+ };
274
+ type WebhookRunResult = Readonly<{
275
+ runId: RunId;
276
+ workflowId: WorkflowId;
277
+ startedAt: string;
278
+ runStatus: "pending" | "completed";
279
+ response: Items;
280
+ }>;
281
+ interface PersistedWorkflowTokenRegistryLike {
282
+ register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): string;
283
+ getTokenId(type: TypeToken<unknown>): string | undefined;
284
+ resolve(tokenId: string): TypeToken<unknown> | undefined;
285
+ registerFromWorkflows?(workflows: ReadonlyArray<WorkflowDefinition>): void;
286
+ }
287
+ //#endregion
288
+ //#region ../core/src/contracts/workflowActivationPolicy.d.ts
289
+ /**
290
+ * Host-controlled policy: when false, trigger {@link TriggerNode} setup is skipped and webhook routes
291
+ * for that workflow are not registered (see engine trigger runtime + webhook matcher).
292
+ */
293
+ interface WorkflowActivationPolicy {
294
+ isActive(workflowId: WorkflowId): boolean;
295
+ }
296
+ //#endregion
297
+ //#region ../core/src/contracts/webhookTypes.d.ts
298
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
299
+ /** Match for an incoming HTTP request: user-defined URL segment + workflow trigger node. */
300
+ interface WebhookInvocationMatch {
301
+ /** Same value as the webhook trigger's configured endpoint key (URL segment under the webhook base path). */
302
+ endpointPath: string;
303
+ workflowId: WorkflowId;
304
+ nodeId: NodeId;
305
+ methods: ReadonlyArray<HttpMethod>;
306
+ parseJsonBody?: (body: unknown) => unknown;
307
+ }
308
+ /** Result of resolving an HTTP method + endpoint path against the catalog webhook index (404 vs 405 vs match). */
309
+ type WebhookTriggerResolution = {
310
+ status: "notFound";
311
+ } | {
312
+ status: "methodNotAllowed";
313
+ match: WebhookInvocationMatch;
314
+ } | {
315
+ status: "ok";
316
+ match: WebhookInvocationMatch;
317
+ };
318
+ /**
319
+ * Resolves webhook routes from workflow definitions (catalog-backed index, no registration at trigger setup).
320
+ */
321
+ interface WebhookTriggerMatcher {
322
+ match(args: {
323
+ endpointPath: string;
324
+ method: HttpMethod;
325
+ }): WebhookInvocationMatch | undefined;
326
+ lookup(endpointPath: string): WebhookInvocationMatch | undefined;
327
+ onEngineWorkflowsLoaded?(): void;
328
+ onEngineStopped?(): void;
329
+ /** Rebuild route index after activation changes without stopping the engine. */
330
+ reloadWebhookRoutes?(): void;
331
+ }
332
+ //#endregion
333
+ //#region ../core/src/contracts/runtimeTypes.d.ts
334
+ interface WorkflowRepository {
335
+ list(): ReadonlyArray<WorkflowDefinition>;
336
+ get(workflowId: WorkflowId): WorkflowDefinition | undefined;
337
+ }
338
+ interface LiveWorkflowRepository extends WorkflowRepository {
339
+ setWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
340
+ }
341
+ interface NodeResolver {
342
+ resolve<T>(token: TypeToken<T>): T;
343
+ }
344
+ interface NodeExecutionStatePublisher {
345
+ markQueued(args: {
346
+ nodeId: NodeId;
347
+ activationId?: NodeActivationId;
348
+ inputsByPort?: NodeInputsByPort;
349
+ }): Promise<void>;
350
+ markRunning(args: {
351
+ nodeId: NodeId;
352
+ activationId?: NodeActivationId;
353
+ inputsByPort?: NodeInputsByPort;
354
+ }): Promise<void>;
355
+ markCompleted(args: {
356
+ nodeId: NodeId;
357
+ activationId?: NodeActivationId;
358
+ inputsByPort?: NodeInputsByPort;
359
+ outputs?: NodeOutputs;
360
+ }): Promise<void>;
361
+ markFailed(args: {
362
+ nodeId: NodeId;
363
+ activationId?: NodeActivationId;
364
+ inputsByPort?: NodeInputsByPort;
365
+ error: Error;
366
+ }): Promise<void>;
367
+ appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise<void>;
368
+ }
369
+ type BinaryBody = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Uint8Array | ArrayBuffer;
370
+ interface BinaryStorageWriteRequest {
371
+ storageKey: string;
372
+ body: BinaryBody;
373
+ }
374
+ interface BinaryStorageWriteResult {
375
+ storageKey: string;
376
+ size: number;
377
+ sha256?: string;
378
+ }
379
+ interface BinaryStorageReadResult {
380
+ body: ReadableStream<Uint8Array>;
381
+ size?: number;
382
+ }
383
+ interface BinaryStorageStatResult {
384
+ exists: boolean;
385
+ size?: number;
386
+ }
387
+ interface BinaryStorage {
388
+ readonly driverName: string;
389
+ write(args: BinaryStorageWriteRequest): Promise<BinaryStorageWriteResult>;
390
+ openReadStream(storageKey: string): Promise<BinaryStorageReadResult | undefined>;
391
+ stat(storageKey: string): Promise<BinaryStorageStatResult>;
392
+ delete(storageKey: string): Promise<void>;
393
+ }
394
+ interface BinaryAttachmentCreateRequest {
395
+ name: string;
396
+ body: BinaryBody;
397
+ mimeType: string;
398
+ filename?: string;
399
+ previewKind?: BinaryAttachment["previewKind"];
400
+ }
401
+ interface NodeBinaryAttachmentService extends ExecutionBinaryService {
402
+ attach(args: BinaryAttachmentCreateRequest): Promise<BinaryAttachment>;
403
+ withAttachment<TJson>(item: Item<TJson>, name: string, attachment: BinaryAttachment): Item<TJson>;
404
+ }
405
+ interface ExecutionBinaryService {
406
+ forNode(args: {
407
+ nodeId: NodeId;
408
+ activationId: NodeActivationId;
409
+ }): NodeBinaryAttachmentService;
410
+ openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
411
+ }
412
+ interface ExecutionContext {
413
+ runId: RunId;
414
+ workflowId: WorkflowId;
415
+ parent?: ParentExecutionRef;
416
+ /** This run's subworkflow depth (0 = root). */
417
+ subworkflowDepth: number;
418
+ /** Effective activation budget cap for this run (after policy merge). */
419
+ engineMaxNodeActivations: number;
420
+ /** Effective subworkflow nesting cap for this run (after policy merge). */
421
+ engineMaxSubworkflowDepth: number;
422
+ now: () => Date;
423
+ data: RunDataSnapshot;
424
+ nodeState?: NodeExecutionStatePublisher;
425
+ binary: ExecutionBinaryService;
426
+ getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
427
+ }
428
+ interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
429
+ nodeId: NodeId;
430
+ activationId: NodeActivationId;
431
+ config: TConfig;
432
+ binary: NodeBinaryAttachmentService;
433
+ }
434
+ interface NodeExecutionRequest {
435
+ runId: RunId;
436
+ activationId: NodeActivationId;
437
+ workflowId: WorkflowId;
438
+ nodeId: NodeId;
439
+ input: Items;
440
+ parent?: ParentExecutionRef;
441
+ queue?: string;
442
+ executionOptions?: RunExecutionOptions;
443
+ }
444
+ interface NodeExecutionScheduler {
445
+ enqueue(request: NodeExecutionRequest): Promise<{
446
+ receiptId: string;
447
+ }>;
448
+ cancel?(receiptId: string): Promise<void>;
449
+ }
450
+ interface NodeActivationContinuation {
451
+ markNodeRunning(args: {
452
+ runId: RunId;
453
+ activationId: NodeActivationId;
454
+ nodeId: NodeId;
455
+ inputsByPort: NodeInputsByPort;
456
+ }): Promise<void>;
457
+ resumeFromNodeResult(args: {
458
+ runId: RunId;
459
+ activationId: NodeActivationId;
460
+ nodeId: NodeId;
461
+ outputs: NodeOutputs;
462
+ }): Promise<RunResult>;
463
+ resumeFromNodeError(args: {
464
+ runId: RunId;
465
+ activationId: NodeActivationId;
466
+ nodeId: NodeId;
467
+ error: Error;
468
+ }): Promise<RunResult>;
469
+ }
470
+ interface WorkflowSnapshotResolver {
471
+ resolve(args: {
472
+ workflowId: WorkflowId;
473
+ workflowSnapshot?: PersistedWorkflowSnapshot;
474
+ }): WorkflowDefinition | undefined;
475
+ }
476
+ //#endregion
477
+ //#region ../core/src/contracts/workflowTypes.d.ts
478
+ type WorkflowId = string;
479
+ type NodeId = string;
480
+ type OutputPortKey = string;
481
+ type InputPortKey = string;
482
+ type PersistedTokenId = string;
483
+ type NodeKind = "trigger" | "node";
484
+ type JsonPrimitive = string | number | boolean | null;
485
+ interface JsonObject {
486
+ readonly [key: string]: JsonValue;
487
+ }
488
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
489
+ type JsonArray = ReadonlyArray<JsonValue>;
490
+ interface Edge {
491
+ from: {
492
+ nodeId: NodeId;
493
+ output: OutputPortKey;
494
+ };
495
+ to: {
496
+ nodeId: NodeId;
497
+ input: InputPortKey;
498
+ };
499
+ }
500
+ type NodeConnectionName = string;
501
+ /**
502
+ * Named connection from an executable parent node to child nodes that exist in {@link WorkflowDefinition.nodes}
503
+ * but are not traversed by the main execution graph.
504
+ */
505
+ interface WorkflowNodeConnection {
506
+ readonly parentNodeId: NodeId;
507
+ readonly connectionName: NodeConnectionName;
508
+ readonly childNodeIds: ReadonlyArray<NodeId>;
509
+ }
510
+ interface WorkflowDefinition {
511
+ id: WorkflowId;
512
+ name: string;
513
+ nodes: NodeDefinition[];
514
+ edges: Edge[];
515
+ /**
516
+ * Optional metadata: which nodes are connection-owned children (e.g. AI agent `llm` / `tools` slots).
517
+ * When omitted, all nodes in {@link nodes} are treated as executable for topology.
518
+ */
519
+ readonly connections?: ReadonlyArray<WorkflowNodeConnection>;
520
+ /** Directory + file-stem path under a workflow discovery root (for UI grouping only). */
521
+ discoveryPathSegments?: readonly string[];
522
+ /** Retention for run JSON and binaries (seconds). Host/env may supply defaults when omitted. */
523
+ readonly prunePolicy?: WorkflowPrunePolicySpec;
524
+ /** Whether to keep run data after completion. Host/env may supply defaults when omitted. */
525
+ readonly storagePolicy?: WorkflowStoragePolicySpec;
526
+ /** Invoked after a node fails permanently (retries exhausted) and node error handler did not recover. */
527
+ readonly workflowErrorHandler?: WorkflowErrorHandlerSpec;
528
+ }
529
+ interface NodeConfigBase {
530
+ readonly kind: NodeKind;
531
+ readonly type: TypeToken<unknown>;
532
+ readonly name?: string;
533
+ readonly id?: NodeId;
534
+ readonly icon?: string;
535
+ readonly execution?: Readonly<{
536
+ hint?: "local" | "worker";
537
+ queue?: string;
538
+ }>;
539
+ /** In-process execute retries (runnable nodes). Triggers typically omit this. */
540
+ readonly retryPolicy?: RetryPolicySpec;
541
+ /** Recover from execute failures; return outputs to continue, or rethrow to fail the node. */
542
+ readonly nodeErrorHandler?: NodeErrorHandlerSpec;
543
+ /**
544
+ * When true, edges carrying zero items on an output port still schedule single-input downstream nodes.
545
+ * Decided from the **source** node that produced the (empty) output. Default (false/undefined): empty
546
+ * main batches skip downstream execution and propagate the empty path.
547
+ */
548
+ readonly continueWhenEmptyOutput?: boolean;
549
+ getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
550
+ }
551
+ interface NodeDefinition {
552
+ id: NodeId;
553
+ kind: NodeKind;
554
+ type: TypeToken<unknown>;
555
+ name?: string;
556
+ config: NodeConfigBase;
557
+ }
558
+ type PairedItemRef = Readonly<{
559
+ nodeId: NodeId;
560
+ output: OutputPortKey;
561
+ itemIndex: number;
562
+ }>;
563
+ type BinaryPreviewKind = "image" | "audio" | "video" | "download";
564
+ type BinaryAttachment = Readonly<{
565
+ id: string;
566
+ storageKey: string;
567
+ mimeType: string;
568
+ size: number;
569
+ storageDriver: string;
570
+ previewKind: BinaryPreviewKind;
571
+ createdAt: string;
572
+ runId: RunId;
573
+ workflowId: WorkflowId;
574
+ nodeId: NodeId;
575
+ activationId: NodeActivationId;
576
+ filename?: string;
577
+ sha256?: string;
578
+ }>;
579
+ type ItemBinary = Readonly<Record<string, BinaryAttachment>>;
580
+ type Item<TJson = unknown> = Readonly<{
581
+ json: TJson;
582
+ binary?: ItemBinary;
583
+ meta?: Readonly<Record<string, unknown>>;
584
+ paired?: ReadonlyArray<PairedItemRef>;
585
+ }>;
586
+ type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
587
+ type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
588
+ type RunId = string;
589
+ type NodeActivationId = string;
590
+ interface ParentExecutionRef {
591
+ runId: RunId;
592
+ workflowId: WorkflowId;
593
+ nodeId: NodeId;
594
+ /** Subworkflow depth of the **spawning** run (0 = root). Passed when starting a child run. */
595
+ subworkflowDepth?: number;
596
+ /** Effective max node activations from the parent run (propagated to child policy merge). */
597
+ engineMaxNodeActivations?: number;
598
+ /** Effective max subworkflow depth from the parent run (propagated to child policy merge). */
599
+ engineMaxSubworkflowDepth?: number;
600
+ }
601
+ interface RunDataSnapshot {
602
+ getOutputs(nodeId: NodeId): NodeOutputs | undefined;
603
+ getOutputItems(nodeId: NodeId, output?: OutputPortKey): Items;
604
+ getOutputItem(nodeId: NodeId, itemIndex: number, output?: OutputPortKey): Item | undefined;
605
+ }
606
+ interface RunIdFactory {
607
+ makeRunId(): RunId;
608
+ }
609
+ interface ActivationIdFactory {
610
+ makeActivationId(): NodeActivationId;
611
+ }
612
+ /** Whether to persist run execution data after the workflow finishes. */
613
+ type WorkflowStoragePolicyMode = "ALL" | "SUCCESS" | "ERROR" | "NEVER";
614
+ type WorkflowStoragePolicySpec = WorkflowStoragePolicyMode | TypeToken<WorkflowStoragePolicyResolver>;
615
+ interface WorkflowStoragePolicyResolver {
616
+ shouldPersist(args: WorkflowStoragePolicyDecisionArgs): boolean | Promise<boolean>;
617
+ }
618
+ interface WorkflowStoragePolicyDecisionArgs {
619
+ readonly runId: RunId;
620
+ readonly workflowId: WorkflowId;
621
+ readonly workflow: WorkflowDefinition;
622
+ readonly finalStatus: "completed" | "failed";
623
+ readonly startedAt: string;
624
+ readonly finishedAt: string;
625
+ }
626
+ interface WorkflowPrunePolicySpec {
627
+ readonly runDataRetentionSeconds?: number;
628
+ readonly binaryRetentionSeconds?: number;
629
+ }
630
+ interface PersistedRunPolicySnapshot {
631
+ readonly retentionSeconds?: number;
632
+ readonly binaryRetentionSeconds?: number;
633
+ readonly storagePolicy: WorkflowStoragePolicyMode;
634
+ }
635
+ interface WorkflowErrorHandler {
636
+ onError(ctx: WorkflowErrorContext): void | Promise<void>;
637
+ }
638
+ interface WorkflowErrorContext {
639
+ readonly runId: RunId;
640
+ readonly workflowId: WorkflowId;
641
+ readonly workflow: WorkflowDefinition;
642
+ readonly failedNodeId: NodeId;
643
+ readonly error: Error;
644
+ readonly startedAt: string;
645
+ readonly finishedAt: string;
646
+ }
647
+ type WorkflowErrorHandlerSpec = TypeToken<WorkflowErrorHandler> | WorkflowErrorHandler;
648
+ interface NodeErrorHandlerArgs<TConfig extends NodeConfigBase = NodeConfigBase> {
649
+ readonly kind: "single" | "multi";
650
+ readonly items: Items;
651
+ readonly inputsByPort: Readonly<Record<InputPortKey, Items>> | undefined;
652
+ readonly ctx: NodeExecutionContext<TConfig>;
653
+ readonly error: Error;
654
+ }
655
+ interface NodeErrorHandler {
656
+ handle<TConfig extends NodeConfigBase>(args: NodeErrorHandlerArgs<TConfig>): Promise<NodeOutputs>;
657
+ }
658
+ type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;
659
+ //#endregion
660
+ //#region ../core/src/contracts/credentialTypes.d.ts
661
+ type CredentialTypeId = string;
662
+ type CredentialInstanceId = string;
663
+ type CredentialMaterialSourceKind = "db" | "env" | "code";
664
+ type CredentialSetupStatus = "draft" | "ready";
665
+ type CredentialHealthStatus = "unknown" | "healthy" | "failing";
666
+ type CredentialFieldSchema = Readonly<{
667
+ key: string;
668
+ label: string;
669
+ type: "string" | "password" | "textarea" | "json" | "boolean";
670
+ required?: true;
671
+ order?: number;
672
+ placeholder?: string;
673
+ helpText?: string;
674
+ /** When set, host resolves this field from process.env at runtime; env wins over stored values. */
675
+ envVarName?: string;
676
+ /**
677
+ * When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI
678
+ * pattern or documentation URL). Do not use for secret values.
679
+ */
680
+ copyValue?: string;
681
+ /** Accessible label for the copy control (default: Copy). */
682
+ copyButtonLabel?: string;
683
+ }>;
684
+ type CredentialRequirement = Readonly<{
685
+ slotKey: string;
686
+ label: string;
687
+ acceptedTypes: ReadonlyArray<CredentialTypeId>;
688
+ optional?: true;
689
+ helpText?: string;
690
+ helpUrl?: string;
691
+ }>;
692
+ type CredentialBindingKey = Readonly<{
693
+ workflowId: WorkflowId;
694
+ nodeId: NodeId;
695
+ slotKey: string;
696
+ }>;
697
+ type CredentialBinding = Readonly<{
698
+ key: CredentialBindingKey;
699
+ instanceId: CredentialInstanceId;
700
+ updatedAt: string;
701
+ }>;
702
+ type CredentialHealth = Readonly<{
703
+ status: CredentialHealthStatus;
704
+ message?: string;
705
+ testedAt?: string;
706
+ expiresAt?: string;
707
+ details?: Readonly<Record<string, unknown>>;
708
+ }>;
709
+ type OAuth2ProviderFromPublicConfig = Readonly<{
710
+ authorizeUrlFieldKey: string;
711
+ tokenUrlFieldKey: string;
712
+ userInfoUrlFieldKey?: string;
713
+ }>;
714
+ type CredentialOAuth2AuthDefinition = Readonly<{
715
+ kind: "oauth2";
716
+ providerId: string;
717
+ scopes: ReadonlyArray<string>;
718
+ clientIdFieldKey?: string;
719
+ clientSecretFieldKey?: string;
720
+ } | {
721
+ kind: "oauth2";
722
+ providerFromPublicConfig: OAuth2ProviderFromPublicConfig;
723
+ scopes: ReadonlyArray<string>;
724
+ clientIdFieldKey?: string;
725
+ clientSecretFieldKey?: string;
726
+ }>;
727
+ type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;
728
+ type CredentialTypeDefinition = Readonly<{
729
+ typeId: CredentialTypeId;
730
+ displayName: string;
731
+ description?: string;
732
+ publicFields?: ReadonlyArray<CredentialFieldSchema>;
733
+ secretFields?: ReadonlyArray<CredentialFieldSchema>;
734
+ supportedSourceKinds?: ReadonlyArray<CredentialMaterialSourceKind>;
735
+ auth?: CredentialAuthDefinition;
736
+ }>;
737
+ /**
738
+ * JSON-shaped credential field bag (public config, resolved secret material, etc.).
739
+ */
740
+ type CredentialJsonRecord = Readonly<Record<string, unknown>>;
741
+ /**
742
+ * Persisted credential instance with typed `publicConfig`.
743
+ * Hosts may specialize `secretRef` with a stricter union while remaining
744
+ * assignable here for session/test callbacks.
745
+ */
746
+ type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
747
+ instanceId: CredentialInstanceId;
748
+ typeId: CredentialTypeId;
749
+ displayName: string;
750
+ sourceKind: CredentialMaterialSourceKind;
751
+ publicConfig: TPublicConfig;
752
+ secretRef: CredentialJsonRecord;
753
+ tags: ReadonlyArray<string>;
754
+ setupStatus: CredentialSetupStatus;
755
+ createdAt: string;
756
+ updatedAt: string;
757
+ }>;
758
+ /**
759
+ * Arguments passed to `CredentialType.createSession` and `CredentialType.test`.
760
+ * Declare `TPublicConfig` / `TMaterial` on `CredentialType` so implementations are checked
761
+ * against your credential shapes (similar to `NodeExecutionContext.config` for nodes).
762
+ */
763
+ type CredentialSessionFactoryArgs<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
764
+ instance: CredentialInstanceRecord<TPublicConfig>;
765
+ material: TMaterial;
766
+ publicConfig: TPublicConfig;
767
+ }>;
768
+ type CredentialSessionFactory<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<TSession>;
769
+ type CredentialHealthTester<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<CredentialHealth>;
770
+ /**
771
+ * Full credential type implementation: `definition` (UI/schema), `createSession`, and `test`.
772
+ * Use this at registration and config boundaries; `CredentialTypeDefinition` is only the schema slice.
773
+ */
774
+ type CredentialType<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = Readonly<{
775
+ definition: CredentialTypeDefinition;
776
+ createSession: CredentialSessionFactory<TPublicConfig, TMaterial, TSession>;
777
+ test: CredentialHealthTester<TPublicConfig, TMaterial>;
778
+ }>;
779
+ /**
780
+ * Credential type with unspecified generics — used for `CodemationConfig.credentialTypes`, the host registry,
781
+ * and anywhere a concrete `CredentialType<YourPublic, YourMaterial, YourSession>` is placed in a heterogeneous list.
782
+ * Using `any` here avoids unsafe `as` casts while keeping typed `satisfies CredentialType<…>` definitions.
783
+ */
784
+ type AnyCredentialType = CredentialType<any, any, unknown>;
785
+ interface CredentialSessionService {
786
+ getSession<TSession = unknown>(args: Readonly<{
787
+ workflowId: WorkflowId;
788
+ nodeId: NodeId;
789
+ slotKey: string;
790
+ }>): Promise<TSession>;
791
+ }
792
+ interface CredentialTypeRegistry {
793
+ listTypes(): ReadonlyArray<CredentialTypeDefinition>;
794
+ getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined;
795
+ }
796
+ //#endregion
797
+ //#region ../core/src/events/runEvents.d.ts
798
+ type RunEvent = Readonly<{
799
+ kind: "runCreated";
800
+ runId: RunId;
801
+ workflowId: WorkflowId;
802
+ parent?: ParentExecutionRef;
803
+ at: string;
804
+ }> | Readonly<{
805
+ kind: "runSaved";
806
+ runId: RunId;
807
+ workflowId: WorkflowId;
808
+ parent?: ParentExecutionRef;
809
+ at: string;
810
+ state: PersistedRunState;
811
+ }> | Readonly<{
812
+ kind: "nodeQueued";
813
+ runId: RunId;
814
+ workflowId: WorkflowId;
815
+ parent?: ParentExecutionRef;
816
+ at: string;
817
+ snapshot: NodeExecutionSnapshot;
818
+ }> | Readonly<{
819
+ kind: "nodeStarted";
820
+ runId: RunId;
821
+ workflowId: WorkflowId;
822
+ parent?: ParentExecutionRef;
823
+ at: string;
824
+ snapshot: NodeExecutionSnapshot;
825
+ }> | Readonly<{
826
+ kind: "nodeCompleted";
827
+ runId: RunId;
828
+ workflowId: WorkflowId;
829
+ parent?: ParentExecutionRef;
830
+ at: string;
831
+ snapshot: NodeExecutionSnapshot;
832
+ }> | Readonly<{
833
+ kind: "nodeFailed";
834
+ runId: RunId;
835
+ workflowId: WorkflowId;
836
+ parent?: ParentExecutionRef;
837
+ at: string;
838
+ snapshot: NodeExecutionSnapshot;
839
+ }>;
840
+ //#endregion
841
+ //#region ../core/src/policies/executionLimits/EngineExecutionLimitsPolicy.d.ts
842
+ interface EngineExecutionLimitsPolicyConfig {
843
+ readonly defaultMaxNodeActivations: number;
844
+ readonly hardMaxNodeActivations: number;
845
+ readonly defaultMaxSubworkflowDepth: number;
846
+ readonly hardMaxSubworkflowDepth: number;
847
+ }
848
+ /**
849
+ * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
850
+ */
851
+ declare class EngineExecutionLimitsPolicy {
852
+ private readonly config;
853
+ constructor(config?: EngineExecutionLimitsPolicyConfig);
854
+ /**
855
+ * Effective options for a new root run (depth 0): defaults merged with engine ceilings.
856
+ * Replaces a separate one-method factory for root-run bootstrap.
857
+ */
858
+ createRootExecutionOptions(): RunExecutionOptions;
859
+ mergeExecutionOptionsForNewRun(parent: ParentExecutionRef | undefined, user: RunExecutionOptions | undefined): RunExecutionOptions;
860
+ private capNumber;
861
+ }
862
+ //#endregion
863
+ //#region ../core/src/orchestration/Engine.d.ts
864
+ interface EngineTriggerRuntime {
865
+ startTriggers(): Promise<void>;
866
+ stop(): Promise<void>;
867
+ syncWorkflowTriggersForActivation(workflowId: WorkflowId): Promise<void>;
868
+ createTriggerTestItems(args: {
869
+ workflow: WorkflowDefinition;
870
+ nodeId: NodeId;
871
+ }): Promise<Items | undefined>;
872
+ }
873
+ interface EngineRunStartService {
874
+ runWorkflow(wf: WorkflowDefinition, startAt: NodeId, items: Items, parent?: ParentExecutionRef, executionOptions?: RunExecutionOptions, persistedStateOverrides?: Readonly<{
875
+ workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
876
+ mutableState?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["mutableState"];
877
+ }>): Promise<RunResult>;
878
+ runWorkflowFromState(request: CurrentStateExecutionRequest): Promise<RunResult>;
879
+ }
880
+ interface EngineRunContinuationService {
881
+ markNodeRunning(args: {
882
+ runId: RunId;
883
+ activationId: NodeActivationId;
884
+ nodeId: NodeId;
885
+ inputsByPort: NodeInputsByPort;
886
+ }): Promise<void>;
887
+ resumeFromNodeResult(args: {
888
+ runId: RunId;
889
+ activationId: NodeActivationId;
890
+ nodeId: NodeId;
891
+ outputs: NodeOutputs;
892
+ }): Promise<RunResult>;
893
+ resumeFromNodeError(args: {
894
+ runId: RunId;
895
+ activationId: NodeActivationId;
896
+ nodeId: NodeId;
897
+ error: Error;
898
+ }): Promise<RunResult>;
899
+ resumeFromStepResult(args: {
900
+ runId: RunId;
901
+ activationId: NodeActivationId;
902
+ nodeId: NodeId;
903
+ outputs: NodeOutputs;
904
+ }): Promise<RunResult>;
905
+ resumeFromStepError(args: {
906
+ runId: RunId;
907
+ activationId: NodeActivationId;
908
+ nodeId: NodeId;
909
+ error: Error;
910
+ }): Promise<RunResult>;
911
+ waitForCompletion(runId: RunId): Promise<Extract<RunResult, {
912
+ status: "completed" | "failed";
913
+ }>>;
914
+ waitForWebhookResponse(runId: RunId): Promise<WebhookRunResult>;
915
+ }
916
+ interface EngineFacadeDeps {
917
+ liveWorkflowRepository: LiveWorkflowRepository;
918
+ tokenRegistry: PersistedWorkflowTokenRegistryLike;
919
+ webhookTriggerMatcher: WebhookTriggerMatcher;
920
+ workflowSnapshotResolver: WorkflowSnapshotResolver;
921
+ triggerRuntime: EngineTriggerRuntime;
922
+ runStartService: EngineRunStartService;
923
+ runContinuationService: EngineRunContinuationService;
924
+ }
925
+ /**
926
+ * Runtime facade for orchestration, continuation, triggers, and webhook routing.
927
+ * Prefer {@link import("../intents/RunIntentService").RunIntentService} for host/HTTP invocation boundaries.
928
+ * The class token is exported from `@codemation/core/bootstrap` (not the main `@codemation/core` barrel).
929
+ */
930
+ declare class Engine implements NodeActivationContinuation {
931
+ private readonly deps;
932
+ constructor(deps: EngineFacadeDeps);
933
+ loadWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
934
+ getTokenRegistry(): EngineFacadeDeps["tokenRegistry"];
935
+ resolveWorkflowSnapshot(args: {
936
+ workflowId: WorkflowId;
937
+ workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
938
+ }): WorkflowDefinition | undefined;
939
+ startTriggers(): Promise<void>;
940
+ syncWorkflowTriggersForActivation(workflowId: WorkflowId): Promise<void>;
941
+ start(workflows: WorkflowDefinition[]): Promise<void>;
942
+ stop(): Promise<void>;
943
+ resolveWebhookTrigger(args: {
944
+ endpointPath: string;
945
+ method: HttpMethod;
946
+ }): WebhookTriggerResolution;
947
+ createTriggerTestItems(args: {
948
+ workflow: WorkflowDefinition;
949
+ nodeId: NodeId;
950
+ }): Promise<Items | undefined>;
951
+ runWorkflow(wf: WorkflowDefinition, startAt: NodeId, items: Items, parent?: ParentExecutionRef, executionOptions?: RunExecutionOptions, persistedStateOverrides?: Readonly<{
952
+ workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
953
+ mutableState?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["mutableState"];
954
+ }>): Promise<RunResult>;
955
+ runWorkflowFromState(request: CurrentStateExecutionRequest): Promise<RunResult>;
956
+ markNodeRunning(args: {
957
+ runId: RunId;
958
+ activationId: NodeActivationId;
959
+ nodeId: NodeId;
960
+ inputsByPort: NodeInputsByPort;
961
+ }): Promise<void>;
962
+ resumeFromNodeResult(args: {
963
+ runId: RunId;
964
+ activationId: NodeActivationId;
965
+ nodeId: NodeId;
966
+ outputs: NodeOutputs;
967
+ }): Promise<RunResult>;
968
+ resumeFromNodeError(args: {
969
+ runId: RunId;
970
+ activationId: NodeActivationId;
971
+ nodeId: NodeId;
972
+ error: Error;
973
+ }): Promise<RunResult>;
974
+ resumeFromStepResult(args: {
975
+ runId: RunId;
976
+ activationId: NodeActivationId;
977
+ nodeId: NodeId;
978
+ outputs: NodeOutputs;
979
+ }): Promise<RunResult>;
980
+ resumeFromStepError(args: {
981
+ runId: RunId;
982
+ activationId: NodeActivationId;
983
+ nodeId: NodeId;
984
+ error: Error;
985
+ }): Promise<RunResult>;
986
+ waitForCompletion(runId: RunId): Promise<Extract<RunResult, {
987
+ status: "completed" | "failed";
988
+ }>>;
989
+ waitForWebhookResponse(runId: RunId): Promise<WebhookRunResult>;
990
+ }
991
+ //#endregion
992
+ //#region ../core/src/runtime/RunIntentService.d.ts
993
+ type StartWorkflowIntent = {
994
+ workflow: WorkflowDefinition;
995
+ startAt?: string;
996
+ items: Items;
997
+ parent?: CurrentStateExecutionRequest["parent"];
998
+ executionOptions?: RunExecutionOptions;
999
+ workflowSnapshot?: CurrentStateExecutionRequest["workflowSnapshot"];
1000
+ mutableState?: CurrentStateExecutionRequest["mutableState"];
1001
+ currentState?: RunCurrentState;
1002
+ stopCondition?: RunStopCondition;
1003
+ reset?: CurrentStateExecutionRequest["reset"];
1004
+ };
1005
+ type RerunFromNodeIntent = {
1006
+ workflow: WorkflowDefinition;
1007
+ nodeId: NodeId;
1008
+ currentState: RunCurrentState;
1009
+ items?: Items;
1010
+ parent?: CurrentStateExecutionRequest["parent"];
1011
+ executionOptions?: RunExecutionOptions;
1012
+ workflowSnapshot?: CurrentStateExecutionRequest["workflowSnapshot"];
1013
+ mutableState?: CurrentStateExecutionRequest["mutableState"];
1014
+ };
1015
+ type MatchedWebhookRunIntent = {
1016
+ endpointPath: string;
1017
+ method: HttpMethod;
1018
+ requestItem: Items[number];
1019
+ };
1020
+ type WebhookMatchRunIntent = {
1021
+ match: WebhookInvocationMatch;
1022
+ requestItem: Items[number];
1023
+ };
1024
+ declare class RunIntentService {
1025
+ private readonly engine;
1026
+ private readonly workflowRepository;
1027
+ constructor(engine: Engine, workflowRepository: WorkflowRepository);
1028
+ startWorkflow(args: StartWorkflowIntent): Promise<RunResult>;
1029
+ rerunFromNode(args: RerunFromNodeIntent): Promise<RunResult>;
1030
+ resolveWebhookTrigger(args: {
1031
+ endpointPath: string;
1032
+ method: HttpMethod;
1033
+ }): WebhookTriggerResolution;
1034
+ runMatchedWebhook(args: MatchedWebhookRunIntent): Promise<WebhookRunResult>;
1035
+ runWebhookMatch(args: WebhookMatchRunIntent): Promise<WebhookRunResult>;
1036
+ /**
1037
+ * Webhook-triggered runs always force inline execution first.
1038
+ * This is the highest-precedence scheduler override: it wins over node hints and container defaults.
1039
+ */
1040
+ private createWebhookExecutionOptions;
1041
+ }
1042
+ //#endregion
1043
+ export { RunIdFactory as A, PersistedRunState as B, CredentialTypeId as C, Item as D, BinaryAttachment as E, NodeExecutionScheduler as F, RunSummary as H, NodeResolver as I, WorkflowRepository as L, WorkflowId as M, BinaryStorage as N, NodeDefinition as O, NodeActivationContinuation as P, WebhookInvocationMatch as R, CredentialTypeDefinition as S, ActivationIdFactory as T, WorkflowExecutionRepository as U, RunCurrentState as V, Clock as W, CredentialRequirement as _, EngineExecutionLimitsPolicyConfig as a, CredentialSetupStatus as b, CredentialBinding as c, CredentialHealth as d, CredentialInstanceId as f, CredentialOAuth2AuthDefinition as g, CredentialMaterialSourceKind as h, EngineExecutionLimitsPolicy as i, WorkflowDefinition as j, RunId as k, CredentialBindingKey as l, CredentialJsonRecord as m, Container as n, RunEvent as o, CredentialInstanceRecord as p, TypeToken as r, AnyCredentialType as s, RunIntentService as t, CredentialFieldSchema as u, CredentialSessionFactoryArgs as v, CredentialTypeRegistry as w, CredentialType as x, CredentialSessionService as y, WorkflowActivationPolicy as z };
1044
+ //# sourceMappingURL=index-Bs4F1IsC.d.ts.map