@lostgradient/weft 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (579) hide show
  1. package/README.md +123 -43
  2. package/dist/cli/conformance.js +7 -1
  3. package/dist/cli/generated/operation-client.generated.d.ts +55 -13
  4. package/dist/cli/generated/operation-client.generated.js +3 -0
  5. package/dist/cli/help-text.d.ts +1 -1
  6. package/dist/cli/help-text.js +1 -0
  7. package/dist/cli/operation-catalog-snapshot.d.ts +8 -0
  8. package/dist/cli/operation-catalog-snapshot.js +11 -0
  9. package/dist/cli/parse-schedule-arguments.js +3 -1
  10. package/dist/cli/schedule.js +2 -1
  11. package/dist/cli/types.d.ts +1 -0
  12. package/dist/cli-main.js +80 -79
  13. package/dist/client/handle-delegation.d.ts +7 -2
  14. package/dist/client/handle-delegation.js +9 -1
  15. package/dist/client/http-client-requests.d.ts +4 -1
  16. package/dist/client/http-client-requests.js +10 -0
  17. package/dist/client/http-client.d.ts +10 -4
  18. package/dist/client/http-client.js +18 -1
  19. package/dist/client/http-request.d.ts +11 -1
  20. package/dist/client/http-request.js +17 -7
  21. package/dist/client/index.d.ts +1 -1
  22. package/dist/client/interface.d.ts +100 -4
  23. package/dist/client/local.d.ts +7 -1
  24. package/dist/client/local.js +17 -2
  25. package/dist/client/start-body.d.ts +9 -2
  26. package/dist/client/start-body.js +13 -4
  27. package/dist/core/byte-arrays.d.ts +5 -0
  28. package/dist/core/byte-arrays.js +5 -0
  29. package/dist/core/checkpoint/lifecycle.d.ts +3 -0
  30. package/dist/core/checkpoint/lifecycle.js +9 -4
  31. package/dist/core/checkpoint/serialization.js +12 -5
  32. package/dist/core/codec/extension-codec.d.ts +16 -0
  33. package/dist/core/codec/extension-codec.js +104 -8
  34. package/dist/core/codec/index.d.ts +1 -0
  35. package/dist/core/codec/index.js +1 -0
  36. package/dist/core/codec/serializer-registry.d.ts +122 -0
  37. package/dist/core/codec/serializer-registry.js +51 -0
  38. package/dist/core/context/activity-retry-state.d.ts +38 -0
  39. package/dist/core/context/activity-retry-state.js +89 -0
  40. package/dist/core/context/activity-schedule-to-close.d.ts +159 -0
  41. package/dist/core/context/activity-schedule-to-close.js +69 -0
  42. package/dist/core/context/child-workflow-pipe.d.ts +5 -5
  43. package/dist/core/context/child-workflow-pipe.js +15 -2
  44. package/dist/core/context/context-presence.d.ts +19 -0
  45. package/dist/core/context/context-presence.js +13 -0
  46. package/dist/core/context/durable-operations.d.ts +25 -0
  47. package/dist/core/context/durable-operations.js +64 -0
  48. package/dist/core/context/index.d.ts +18 -5
  49. package/dist/core/context/index.js +17 -12
  50. package/dist/core/context/internals.d.ts +29 -0
  51. package/dist/core/context/internals.js +6 -1
  52. package/dist/core/context/operation-request.d.ts +35 -0
  53. package/dist/core/context/parallel-cache-entry.d.ts +14 -5
  54. package/dist/core/context/run-operation.d.ts +21 -3
  55. package/dist/core/context/run-operation.js +56 -93
  56. package/dist/core/context/session-state.js +7 -8
  57. package/dist/core/context/speculative-child.js +2 -0
  58. package/dist/core/context/types.d.ts +15 -0
  59. package/dist/core/context/version-patching.d.ts +8 -0
  60. package/dist/core/context/version-patching.js +40 -0
  61. package/dist/core/context/workflow-logger.d.ts +98 -0
  62. package/dist/core/context/workflow-logger.js +68 -0
  63. package/dist/core/engine/activity-heartbeat-tracking.d.ts +64 -0
  64. package/dist/core/engine/activity-heartbeat-tracking.js +42 -0
  65. package/dist/core/engine/activity-per-attempt-timeout.d.ts +41 -0
  66. package/dist/core/engine/activity-per-attempt-timeout.js +36 -0
  67. package/dist/core/engine/activity-reconciliation.d.ts +1 -0
  68. package/dist/core/engine/activity-reconciliation.js +12 -1
  69. package/dist/core/engine/activity-resolution.d.ts +23 -0
  70. package/dist/core/engine/activity-resolution.js +37 -0
  71. package/dist/core/engine/aggregate.js +66 -30
  72. package/dist/core/engine/async-activity-completion.d.ts +23 -6
  73. package/dist/core/engine/async-activity-completion.js +53 -12
  74. package/dist/core/engine/attributes-tags.js +9 -4
  75. package/dist/core/engine/bulk-operations-purge.d.ts +26 -0
  76. package/dist/core/engine/bulk-operations-purge.js +38 -3
  77. package/dist/core/engine/bulk-operations-shared.d.ts +2 -0
  78. package/dist/core/engine/bulk-operations-shared.js +8 -2
  79. package/dist/core/engine/bulk-operations.d.ts +4 -1
  80. package/dist/core/engine/bulk-operations.js +235 -24
  81. package/dist/core/engine/callback-creators-bundles.d.ts +9 -0
  82. package/dist/core/engine/callback-creators-bundles.js +30 -2
  83. package/dist/core/engine/callback-creators-core.js +6 -4
  84. package/dist/core/engine/callback-creators-router.js +10 -0
  85. package/dist/core/engine/callback-creators-schedule.d.ts +2 -2
  86. package/dist/core/engine/callback-creators-schedule.js +12 -8
  87. package/dist/core/engine/candidate-read-batching.d.ts +6 -0
  88. package/dist/core/engine/candidate-read-batching.js +1 -0
  89. package/dist/core/engine/checkpoint-io.js +61 -25
  90. package/dist/core/engine/checkpoint-reads.js +3 -2
  91. package/dist/core/engine/checkpoint-replay.d.ts +20 -0
  92. package/dist/core/engine/checkpoint-replay.js +242 -0
  93. package/dist/core/engine/checkpoint-side-effects.d.ts +23 -0
  94. package/dist/core/engine/checkpoint-side-effects.js +35 -0
  95. package/dist/core/engine/child-workflow-cancellation.d.ts +10 -0
  96. package/dist/core/engine/child-workflow-cancellation.js +40 -0
  97. package/dist/core/engine/child-workflow.js +27 -4
  98. package/dist/core/engine/condition-waiters.d.ts +14 -0
  99. package/dist/core/engine/condition-waiters.js +5 -0
  100. package/dist/core/engine/construction.d.ts +3 -1
  101. package/dist/core/engine/construction.js +30 -8
  102. package/dist/core/engine/coordination-branch-executors.d.ts +70 -0
  103. package/dist/core/engine/coordination-branch-executors.js +107 -0
  104. package/dist/core/engine/deferred-consume-envelope.d.ts +59 -0
  105. package/dist/core/engine/deferred-consume-envelope.js +14 -0
  106. package/dist/core/engine/disposal.js +25 -0
  107. package/dist/core/engine/engine-create-types.d.ts +14 -18
  108. package/dist/core/engine/engine-internal-types.d.ts +38 -3
  109. package/dist/core/engine/engine-leak-warnings.d.ts +6 -0
  110. package/dist/core/engine/engine-leak-warnings.js +4 -0
  111. package/dist/core/engine/engine-runtime-helpers.d.ts +17 -0
  112. package/dist/core/engine/engine-runtime-helpers.js +26 -5
  113. package/dist/core/engine/errors.d.ts +121 -0
  114. package/dist/core/engine/errors.js +45 -1
  115. package/dist/core/engine/event-log-compaction.d.ts +8 -0
  116. package/dist/core/engine/event-log-compaction.js +20 -2
  117. package/dist/core/engine/fenced-write.d.ts +65 -0
  118. package/dist/core/engine/fenced-write.js +71 -0
  119. package/dist/core/engine/finalizer-state.d.ts +28 -0
  120. package/dist/core/engine/finalizer-state.js +16 -0
  121. package/dist/core/engine/handle-result.js +1 -1
  122. package/dist/core/engine/handles.d.ts +97 -40
  123. package/dist/core/engine/handles.js +25 -27
  124. package/dist/core/engine/index.d.ts +125 -15
  125. package/dist/core/engine/index.js +207 -11
  126. package/dist/core/engine/inline-launch-queue.d.ts +14 -0
  127. package/dist/core/engine/inline-launch-queue.js +32 -7
  128. package/dist/core/engine/inline-parking.js +3 -2
  129. package/dist/core/engine/internals.d.ts +125 -13
  130. package/dist/core/engine/lease-codec.d.ts +35 -0
  131. package/dist/core/engine/lease-codec.js +32 -0
  132. package/dist/core/engine/lease-deposition.d.ts +66 -0
  133. package/dist/core/engine/lease-deposition.js +10 -0
  134. package/dist/core/engine/lease-errors.d.ts +99 -0
  135. package/dist/core/engine/lease-errors.js +30 -0
  136. package/dist/core/engine/lease-manager.d.ts +114 -0
  137. package/dist/core/engine/lease-manager.js +135 -0
  138. package/dist/core/engine/lifecycle/fork-helpers.js +1 -7
  139. package/dist/core/engine/lifecycle/persist.js +15 -52
  140. package/dist/core/engine/lifecycle/recovered-services.d.ts +8 -6
  141. package/dist/core/engine/lifecycle/recovered-services.js +18 -3
  142. package/dist/core/engine/lifecycle/resume.js +39 -11
  143. package/dist/core/engine/lifecycle/shared.d.ts +8 -1
  144. package/dist/core/engine/lifecycle/start-batch.d.ts +1 -1
  145. package/dist/core/engine/lifecycle/start-batch.js +2 -1
  146. package/dist/core/engine/lifecycle/start-commit.d.ts +56 -0
  147. package/dist/core/engine/lifecycle/start-commit.js +69 -0
  148. package/dist/core/engine/lifecycle/start-exec.d.ts +30 -2
  149. package/dist/core/engine/lifecycle/start-exec.js +38 -0
  150. package/dist/core/engine/lifecycle/start-or-signal-create.d.ts +58 -0
  151. package/dist/core/engine/lifecycle/start-or-signal-create.js +95 -0
  152. package/dist/core/engine/lifecycle/start-or-signal-resolution.d.ts +79 -0
  153. package/dist/core/engine/lifecycle/start-or-signal-resolution.js +60 -0
  154. package/dist/core/engine/lifecycle/start-or-signal.d.ts +46 -0
  155. package/dist/core/engine/lifecycle/start-or-signal.js +71 -0
  156. package/dist/core/engine/lifecycle/start-terminal-conflict-purge.d.ts +39 -0
  157. package/dist/core/engine/lifecycle/start-terminal-conflict-purge.js +28 -0
  158. package/dist/core/engine/lifecycle/start.d.ts +6 -6
  159. package/dist/core/engine/lifecycle/start.js +47 -45
  160. package/dist/core/engine/lifecycle/transition.js +17 -5
  161. package/dist/core/engine/lifecycle.d.ts +3 -2
  162. package/dist/core/engine/lifecycle.js +9 -2
  163. package/dist/core/engine/list-candidate-resolution.js +2 -2
  164. package/dist/core/engine/listing.js +10 -6
  165. package/dist/core/engine/operations-activity.d.ts +4 -11
  166. package/dist/core/engine/operations-activity.js +22 -49
  167. package/dist/core/engine/operations-coordination.d.ts +10 -0
  168. package/dist/core/engine/operations-coordination.js +43 -8
  169. package/dist/core/engine/operations-router.d.ts +6 -0
  170. package/dist/core/engine/operations-router.js +2 -0
  171. package/dist/core/engine/operations-speculate.js +6 -2
  172. package/dist/core/engine/operations-stream.js +12 -2
  173. package/dist/core/engine/operations-time.d.ts +4 -2
  174. package/dist/core/engine/operations-time.js +14 -2
  175. package/dist/core/engine/operations-wait-condition.d.ts +23 -0
  176. package/dist/core/engine/operations-wait-condition.js +62 -0
  177. package/dist/core/engine/ownership-options.d.ts +23 -0
  178. package/dist/core/engine/ownership-options.js +26 -0
  179. package/dist/core/engine/payload-size-policy.d.ts +3 -0
  180. package/dist/core/engine/payload-size-policy.js +4 -0
  181. package/dist/core/engine/pending-updates.d.ts +17 -0
  182. package/dist/core/engine/pending-updates.js +33 -11
  183. package/dist/core/engine/persisted-data-version.d.ts +5 -9
  184. package/dist/core/engine/persisted-data-version.js +4 -5
  185. package/dist/core/engine/queries.js +1 -1
  186. package/dist/core/engine/registration.d.ts +1 -0
  187. package/dist/core/engine/registration.js +18 -3
  188. package/dist/core/engine/schedule-handle.d.ts +45 -0
  189. package/dist/core/engine/schedule-handle.js +26 -0
  190. package/dist/core/engine/schedule-jitter.d.ts +5 -0
  191. package/dist/core/engine/schedule-jitter.js +10 -0
  192. package/dist/core/engine/schedule-run.d.ts +17 -0
  193. package/dist/core/engine/schedule-run.js +38 -0
  194. package/dist/core/engine/schedule-timer.js +81 -17
  195. package/dist/core/engine/schedules.d.ts +8 -5
  196. package/dist/core/engine/schedules.js +44 -19
  197. package/dist/core/engine/search-attribute-records.d.ts +4 -0
  198. package/dist/core/engine/search-attribute-records.js +17 -0
  199. package/dist/core/engine/second-instance-detector.d.ts +96 -0
  200. package/dist/core/engine/second-instance-detector.js +108 -0
  201. package/dist/core/engine/signals.d.ts +38 -0
  202. package/dist/core/engine/signals.js +55 -19
  203. package/dist/core/engine/state-utilities.d.ts +49 -2
  204. package/dist/core/engine/state-utilities.js +114 -3
  205. package/dist/core/engine/storage-io.d.ts +16 -2
  206. package/dist/core/engine/storage-io.js +26 -5
  207. package/dist/core/engine/stream-chunk-loading.d.ts +2 -0
  208. package/dist/core/engine/stream-chunk-loading.js +24 -1
  209. package/dist/core/engine/sub-operation.js +22 -3
  210. package/dist/core/engine/termination/cleanup.d.ts +28 -1
  211. package/dist/core/engine/termination/cleanup.js +44 -2
  212. package/dist/core/engine/termination/complete.js +48 -9
  213. package/dist/core/engine/termination/finalizer-activity.d.ts +53 -0
  214. package/dist/core/engine/termination/finalizer-activity.js +30 -0
  215. package/dist/core/engine/termination/finalizer-claim.d.ts +110 -0
  216. package/dist/core/engine/termination/finalizer-claim.js +80 -0
  217. package/dist/core/engine/termination/finalizer.d.ts +48 -0
  218. package/dist/core/engine/termination/finalizer.js +159 -0
  219. package/dist/core/engine/termination/suspend.d.ts +70 -0
  220. package/dist/core/engine/termination/suspend.js +41 -0
  221. package/dist/core/engine/termination.d.ts +5 -2
  222. package/dist/core/engine/termination.js +6 -0
  223. package/dist/core/engine/updates.js +5 -25
  224. package/dist/core/engine/validation/schedule.d.ts +2 -1
  225. package/dist/core/engine/validation/schedule.js +51 -2
  226. package/dist/core/engine/validation.js +54 -3
  227. package/dist/core/engine/waiting-update-response.d.ts +8 -0
  228. package/dist/core/engine/waiting-update-response.js +22 -0
  229. package/dist/core/engine/workflow-concurrency.d.ts +10 -0
  230. package/dist/core/engine/workflow-concurrency.js +136 -0
  231. package/dist/core/engine/workflow-feed.d.ts +9 -8
  232. package/dist/core/engine/workflow-feed.js +4 -1
  233. package/dist/core/engine/workflow-indexes.d.ts +9 -0
  234. package/dist/core/engine/workflow-indexes.js +10 -0
  235. package/dist/core/engine/workflow-state-stream.js +33 -13
  236. package/dist/core/engine/workflow-visibility-queries.d.ts +2 -2
  237. package/dist/core/engine-helpers.js +1 -0
  238. package/dist/core/events/activity-events.d.ts +43 -12
  239. package/dist/core/events/activity-events.js +28 -0
  240. package/dist/core/events/attribute-events.d.ts +2 -3
  241. package/dist/core/events/event-map.d.ts +19 -12
  242. package/dist/core/events/index.d.ts +1 -0
  243. package/dist/core/events/index.js +1 -0
  244. package/dist/core/events/schedule-events.d.ts +71 -0
  245. package/dist/core/events/schedule-events.js +29 -0
  246. package/dist/core/events/signal-events.d.ts +4 -6
  247. package/dist/core/events/system-events.d.ts +29 -19
  248. package/dist/core/events/system-events.js +26 -0
  249. package/dist/core/events/update-events.d.ts +6 -8
  250. package/dist/core/events/workflow-events.d.ts +108 -20
  251. package/dist/core/events/workflow-events.js +35 -0
  252. package/dist/core/failure-categories.js +5 -17
  253. package/dist/core/fault-code.d.ts +9 -3
  254. package/dist/core/fault-code.js +1 -0
  255. package/dist/core/inline-execution-strategy.context-options.d.ts +69 -0
  256. package/dist/core/inline-execution-strategy.context-options.js +56 -0
  257. package/dist/core/inline-execution-strategy.d.ts +31 -36
  258. package/dist/core/inline-execution-strategy.js +16 -27
  259. package/dist/core/list-filter-validation.d.ts +1 -1
  260. package/dist/core/list-filter-validation.js +2 -1
  261. package/dist/core/payload-size.d.ts +1 -1
  262. package/dist/core/persisted-data-incompatible-error.d.ts +9 -7
  263. package/dist/core/review/events.d.ts +6 -8
  264. package/dist/core/scheduler/scheduler-class.d.ts +10 -1
  265. package/dist/core/scheduler/scheduler-class.js +38 -11
  266. package/dist/core/scheduler/timer-batch.js +9 -1
  267. package/dist/core/scheduler/timer-sources.d.ts +1 -0
  268. package/dist/core/scheduler/timer-sources.js +11 -5
  269. package/dist/core/session-state.d.ts +0 -1
  270. package/dist/core/session-state.js +2 -2
  271. package/dist/core/start-workflow-validation.d.ts +56 -0
  272. package/dist/core/start-workflow-validation.js +30 -1
  273. package/dist/core/step-context.d.ts +10 -6
  274. package/dist/core/step-context.js +7 -15
  275. package/dist/core/types/activity-verification.d.ts +67 -0
  276. package/dist/core/types/activity-verification.js +0 -0
  277. package/dist/core/types/activity.d.ts +86 -64
  278. package/dist/core/types/bulk.d.ts +50 -9
  279. package/dist/core/types/checkpoint.d.ts +44 -8
  280. package/dist/core/types/identity.d.ts +8 -1
  281. package/dist/core/types/launch-metadata.d.ts +33 -0
  282. package/dist/core/types/launch-metadata.js +0 -0
  283. package/dist/core/types/list-options.d.ts +146 -0
  284. package/dist/core/types/list-options.js +0 -0
  285. package/dist/core/types/message-handles.d.ts +25 -0
  286. package/dist/core/types/options.d.ts +165 -215
  287. package/dist/core/types/reviews.d.ts +2 -1
  288. package/dist/core/types/schedules.d.ts +39 -3
  289. package/dist/core/types/services-resolution.d.ts +47 -0
  290. package/dist/core/types/services-resolution.js +0 -0
  291. package/dist/core/types/state.d.ts +11 -11
  292. package/dist/core/types/workflow-builder-runtime.d.ts +12 -3
  293. package/dist/core/types/workflow-builder-runtime.js +11 -2
  294. package/dist/core/types/workflow-builder.d.ts +47 -15
  295. package/dist/core/types/workflow-concurrency.d.ts +39 -0
  296. package/dist/core/types/workflow-concurrency.js +0 -0
  297. package/dist/core/types/workflow-context.d.ts +157 -14
  298. package/dist/core/types/workflow-definition.d.ts +53 -10
  299. package/dist/core/types/workflow-function.d.ts +101 -9
  300. package/dist/core/types/workflow-log.d.ts +98 -0
  301. package/dist/core/types/workflow-log.js +0 -0
  302. package/dist/core/types/workflow-registries.d.ts +14 -3
  303. package/dist/core/types/workflow-registry.d.ts +3 -0
  304. package/dist/core/types/workflow-snapshot.d.ts +29 -0
  305. package/dist/core/types/workflow-snapshot.js +0 -0
  306. package/dist/core/types.d.ts +7 -0
  307. package/dist/core/types.js +7 -0
  308. package/dist/core/versioning.d.ts +9 -39
  309. package/dist/core/versioning.js +2 -12
  310. package/dist/core/weft-error.d.ts +44 -1
  311. package/dist/core/weft-error.js +19 -1
  312. package/dist/core/worker-execution-strategy-options.d.ts +26 -0
  313. package/dist/core/worker-execution-strategy.js +40 -36
  314. package/dist/core/worker-inbound-message.d.ts +38 -0
  315. package/dist/core/worker-inbound-message.js +37 -0
  316. package/dist/core/worker-log-abuse-counter.d.ts +175 -0
  317. package/dist/core/worker-log-abuse-counter.js +107 -0
  318. package/dist/core/worker-message-helpers.d.ts +47 -0
  319. package/dist/core/worker-message-helpers.js +26 -0
  320. package/dist/core/worker-protocol-guard.js +1 -1
  321. package/dist/core/worker-protocol-log.d.ts +56 -0
  322. package/dist/core/worker-protocol-log.js +18 -0
  323. package/dist/core/worker-protocol.d.ts +23 -0
  324. package/dist/core/worker-protocol.js +12 -2
  325. package/dist/core/workflow-version-tuple.d.ts +3 -9
  326. package/dist/core/workflow-version-tuple.js +2 -3
  327. package/dist/diagnostics/doctor.js +6 -3
  328. package/dist/diagnostics/format.js +3 -8
  329. package/dist/diagnostics/types.d.ts +5 -5
  330. package/dist/diagnostics/validate.d.ts +0 -1
  331. package/dist/diagnostics/version-check.d.ts +1 -1
  332. package/dist/diagnostics/version-check.js +10 -13
  333. package/dist/index.d.ts +13 -11
  334. package/dist/index.js +39 -4
  335. package/dist/json-schema.js +3 -3
  336. package/dist/mcp/cli.js +35 -35
  337. package/dist/mcp/dispatcher.js +1 -1
  338. package/dist/mcp/http.js +16 -6
  339. package/dist/mcp/list-filter.js +2 -1
  340. package/dist/mcp/protocol.d.ts +2 -0
  341. package/dist/mcp/protocol.js +1 -1
  342. package/dist/mcp/session.d.ts +16 -0
  343. package/dist/mcp/session.js +60 -6
  344. package/dist/mcp/tools.js +73 -6
  345. package/dist/observability/index.js +2 -2
  346. package/dist/server/asyncapi-channels.js +5 -2
  347. package/dist/server/attribute-filters.d.ts +8 -3
  348. package/dist/server/attribute-filters.js +6 -1
  349. package/dist/server/authentication/api-key.d.ts +2 -1
  350. package/dist/server/authentication/api-key.js +5 -2
  351. package/dist/server/authentication/constant-time-api-key.d.ts +15 -0
  352. package/dist/server/authentication/constant-time-api-key.js +24 -0
  353. package/dist/server/authentication/index.d.ts +1 -1
  354. package/dist/server/authentication/index.js +7 -4
  355. package/dist/server/authentication/rotating-api-key-store.d.ts +5 -3
  356. package/dist/server/authentication/rotating-api-key-store.js +19 -11
  357. package/dist/server/engine-event-feed-backend.d.ts +4 -5
  358. package/dist/server/fault-to-http.js +8 -1
  359. package/dist/server/fault-to-json-rpc.js +1 -0
  360. package/dist/server/fleet-event-feed.d.ts +31 -0
  361. package/dist/server/fleet-event-feed.js +157 -0
  362. package/dist/server/handler/index.js +1 -1
  363. package/dist/server/handler/response-helpers.js +2 -1
  364. package/dist/server/handler/route-dispatch.d.ts +6 -3
  365. package/dist/server/handler/route-dispatch.js +2 -2
  366. package/dist/server/handler.js +31 -31
  367. package/dist/server/index.d.ts +32 -2
  368. package/dist/server/index.js +35 -35
  369. package/dist/server/interactive-operations.js +1 -0
  370. package/dist/server/json-rpc-transport-helpers.d.ts +1 -0
  371. package/dist/server/json-rpc-transport-helpers.js +2 -1
  372. package/dist/server/json-rpc-websocket-runtime.d.ts +11 -2
  373. package/dist/server/json-rpc-websocket-runtime.js +1 -0
  374. package/dist/server/json-rpc-websocket-subscriptions.d.ts +10 -0
  375. package/dist/server/json-rpc-websocket-subscriptions.js +29 -0
  376. package/dist/server/json-rpc-websocket-types.d.ts +22 -0
  377. package/dist/server/json-rpc-websocket-types.js +0 -0
  378. package/dist/server/json-rpc-websocket-validation.js +20 -4
  379. package/dist/server/json-rpc-websocket.d.ts +2 -43
  380. package/dist/server/json-rpc-websocket.js +57 -74
  381. package/dist/server/openapi.d.ts +2 -1
  382. package/dist/server/openapi.js +1 -3
  383. package/dist/server/openrpc-document-schema.d.ts +78 -0
  384. package/dist/server/openrpc-document-schema.js +27 -1
  385. package/dist/server/openrpc-errors.d.ts +3 -0
  386. package/dist/server/openrpc-errors.js +2 -1
  387. package/dist/server/openrpc.js +32 -0
  388. package/dist/server/operation-catalog/index.d.ts +1 -1
  389. package/dist/server/operation-catalog/pipeline-helpers.js +1 -0
  390. package/dist/server/operation-catalog/pipeline-stages.js +26 -12
  391. package/dist/server/operation-catalog/pipeline.js +8 -1
  392. package/dist/server/operation-catalog/registry.js +13 -0
  393. package/dist/server/operation-catalog/types.d.ts +20 -9
  394. package/dist/server/operation-fault.d.ts +10 -0
  395. package/dist/server/operation-fault.js +2 -0
  396. package/dist/server/operation-registry.d.ts +12 -11
  397. package/dist/server/operation-registry.js +12 -3
  398. package/dist/server/operations/aggregate-workflows.d.ts +15 -15
  399. package/dist/server/operations/async-activity.d.ts +2 -2
  400. package/dist/server/operations/async-activity.js +12 -7
  401. package/dist/server/operations/bulk-cancel-workflows.d.ts +1 -1
  402. package/dist/server/operations/bulk-cancel-workflows.js +2 -2
  403. package/dist/server/operations/bulk-delete-workflows.d.ts +1 -1
  404. package/dist/server/operations/bulk-delete-workflows.js +2 -2
  405. package/dist/server/operations/bulk-filter-helpers.d.ts +8 -6
  406. package/dist/server/operations/bulk-filter-helpers.js +54 -24
  407. package/dist/server/operations/bulk-mutate-workflow-tags.d.ts +11 -9
  408. package/dist/server/operations/bulk-mutate-workflow-tags.js +2 -2
  409. package/dist/server/operations/bulk-operation-helpers.d.ts +2 -2
  410. package/dist/server/operations/bulk-retry-failed-workflows.d.ts +7 -0
  411. package/dist/server/operations/bulk-retry-failed-workflows.js +64 -0
  412. package/dist/server/operations/bulk-signal-workflows.d.ts +11 -9
  413. package/dist/server/operations/bulk-signal-workflows.js +2 -2
  414. package/dist/server/operations/cancel-schedule.d.ts +1 -1
  415. package/dist/server/operations/create-schedule.d.ts +3 -1
  416. package/dist/server/operations/create-schedule.js +29 -11
  417. package/dist/server/operations/fleet-events-subscription.d.ts +54 -0
  418. package/dist/server/operations/fleet-events-subscription.js +99 -0
  419. package/dist/server/operations/fork-workflow.d.ts +1 -1
  420. package/dist/server/operations/fork-workflow.js +3 -2
  421. package/dist/server/operations/get-checkpoint-at.d.ts +1 -1
  422. package/dist/server/operations/get-registry.d.ts +1 -1
  423. package/dist/server/operations/get-retention-overview.d.ts +1 -1
  424. package/dist/server/operations/get-review.d.ts +1 -1
  425. package/dist/server/operations/get-schedule.d.ts +1 -1
  426. package/dist/server/operations/get-stream-chunks.d.ts +1 -1
  427. package/dist/server/operations/get-system-metrics.d.ts +2 -2
  428. package/dist/server/operations/get-task-diagnostics.d.ts +45 -6
  429. package/dist/server/operations/get-task-diagnostics.js +101 -7
  430. package/dist/server/operations/get-update-result.d.ts +1 -1
  431. package/dist/server/operations/get-workflow-attributes.d.ts +1 -1
  432. package/dist/server/operations/get-workflow-events.d.ts +1 -1
  433. package/dist/server/operations/get-workflow-result.d.ts +1 -1
  434. package/dist/server/operations/get-workflow-timeline.d.ts +1 -1
  435. package/dist/server/operations/get-workflow.d.ts +1 -1
  436. package/dist/server/operations/list-checkpoints.d.ts +1 -1
  437. package/dist/server/operations/list-reviews.d.ts +1 -1
  438. package/dist/server/operations/list-schedules.d.ts +1 -1
  439. package/dist/server/operations/list-task-queues.d.ts +2 -2
  440. package/dist/server/operations/list-workers.d.ts +2 -2
  441. package/dist/server/operations/list-workflows.d.ts +1 -1
  442. package/dist/server/operations/operation-helpers.d.ts +16 -1
  443. package/dist/server/operations/operation-helpers.js +15 -3
  444. package/dist/server/operations/pause-schedule.d.ts +1 -1
  445. package/dist/server/operations/purge-workflows.d.ts +5 -5
  446. package/dist/server/operations/purge-workflows.js +2 -2
  447. package/dist/server/operations/query-workflow.d.ts +1 -1
  448. package/dist/server/operations/query-workflow.js +3 -2
  449. package/dist/server/operations/recover-all.d.ts +1 -1
  450. package/dist/server/operations/replay-workflow.d.ts +1 -1
  451. package/dist/server/operations/resume-schedule.d.ts +1 -1
  452. package/dist/server/operations/resume-workflow.js +2 -2
  453. package/dist/server/operations/set-workflow-attributes.d.ts +1 -1
  454. package/dist/server/operations/set-workflow-attributes.js +6 -3
  455. package/dist/server/operations/signal-workflow.js +8 -3
  456. package/dist/server/operations/single-workflow-tag-mutation.js +13 -3
  457. package/dist/server/operations/start-or-signal-workflow.d.ts +44 -0
  458. package/dist/server/operations/start-or-signal-workflow.js +130 -0
  459. package/dist/server/operations/start-workflow-options.d.ts +38 -0
  460. package/dist/server/operations/start-workflow-options.js +63 -0
  461. package/dist/server/operations/start-workflow-rest-input.d.ts +14 -0
  462. package/dist/server/operations/start-workflow-rest-input.js +31 -0
  463. package/dist/server/operations/start-workflow.d.ts +1 -1
  464. package/dist/server/operations/start-workflow.js +15 -92
  465. package/dist/server/operations/storage.d.ts +6 -6
  466. package/dist/server/operations/storage.js +24 -14
  467. package/dist/server/operations/stream-workflow-sse.d.ts +1 -1
  468. package/dist/server/operations/submit-review-decision.d.ts +1 -1
  469. package/dist/server/operations/submit-review-decision.js +6 -3
  470. package/dist/server/operations/suspend-workflow.d.ts +13 -0
  471. package/dist/server/operations/suspend-workflow.js +36 -0
  472. package/dist/server/operations/update-schedule.d.ts +1 -1
  473. package/dist/server/operations/update-schedule.js +7 -4
  474. package/dist/server/operations/update-workflow.d.ts +1 -1
  475. package/dist/server/operations/update-workflow.js +7 -3
  476. package/dist/server/operations/worker-drain.d.ts +8 -8
  477. package/dist/server/operations/worker-drain.js +11 -8
  478. package/dist/server/operations/workflow-events-subscription.d.ts +7 -8
  479. package/dist/server/operations/workflow-events-subscription.js +43 -8
  480. package/dist/server/rest-binding.d.ts +21 -8
  481. package/dist/server/rest-bindings.js +24 -0
  482. package/dist/server/rest-body.d.ts +10 -0
  483. package/dist/server/rest-body.js +80 -0
  484. package/dist/server/runtime/authentication-bridge.d.ts +1 -0
  485. package/dist/server/runtime/authentication-bridge.js +33 -6
  486. package/dist/server/runtime/client-visible-events.d.ts +3 -0
  487. package/dist/server/runtime/client-visible-events.js +65 -0
  488. package/dist/server/runtime/context.d.ts +7 -0
  489. package/dist/server/runtime/event-broadcasting.d.ts +6 -0
  490. package/dist/server/runtime/event-broadcasting.js +72 -38
  491. package/dist/server/runtime/retry.d.ts +1 -0
  492. package/dist/server/runtime/retry.js +14 -0
  493. package/dist/server/runtime/shutdown.d.ts +7 -6
  494. package/dist/server/runtime/shutdown.js +6 -1
  495. package/dist/server/runtime/task-dispatch.js +5 -3
  496. package/dist/server/runtime/task-polling.d.ts +16 -2
  497. package/dist/server/runtime/task-polling.js +80 -24
  498. package/dist/server/runtime/task-reconciliation.js +9 -1
  499. package/dist/server/runtime/task-result-resolution.d.ts +15 -0
  500. package/dist/server/runtime/task-result-resolution.js +81 -0
  501. package/dist/server/runtime/websocket-stream.d.ts +20 -1
  502. package/dist/server/runtime/websocket-stream.js +173 -7
  503. package/dist/server/runtime/websocket-upgrade.js +22 -3
  504. package/dist/server/runtime/websocket-worker.d.ts +1 -1
  505. package/dist/server/runtime/websocket-worker.js +46 -30
  506. package/dist/server/serve-internals.d.ts +11 -1
  507. package/dist/server/serve-internals.js +20 -2
  508. package/dist/server/task-state.d.ts +38 -0
  509. package/dist/server/task-state.js +28 -0
  510. package/dist/server/workflow-event-feed.d.ts +36 -115
  511. package/dist/server/workflow-event-feed.js +92 -27
  512. package/dist/service-worker/index.js +31 -31
  513. package/dist/storage/auto.js +1 -1
  514. package/dist/storage/bun-sql.js +24 -0
  515. package/dist/storage/capabilities.d.ts +10 -2
  516. package/dist/storage/capabilities.js +2 -2
  517. package/dist/storage/compressed-storage.js +1 -1
  518. package/dist/storage/default-scope.d.ts +7 -4
  519. package/dist/storage/http.js +2 -2
  520. package/dist/storage/index.d.ts +81 -4
  521. package/dist/storage/indexeddb.js +1 -1
  522. package/dist/storage/interface.d.ts +189 -0
  523. package/dist/storage/interface.js +1 -1
  524. package/dist/storage/key-prefixes.d.ts +1 -1
  525. package/dist/storage/key-prefixes.js +12 -0
  526. package/dist/storage/lmdb.d.ts +4 -3
  527. package/dist/storage/lmdb.js +1 -1
  528. package/dist/storage/memory.js +1 -1
  529. package/dist/storage/neon-batch.d.ts +30 -0
  530. package/dist/storage/neon-batch.js +30 -0
  531. package/dist/storage/neon-value-mapping.d.ts +74 -0
  532. package/dist/storage/neon-value-mapping.js +23 -0
  533. package/dist/storage/neon.d.ts +124 -0
  534. package/dist/storage/neon.js +15 -0
  535. package/dist/storage/node-sqlite-loader.d.ts +71 -0
  536. package/dist/storage/node-sqlite-loader.js +41 -0
  537. package/dist/storage/node-sqlite.d.ts +1 -19
  538. package/dist/storage/node-sqlite.js +61 -32
  539. package/dist/storage/postgres-key-value-queries.d.ts +104 -0
  540. package/dist/storage/postgres-key-value-queries.js +101 -0
  541. package/dist/storage/resolve.d.ts +2 -165
  542. package/dist/storage/resolve.js +1 -1
  543. package/dist/storage/scoped-storage.js +1 -1
  544. package/dist/storage/storage-configuration.d.ts +209 -0
  545. package/dist/storage/storage-configuration.js +0 -0
  546. package/dist/storage/testing.d.ts +168 -0
  547. package/dist/storage/testing.js +2 -0
  548. package/dist/storage/text-value-store.d.ts +9 -9
  549. package/dist/storage/turso.d.ts +8 -0
  550. package/dist/storage/turso.js +2 -2
  551. package/dist/storage/typed-storage.js +1 -1
  552. package/dist/storage/web-extension.js +1 -1
  553. package/dist/testing/index.js +35 -35
  554. package/dist/version.d.ts +1 -1
  555. package/dist/version.js +1 -1
  556. package/dist/worker/index.js +9 -5
  557. package/dist/worker/long-poll.js +4 -0
  558. package/dist/worker/protocol-messages.d.ts +20 -0
  559. package/dist/worker/protocol-schemas.d.ts +32 -0
  560. package/dist/worker/protocol-schemas.js +8 -4
  561. package/dist/worker/protocol-task-result.d.ts +28 -0
  562. package/dist/worker/protocol-task-result.js +76 -0
  563. package/dist/worker/protocol.d.ts +4 -15
  564. package/dist/worker/protocol.js +1 -1
  565. package/dist/worker/registry/fair-share.d.ts +29 -0
  566. package/dist/worker/registry/fair-share.js +30 -0
  567. package/dist/worker/registry/routing.d.ts +18 -0
  568. package/dist/worker/registry/routing.js +14 -0
  569. package/dist/worker/registry/types.d.ts +7 -0
  570. package/dist/worker/registry.d.ts +16 -1
  571. package/dist/worker/registry.js +24 -36
  572. package/dist/workers/worker-replay-state.d.ts +32 -0
  573. package/dist/workers/worker-replay-state.js +35 -0
  574. package/dist/workers/worker-state-namespace.d.ts +21 -0
  575. package/dist/workers/worker-state-namespace.js +13 -0
  576. package/dist/workers/workflow-runner.d.ts +19 -15
  577. package/dist/workers/workflow-runner.js +72 -60
  578. package/dist/workers/workflow-worker-entry.js +5 -2
  579. package/package.json +21 -4
@@ -1,4 +1,6 @@
1
1
  import { serializeCheckpoint } from "../../checkpoint.js";
2
+ import { WorkflowStartedEvent } from "../../events.js";
3
+ import { StartWorkflowValidationError } from "../../start-workflow-validation.js";
2
4
  export function runWorkflowStartInterceptor(_internals, workflowId, workflowType, input, parentHeaders, callbacks) {
3
5
  const composedInterceptor = callbacks.getComposedWorkflowInterceptor();
4
6
  if (!composedInterceptor)
@@ -37,3 +39,39 @@ export function startWorkflowExecution(internals, workflowId, workflowType, inpu
37
39
  }
38
40
  });
39
41
  }
42
+ export function beginWorkflowExecution(internals, workflowId, workflowType, input, checkpoint, executionDeadline, executionStateOwnerId, _registration, callbacks, onStarted) {
43
+ const nestingDepth = internals.pendingNestingDepth ?? 0;
44
+ internals.pendingNestingDepth = void 0;
45
+ if (internals.inlineStrategy !== null) {
46
+ callbacks.queueInlineWorkflowExecutionStart({
47
+ workflowId,
48
+ workflowType,
49
+ input,
50
+ checkpoint,
51
+ nestingDepth,
52
+ executionDeadline,
53
+ executionStateOwnerId,
54
+ ...onStarted !== void 0 && { onStarted }
55
+ });
56
+ return;
57
+ }
58
+ callbacks.dispatchEvent(new WorkflowStartedEvent(workflowId, workflowType, input));
59
+ startWorkflowExecution(internals, workflowId, workflowType, input, checkpoint, nestingDepth, executionDeadline, executionStateOwnerId, callbacks);
60
+ onStarted?.();
61
+ }
62
+ export function assertDeferSupported(internals, options, isDelayedStart) {
63
+ if (options?.defer !== !1)
64
+ return;
65
+ if (internals.inlineStrategy === null)
66
+ throw new StartWorkflowValidationError('options.defer: false is only supported in inline execution mode; a worker-mode start cannot be awaited for inline liveness. Use workflowExecutionMode: "inline" or remove defer.');
67
+ if (isDelayedStart)
68
+ throw new StartWorkflowValidationError("options.defer: false is incompatible with a delayed start (startAt/startAfter): a scheduled run has not begun executing, so there is no liveness to await. Remove defer or the delayed-start option.");
69
+ }
70
+ export async function beginExecutionAwaitingLiveness(internals, params, workflowId, callbacks) {
71
+ if (params.isDelayed)
72
+ return;
73
+ const liveness = params.options?.defer === !1 ? Promise.withResolvers() : void 0;
74
+ beginWorkflowExecution(internals, workflowId, params.type, params.input, params.checkpoint, params.state.executionDeadline, params.state.executionStateOwnerId ?? workflowId, params.registration, callbacks, liveness ? () => liveness.resolve() : void 0);
75
+ if (liveness)
76
+ await liveness.promise;
77
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Create-and-deliver machinery for {@link startOrSignal}: building the atomic
3
+ * start-with-signal batch, running it, and recovering from every way the create
4
+ * can lose its CAS (keyed-mapping loss, caller-`id` reservation collision, or a
5
+ * pre-buffered signal). Split from `start-or-signal.ts` to keep that module
6
+ * focused on the public `startOrSignal` / `startWithIdempotency` entry points.
7
+ *
8
+ * @module core/engine/lifecycle/start-or-signal-create
9
+ */
10
+ import type { StartOptions, StartOrSignalSignal } from '../../types.ts';
11
+ import { type StartOrSignalOutcome, type WorkflowHandle } from '../handles.ts';
12
+ import type { EngineInternals } from '../internals.ts';
13
+ import { type BuildIdempotentStartOperations } from './start-commit.ts';
14
+ import { type StartOrSignalCallbacks } from './start-or-signal-resolution.ts';
15
+ /**
16
+ * Build the `(workflowId) => { operations, conditions }` callback that folds the
17
+ * idempotency mapping and (optionally) the create-batch signal into the start
18
+ * batch, gated on the mapping key being absent. Every caller supplies at least
19
+ * one of `idempotencyKey` / `signal` (the plain start path skips this builder
20
+ * entirely), so the returned callback always contributes at least one operation.
21
+ */
22
+ export declare function idempotentStartOperationsFor(internals: EngineInternals, idempotencyKey: string | undefined, signal: {
23
+ name: string;
24
+ payload: unknown;
25
+ signalId: string;
26
+ } | undefined): BuildIdempotentStartOperations;
27
+ /**
28
+ * A resolved start-or-signal handle paired with which atomic path produced it
29
+ * (#466), computed during the call at zero extra cost.
30
+ */
31
+ export type StartOrSignalResult<TResult = unknown> = {
32
+ handle: WorkflowHandle<TResult>;
33
+ outcome: StartOrSignalOutcome;
34
+ };
35
+ /**
36
+ * Create the workflow and deliver the signal atomically, recovering from a lost
37
+ * create batch:
38
+ *
39
+ * - **Lost to a keyed winner** — idempotency-mapping CAS loss
40
+ * ({@link StartIdempotencyRaceLostError} on the keyed path): the mapping commits
41
+ * atomically with the record, so the winner is guaranteed committed — resolve it
42
+ * and signal it (or conflict if terminal).
43
+ * - **Lost to a caller-`id` winner** — collision on the winner's in-memory
44
+ * `pendingStarts` reservation ({@link WorkflowAlreadyExistsError}): the
45
+ * reservation is held BEFORE the durable commit, so it may clear without a run
46
+ * ever existing (the winner aborted: storage failure, oversized payload, a
47
+ * throwing start interceptor). Wait for the reservation to clear, then signal a
48
+ * committed winner or — if it aborted — retry the create. Bounded by
49
+ * {@link CALLER_ID_CREATE_MAX_ATTEMPTS}.
50
+ * - **Signal already buffered** — `StartIdempotencyRaceLostError` on the
51
+ * caller-`id` path: the only CAS condition there is the signal's `sigres:`
52
+ * accepted-response marker, so the loss means a signal with this signalId was
53
+ * pre-buffered and (the batch being atomic) the `wf:` record was NOT written.
54
+ * Plain-create the workflow; the buffered signal is consumed on first drive
55
+ * (scan-then-park), and the caller's payload loses to the pre-buffered one by
56
+ * the same first-wins dedup.
57
+ */
58
+ export declare function createWithSignalOrFallback(internals: EngineInternals, type: string, input: unknown, signalSpec: StartOrSignalSignal, signalId: string, options: StartOptions | undefined, callbacks: StartOrSignalCallbacks): Promise<StartOrSignalResult>;
@@ -0,0 +1,95 @@
1
+ import { KEYS } from "../../../storage/interface.js";
2
+ import { encode } from "../../codec.js";
3
+ import { WorkflowAlreadyExistsError } from "../errors.js";
4
+ import { buildCreateBatchSignalOperations } from "../signals.js";
5
+ import {
6
+ StartIdempotencyRaceLostError
7
+ } from "./start-commit.js";
8
+ import {
9
+ requireWinnerId,
10
+ resolveCallerIdWinnerOrRetry,
11
+ resolveWinnerWithSignal
12
+ } from "./start-or-signal-resolution.js";
13
+ import { startWorkflow } from "./start.js";
14
+ export function idempotentStartOperationsFor(internals, idempotencyKey, signal) {
15
+ return (workflowId) => {
16
+ const operations = [], conditions = [];
17
+ if (idempotencyKey !== void 0) {
18
+ const key = KEYS.startIdempotency(idempotencyKey);
19
+ operations.push({
20
+ type: "put",
21
+ key,
22
+ value: encode({ workflowId })
23
+ });
24
+ conditions.push({ key, expectedValue: null });
25
+ }
26
+ if (signal !== void 0) {
27
+ const built = buildCreateBatchSignalOperations(internals, workflowId, signal.name, signal.payload, signal.signalId);
28
+ operations.push(...built.operations);
29
+ conditions.push(built.condition);
30
+ }
31
+ return { operations, conditions };
32
+ };
33
+ }
34
+ const CALLER_ID_CREATE_MAX_ATTEMPTS = 5;
35
+ export async function createWithSignalOrFallback(internals, type, input, signalSpec, signalId, options, callbacks) {
36
+ const idempotencyKey = options?.idempotencyKey;
37
+ for (let attempt = 0;attempt < CALLER_ID_CREATE_MAX_ATTEMPTS; attempt += 1) {
38
+ const outcome = await resolveCreateRaceOutcome(internals, options, async () => {
39
+ return startWorkflow(internals, type, input, options, void 0, callbacks, idempotentStartOperationsFor(internals, idempotencyKey, {
40
+ name: signalSpec.name,
41
+ payload: signalSpec.payload,
42
+ signalId
43
+ }));
44
+ });
45
+ if (outcome.kind === "created")
46
+ return { handle: outcome.handle, outcome: "started" };
47
+ if (outcome.kind === "lost-keyed")
48
+ return {
49
+ handle: await resolveWinnerWithSignal(internals, outcome.id, signalSpec, signalId, callbacks, outcome.idempotencyKey),
50
+ outcome: "signalled"
51
+ };
52
+ if (outcome.kind === "lost-caller-id") {
53
+ const resolved = await resolveCallerIdWinnerOrRetry(internals, outcome.id, signalSpec, signalId, callbacks);
54
+ if (resolved !== void 0)
55
+ return { handle: resolved, outcome: "signalled" };
56
+ } else {
57
+ const resolved = await plainCreateBufferedSignalOrResolve(internals, type, input, signalSpec, signalId, options, callbacks);
58
+ if (resolved !== void 0)
59
+ return resolved;
60
+ }
61
+ }
62
+ throw Error(`startOrSignal could not create workflow "${options?.id ?? "<generated>"}" after ${CALLER_ID_CREATE_MAX_ATTEMPTS} attempts: each concurrent same-id winner aborted before its durable commit.`);
63
+ }
64
+ async function plainCreateBufferedSignalOrResolve(internals, type, input, signalSpec, signalId, options, callbacks) {
65
+ try {
66
+ return {
67
+ handle: await startWorkflow(internals, type, input, options, void 0, callbacks),
68
+ outcome: "started"
69
+ };
70
+ } catch (error) {
71
+ if (!(error instanceof WorkflowAlreadyExistsError))
72
+ throw error;
73
+ const resolved = await resolveCallerIdWinnerOrRetry(internals, error.workflowId, signalSpec, signalId, callbacks);
74
+ return resolved === void 0 ? void 0 : { handle: resolved, outcome: "signalled" };
75
+ }
76
+ }
77
+ async function resolveCreateRaceOutcome(internals, options, runCreate) {
78
+ try {
79
+ return { kind: "created", handle: await runCreate() };
80
+ } catch (error) {
81
+ if (error instanceof WorkflowAlreadyExistsError)
82
+ return { kind: "lost-caller-id", id: error.workflowId };
83
+ if (error instanceof StartIdempotencyRaceLostError) {
84
+ const idempotencyKey = options?.idempotencyKey;
85
+ if (idempotencyKey !== void 0)
86
+ return {
87
+ kind: "lost-keyed",
88
+ id: await requireWinnerId(internals, idempotencyKey),
89
+ idempotencyKey
90
+ };
91
+ return { kind: "signal-already-buffered" };
92
+ }
93
+ throw error;
94
+ }
95
+ }
@@ -0,0 +1,79 @@
1
+ import type { StartOrSignalSignal } from '../../types.ts';
2
+ import { type WorkflowHandle } from '../handles.ts';
3
+ import type { EngineInternals } from '../internals.ts';
4
+ import { type LifecycleCallbacks } from './shared.ts';
5
+ /**
6
+ * Callbacks `startOrSignal` needs beyond the lifecycle set: a way to deliver a
7
+ * signal to an already-running workflow through the full engine signal path
8
+ * (interceptors, events, parked-run wakeups). Supplied by the engine so the
9
+ * "signal an existing non-terminal run" branch reuses `engine.signal` with the
10
+ * same `signalId` the create batch would have used.
11
+ */
12
+ export type StartOrSignalCallbacks = LifecycleCallbacks & {
13
+ signalExistingWorkflow: (workflowId: string, signalName: string, payload: unknown, signalId: string) => Promise<void>;
14
+ };
15
+ /** The value stored at `KEYS.startIdempotency(key)`: the workflow the key created. */
16
+ export type StartIdempotencyMapping = {
17
+ workflowId: string;
18
+ };
19
+ /** Resolve an existing workflow id for an idempotency key, if one was created. */
20
+ export declare function resolveIdempotencyKeyWorkflowId(internals: EngineInternals, idempotencyKey: string): Promise<string | undefined>;
21
+ /**
22
+ * Resolve a key-mapped workflow id to a handle id, asserting its record still
23
+ * exists. The `start-idem:` mapping is permanent — it survives BOTH terminal
24
+ * cleanup AND purge/retention (those reclaim the workflow record, never the
25
+ * `start-idem:` keyspace) — so a present mapping whose record is gone means the
26
+ * key is spent: a fresh create would fail the still-present mapping CAS and strand
27
+ * the caller. Surface {@link IdempotencyKeyPurgedError} instead of handing back a
28
+ * handle to a vanished run. Shared by the synchronous mapping hit and the
29
+ * post-race winner lookup so both reject a purged key identically.
30
+ */
31
+ export declare function resolveExistingRunOrThrowPurged(internals: EngineInternals, workflowId: string): Promise<string>;
32
+ /**
33
+ * Resolve a caller-`id` create-race loss without conflating an in-memory
34
+ * reservation with a durable record. A loser collides on the winner's
35
+ * `pendingStarts` reservation (start.ts) BEFORE the winner commits, so the bare
36
+ * collision proves nothing about whether a run will exist.
37
+ *
38
+ * Read the winner's record FIRST: this catches a winner that has already committed
39
+ * but is still non-terminal before it can complete (a fast workflow consumes its
40
+ * create-batch signal and finishes the moment it is driven — reading immediately
41
+ * resolves it instead of racing it to a terminal-conflict). Only when the record is
42
+ * absent do we wait for the reservation to clear and read once more to discriminate:
43
+ *
44
+ * - **record present** — the winner committed: signal it (or conflict if terminal)
45
+ * and return the handle.
46
+ * - **record absent after the reservation clears** — the winner aborted before
47
+ * committing (storage failure, oversized payload, throwing start interceptor): no
48
+ * run exists, so return `undefined` and let the caller retry its own create.
49
+ */
50
+ export declare function resolveCallerIdWinnerOrRetry(internals: EngineInternals, winnerId: string, signalSpec: StartOrSignalSignal, signalId: string, callbacks: StartOrSignalCallbacks): Promise<WorkflowHandle | undefined>;
51
+ /**
52
+ * For a workflow that already exists: signal it if non-terminal, conflict if
53
+ * terminal. Returns the handle on a successful signal, or `undefined` when the
54
+ * workflow record is not present (so the caller falls through to create).
55
+ */
56
+ export declare function signalOrConflictExistingWorkflow(internals: EngineInternals, workflowId: string, signalSpec: StartOrSignalSignal, signalId: string, callbacks: StartOrSignalCallbacks): Promise<WorkflowHandle | undefined>;
57
+ /**
58
+ * Signal a KEYED race winner, bounded-retrying when its record is not yet readable.
59
+ * The keyed winner commits its record atomically with the `start-idem:` mapping, so
60
+ * the record is guaranteed to exist — but the loser may read before the commit
61
+ * settles, so a short delay between reads lets it land. (Caller-`id` winners can
62
+ * abort before committing and are handled by `resolveCallerIdWinnerOrRetry`, not
63
+ * here.)
64
+ *
65
+ * After {@link WINNER_RESOLUTION_MAX_ATTEMPTS} reads with no record, the record is
66
+ * absent for a committed-with-mapping winner only because it was purged: re-read
67
+ * the mapping, and if it still resolves to this exact `winnerId` the key is spent —
68
+ * throw {@link IdempotencyKeyPurgedError}. A mapping that now resolves to a
69
+ * DIFFERENT id (or vanished) cannot prove this winner was purged, so it falls
70
+ * through to the invariant throw rather than mislabelling external keyspace
71
+ * mutation as a spent key.
72
+ */
73
+ export declare function resolveWinnerWithSignal(internals: EngineInternals, winnerId: string, signalSpec: StartOrSignalSignal, signalId: string, callbacks: StartOrSignalCallbacks, idempotencyKey: string): Promise<WorkflowHandle>;
74
+ /**
75
+ * Read the winning workflow id from the idempotency mapping after a lost CAS. The
76
+ * mapping must exist once any caller's create commits; its absence means the
77
+ * `start-idem:` keyspace was mutated externally.
78
+ */
79
+ export declare function requireWinnerId(internals: EngineInternals, idempotencyKey: string): Promise<string>;
@@ -0,0 +1,60 @@
1
+ import { sleep } from "../../../runtime/portable.js";
2
+ import { KEYS } from "../../../storage/interface.js";
3
+ import { decode } from "../../codec.js";
4
+ import { IdempotencyKeyPurgedError, StartOrSignalConflictError } from "../errors.js";
5
+ import { loadWorkflowState } from "../storage-io.js";
6
+ import { isTerminalWorkflowStatus } from "../validation.js";
7
+ export async function resolveIdempotencyKeyWorkflowId(internals, idempotencyKey) {
8
+ const bytes = await internals.storage.get(KEYS.startIdempotency(idempotencyKey));
9
+ if (bytes === null)
10
+ return;
11
+ return decode(bytes).workflowId;
12
+ }
13
+ export async function resolveExistingRunOrThrowPurged(internals, workflowId) {
14
+ if (await loadWorkflowState(internals, workflowId) === null)
15
+ throw new IdempotencyKeyPurgedError(workflowId);
16
+ return workflowId;
17
+ }
18
+ const RESERVATION_CLEAR_MAX_ATTEMPTS = 5, RESERVATION_CLEAR_RETRY_DELAY_MS = 5;
19
+ async function awaitReservationCleared(internals, workflowId) {
20
+ for (let attempt = 0;attempt < RESERVATION_CLEAR_MAX_ATTEMPTS; attempt += 1) {
21
+ if (!internals.pendingStarts.has(workflowId))
22
+ return;
23
+ await sleep(RESERVATION_CLEAR_RETRY_DELAY_MS);
24
+ }
25
+ }
26
+ export async function resolveCallerIdWinnerOrRetry(internals, winnerId, signalSpec, signalId, callbacks) {
27
+ const resolved = await signalOrConflictExistingWorkflow(internals, winnerId, signalSpec, signalId, callbacks);
28
+ if (resolved !== void 0)
29
+ return resolved;
30
+ await awaitReservationCleared(internals, winnerId);
31
+ return signalOrConflictExistingWorkflow(internals, winnerId, signalSpec, signalId, callbacks);
32
+ }
33
+ export async function signalOrConflictExistingWorkflow(internals, workflowId, signalSpec, signalId, callbacks) {
34
+ const state = await loadWorkflowState(internals, workflowId);
35
+ if (state === null)
36
+ return;
37
+ if (isTerminalWorkflowStatus(state.status))
38
+ throw new StartOrSignalConflictError(workflowId, state.status);
39
+ await callbacks.signalExistingWorkflow(workflowId, signalSpec.name, signalSpec.payload, signalId);
40
+ return callbacks.getHandle(workflowId);
41
+ }
42
+ const WINNER_RESOLUTION_MAX_ATTEMPTS = 5, WINNER_RESOLUTION_RETRY_DELAY_MS = 5;
43
+ export async function resolveWinnerWithSignal(internals, winnerId, signalSpec, signalId, callbacks, idempotencyKey) {
44
+ for (let attempt = 0;attempt < WINNER_RESOLUTION_MAX_ATTEMPTS; attempt += 1) {
45
+ const resolved = await signalOrConflictExistingWorkflow(internals, winnerId, signalSpec, signalId, callbacks);
46
+ if (resolved !== void 0)
47
+ return resolved;
48
+ if (attempt < WINNER_RESOLUTION_MAX_ATTEMPTS - 1)
49
+ await sleep(WINNER_RESOLUTION_RETRY_DELAY_MS);
50
+ }
51
+ if (await resolveIdempotencyKeyWorkflowId(internals, idempotencyKey) === winnerId)
52
+ throw new IdempotencyKeyPurgedError(winnerId);
53
+ throw Error(`startOrSignal resolved winning workflow "${winnerId}" but its record never became readable after ${WINNER_RESOLUTION_MAX_ATTEMPTS} attempts.`);
54
+ }
55
+ export async function requireWinnerId(internals, idempotencyKey) {
56
+ const winnerId = await resolveIdempotencyKeyWorkflowId(internals, idempotencyKey);
57
+ if (winnerId === void 0)
58
+ throw Error(`start idempotency mapping for key "${idempotencyKey}" vanished after a lost compare-and-swap; the start-idem: keyspace may have been mutated externally.`);
59
+ return winnerId;
60
+ }
@@ -0,0 +1,46 @@
1
+ import type { StartOptions, StartOrSignalSignal } from '../../types.ts';
2
+ import { type WorkflowHandle } from '../handles.ts';
3
+ import type { EngineInternals } from '../internals.ts';
4
+ import { type LifecycleCallbacks } from './shared.ts';
5
+ import { type StartOrSignalResult } from './start-or-signal-create.ts';
6
+ import { type StartOrSignalCallbacks } from './start-or-signal-resolution.ts';
7
+ export type { StartOrSignalCallbacks, StartOrSignalResult };
8
+ /**
9
+ * Enforce at-most-once start for a given `idempotencyKey`. On the first call,
10
+ * the workflow record and a `startIdempotency(key) → { workflowId }` mapping
11
+ * commit in one compare-and-swap gated on the mapping being absent. Every later
12
+ * call with the same key resolves the mapping and returns a handle to that run —
13
+ * even if it has since reached a terminal state (idempotent start is a pure
14
+ * dedup; it never restarts).
15
+ *
16
+ * Concurrent same-key callers race at the lookup→commit gap; the CAS lets exactly
17
+ * one win, and the loser (its create batch rejected) resolves to the winner's
18
+ * run. Requires the `conditionalBatch` capability and throws if it is absent —
19
+ * single-execution semantics cannot be honored without atomic compare-and-swap.
20
+ */
21
+ export declare function startWithIdempotency(internals: EngineInternals, type: string, input: unknown, options: StartOptions, callbacks: LifecycleCallbacks): Promise<WorkflowHandle>;
22
+ /**
23
+ * Atomic start-or-signal (signal-with-start). Resolves the target workflow, then:
24
+ *
25
+ * - **Absent** → create the workflow and deliver the signal in ONE conditional
26
+ * batch (workflow record + `sig:`/`sigres:` pair + optional idempotency
27
+ * mapping). The freshly-launched run consumes the signal on its first drive.
28
+ * - **Non-terminal** (running, pending, suspended) → deliver the signal through
29
+ * the standard engine signal path with the same `signalId`, so it dedups
30
+ * against a create-batch signal a concurrent winner may have written.
31
+ * - **Terminal** → throw {@link StartOrSignalConflictError}: a finished run
32
+ * cannot be signalled and is not silently replaced.
33
+ *
34
+ * Convergence requires a SHARED workflow identity. Concurrent callers converge on
35
+ * one workflow and one signal only when they share an `options.idempotencyKey`
36
+ * (the durable mapping picks one creator and the signal id derives from the key)
37
+ * or an explicit `options.id` (the caller-id reservation picks one creator).
38
+ *
39
+ * A bare `signal.signalId` with NEITHER `options.id` nor `options.idempotencyKey`
40
+ * does NOT converge: each absent-target call generates its own workflow id, so
41
+ * concurrent callers create distinct runs and each delivers its own signal. In
42
+ * that mode `startOrSignal` is an atomic start-with-one-initial-signal, not a
43
+ * convergence primitive. Use `idempotencyKey` (id-free convergence) or
44
+ * `id` + `signalId` when concurrent callers must converge.
45
+ */
46
+ export declare function startOrSignal(internals: EngineInternals, type: string, input: unknown, signalSpec: StartOrSignalSignal, options: StartOptions | undefined, callbacks: StartOrSignalCallbacks): Promise<StartOrSignalResult>;
@@ -0,0 +1,71 @@
1
+ import { KEYS, requireStorageCapability } from "../../../storage/interface.js";
2
+ import {
3
+ assertIdAndIdempotencyKeyExclusive,
4
+ assertOnTerminalConflictUnsupported,
5
+ assertValidIdempotencyKey,
6
+ assertValidOnTerminalConflict,
7
+ StartWorkflowValidationError
8
+ } from "../../start-workflow-validation.js";
9
+ import { IdempotencyKeyPurgedError } from "../errors.js";
10
+ import { StartIdempotencyRaceLostError } from "./start-commit.js";
11
+ import {
12
+ createWithSignalOrFallback,
13
+ idempotentStartOperationsFor
14
+ } from "./start-or-signal-create.js";
15
+ import {
16
+ requireWinnerId,
17
+ resolveExistingRunOrThrowPurged,
18
+ resolveIdempotencyKeyWorkflowId,
19
+ signalOrConflictExistingWorkflow
20
+ } from "./start-or-signal-resolution.js";
21
+ import { startWorkflow } from "./start.js";
22
+ function resolveSignalId(signalSpec, idempotencyKey) {
23
+ if (idempotencyKey !== void 0)
24
+ return KEYS.startIdempotencySignalId(idempotencyKey);
25
+ if (signalSpec.signalId !== void 0)
26
+ return signalSpec.signalId;
27
+ throw new StartWorkflowValidationError("startOrSignal requires either signal.signalId or options.idempotencyKey to identify the signal to deliver. (Concurrent callers converge on one workflow and one signal only with a shared idempotencyKey, or a shared id plus signalId; a bare signalId starts a fresh run per caller.)");
28
+ }
29
+ export async function startWithIdempotency(internals, type, input, options, callbacks) {
30
+ requireStorageCapability(internals.storage, "conditionalBatch", "start idempotency");
31
+ const { idempotencyKey } = options;
32
+ if (idempotencyKey === void 0)
33
+ throw new StartWorkflowValidationError("startWithIdempotency requires options.idempotencyKey");
34
+ assertValidIdempotencyKey(idempotencyKey, "options.idempotencyKey");
35
+ assertIdAndIdempotencyKeyExclusive(options);
36
+ assertValidOnTerminalConflict(options);
37
+ const existingId = await resolveIdempotencyKeyWorkflowId(internals, idempotencyKey);
38
+ if (existingId !== void 0)
39
+ return callbacks.getHandle(await resolveExistingRunOrThrowPurged(internals, existingId));
40
+ try {
41
+ return await startWorkflow(internals, type, input, options, void 0, callbacks, idempotentStartOperationsFor(internals, idempotencyKey, void 0));
42
+ } catch (error) {
43
+ if (!(error instanceof StartIdempotencyRaceLostError))
44
+ throw error;
45
+ }
46
+ return callbacks.getHandle(await resolveExistingRunOrThrowPurged(internals, await requireWinnerId(internals, idempotencyKey)));
47
+ }
48
+ function validateStartOrSignalConvergence(signalSpec, options) {
49
+ const idempotencyKey = options?.idempotencyKey;
50
+ if (idempotencyKey === void 0)
51
+ return;
52
+ assertValidIdempotencyKey(idempotencyKey, "options.idempotencyKey");
53
+ assertIdAndIdempotencyKeyExclusive(options ?? {});
54
+ if (signalSpec.signalId !== void 0)
55
+ throw new StartWorkflowValidationError("startOrSignal does not accept both signal.signalId and options.idempotencyKey: the signal id derives from the idempotency key for convergence. Provide exactly one.");
56
+ }
57
+ export async function startOrSignal(internals, type, input, signalSpec, options, callbacks) {
58
+ requireStorageCapability(internals.storage, "conditionalBatch", "startOrSignal");
59
+ assertOnTerminalConflictUnsupported(options, "startOrSignal");
60
+ const idempotencyKey = options?.idempotencyKey;
61
+ validateStartOrSignalConvergence(signalSpec, options);
62
+ const signalId = resolveSignalId(signalSpec, idempotencyKey), mappedId = idempotencyKey !== void 0 ? await resolveIdempotencyKeyWorkflowId(internals, idempotencyKey) : void 0, existingId = mappedId ?? options?.id;
63
+ if (existingId !== void 0) {
64
+ const resolved = await signalOrConflictExistingWorkflow(internals, existingId, signalSpec, signalId, callbacks);
65
+ if (resolved !== void 0)
66
+ return { handle: resolved, outcome: "signalled" };
67
+ if (mappedId !== void 0)
68
+ throw new IdempotencyKeyPurgedError(mappedId);
69
+ }
70
+ return createWithSignalOrFallback(internals, type, input, signalSpec, signalId, options, callbacks);
71
+ }
@@ -0,0 +1,39 @@
1
+ import type { BatchOperation } from '../../../storage/interface.ts';
2
+ import type { StartWorkflowOptions, WorkflowState } from '../../types.ts';
3
+ import type { EngineInternals } from '../internals.ts';
4
+ import { type LifecycleCallbacks } from './shared.ts';
5
+ /**
6
+ * Decide what a caller-supplied workflow id that already has a persisted record
7
+ * means, WITHOUT performing any destructive action. Only invoked when the caller
8
+ * supplied the id — a generated v4 UUID is effectively unique, so skipping this
9
+ * read keeps generated-id starts on the single-write hot path.
10
+ *
11
+ * - default (`'error'`): throw {@link WorkflowAlreadyExistsError} (the existing
12
+ * contract — a duplicate id is always a conflict).
13
+ * - `'start-new'` on a **terminal** run: return that run's {@link WorkflowState}
14
+ * so the caller can purge it *after* all deterministic new-run validation has
15
+ * succeeded. This keeps the destructive purge as the last possible step before
16
+ * the atomic create commit, so a restart that is rejected by any later
17
+ * validation (payload size, execution-timeout overflow, a start interceptor
18
+ * throwing) leaves the prior terminal run intact.
19
+ * - `'start-new'` on a **non-terminal** run: throw
20
+ * {@link WorkflowAlreadyExistsError} — `'start-new'` never displaces a live run.
21
+ * - `'start-new'` on a **terminal** run that still owes a finalizer (#446): throw
22
+ * {@link WorkflowTeardownPendingError} (transient). The displacing purge would
23
+ * delete the finalizer payload before the resource is torn down, leaking it, so
24
+ * the restart is refused until teardown settles (which clears the marker).
25
+ *
26
+ * Returns `null` when there is no existing record (the create proceeds normally).
27
+ */
28
+ export declare function resolveTerminalConflictForRestart(internals: EngineInternals, workflowId: string, options: StartWorkflowOptions | undefined): Promise<WorkflowState | null>;
29
+ /**
30
+ * Prepare a prior terminal run for displacement by a `'start-new'` restart WITHOUT
31
+ * committing the destructive delete. Returns the storage delete operations (for the
32
+ * caller to fold into the atomic create batch so purge-and-recreate land as one
33
+ * unit) and clears the OLD run's in-memory caches up front — before the new run
34
+ * writes its own caches under the reused id, so the clear cannot wipe fresh
35
+ * entries. `clearPurgedWorkflowInMemoryState` runs `cleanupWaiters` to settle the
36
+ * old run's pending signal/update/sleep waiters; it only needs
37
+ * `swallowPromiseRejection`, which `LifecycleCallbacks` already exposes.
38
+ */
39
+ export declare function prepareTerminalRunPurge(internals: EngineInternals, state: WorkflowState, callbacks: LifecycleCallbacks): Promise<BatchOperation[]>;
@@ -0,0 +1,28 @@
1
+ import { KEYS, storageHas } from "../../../storage/interface.js";
2
+ import {
3
+ clearPurgedWorkflowInMemoryState,
4
+ collectWorkflowPurgeDeleteOperations
5
+ } from "../bulk-operations-purge.js";
6
+ import { WorkflowAlreadyExistsError, WorkflowTeardownPendingError } from "../errors.js";
7
+ import { cleanupWaiters } from "../termination/cleanup.js";
8
+ import { decodeWorkflowState, isTerminalWorkflowStatus } from "../validation.js";
9
+ export async function resolveTerminalConflictForRestart(internals, workflowId, options) {
10
+ const existingBytes = await internals.storage.get(KEYS.workflow(workflowId));
11
+ if (existingBytes === null)
12
+ return null;
13
+ if (options?.onTerminalConflict !== "start-new")
14
+ throw new WorkflowAlreadyExistsError(workflowId);
15
+ const existingState = decodeWorkflowState(existingBytes);
16
+ if (!isTerminalWorkflowStatus(existingState.status))
17
+ throw new WorkflowAlreadyExistsError(workflowId);
18
+ if (await storageHas(internals.storage, KEYS.teardownOwed(workflowId)))
19
+ throw new WorkflowTeardownPendingError(workflowId);
20
+ return existingState;
21
+ }
22
+ export async function prepareTerminalRunPurge(internals, state, callbacks) {
23
+ const cleanupWaitersForStart = (id) => cleanupWaiters(internals, id, {
24
+ swallowPromiseRejection: callbacks.swallowPromiseRejection
25
+ }), deleteOperations = await collectWorkflowPurgeDeleteOperations(internals, state);
26
+ clearPurgedWorkflowInMemoryState(internals, state.id, cleanupWaitersForStart);
27
+ return deleteOperations;
28
+ }
@@ -1,13 +1,13 @@
1
1
  import type { BatchOperation } from '../../../storage/interface.ts';
2
- import type { Checkpoint, Duration, StartOptions, TimerEntry, WorkflowState } from '../../types.ts';
2
+ import type { Checkpoint, Duration, StartOptions, StartWorkflowOptions, TimerEntry, WorkflowState } from '../../types.ts';
3
3
  import { type WorkflowVersionTuple } from '../../workflow-version-tuple.ts';
4
4
  import { type WorkflowHandle } from '../handles.ts';
5
5
  import type { EngineInternals } from '../internals.ts';
6
- import { type LifecycleCallbacks, type RegistrationEntry } from './shared.ts';
7
- export declare function start(internals: EngineInternals, type: string, input: unknown, options: StartOptions | undefined, callbacks: LifecycleCallbacks): Promise<WorkflowHandle>;
8
- export declare function startWorkflow(internals: EngineInternals, type: string, input: unknown, options: StartOptions | undefined, additionalStartOperations: BatchOperation[] | undefined, callbacks: LifecycleCallbacks): Promise<WorkflowHandle>;
6
+ import { type LifecycleCallbacks } from './shared.ts';
7
+ import { type BuildIdempotentStartOperations } from './start-commit.ts';
8
+ export declare function start(internals: EngineInternals, type: string, input: unknown, options: StartWorkflowOptions | undefined, callbacks: LifecycleCallbacks): Promise<WorkflowHandle>;
9
+ export declare function startWorkflow(internals: EngineInternals, type: string, input: unknown, options: StartWorkflowOptions | undefined, additionalStartOperations: BatchOperation[] | undefined, callbacks: LifecycleCallbacks, buildIdempotentStartOperations?: BuildIdempotentStartOperations): Promise<WorkflowHandle>;
9
10
  export declare function resolveScheduledStartAt(internals: EngineInternals, options: StartOptions | undefined, submissionTime: number, callbacks: LifecycleCallbacks): number | undefined;
10
11
  export declare function parseStartOptionDuration(_internals: EngineInternals, duration: Duration, fieldName: 'options.executionTimeout' | 'options.startAfter', _callbacks: LifecycleCallbacks): number;
11
- export declare function beginWorkflowExecution(internals: EngineInternals, workflowId: string, workflowType: string, input: unknown, checkpoint: Checkpoint, executionDeadline: number | undefined, executionStateOwnerId: string, _registration: RegistrationEntry, callbacks: LifecycleCallbacks): void;
12
- export declare function createInitialWorkflowState(internals: EngineInternals, workflowId: string, type: string, input: unknown, versionTuple: WorkflowVersionTuple, options: StartOptions | undefined, tags: string[] | undefined, executionStateOwnerId: string, delayedStartTimer: TimerEntry | undefined, callbacks: LifecycleCallbacks): WorkflowState;
12
+ export declare function createInitialWorkflowState(internals: EngineInternals, workflowId: string, type: string, input: unknown, versionTuple: WorkflowVersionTuple, options: StartOptions | undefined, tags: string[] | undefined, executionStateOwnerId: string | undefined, delayedStartTimer: TimerEntry | undefined, callbacks: LifecycleCallbacks): WorkflowState;
13
13
  export declare function createInitialCheckpoint(internals: EngineInternals, workflowId: string, workflowVersion: string, options: StartOptions | undefined, _callbacks: LifecycleCallbacks): Checkpoint;