@lostgradient/weft 0.23.1 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -4
- package/dist/cli/codegen-emit-dedup.d.ts +81 -0
- package/dist/cli/codegen-emit-dedup.js +45 -0
- package/dist/cli/codegen-emit-registry.d.ts +90 -0
- package/dist/cli/codegen-emit-registry.js +50 -0
- package/dist/cli/codegen-emit.d.ts +26 -39
- package/dist/cli/codegen-emit.js +4 -27
- package/dist/cli/codegen-validate.d.ts +49 -0
- package/dist/cli/codegen-validate.js +186 -0
- package/dist/cli/codegen.js +6 -87
- package/dist/cli/conformance.js +5 -2
- package/dist/cli/generated/operation-catalog.snapshot.json +381 -3
- package/dist/cli/generated/operation-client.generated.d.ts +350 -10
- package/dist/cli/generated/operation-client.generated.js +14 -0
- package/dist/cli/output.js +1 -1
- package/dist/cli/parse-schedule-arguments.js +15 -3
- package/dist/cli/schedule.js +2 -1
- package/dist/cli/storage-factory.js +2 -0
- package/dist/cli/types.d.ts +2 -1
- package/dist/cli/workflow-commands.js +2 -0
- package/dist/cli-main.js +1 -1
- package/dist/client/http-client-requests.js +6 -9
- package/dist/client/start-body.js +1 -0
- package/dist/core/application-payload-digest.d.ts +42 -0
- package/dist/core/application-payload-digest.js +76 -0
- package/dist/core/application-primitive-abort.d.ts +50 -0
- package/dist/core/application-primitive-abort.js +40 -0
- package/dist/core/application-primitive-attempt-registry.d.ts +74 -0
- package/dist/core/application-primitive-attempt-registry.js +73 -0
- package/dist/core/application-primitive-codec.d.ts +36 -0
- package/dist/core/application-primitive-codec.js +56 -0
- package/dist/core/application-primitive-commit.d.ts +67 -0
- package/dist/core/application-primitive-commit.js +66 -0
- package/dist/core/application-primitive-guards.d.ts +62 -0
- package/dist/core/application-primitive-guards.js +89 -0
- package/dist/core/application-primitive-payload.d.ts +29 -0
- package/dist/core/application-primitive-payload.js +65 -0
- package/dist/core/application-primitive-timing.d.ts +18 -0
- package/dist/core/application-primitive-timing.js +22 -0
- package/dist/core/atomic-state.js +2 -0
- package/dist/core/catalog/codec.d.ts +40 -0
- package/dist/core/catalog/codec.js +45 -0
- package/dist/core/catalog/errors.d.ts +104 -0
- package/dist/core/catalog/errors.js +41 -0
- package/dist/core/catalog/index.d.ts +25 -0
- package/dist/core/catalog/index.js +22 -0
- package/dist/core/catalog/reference-counts.d.ts +120 -0
- package/dist/core/catalog/reference-counts.js +28 -0
- package/dist/core/catalog/removal.d.ts +105 -0
- package/dist/core/catalog/removal.js +30 -0
- package/dist/core/catalog/storage-io.d.ts +101 -0
- package/dist/core/catalog/storage-io.js +106 -0
- package/dist/core/catalog/types.d.ts +108 -0
- package/dist/core/catalog/types.js +0 -0
- package/dist/core/catalog/workflow-catalog.d.ts +165 -0
- package/dist/core/catalog/workflow-catalog.js +198 -0
- package/dist/core/compare-codepoint.d.ts +13 -0
- package/dist/core/compare-codepoint.js +7 -0
- package/dist/core/compression.js +2 -0
- package/dist/core/context/attributes.d.ts +1 -1
- package/dist/core/context/durable-operations.d.ts +2 -2
- package/dist/core/context/index.js +5 -3
- package/dist/core/context/state-namespace.d.ts +1 -1
- package/dist/core/contract/build.d.ts +64 -0
- package/dist/core/contract/build.js +99 -0
- package/dist/core/contract/compatibility.d.ts +187 -0
- package/dist/core/contract/compatibility.js +37 -0
- package/dist/core/contract/failure.d.ts +64 -0
- package/dist/core/contract/failure.js +4 -0
- package/dist/core/contract/hash.d.ts +92 -0
- package/dist/core/contract/hash.js +34 -0
- package/dist/core/contract/index.d.ts +21 -0
- package/dist/core/contract/index.js +22 -0
- package/dist/core/contract/limits.d.ts +74 -0
- package/dist/core/contract/limits.js +1 -0
- package/dist/core/contract/manifest-parse-schema.d.ts +37 -0
- package/dist/core/contract/manifest-parse-schema.js +106 -0
- package/dist/core/contract/manifest-parse.d.ts +76 -0
- package/dist/core/contract/manifest-parse.js +189 -0
- package/dist/core/contract/manifest.d.ts +56 -0
- package/dist/core/contract/manifest.js +31 -0
- package/dist/core/contract/normalize.d.ts +97 -0
- package/dist/core/contract/normalize.js +127 -0
- package/dist/core/contract/revision.d.ts +29 -0
- package/dist/core/contract/revision.js +5 -0
- package/dist/core/contract/types.d.ts +274 -0
- package/dist/core/contract/types.js +1 -0
- package/dist/core/engine/activity-resolution.js +17 -17
- package/dist/core/engine/bulk-operations-purge.js +14 -20
- package/dist/core/engine/bulk-operations-retry.d.ts +9 -0
- package/dist/core/engine/bulk-operations-retry.js +177 -0
- package/dist/core/engine/bulk-operations-shared.d.ts +18 -0
- package/dist/core/engine/bulk-operations-shared.js +14 -0
- package/dist/core/engine/bulk-operations.js +8 -167
- package/dist/core/engine/callback-creators-bundles.js +4 -2
- package/dist/core/engine/callback-creators-core.js +9 -1
- package/dist/core/engine/callback-creators-schedule.js +2 -2
- package/dist/core/engine/catalog-activation.d.ts +40 -0
- package/dist/core/engine/catalog-activation.js +17 -0
- package/dist/core/engine/catalog-events.d.ts +36 -0
- package/dist/core/engine/catalog-events.js +15 -0
- package/dist/core/engine/catalog-readiness.d.ts +49 -0
- package/dist/core/engine/catalog-readiness.js +61 -0
- package/dist/core/engine/catalog-removal.d.ts +236 -0
- package/dist/core/engine/catalog-removal.js +123 -0
- package/dist/core/engine/catalog-tombstone-recovery.d.ts +56 -0
- package/dist/core/engine/catalog-tombstone-recovery.js +39 -0
- package/dist/core/engine/constraints.js +5 -1
- package/dist/core/engine/construction.d.ts +2 -2
- package/dist/core/engine/construction.js +4 -2
- package/dist/core/engine/decode-revision.d.ts +32 -0
- package/dist/core/engine/decode-revision.js +9 -0
- package/dist/core/engine/disposal.d.ts +6 -2
- package/dist/core/engine/disposal.js +26 -3
- package/dist/core/engine/dynamic-source-errors.d.ts +81 -0
- package/dist/core/engine/dynamic-source-errors.js +25 -0
- package/dist/core/engine/dynamic-source-execution.d.ts +173 -0
- package/dist/core/engine/dynamic-source-execution.js +108 -0
- package/dist/core/engine/engine-internal-types.d.ts +16 -0
- package/dist/core/engine/engine-workflows-namespace.d.ts +140 -0
- package/dist/core/engine/engine-workflows-namespace.js +51 -0
- package/dist/core/engine/finalizer-metadata.d.ts +22 -0
- package/dist/core/engine/finalizer-metadata.js +12 -0
- package/dist/core/engine/handle-result.js +2 -0
- package/dist/core/engine/index.d.ts +91 -0
- package/dist/core/engine/index.js +78 -6
- package/dist/core/engine/inline-launch-queue.js +1 -1
- package/dist/core/engine/internals.d.ts +54 -15
- package/dist/core/engine/internals.js +6 -0
- package/dist/core/engine/lifecycle/checkpoint-launch.d.ts +29 -0
- package/dist/core/engine/lifecycle/checkpoint-launch.js +75 -0
- package/dist/core/engine/lifecycle/delayed-start-registration.d.ts +30 -0
- package/dist/core/engine/lifecycle/delayed-start-registration.js +11 -0
- package/dist/core/engine/lifecycle/fork-helpers.d.ts +33 -1
- package/dist/core/engine/lifecycle/fork-helpers.js +3 -1
- package/dist/core/engine/lifecycle/recovery-revision-groups.d.ts +75 -0
- package/dist/core/engine/lifecycle/recovery-revision-groups.js +64 -0
- package/dist/core/engine/lifecycle/resume-generation-guard.d.ts +58 -0
- package/dist/core/engine/lifecycle/resume-generation-guard.js +11 -0
- package/dist/core/engine/lifecycle/resume.js +18 -9
- package/dist/core/engine/lifecycle/shared.d.ts +43 -0
- package/dist/core/engine/lifecycle/standalone-claim-acquire.d.ts +12 -0
- package/dist/core/engine/lifecycle/standalone-claim-acquire.js +6 -0
- package/dist/core/engine/lifecycle/start-commit-errors.d.ts +12 -0
- package/dist/core/engine/lifecycle/start-commit-errors.js +6 -0
- package/dist/core/engine/lifecycle/start-commit.d.ts +22 -7
- package/dist/core/engine/lifecycle/start-commit.js +49 -15
- package/dist/core/engine/lifecycle/start-exec.d.ts +18 -2
- package/dist/core/engine/lifecycle/start-exec.js +7 -5
- package/dist/core/engine/lifecycle/start-or-signal-create.js +1 -3
- package/dist/core/engine/lifecycle/start-or-signal.js +1 -1
- package/dist/core/engine/lifecycle/start-precondition-attribution.d.ts +49 -0
- package/dist/core/engine/lifecycle/start-precondition-attribution.js +13 -0
- package/dist/core/engine/lifecycle/start-revision-resolution.d.ts +34 -0
- package/dist/core/engine/lifecycle/start-revision-resolution.js +11 -0
- package/dist/core/engine/lifecycle/start-state.d.ts +16 -0
- package/dist/core/engine/lifecycle/start-state.js +60 -0
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.d.ts +66 -3
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.js +13 -3
- package/dist/core/engine/lifecycle/start.d.ts +16 -6
- package/dist/core/engine/lifecycle/start.js +39 -66
- package/dist/core/engine/lifecycle/transition.d.ts +3 -4
- package/dist/core/engine/lifecycle/transition.js +30 -80
- package/dist/core/engine/lifecycle.d.ts +4 -2
- package/dist/core/engine/lifecycle.js +6 -6
- package/dist/core/engine/listing.js +15 -1
- package/dist/core/engine/memo-durable-activity.js +4 -1
- package/dist/core/engine/nonterminal-revision-count.d.ts +25 -0
- package/dist/core/engine/nonterminal-revision-count.js +16 -0
- package/dist/core/engine/operations-time.d.ts +5 -23
- package/dist/core/engine/operations-time.js +13 -11
- package/dist/core/engine/ownership-bootstrap.d.ts +1 -1
- package/dist/core/engine/pinned-schedule-revision-count.d.ts +26 -0
- package/dist/core/engine/pinned-schedule-revision-count.js +19 -0
- package/dist/core/engine/pinned-schedule-revision.d.ts +76 -0
- package/dist/core/engine/pinned-schedule-revision.js +53 -0
- package/dist/core/engine/registration.d.ts +106 -0
- package/dist/core/engine/registration.js +28 -7
- package/dist/core/engine/retention.js +9 -2
- package/dist/core/engine/revision-errors.d.ts +71 -0
- package/dist/core/engine/revision-errors.js +13 -0
- package/dist/core/engine/schedule-revision-fire.d.ts +17 -0
- package/dist/core/engine/schedule-revision-fire.js +3 -0
- package/dist/core/engine/schedule-run.js +2 -1
- package/dist/core/engine/schedules.d.ts +2 -1
- package/dist/core/engine/schedules.js +28 -9
- package/dist/core/engine/source-diagnostics.d.ts +76 -0
- package/dist/core/engine/source-diagnostics.js +105 -0
- package/dist/core/engine/source-registration.d.ts +42 -0
- package/dist/core/engine/source-registration.js +38 -0
- package/dist/core/engine/source-resolution.d.ts +101 -0
- package/dist/core/engine/source-resolution.js +154 -0
- package/dist/core/engine/source-runtime-state.d.ts +92 -0
- package/dist/core/engine/source-runtime-state.js +36 -0
- package/dist/core/engine/storage-io.d.ts +19 -2
- package/dist/core/engine/storage-io.js +21 -2
- package/dist/core/engine/termination/finalizer-registration.d.ts +18 -0
- package/dist/core/engine/termination/finalizer-registration.js +21 -0
- package/dist/core/engine/termination/finalizer.d.ts +16 -19
- package/dist/core/engine/termination/finalizer.js +3 -3
- package/dist/core/engine/time-operation-callbacks.d.ts +32 -0
- package/dist/core/engine/time-operation-callbacks.js +0 -0
- package/dist/core/engine/validation/schedule-cadence.d.ts +16 -0
- package/dist/core/engine/validation/schedule-cadence.js +20 -0
- package/dist/core/engine/validation/schedule-options.d.ts +4 -1
- package/dist/core/engine/validation/schedule-options.js +14 -0
- package/dist/core/engine/validation/schedule-revision.d.ts +24 -0
- package/dist/core/engine/validation/schedule-revision.js +21 -0
- package/dist/core/engine/validation/schedule-warnings.d.ts +11 -0
- package/dist/core/engine/validation/schedule-warnings.js +5 -0
- package/dist/core/engine/validation/schedule.d.ts +4 -3
- package/dist/core/engine/validation/schedule.js +15 -26
- package/dist/core/engine/validation.js +5 -2
- package/dist/core/engine/workflow-claim-reclaim-target.d.ts +1 -1
- package/dist/core/engine/workflow-claim-reclaim-target.js +16 -2
- package/dist/core/engine/workflow-retention-deadline.d.ts +16 -0
- package/dist/core/engine/workflow-retention-deadline.js +33 -0
- package/dist/core/events/catalog-events.d.ts +117 -0
- package/dist/core/events/catalog-events.js +62 -0
- package/dist/core/events/event-map.d.ts +11 -0
- package/dist/core/events/index.d.ts +2 -0
- package/dist/core/events/index.js +2 -0
- package/dist/core/events/workflow-source-events.d.ts +102 -0
- package/dist/core/events/workflow-source-events.js +57 -0
- package/dist/core/execution-strategy.d.ts +7 -0
- package/dist/core/inline-execution-strategy.context-options.d.ts +1 -1
- package/dist/core/inline-execution-strategy.js +1 -1
- package/dist/core/mailbox-admission.d.ts +26 -0
- package/dist/core/mailbox-admission.js +130 -0
- package/dist/core/mailbox-claims.d.ts +251 -0
- package/dist/core/mailbox-claims.js +0 -0
- package/dist/core/mailbox-codec.d.ts +32 -0
- package/dist/core/mailbox-codec.js +221 -0
- package/dist/core/mailbox-contract.d.ts +290 -0
- package/dist/core/mailbox-contract.js +0 -0
- package/dist/core/mailbox-delivery.d.ts +37 -0
- package/dist/core/mailbox-delivery.js +193 -0
- package/dist/core/mailbox-guards.d.ts +78 -0
- package/dist/core/mailbox-guards.js +58 -0
- package/dist/core/mailbox-index-codec.d.ts +41 -0
- package/dist/core/mailbox-index-codec.js +71 -0
- package/dist/core/mailbox-internals.d.ts +156 -0
- package/dist/core/mailbox-internals.js +154 -0
- package/dist/core/mailbox-maintenance.d.ts +29 -0
- package/dist/core/mailbox-maintenance.js +196 -0
- package/dist/core/mailbox-settlement.d.ts +69 -0
- package/dist/core/mailbox-settlement.js +206 -0
- package/dist/core/mailbox-storage.d.ts +117 -0
- package/dist/core/mailbox-storage.js +115 -0
- package/dist/core/mailbox-transition-helpers.d.ts +70 -0
- package/dist/core/mailbox-transition-helpers.js +43 -0
- package/dist/core/mailbox-transitions-recovery.d.ts +28 -0
- package/dist/core/mailbox-transitions-recovery.js +64 -0
- package/dist/core/mailbox-transitions.d.ts +138 -0
- package/dist/core/mailbox-transitions.js +180 -0
- package/dist/core/mailbox-types.d.ts +406 -0
- package/dist/core/mailbox-types.js +16 -0
- package/dist/core/mailbox-validation.d.ts +65 -0
- package/dist/core/mailbox-validation.js +73 -0
- package/dist/core/mailbox-waits.d.ts +50 -0
- package/dist/core/mailbox-waits.js +97 -0
- package/dist/core/mailbox.d.ts +163 -0
- package/dist/core/mailbox.js +211 -0
- package/dist/core/outbox-claims.d.ts +307 -0
- package/dist/core/outbox-claims.js +0 -0
- package/dist/core/outbox-codec.d.ts +24 -0
- package/dist/core/outbox-codec.js +257 -0
- package/dist/core/outbox-contract.d.ts +346 -0
- package/dist/core/outbox-contract.js +0 -0
- package/dist/core/outbox-delivery.d.ts +34 -0
- package/dist/core/outbox-delivery.js +149 -0
- package/dist/core/outbox-drain.d.ts +29 -0
- package/dist/core/outbox-drain.js +158 -0
- package/dist/core/outbox-enqueue.d.ts +24 -0
- package/dist/core/outbox-enqueue.js +115 -0
- package/dist/core/outbox-guards.d.ts +76 -0
- package/dist/core/outbox-guards.js +60 -0
- package/dist/core/outbox-index-codec.d.ts +33 -0
- package/dist/core/outbox-index-codec.js +71 -0
- package/dist/core/outbox-internals.d.ts +99 -0
- package/dist/core/outbox-internals.js +159 -0
- package/dist/core/outbox-listing.d.ts +12 -0
- package/dist/core/outbox-listing.js +38 -0
- package/dist/core/outbox-maintenance.d.ts +28 -0
- package/dist/core/outbox-maintenance.js +191 -0
- package/dist/core/outbox-operations.d.ts +18 -0
- package/dist/core/outbox-operations.js +46 -0
- package/dist/core/outbox-runner.d.ts +30 -0
- package/dist/core/outbox-runner.js +217 -0
- package/dist/core/outbox-settlement.d.ts +57 -0
- package/dist/core/outbox-settlement.js +183 -0
- package/dist/core/outbox-storage.d.ts +107 -0
- package/dist/core/outbox-storage.js +127 -0
- package/dist/core/outbox-transition-helpers.d.ts +83 -0
- package/dist/core/outbox-transition-helpers.js +63 -0
- package/dist/core/outbox-transitions-recovery.d.ts +30 -0
- package/dist/core/outbox-transitions-recovery.js +42 -0
- package/dist/core/outbox-transitions.d.ts +145 -0
- package/dist/core/outbox-transitions.js +236 -0
- package/dist/core/outbox-types.d.ts +400 -0
- package/dist/core/outbox-types.js +20 -0
- package/dist/core/outbox-validation.d.ts +101 -0
- package/dist/core/outbox-validation.js +127 -0
- package/dist/core/outbox-waits.d.ts +39 -0
- package/dist/core/outbox-waits.js +88 -0
- package/dist/core/outbox.d.ts +156 -0
- package/dist/core/outbox.js +234 -0
- package/dist/core/registry-limits.d.ts +49 -0
- package/dist/core/registry-limits.js +10 -0
- package/dist/core/registry-schema-conversion.d.ts +20 -0
- package/dist/core/registry-schema-conversion.js +22 -0
- package/dist/core/registry-snapshot.d.ts +91 -42
- package/dist/core/registry-snapshot.js +39 -77
- package/dist/core/registry-workflow-contract-draft.d.ts +32 -0
- package/dist/core/registry-workflow-contract-draft.js +28 -0
- package/dist/core/registry-workflow-manifest.d.ts +122 -0
- package/dist/core/registry-workflow-manifest.js +92 -0
- package/dist/core/source/errors.d.ts +55 -0
- package/dist/core/source/errors.js +13 -0
- package/dist/core/source/index.d.ts +19 -0
- package/dist/core/source/index.js +4 -0
- package/dist/core/source/resolvers.d.ts +45 -0
- package/dist/core/source/resolvers.js +9 -0
- package/dist/core/source/types.d.ts +211 -0
- package/dist/core/source/types.js +0 -0
- package/dist/core/source/validate.d.ts +91 -0
- package/dist/core/source/validate.js +62 -0
- package/dist/core/source/workflow-source.d.ts +43 -0
- package/dist/core/source/workflow-source.js +16 -0
- package/dist/core/types/checkpoint.d.ts +14 -0
- package/dist/core/types/schedules.d.ts +52 -1
- package/dist/core/types/state.d.ts +16 -0
- package/dist/core/types/workflow-registries.d.ts +7 -0
- package/dist/core/types/workflow-registry.d.ts +12 -0
- package/dist/core/versioning.js +2 -0
- package/dist/core/weft-error.d.ts +1 -1
- package/dist/core/weft-error.js +12 -1
- package/dist/core/worker-execution-strategy.d.ts +1 -0
- package/dist/core/worker-execution-strategy.js +13 -1
- package/dist/core/worker-fault-handling.d.ts +10 -0
- package/dist/core/worker-fault-handling.js +1 -0
- package/dist/core/worker-inbound-message.d.ts +1 -0
- package/dist/core/worker-inbound-message.js +1 -0
- package/dist/core/worker-protocol-guard.js +4 -0
- package/dist/core/worker-protocol.d.ts +7 -0
- package/dist/core/worker-protocol.js +2 -1
- package/dist/core/worker-turn-watchdog.d.ts +8 -1
- package/dist/core/worker-turn-watchdog.js +3 -2
- package/dist/diagnostics/format.js +5 -0
- package/dist/diagnostics/types.d.ts +24 -0
- package/dist/diagnostics/version-check.js +8 -2
- package/dist/http.js +2 -2
- package/dist/index.d.ts +25 -4
- package/dist/index.js +57 -0
- package/dist/indexeddb.js +1 -1
- package/dist/json-schema.js +3 -3
- package/dist/mcp/resources.js +2 -0
- package/dist/runtime/portable.d.ts +9 -1
- package/dist/server/fault-to-json-rpc.js +4 -1
- package/dist/server/handler/auth-context-principal.js +4 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/json-rpc-http.js +2 -0
- package/dist/server/json-rpc-websocket.js +6 -4
- package/dist/server/operation-catalog/index.d.ts +1 -1
- package/dist/server/operation-catalog/pipeline-helpers.js +2 -0
- package/dist/server/operation-catalog/types.d.ts +17 -0
- package/dist/server/operation-fault.d.ts +5 -0
- package/dist/server/operation-fault.js +4 -1
- package/dist/server/operations/activate-workflow-revision.d.ts +30 -0
- package/dist/server/operations/activate-workflow-revision.js +69 -0
- package/dist/server/operations/create-schedule.d.ts +2 -0
- package/dist/server/operations/create-schedule.js +10 -6
- package/dist/server/operations/fleet-events-subscription.js +1 -1
- package/dist/server/operations/fork-workflow.js +1 -1
- package/dist/server/operations/get-active-workflow-revision.d.ts +32 -0
- package/dist/server/operations/get-active-workflow-revision.js +46 -0
- package/dist/server/operations/get-catalog-diagnostics.d.ts +113 -0
- package/dist/server/operations/get-catalog-diagnostics.js +65 -0
- package/dist/server/operations/get-registry.js +17 -4
- package/dist/server/operations/get-task-detail-schema.d.ts +8 -0
- package/dist/server/operations/get-task-detail-schema.js +1 -0
- package/dist/server/operations/get-task-detail.d.ts +8 -0
- package/dist/server/operations/get-task-detail.js +1 -0
- package/dist/server/operations/get-task-diagnostics.d.ts +4 -4
- package/dist/server/operations/get-workflow-revision.d.ts +25 -0
- package/dist/server/operations/get-workflow-revision.js +50 -0
- package/dist/server/operations/install-workflow-revision.d.ts +27 -0
- package/dist/server/operations/install-workflow-revision.js +46 -0
- package/dist/server/operations/list-workflow-revisions.d.ts +20 -0
- package/dist/server/operations/list-workflow-revisions.js +40 -0
- package/dist/server/operations/preload-workflow-revision.d.ts +28 -0
- package/dist/server/operations/preload-workflow-revision.js +60 -0
- package/dist/server/operations/schedule-faults.d.ts +1 -0
- package/dist/server/operations/schedule-faults.js +32 -4
- package/dist/server/operations/schedule-rest-body.d.ts +1 -0
- package/dist/server/operations/schedule-rest-body.js +2 -1
- package/dist/server/operations/start-or-signal-workflow.js +1 -1
- package/dist/server/operations/start-workflow.js +1 -1
- package/dist/server/operations/static-registrations.js +42 -0
- package/dist/server/operations/storage.js +2 -2
- package/dist/server/operations/submit-review-decision.js +1 -1
- package/dist/server/operations/update-schedule.d.ts +2 -0
- package/dist/server/operations/update-schedule.js +4 -2
- package/dist/server/operations/workflow-catalog-operation-helpers.d.ts +59 -0
- package/dist/server/operations/workflow-catalog-operation-helpers.js +162 -0
- package/dist/server/runtime/task-dispatch-envelope.d.ts +14 -0
- package/dist/server/runtime/task-dispatch-envelope.js +32 -0
- package/dist/server/runtime/task-dispatch-revision.d.ts +29 -0
- package/dist/server/runtime/task-dispatch-revision.js +13 -0
- package/dist/server/runtime/task-dispatch.js +12 -37
- package/dist/server/runtime/task-ledger-recovery.js +1 -1
- package/dist/server/runtime/task-ledger-runtime.d.ts +14 -2
- package/dist/server/runtime/task-ledger-runtime.js +5 -3
- package/dist/server/runtime/task-polling.js +9 -3
- package/dist/server/runtime/task-reconciliation.js +2 -1
- package/dist/server/runtime/websocket-upgrade.js +2 -0
- package/dist/server/runtime/websocket-worker.js +9 -0
- package/dist/server/task-ledger-codec.d.ts +9 -0
- package/dist/server/task-ledger-codec.js +4 -1
- package/dist/server/task-ledger-transition-helpers.js +1 -0
- package/dist/server/task-ledger-types.d.ts +9 -0
- package/dist/server/task-ledger.d.ts +1 -1
- package/dist/server/task-ledger.js +2 -1
- package/dist/server/task-queue-types.d.ts +2 -0
- package/dist/storage/bun-sql.js +51 -6
- package/dist/storage/catalog-keys.d.ts +64 -0
- package/dist/storage/catalog-keys.js +8 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/derived-operations.js +1 -1
- package/dist/storage/index.d.ts +28 -1
- package/dist/storage/interface.d.ts +28 -1
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-encoding.d.ts +15 -0
- package/dist/storage/key-encoding.js +3 -0
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +16 -0
- package/dist/storage/lmdb.d.ts +54 -1
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/mailbox-keys.d.ts +80 -0
- package/dist/storage/mailbox-keys.js +14 -0
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon.js +2 -2
- package/dist/storage/node-sqlite-loader.d.ts +1 -1
- package/dist/storage/node-sqlite.js +51 -6
- package/dist/storage/outbox-keys.d.ts +77 -0
- package/dist/storage/outbox-keys.js +14 -0
- package/dist/storage/postgres.js +2 -2
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/storage-configuration.d.ts +6 -0
- package/dist/storage/testing.js +1 -1
- package/dist/storage/turso.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web-extension.js +1 -1
- package/dist/worker/manifest/registry-contract-builder.d.ts +21 -3
- package/dist/worker/manifest/registry-contract-builder.js +40 -31
- package/dist/worker/protocol-messages.d.ts +17 -0
- package/dist/worker/protocol-schemas.d.ts +32 -0
- package/dist/worker/protocol-schemas.js +7 -3
- package/dist/worker/protocol-task-result.js +35 -3
- package/dist/worker/protocol.js +1 -1
- package/dist/worker/registry/types.d.ts +2 -0
- package/dist/worker/registry.d.ts +1 -1
- package/dist/worker/registry.js +3 -1
- package/dist/workers/workflow-runner.d.ts +9 -0
- package/dist/workers/workflow-runner.js +9 -2
- package/dist/workers/workflow-worker-entry.js +9 -4
- package/package.json +2 -2
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { AlertStateSnapshot } from '../../alerting/types.ts';
|
|
2
2
|
import { type Storage as WeftStorage } from '../../storage/interface.ts';
|
|
3
3
|
import { type ActivityMetadata, type ActivityRegistrationOptions, type RegisteredActivityFunction } from '../activity-registry.ts';
|
|
4
|
+
import type { WorkflowRevisionRecord } from '../catalog/index.ts';
|
|
4
5
|
import type { StoredStreamChunk } from '../context.ts';
|
|
5
6
|
import type { TypedEventTarget, WeftEventMap } from '../events.ts';
|
|
6
7
|
import type { Interceptor } from '../interceptor.ts';
|
|
7
8
|
import { type ReviewRequest } from '../review/index.ts';
|
|
8
9
|
import { Scheduler } from '../scheduler.ts';
|
|
10
|
+
import type { WorkflowSourceHandle } from '../source/index.ts';
|
|
9
11
|
import { type AnyActivityDefinition, type AnyWorkflowDefinition, type AttributeFilterKey, type BulkCancelResult, type BulkDeleteResult, type BulkOperationCommitOptions, type BulkOperationDryRunOptions, type BulkOperationDryRunResult, type BulkRetryFailedResult, type BulkSignalAllCommitOptions, type BulkSignalAllDryRunOptions, type BulkSignalResult, type BulkTagResult, type CheckpointState, type CheckpointSummary, type CoordinatedUpdateResult, type DefaultActivityTypes, type DefaultWorkflowRegistry, type ForkOptions, type InferActivityEntries, type InferActivityEntry, type InferWorkflowEntries, type InferWorkflowEntry, type ListFilter, type ListOptions, type PaginatedResult, type PendingAsyncActivityListOptions, type PendingAsyncActivityPage, type PurgeResult, type QueryDefinition, type RegisteredWorkflowDefinition, type RetentionOverview, type ReviewListEntry, type ReviewListFilter, type ScheduleDefinition, type ScheduleFilter, type ScheduleOptions, type ScheduleSpec, type ScheduleSummary, type ScheduleUpdateOptions, type SearchAttributeValue, type SignalDefinition, type SignalDeliveryOptions, type StartOrSignalOptions, type StartOrSignalSignal, type StartWorkflowOptions, type SubmitReviewOptions, type TypedListFilter, type UpdateDefinition, type WorkflowEvent, type WorkflowFinalizerStatus, type WorkflowInput, type WorkflowOutput, type WorkflowReplay, type WorkflowScheduleProvenance, type WorkflowServices, type WorkflowServicesUnion, type WorkflowState, type WorkflowSummary, type WorkflowTimelineEntry } from '../types.ts';
|
|
10
12
|
import type { TimerEntry } from '../types/checkpoint.ts';
|
|
11
13
|
import type { WorkflowAlreadyRegistered } from '../types/workflow-builder.ts';
|
|
@@ -14,29 +16,38 @@ import { type EmptyActivityDefinitions, type EmptyWorkflowDefinitions, type Know
|
|
|
14
16
|
import { type ActivityDefinitionName, type EngineCreateOptions, type EngineCreateWorkflowRegistry, type RegisteredActivityDefinitionExecute, type UnknownWorkflowNameWhenDefaultRegistryIsEmpty } from './engine-create-types.ts';
|
|
15
17
|
import type { EngineConstructorOptions } from './engine-internal-types.ts';
|
|
16
18
|
import type { EngineStateNamespace } from './engine-state-namespace.ts';
|
|
19
|
+
import { type EngineWorkflowsNamespace } from './engine-workflows-namespace.ts';
|
|
17
20
|
import { HANDLE_RESULT_PROMISE, WorkflowHandle } from './handles.ts';
|
|
18
21
|
import { ENGINE_LEASE_LOST_WARNING_NAME } from './lease-deposition.ts';
|
|
19
22
|
import type { EngineLeaseHealth } from './lease-health.ts';
|
|
20
23
|
import { type RecoverAllOptions, type StartOrSignalResult } from './lifecycle.ts';
|
|
21
24
|
import { assertCompatiblePersistedDataVersion } from './persisted-data-version.ts';
|
|
22
25
|
import { ScheduleHandle } from './schedule-handle.ts';
|
|
26
|
+
import { type ResolveWorkflowSourceOptions } from './source-resolution.ts';
|
|
23
27
|
import { type WorkflowFeedListener, type WorkflowFeedRecord, type WorkflowFeedSelector } from './workflow-feed.ts';
|
|
28
|
+
export type { WorkflowRevisionReferenceCounts } from '../catalog/index.ts';
|
|
24
29
|
export { ActivityReconciliationCapabilityError, ActivityReconciliationConflictError, ActivityReconciliationIndeterminateError, } from './activity-reconciliation.ts';
|
|
25
30
|
export { AsyncActivityTokenNotFoundError } from './async-activity-completion.ts';
|
|
26
31
|
export type { PendingAsyncActivity } from './async-activity-records.ts';
|
|
32
|
+
export { getWorkflowRevisionDiagnostics, removeWorkflowRevision, type WorkflowCatalogRemovalResult, type WorkflowRevisionDiagnostics, } from './catalog-removal.ts';
|
|
33
|
+
export { DynamicWorkflowSourceUnavailableError, WorkflowSourceNotRegisteredError, } from './dynamic-source-errors.ts';
|
|
27
34
|
export type { PendingTimelineEntry, RegistrationEntry, ResolvedOptions, TrackedWaiterKeys, WorkflowResultWaiter, } from './engine-internal-types.ts';
|
|
28
35
|
export { ActivityResolutionError, BulkDeleteRequiresTerminalWorkflowsError, BulkOperationConfirmationError, EngineCreateNameMismatchError, EngineDisposalError, EngineDisposedError, IdempotencyKeyPurgedError, PersistedDataCorruptError, PersistedDataIncompatibleError, StartOrSignalConflictError, WorkflowAlreadyExistsError, WorkflowConcurrencyLimitExceededError, WorkflowNotFoundError, WorkflowNotRegisteredError, WorkflowSuspendNotSupportedError, WorkflowTeardownPendingError, WorkflowTypeNotRegisteredForRecoveryError, } from './errors.ts';
|
|
29
36
|
export { HANDLE_RESULT_PROMISE, WorkflowHandle } from './handles.ts';
|
|
37
|
+
export { getWorkflowCatalog } from './internals.ts';
|
|
30
38
|
export { WeftWorkflowClaimLostWarning, WeftWorkflowWakeDiscardedWarning, WORKFLOW_CLAIM_LOST_WARNING_NAME, WORKFLOW_WAKE_DISCARDED_WARNING_NAME, } from './lease-deposition.ts';
|
|
31
39
|
export type { WorkflowWakeKind } from './lease-deposition.ts';
|
|
32
40
|
export { EngineLeaseAcquisitionTimeoutError, EngineLeaseCorruptedError, EngineLeaseNotHeldError, OwnershipModeMismatchError, WorkflowClaimUnavailableError, } from './lease-errors.ts';
|
|
33
41
|
export type { EngineLeaseHealth, LeaseLostReason } from './lease-health.ts';
|
|
34
42
|
export type { RecoverAllOptions, RecoveredWorkflowInfo } from './lifecycle.ts';
|
|
43
|
+
export { WorkflowRevisionUnavailableError } from './revision-errors.ts';
|
|
35
44
|
export { ScheduleHandle } from './schedule-handle.ts';
|
|
45
|
+
export type { ResolveWorkflowSourceOptions } from './source-resolution.ts';
|
|
36
46
|
export type { WorkflowFeedListener, WorkflowFeedRecord, WorkflowFeedSelector, } from './workflow-feed.ts';
|
|
37
47
|
export type { EngineCreateOptions } from './engine-create-types.ts';
|
|
38
48
|
export { clearEngineLeakWarningTokenForTesting, getEngineLeakCollectionCountForTesting, hasEngineLeakWarningTokenForTesting, setEngineLeakWarningOverrideForTesting, setNextEngineLeakWarningTokenForTesting, shouldEmitEngineLeakWarningForTesting, } from './engine-leak-warnings.ts';
|
|
39
49
|
export type { EngineStateNamespace } from './engine-state-namespace.ts';
|
|
50
|
+
export type { ActivateWorkflowRevisionOptions, EngineWorkflowsNamespace, } from './engine-workflows-namespace.ts';
|
|
40
51
|
export { assertCompatiblePersistedDataVersion };
|
|
41
52
|
export declare const ENGINE_PARKED_WORKFLOW_COUNT_FOR_TESTING: unique symbol;
|
|
42
53
|
export declare const ENGINE_SIGNAL_WAITER_COUNT_FOR_TESTING: unique symbol;
|
|
@@ -172,6 +183,7 @@ export declare class Engine<TWorkflows extends object = DefaultWorkflowRegistry,
|
|
|
172
183
|
removeEventListener<K extends Extract<keyof WeftEventMap, string>>(type: K, listener: (event: WeftEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
|
|
173
184
|
removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void;
|
|
174
185
|
get state(): EngineStateNamespace;
|
|
186
|
+
get workflows(): EngineWorkflowsNamespace;
|
|
175
187
|
/** Return detached snapshots of the alert rules that are currently firing. */
|
|
176
188
|
getActiveAlerts(): readonly AlertStateSnapshot[];
|
|
177
189
|
/**
|
|
@@ -212,6 +224,50 @@ export declare class Engine<TWorkflows extends object = DefaultWorkflowRegistry,
|
|
|
212
224
|
readonly execute: RegisteredActivityDefinitionExecute<TActivities, TName>;
|
|
213
225
|
}): Engine<TWorkflows, TActivities & InferActivityEntry<TDefinition>>;
|
|
214
226
|
register<TDefinition extends AnyActivityDefinition>(definition: ActivityDefinitionName<TDefinition> extends Extract<keyof TActivities, string> ? never : TDefinition): Engine<TWorkflows, TActivities & InferActivityEntry<TDefinition>>;
|
|
227
|
+
/**
|
|
228
|
+
* Record `source` as a lazily-resolvable dynamic workflow source
|
|
229
|
+
* (WFT-13/14): synchronous, and it never invokes `source.load` — it only
|
|
230
|
+
* records a catalog candidate keyed `(source.descriptor.name,
|
|
231
|
+
* source.descriptor.revision)`. Call `resolveWorkflowSource()` to
|
|
232
|
+
* actually load, validate, and install it. A workflow name may not be
|
|
233
|
+
* both eagerly registered (`engine.register()`) and a dynamic source;
|
|
234
|
+
* registering the identical `source` reference twice for the same
|
|
235
|
+
* `(name, revision)` is idempotent.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```ts
|
|
239
|
+
* import { Engine, workflowSource } from '@lostgradient/weft';
|
|
240
|
+
*
|
|
241
|
+
* declare const loadCheckout: () => Promise<{
|
|
242
|
+
* checkout: import('@lostgradient/weft').WorkflowDefinition<unknown, unknown, 'checkout'>;
|
|
243
|
+
* }>;
|
|
244
|
+
* const engine = new Engine();
|
|
245
|
+
* engine.registerSource(
|
|
246
|
+
* workflowSource(
|
|
247
|
+
* { name: 'checkout', location: './checkout.ts', exportName: 'checkout', revision: 'r1' },
|
|
248
|
+
* loadCheckout,
|
|
249
|
+
* ),
|
|
250
|
+
* );
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
registerSource(source: WorkflowSourceHandle): void;
|
|
254
|
+
/**
|
|
255
|
+
* Load, validate, and install one dynamic workflow source revision
|
|
256
|
+
* previously recorded via {@link Engine.registerSource}. Single-flight
|
|
257
|
+
* per `(name, revision)`: concurrent callers for the same key share one
|
|
258
|
+
* loader invocation. Does not wire `engine.start()` or recovery to await
|
|
259
|
+
* resolution — that is a later batch's job (WFT-15).
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```ts
|
|
263
|
+
* import { Engine } from '@lostgradient/weft';
|
|
264
|
+
*
|
|
265
|
+
* declare const engine: Engine;
|
|
266
|
+
* const record = await engine.resolveWorkflowSource('checkout', 'r1');
|
|
267
|
+
* console.log(record.manifest.revision);
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
resolveWorkflowSource(name: string, revision: string, options?: ResolveWorkflowSourceOptions): Promise<WorkflowRevisionRecord>;
|
|
215
271
|
/**
|
|
216
272
|
* Register every workflow from an object map at once and return a typed
|
|
217
273
|
* engine view that exposes the newly added workflow names.
|
|
@@ -244,6 +300,41 @@ export declare class Engine<TWorkflows extends object = DefaultWorkflowRegistry,
|
|
|
244
300
|
listWorkflowDefinitions(): RegisteredWorkflowDefinition[];
|
|
245
301
|
getActivityDefinition(name: string): ActivityMetadata | undefined;
|
|
246
302
|
listActivityDefinitions(): ActivityMetadata[];
|
|
303
|
+
/**
|
|
304
|
+
* Resolve one activity's catalog metadata against the EAGER per-workflow
|
|
305
|
+
* `.activities({...})` registry only, falling back to the global registry
|
|
306
|
+
* — never a `registerSource()`-registered type's dynamic-source revision,
|
|
307
|
+
* resolved or not (WFT-19: `internals.activityRegistriesByWorkflow` is
|
|
308
|
+
* eager-only as of this batch; a dynamic-source workflow's own activity
|
|
309
|
+
* dispatch resolves via the running instance's exact `(type, revision)`
|
|
310
|
+
* pin instead, in `activity-resolution.ts`, which this synchronous,
|
|
311
|
+
* type-only accessor has no instance to pin against). Build tooling
|
|
312
|
+
* (`buildWorkerManifestFromRegistry`) uses this so a workflow-scoped
|
|
313
|
+
* activity's schema, not a same-named global activity's, feeds its
|
|
314
|
+
* `contractHash` when both are registered.
|
|
315
|
+
*/
|
|
316
|
+
getWorkflowActivityDefinition(workflowType: string, activityName: string): ActivityMetadata | undefined;
|
|
317
|
+
/**
|
|
318
|
+
* List every activity definition registered on this workflow's own
|
|
319
|
+
* per-workflow `.activities({...})` registry — name, schema, description,
|
|
320
|
+
* tags, retry/timeout metadata, never a handler function. Returns an
|
|
321
|
+
* empty array for a workflow with no `.activities({...})` step (including
|
|
322
|
+
* an unknown `workflowType`), never `undefined`, so a caller can fold the
|
|
323
|
+
* result straight into a contract without an existence check first.
|
|
324
|
+
*
|
|
325
|
+
* Companion to {@link getWorkflowActivityDefinition}: that resolves one
|
|
326
|
+
* activity by name with the per-workflow-first, global-fallback dispatch
|
|
327
|
+
* order; this enumerates only the names the EAGER per-workflow registry
|
|
328
|
+
* itself declares — activities a workflow reaches solely through the
|
|
329
|
+
* global registry are deliberately excluded, and so (as of WFT-19) is
|
|
330
|
+
* every `registerSource()`-registered type regardless of whether a
|
|
331
|
+
* revision has been resolved (see {@link getWorkflowActivityDefinition}'s
|
|
332
|
+
* doc). Build tooling that needs a workflow's full scoped-activity
|
|
333
|
+
* contract set (`buildRegistrySnapshot`,
|
|
334
|
+
* `worker/manifest/registry-contract-builder.ts`) uses this instead of
|
|
335
|
+
* reaching into engine internals directly.
|
|
336
|
+
*/
|
|
337
|
+
listWorkflowActivityDefinitions(workflowType: string): ActivityMetadata[];
|
|
247
338
|
start<TName extends KnownWorkflowNames<TWorkflows>>(type: TName, input: WorkflowInput<TWorkflows, TName>, options?: StartWorkflowOptions<WorkflowServices<TWorkflows, TName>>): Promise<WorkflowHandle<WorkflowOutput<TWorkflows, TName>>>;
|
|
248
339
|
start<TName extends string>(type: UnknownWorkflowNameWhenDefaultRegistryIsEmpty<TWorkflows, TName>, input: unknown, options?: StartWorkflowOptions): Promise<WorkflowHandle>;
|
|
249
340
|
/**
|
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
createUpdateCallbacks as createUpdateCallbacksForEngine
|
|
48
48
|
} from "./callback-creators.js";
|
|
49
49
|
import { registerCancelHandler } from "./cancel-handlers.js";
|
|
50
|
+
import { ensureWorkflowCatalogReady, isWorkflowCatalogReady } from "./catalog-readiness.js";
|
|
50
51
|
import {
|
|
51
52
|
getCheckpointAt as getCheckpointStateAt,
|
|
52
53
|
getEvents as getWorkflowEvents,
|
|
@@ -65,6 +66,10 @@ import {
|
|
|
65
66
|
typedEngineView
|
|
66
67
|
} from "./construction.js";
|
|
67
68
|
import { disposeEngine } from "./disposal.js";
|
|
69
|
+
import {
|
|
70
|
+
canResolveRevisionLocally,
|
|
71
|
+
getResolvedDynamicRegistration
|
|
72
|
+
} from "./dynamic-source-execution.js";
|
|
68
73
|
import {
|
|
69
74
|
consumeNextEngineLeakWarningTokenForTesting,
|
|
70
75
|
engineCleanupIntervalFinalizer
|
|
@@ -78,6 +83,9 @@ import {
|
|
|
78
83
|
shouldStartEngineScheduler,
|
|
79
84
|
validateEngineCreateBackgroundTaskOptions
|
|
80
85
|
} from "./engine-runtime-helpers.js";
|
|
86
|
+
import {
|
|
87
|
+
createEngineWorkflowsNamespace
|
|
88
|
+
} from "./engine-workflows-namespace.js";
|
|
81
89
|
import {
|
|
82
90
|
EngineCreateNameMismatchError,
|
|
83
91
|
EngineDisposalError,
|
|
@@ -167,6 +175,11 @@ import {
|
|
|
167
175
|
releaseSignalWaiter,
|
|
168
176
|
signal as signalWorkflow
|
|
169
177
|
} from "./signals.js";
|
|
178
|
+
import { registerSource as registerWorkflowSource } from "./source-registration.js";
|
|
179
|
+
import {
|
|
180
|
+
resolveWorkflowSource as resolveWorkflowSourceImpl
|
|
181
|
+
} from "./source-resolution.js";
|
|
182
|
+
import { createWorkflowSourceRuntimeState } from "./source-runtime-state.js";
|
|
170
183
|
import {
|
|
171
184
|
loadScheduleState,
|
|
172
185
|
loadWorkflowState,
|
|
@@ -204,6 +217,14 @@ export {
|
|
|
204
217
|
ActivityReconciliationIndeterminateError
|
|
205
218
|
} from "./activity-reconciliation.js";
|
|
206
219
|
export { AsyncActivityTokenNotFoundError } from "./async-activity-completion.js";
|
|
220
|
+
export {
|
|
221
|
+
getWorkflowRevisionDiagnostics,
|
|
222
|
+
removeWorkflowRevision
|
|
223
|
+
} from "./catalog-removal.js";
|
|
224
|
+
export {
|
|
225
|
+
DynamicWorkflowSourceUnavailableError,
|
|
226
|
+
WorkflowSourceNotRegisteredError
|
|
227
|
+
} from "./dynamic-source-errors.js";
|
|
207
228
|
export {
|
|
208
229
|
ActivityResolutionError,
|
|
209
230
|
BulkDeleteRequiresTerminalWorkflowsError,
|
|
@@ -224,6 +245,7 @@ export {
|
|
|
224
245
|
WorkflowTypeNotRegisteredForRecoveryError
|
|
225
246
|
} from "./errors.js";
|
|
226
247
|
export { HANDLE_RESULT_PROMISE, WorkflowHandle } from "./handles.js";
|
|
248
|
+
export { getWorkflowCatalog } from "./internals.js";
|
|
227
249
|
export {
|
|
228
250
|
WeftWorkflowClaimLostWarning,
|
|
229
251
|
WeftWorkflowWakeDiscardedWarning,
|
|
@@ -237,6 +259,7 @@ export {
|
|
|
237
259
|
OwnershipModeMismatchError,
|
|
238
260
|
WorkflowClaimUnavailableError
|
|
239
261
|
} from "./lease-errors.js";
|
|
262
|
+
export { WorkflowRevisionUnavailableError } from "./revision-errors.js";
|
|
240
263
|
export { ScheduleHandle } from "./schedule-handle.js";
|
|
241
264
|
export {
|
|
242
265
|
clearEngineLeakWarningTokenForTesting,
|
|
@@ -257,7 +280,8 @@ function scheduleDefinitionFromInternals(internals, definition) {
|
|
|
257
280
|
...definition.description !== void 0 && { description: definition.description },
|
|
258
281
|
...definition.overlapPolicy !== void 0 && { overlap: definition.overlapPolicy },
|
|
259
282
|
...definition.backfill !== void 0 && { backfill: definition.backfill },
|
|
260
|
-
...definition.jitter !== void 0 && { jitter: definition.jitter }
|
|
283
|
+
...definition.jitter !== void 0 && { jitter: definition.jitter },
|
|
284
|
+
...definition.revisionPolicy !== void 0 && { revisionPolicy: definition.revisionPolicy }
|
|
261
285
|
});
|
|
262
286
|
}
|
|
263
287
|
|
|
@@ -282,6 +306,8 @@ export class Engine extends EventTarget {
|
|
|
282
306
|
}
|
|
283
307
|
await engine.#bootstrapOwnershipIfConfigured();
|
|
284
308
|
await engine.#acquireLeaseIfConfigured();
|
|
309
|
+
if (!isWorkflowCatalogReady(engine))
|
|
310
|
+
await ensureWorkflowCatalogReady(engine);
|
|
285
311
|
if (options.recover !== !1)
|
|
286
312
|
await engine.recoverAll(options.acknowledgeUnknownWorkflowTypes !== void 0 ? { acknowledgeUnknownWorkflowTypes: options.acknowledgeUnknownWorkflowTypes } : {});
|
|
287
313
|
if (shouldStartEngineScheduler(options, getInternals(engine).options.backgroundTaskMode))
|
|
@@ -303,8 +329,11 @@ export class Engine extends EventTarget {
|
|
|
303
329
|
maxNestingDepth: resolvedOptions.maxNestingDepth,
|
|
304
330
|
development: resolvedOptions.development,
|
|
305
331
|
broadcastEvents: resolvedOptions.broadcastEvents,
|
|
306
|
-
getRegistration: getInternals(this)
|
|
307
|
-
listRegisteredWorkflowTypes: () =>
|
|
332
|
+
getRegistration: (workflowType, workflowId) => getResolvedDynamicRegistration(getInternals(this), workflowType, getInternals(this).workflowTypeByWorkflowId.get(workflowId)?.revision),
|
|
333
|
+
listRegisteredWorkflowTypes: () => new Set([
|
|
334
|
+
...getInternals(this).registrations.keys(),
|
|
335
|
+
...getInternals(this).sources.lastResolvedRevisionByName.keys()
|
|
336
|
+
]).values(),
|
|
308
337
|
getComposedWorkflowInterceptor: () => getComposedWorkflowInterceptor(getInternals(this)),
|
|
309
338
|
resolveWorkflowType: this.#resolveWorkflowTypeTarget.bind(this),
|
|
310
339
|
registerCancelHandler: (workflowId, handler) => registerCancelHandler(getInternals(this), workflowId, handler),
|
|
@@ -424,6 +453,13 @@ export class Engine extends EventTarget {
|
|
|
424
453
|
getInternals(this).activityWorkerDispatcher = createActivityWorkerDispatcher(options?.activityExecution);
|
|
425
454
|
getInternals(this).strategy.onMessage(this.#handleStrategyMessage.bind(this));
|
|
426
455
|
getInternals(this).alertManager = options?.alerts ? new AlertManager(this, options.alerts, getNow, resolvedOptions.backgroundTaskMode === "automatic") : null;
|
|
456
|
+
getInternals(this).workflowCatalog = null;
|
|
457
|
+
getInternals(this).pendingCatalogInstalls = [];
|
|
458
|
+
getInternals(this).catalogRestored = !1;
|
|
459
|
+
getInternals(this).catalogDrainPromise = null;
|
|
460
|
+
getInternals(this).registeredCatalogRevisions = new Map;
|
|
461
|
+
getInternals(this).inFlightStartsByRevision = new Map;
|
|
462
|
+
getInternals(this).sources = createWorkflowSourceRuntimeState();
|
|
427
463
|
this.#ensureRetentionSweepInterval();
|
|
428
464
|
this.#startSecondInstanceDetection();
|
|
429
465
|
}
|
|
@@ -514,7 +550,7 @@ export class Engine extends EventTarget {
|
|
|
514
550
|
getNow: internals.options.getNow,
|
|
515
551
|
claimTtlMs: internals.options.workflowClaimTtlMs,
|
|
516
552
|
claimRenewIntervalMs: internals.options.workflowClaimRenewIntervalMs,
|
|
517
|
-
isWorkflowTypeRegistered: (workflowType) => internals
|
|
553
|
+
isWorkflowTypeRegistered: (workflowType, revision) => canResolveRevisionLocally(internals, workflowType, revision),
|
|
518
554
|
onWorkflowClaimReclaimed: async (workflowId) => {
|
|
519
555
|
internals.inlineStrategy?.evictContextForReclaim(workflowId);
|
|
520
556
|
internals.deliveredPendingUpdateIds.delete(workflowId);
|
|
@@ -675,6 +711,9 @@ export class Engine extends EventTarget {
|
|
|
675
711
|
workflow: (workflowType, key, options) => new AtomicState(storage, KEYS.stateWorkflow(workflowType, key), options)
|
|
676
712
|
};
|
|
677
713
|
}
|
|
714
|
+
get workflows() {
|
|
715
|
+
return createEngineWorkflowsNamespace(this);
|
|
716
|
+
}
|
|
678
717
|
getActiveAlerts() {
|
|
679
718
|
return getInternals(this).alertManager?.activeStates ?? [];
|
|
680
719
|
}
|
|
@@ -692,6 +731,12 @@ export class Engine extends EventTarget {
|
|
|
692
731
|
registerWorkflow(getInternals(this), definition, this.#createRegistrationCallbacks());
|
|
693
732
|
return typedEngineView(this);
|
|
694
733
|
}
|
|
734
|
+
registerSource(source) {
|
|
735
|
+
registerWorkflowSource(getInternals(this), source);
|
|
736
|
+
}
|
|
737
|
+
async resolveWorkflowSource(name, revision, options) {
|
|
738
|
+
return resolveWorkflowSourceImpl(this, name, revision, options);
|
|
739
|
+
}
|
|
695
740
|
registerWorkflows(workflows) {
|
|
696
741
|
for (const [name, definition] of Object.entries(workflows)) {
|
|
697
742
|
if (name !== definition.name)
|
|
@@ -730,14 +775,25 @@ export class Engine extends EventTarget {
|
|
|
730
775
|
listActivityDefinitions() {
|
|
731
776
|
return getInternals(this).activityRegistry.listDefinitions();
|
|
732
777
|
}
|
|
778
|
+
getWorkflowActivityDefinition(workflowType, activityName) {
|
|
779
|
+
const internals = getInternals(this);
|
|
780
|
+
return internals.activityRegistriesByWorkflow.get(workflowType)?.getDefinition(activityName) ?? internals.activityRegistry.getDefinition(activityName);
|
|
781
|
+
}
|
|
782
|
+
listWorkflowActivityDefinitions(workflowType) {
|
|
783
|
+
return getInternals(this).activityRegistriesByWorkflow.get(workflowType)?.listDefinitions() ?? [];
|
|
784
|
+
}
|
|
733
785
|
async start(type, input, options) {
|
|
734
786
|
assertLeaseHeldForEngineWork(getInternals(this));
|
|
787
|
+
if (!isWorkflowCatalogReady(this))
|
|
788
|
+
await ensureWorkflowCatalogReady(this);
|
|
735
789
|
if (options?.idempotencyKey !== void 0)
|
|
736
790
|
return startWithIdempotencyFromLifecycle(getInternals(this), type, input, options, this.#createLifecycleCallbacks());
|
|
737
791
|
return startWorkflowFromLifecycle(getInternals(this), type, input, options, void 0, this.#createLifecycleCallbacks());
|
|
738
792
|
}
|
|
739
793
|
async startOrSignal(type, input, signal, options) {
|
|
740
794
|
assertLeaseHeldForEngineWork(getInternals(this));
|
|
795
|
+
if (!isWorkflowCatalogReady(this))
|
|
796
|
+
await ensureWorkflowCatalogReady(this);
|
|
741
797
|
return startOrSignalFromLifecycle(getInternals(this), type, input, signal, options, this.#createStartOrSignalCallbacks());
|
|
742
798
|
}
|
|
743
799
|
#createStartOrSignalCallbacks() {
|
|
@@ -810,6 +866,8 @@ export class Engine extends EventTarget {
|
|
|
810
866
|
async schedule(typeOrDefinition, input, spec, options) {
|
|
811
867
|
const internals = getInternals(this);
|
|
812
868
|
assertLeaseHeldForEngineWork(internals);
|
|
869
|
+
if (!isWorkflowCatalogReady(this))
|
|
870
|
+
await ensureWorkflowCatalogReady(this);
|
|
813
871
|
if (typeof typeOrDefinition === "object")
|
|
814
872
|
return scheduleDefinitionFromInternals(internals, typeOrDefinition);
|
|
815
873
|
if (spec === void 0)
|
|
@@ -826,21 +884,29 @@ export class Engine extends EventTarget {
|
|
|
826
884
|
async pauseSchedule(scheduleId) {
|
|
827
885
|
const internals = getInternals(this);
|
|
828
886
|
assertLeaseHeldForEngineWork(internals);
|
|
887
|
+
if (!isWorkflowCatalogReady(this))
|
|
888
|
+
await ensureWorkflowCatalogReady(this);
|
|
829
889
|
return pauseScheduleFromInternals(internals, scheduleId);
|
|
830
890
|
}
|
|
831
891
|
async resumeSchedule(scheduleId) {
|
|
832
892
|
const internals = getInternals(this);
|
|
833
893
|
assertLeaseHeldForEngineWork(internals);
|
|
894
|
+
if (!isWorkflowCatalogReady(this))
|
|
895
|
+
await ensureWorkflowCatalogReady(this);
|
|
834
896
|
return resumeScheduleFromInternals(internals, scheduleId);
|
|
835
897
|
}
|
|
836
898
|
async cancelSchedule(scheduleId) {
|
|
837
899
|
const internals = getInternals(this);
|
|
838
900
|
assertLeaseHeldForEngineWork(internals);
|
|
901
|
+
if (!isWorkflowCatalogReady(this))
|
|
902
|
+
await ensureWorkflowCatalogReady(this);
|
|
839
903
|
return cancelScheduleFromInternals(internals, scheduleId);
|
|
840
904
|
}
|
|
841
905
|
async updateSchedule(scheduleId, newSpec, options) {
|
|
842
906
|
const internals = getInternals(this);
|
|
843
907
|
assertLeaseHeldForEngineWork(internals);
|
|
908
|
+
if (!isWorkflowCatalogReady(this))
|
|
909
|
+
await ensureWorkflowCatalogReady(this);
|
|
844
910
|
return updateScheduleFromInternals(internals, scheduleId, newSpec, options);
|
|
845
911
|
}
|
|
846
912
|
[HANDLE_RESULT_PROMISE](workflowId) {
|
|
@@ -906,10 +972,14 @@ export class Engine extends EventTarget {
|
|
|
906
972
|
}
|
|
907
973
|
async fork(sourceWorkflowId, options) {
|
|
908
974
|
assertLeaseHeldForEngineWork(getInternals(this));
|
|
975
|
+
if (!isWorkflowCatalogReady(this))
|
|
976
|
+
await ensureWorkflowCatalogReady(this);
|
|
909
977
|
return forkFromLifecycle(getInternals(this), sourceWorkflowId, options, this.#createLifecycleCallbacks());
|
|
910
978
|
}
|
|
911
979
|
async resume(workflowId) {
|
|
912
980
|
assertLeaseHeldForEngineWork(getInternals(this));
|
|
981
|
+
if (!isWorkflowCatalogReady(this))
|
|
982
|
+
await ensureWorkflowCatalogReady(this);
|
|
913
983
|
return resumeFromLifecycle(getInternals(this), workflowId, this.#createLifecycleCallbacks());
|
|
914
984
|
}
|
|
915
985
|
async recoverAll(options) {
|
|
@@ -917,6 +987,8 @@ export class Engine extends EventTarget {
|
|
|
917
987
|
await this.#acquireLeaseIfConfigured();
|
|
918
988
|
if (getInternals(this).disposed)
|
|
919
989
|
throw new EngineDisposedError;
|
|
990
|
+
if (!isWorkflowCatalogReady(this))
|
|
991
|
+
await ensureWorkflowCatalogReady(this);
|
|
920
992
|
await recoverPendingAsyncActivities(getInternals(this));
|
|
921
993
|
await recoverOrphanedScheduleTimers(getInternals(this));
|
|
922
994
|
getInternals(this).onRecoveredWorkflowHook = options?.onRecoveredWorkflow;
|
|
@@ -1082,7 +1154,7 @@ export class Engine extends EventTarget {
|
|
|
1082
1154
|
if (leaseManager !== null && leaseManager.currentEpochBytes() !== null)
|
|
1083
1155
|
process.emitWarning("engine ownership lease disposed synchronously; lease release is fire-and-forget, so exiting before the release completes can make the next instance wait for leaseTtl. Use await engine.shutdown(), await using, or await engine[Symbol.asyncDispose]() for prompt rolling-deploy handoff.", ENGINE_LEASE_SYNCHRONOUS_DISPOSE_WARNING_NAME);
|
|
1084
1156
|
const { registry: workflowClaimRegistry } = this.#detachWorkflowClaimOwnership();
|
|
1085
|
-
disposeEngine(getInternals(this));
|
|
1157
|
+
disposeEngine(getInternals(this), (event) => this.dispatchEvent(event));
|
|
1086
1158
|
if (this.#synchronousDisposeResult === null)
|
|
1087
1159
|
this.#synchronousDisposeResult = leaseManager?.release() ?? Promise.resolve(!0);
|
|
1088
1160
|
this.#synchronousDisposeResult;
|
|
@@ -1100,7 +1172,7 @@ export class Engine extends EventTarget {
|
|
|
1100
1172
|
drainFailure = { error };
|
|
1101
1173
|
} finally {
|
|
1102
1174
|
const { registry: workflowClaimRegistry } = this.#detachWorkflowClaimOwnership();
|
|
1103
|
-
disposeEngine(getInternals(this));
|
|
1175
|
+
disposeEngine(getInternals(this), (event) => this.dispatchEvent(event));
|
|
1104
1176
|
await getInternals(this).inFlightLeaseAcquire?.catch(() => {});
|
|
1105
1177
|
leaseReleased = await (this.#synchronousDisposeResult ?? leaseManager?.release() ?? Promise.resolve(!0));
|
|
1106
1178
|
await this.#releaseWorkflowClaimsBestEffort(workflowClaimRegistry);
|
|
@@ -99,7 +99,7 @@ async function startQueuedInlineWorkflowExecution(internals, start, callbacks, o
|
|
|
99
99
|
return;
|
|
100
100
|
internals.queuedInlineWorkflowStartIds.delete(start.workflowId);
|
|
101
101
|
internals.engine.dispatchEvent(new WorkflowStartedEvent(start.workflowId, start.workflowType, start.input));
|
|
102
|
-
startWorkflowExecution(internals, start.workflowId, state.workflowExecutionToken, start.workflowType, start.input, start.checkpoint, start.nestingDepth, start.executionDeadline, start.executionStateOwnerId);
|
|
102
|
+
startWorkflowExecution(internals, start.workflowId, state.workflowExecutionToken, start.workflowType, state.revision, start.input, start.checkpoint, start.nestingDepth, start.executionDeadline, start.executionStateOwnerId);
|
|
103
103
|
if (options?.abortStartedWorkflows === !0)
|
|
104
104
|
internals.inlineStrategy?.abortWorkflowAdvanceForShutdown(start.workflowId);
|
|
105
105
|
else
|
|
@@ -34,13 +34,14 @@ import type { UpdateCoordinator } from '../updates.ts';
|
|
|
34
34
|
import type { WorkflowVersionTuple } from '../workflow-version-tuple.ts';
|
|
35
35
|
import type { RecoveredWorkflowInfo } from './lifecycle/shared.ts';
|
|
36
36
|
import type { ActivityHeartbeatKey } from './activity-heartbeat-tracking.ts';
|
|
37
|
-
import type { PendingTimelineEntry, QueuedInlineWorkflowExecutionStart, RegistrationEntry, ResolvedOptions, TrackedWaiterKeys, WorkflowResultWaiter } from './engine-internal-types.ts';
|
|
37
|
+
import type { PendingTimelineEntry, QueuedInlineWorkflowExecutionStart, RegistrationEntry, ResolvedOptions, TrackedWaiterKeys, WorkflowExecutionIdentity, WorkflowResultWaiter } from './engine-internal-types.ts';
|
|
38
38
|
import type { EngineCleanupIntervalDisposalTracker } from './engine-leak-warnings.ts';
|
|
39
39
|
import type { WorkflowHandle, WorkflowHandleEngine } from './handles.ts';
|
|
40
40
|
import type { WorkflowFeedListener } from './index.ts';
|
|
41
41
|
import type { LeaseManager } from './lease-manager.ts';
|
|
42
42
|
import type { ScheduleHandleEngine } from './schedule-handle.ts';
|
|
43
43
|
import type { SecondInstanceDetector } from './second-instance-detector.ts';
|
|
44
|
+
import type { WorkflowSourceRuntimeState } from './source-runtime-state.ts';
|
|
44
45
|
import type { WorkflowClaimMetricsRecorder } from './workflow-claim-metrics.ts';
|
|
45
46
|
import type { WorkflowClaimRegistry } from './workflow-claim-registry.ts';
|
|
46
47
|
import type { WorkflowClaimRenewalTask } from './workflow-claim-renewal-task.ts';
|
|
@@ -149,15 +150,15 @@ export interface EngineInternals {
|
|
|
149
150
|
/**
|
|
150
151
|
* Per-workflow activity registries built from
|
|
151
152
|
* `workflow({ name }).activities({ ... }).execute(...)`, indexed by workflow
|
|
152
|
-
* type.
|
|
153
|
-
*
|
|
154
|
-
* that registry
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
153
|
+
* type. Lookup consults `activityRegistriesByWorkflow.get(type)` first,
|
|
154
|
+
* falling back to {@link EngineInternals.activityRegistry} for any activity
|
|
155
|
+
* that registry lacks. Each entry is a defensive deep clone+freeze of the
|
|
156
|
+
* workflow's `activities` map. EAGER-ONLY as of WFT-19: only `registration.ts`
|
|
157
|
+
* writes here (never a `registerSource()` load), so a dynamic-source type's
|
|
158
|
+
* per-revision activities resolve instead via
|
|
159
|
+
* `internals.sources.resolved.get(type)?.get(revision)?.activityRegistry`
|
|
160
|
+
* (`activity-resolution.ts`), keyed by the running instance's own pin —
|
|
161
|
+
* never this type-only map, which would clobber across revisions.
|
|
161
162
|
*/
|
|
162
163
|
activityRegistriesByWorkflow: Map<string, ActivityRegistry>;
|
|
163
164
|
/**
|
|
@@ -169,12 +170,13 @@ export interface EngineInternals {
|
|
|
169
170
|
*/
|
|
170
171
|
workflowDefinitionsByName: Map<string, object>;
|
|
171
172
|
/**
|
|
172
|
-
* In-memory cache of `workflowId ->
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
173
|
+
* In-memory cache of `workflowId -> {type, revision}`, populated whenever a
|
|
174
|
+
* workflow begins executing in THIS process (fresh start, delayed-start
|
|
175
|
+
* fire, resume, recovery, workflow-lease reclaim redrive — WFT-19) and
|
|
176
|
+
* cleared on terminal cleanup. Lets the activity-dispatch hot path, and any
|
|
177
|
+
* other lookup needing an instance's own exact pin, resolve synchronously.
|
|
176
178
|
*/
|
|
177
|
-
workflowTypeByWorkflowId: Map<string,
|
|
179
|
+
workflowTypeByWorkflowId: Map<string, WorkflowExecutionIdentity>;
|
|
178
180
|
activityWorkerDispatcher: ActivityWorkerDispatcher | null;
|
|
179
181
|
checkpoints: Map<string, Checkpoint>;
|
|
180
182
|
broadcastChannel: BroadcastChannel | null;
|
|
@@ -386,6 +388,31 @@ export interface EngineInternals {
|
|
|
386
388
|
workflowVisibilityWatermarkExpiresAt: number | undefined;
|
|
387
389
|
pendingTimelineEntries: Map<string, PendingTimelineEntry>;
|
|
388
390
|
pendingAtomicWorkflowCommitSideEffects: Map<string, import('./checkpoint-side-effects.ts').AtomicWorkflowCommitSideEffects>;
|
|
391
|
+
/**
|
|
392
|
+
* The durable workflow catalog (WFT-9/WFT-10), `null` until
|
|
393
|
+
* {@link import('./catalog-readiness.ts').ensureWorkflowCatalogReady} first
|
|
394
|
+
* restores it from storage. Read via {@link getWorkflowCatalog}, never
|
|
395
|
+
* directly.
|
|
396
|
+
*/
|
|
397
|
+
workflowCatalog: import('../catalog/index.ts').WorkflowCatalog | null;
|
|
398
|
+
/** Workflow names `commitWorkflowDefinition` (`registration.ts`) has queued for catalog install+activate since the last drain — `engine.register()` stays synchronous (it cannot itself build a manifest) and defers to the next `ensureWorkflowCatalogReady` call. */
|
|
399
|
+
pendingCatalogInstalls: string[];
|
|
400
|
+
/** Whether {@link workflowCatalog} has been restored from storage at least once. */
|
|
401
|
+
catalogRestored: boolean;
|
|
402
|
+
/** The in-flight catalog restore-and-drain, or `null` when none is running; concurrent `ensureWorkflowCatalogReady` callers await this same promise rather than racing a second restore/drain. */
|
|
403
|
+
catalogDrainPromise: Promise<void> | null;
|
|
404
|
+
/** Name -> revision this process's own register()-drain most recently activated (WFT-12, `catalog-readiness.ts`). Process-local, never persisted. */
|
|
405
|
+
registeredCatalogRevisions: Map<string, string>;
|
|
406
|
+
/** Name -> revision -> in-flight `startWorkflow` count (WFT-12, `lifecycle/start.ts`). Process-local, never persisted. */
|
|
407
|
+
inFlightStartsByRevision: Map<string, Map<string, number>>;
|
|
408
|
+
/**
|
|
409
|
+
* Dynamic workflow sources (WFT-13/14, WFT-15/16): candidates, in-flight
|
|
410
|
+
* single-flight loads, per-caller waiter controllers, locally-resolved
|
|
411
|
+
* definitions, and bounded per-`(name, revision)` diagnostics — see
|
|
412
|
+
* {@link import('./source-runtime-state.ts').WorkflowSourceRuntimeState}
|
|
413
|
+
* for the full field-by-field breakdown. Process-local, never persisted.
|
|
414
|
+
*/
|
|
415
|
+
sources: WorkflowSourceRuntimeState;
|
|
389
416
|
}
|
|
390
417
|
/**
|
|
391
418
|
* Set up an empty `EngineInternals` skeleton in the WeakMap. The Engine
|
|
@@ -406,4 +433,16 @@ export declare function initializeInternals(engine: EngineRuntime): void;
|
|
|
406
433
|
* internals existing.
|
|
407
434
|
*/
|
|
408
435
|
export declare function getInternals(engine: object): EngineInternals;
|
|
436
|
+
/**
|
|
437
|
+
* Read an engine's durable workflow catalog. Throws when it has not been
|
|
438
|
+
* restored yet — every public entry point that can observe catalog state
|
|
439
|
+
* (`start`, `startOrSignal`, `schedule`/`pauseSchedule`/`resumeSchedule`/
|
|
440
|
+
* `cancelSchedule`/`updateSchedule`, `fork`, `resume`, `recoverAll`,
|
|
441
|
+
* `Engine.create`, and `buildRegistrySnapshot`) awaits
|
|
442
|
+
* `ensureWorkflowCatalogReady(engine)` first, which restores it. Calling
|
|
443
|
+
* this before that await boundary — for example from a pathological
|
|
444
|
+
* direct-internals test — is a programming error, not a recoverable runtime
|
|
445
|
+
* condition, so it fails loud rather than returning a placeholder catalog.
|
|
446
|
+
*/
|
|
447
|
+
export declare function getWorkflowCatalog(engine: object): import('../catalog/index.ts').WorkflowCatalog;
|
|
409
448
|
export {};
|
|
@@ -9,3 +9,9 @@ export function getInternals(engine) {
|
|
|
9
9
|
throw Error("Engine internals not initialized \u2014 initializeInternals(this) was not called in the Engine constructor");
|
|
10
10
|
return internals;
|
|
11
11
|
}
|
|
12
|
+
export function getWorkflowCatalog(engine) {
|
|
13
|
+
const internals = getInternals(engine);
|
|
14
|
+
if (internals.workflowCatalog === null)
|
|
15
|
+
throw Error("Workflow catalog not restored \u2014 ensureWorkflowCatalogReady(engine) was not awaited before " + "getWorkflowCatalog(engine) was called.");
|
|
16
|
+
return internals.workflowCatalog;
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Launch a workflow run from an already-built `WorkflowState`/`Checkpoint`
|
|
3
|
+
* pair — the shared tail `fork()` (`transition.ts`) drives after planting a
|
|
4
|
+
* new run's durable records. Split out of `transition.ts`, which has no
|
|
5
|
+
* headroom under the repository's 500-line implementation-file ceiling for
|
|
6
|
+
* this logic inline.
|
|
7
|
+
*
|
|
8
|
+
* @module core/engine/lifecycle/checkpoint-launch
|
|
9
|
+
*/
|
|
10
|
+
import type { Checkpoint, WorkflowState } from '../../types.ts';
|
|
11
|
+
import { type WorkflowHandle } from '../handles.ts';
|
|
12
|
+
import type { EngineInternals } from '../internals.ts';
|
|
13
|
+
import { type LifecycleCallbacks, type RegistrationEntry } from './shared.ts';
|
|
14
|
+
export declare function launchWorkflowFromCheckpoint(internals: EngineInternals, workflowId: string, state: WorkflowState, checkpoint: Checkpoint, registration: RegistrationEntry,
|
|
15
|
+
/**
|
|
16
|
+
* The EXACT revision `registration` was resolved against — from the same
|
|
17
|
+
* `resolveExecutableRegistrationForRevision()` call that produced
|
|
18
|
+
* `registration`, threaded through explicitly rather than re-read off
|
|
19
|
+
* `state.revision` (WFT-19 review round 5, Codex, mirroring the identical
|
|
20
|
+
* fix in `lifecycle/resume.ts`). `fork()`'s own `forkState.revision` is
|
|
21
|
+
* now stamped with this same resolved value too (WFT-19 review round 6,
|
|
22
|
+
* Codex — `createForkedWorkflowState()`'s matching fix, so a legacy
|
|
23
|
+
* fork's durable pin agrees with this in-memory one), so `state.revision`
|
|
24
|
+
* and `resolvedRevision` coincide for every current caller; kept as an
|
|
25
|
+
* explicit parameter regardless, since this function's identity-cache
|
|
26
|
+
* write must never depend on that invariant holding at a future call
|
|
27
|
+
* site.
|
|
28
|
+
*/
|
|
29
|
+
resolvedRevision: string | undefined, callbacks: LifecycleCallbacks): WorkflowHandle;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { serializeCheckpoint } from "../../checkpoint.js";
|
|
2
|
+
import { Context, setContextWorkflowInterceptor } from "../../context.js";
|
|
3
|
+
import { WorkflowStartedEvent } from "../../events.js";
|
|
4
|
+
import { createCancelHandlerRegistration, resetCancelHandlers } from "../cancel-handlers.js";
|
|
5
|
+
import { getWorkflowExecutionStartedAt } from "../handles.js";
|
|
6
|
+
import { getComposedWorkflowInterceptor } from "../strategy-helpers.js";
|
|
7
|
+
import { createWorkflowVersionTuple } from "./persist.js";
|
|
8
|
+
import { createWorkflowHandle } from "./shared.js";
|
|
9
|
+
function launchInlineWorkflowFromCheckpoint(internals, workflowId, state, checkpoint, registration, callbacks) {
|
|
10
|
+
const inlineStrategy = internals.inlineStrategy;
|
|
11
|
+
if (!inlineStrategy)
|
|
12
|
+
throw Error("Inline workflow launch requested without an inline strategy.");
|
|
13
|
+
const accumulatedResults = new Map(checkpoint.accumulatedResults), workflowAbort = new AbortController;
|
|
14
|
+
resetCancelHandlers(internals, workflowId);
|
|
15
|
+
const context = new Context({
|
|
16
|
+
workflowId,
|
|
17
|
+
...state.workflowExecutionToken !== void 0 && {
|
|
18
|
+
workflowExecutionToken: state.workflowExecutionToken
|
|
19
|
+
},
|
|
20
|
+
workflowType: state.type,
|
|
21
|
+
startedAt: getWorkflowExecutionStartedAt(state),
|
|
22
|
+
abortController: workflowAbort,
|
|
23
|
+
getNow: internals.options.getNow,
|
|
24
|
+
resolveWorkflowType: callbacks.resolveWorkflowTypeTarget,
|
|
25
|
+
executionStateOwnerId: state.executionStateOwnerId ?? workflowId,
|
|
26
|
+
accumulatedResults,
|
|
27
|
+
searchAttributes: checkpoint.searchAttributes,
|
|
28
|
+
registerCancelHandler: createCancelHandlerRegistration(internals, workflowId),
|
|
29
|
+
...registration.searchAttributes && {
|
|
30
|
+
searchAttributeSchema: registration.searchAttributes
|
|
31
|
+
},
|
|
32
|
+
sleepReferenceTime: checkpoint.createdAt,
|
|
33
|
+
...state.executionDeadline !== void 0 && { deadline: state.executionDeadline },
|
|
34
|
+
...internals.options.onLog != null && { logSink: internals.options.onLog }
|
|
35
|
+
});
|
|
36
|
+
setContextWorkflowInterceptor(context, getComposedWorkflowInterceptor(internals));
|
|
37
|
+
if (internals.options.development)
|
|
38
|
+
context.explain(!0);
|
|
39
|
+
const generator = registration.handler(context, state.input);
|
|
40
|
+
inlineStrategy.adoptWorkflow(workflowId, generator, context, workflowAbort);
|
|
41
|
+
inlineStrategy.continueWorkflow(workflowId, void 0);
|
|
42
|
+
callbacks.swallowPromiseRejection(callbacks.processPendingUpdatesAfterInlineAdvance(workflowId));
|
|
43
|
+
}
|
|
44
|
+
function launchWorkerWorkflowFromCheckpoint(internals, workflowId, state, checkpoint) {
|
|
45
|
+
const serialized = serializeCheckpoint(checkpoint);
|
|
46
|
+
internals.strategy.startWorkflow({
|
|
47
|
+
workflowId,
|
|
48
|
+
...state.workflowExecutionToken !== void 0 && {
|
|
49
|
+
workflowExecutionToken: state.workflowExecutionToken
|
|
50
|
+
},
|
|
51
|
+
workflowType: state.type,
|
|
52
|
+
input: state.input,
|
|
53
|
+
checkpoint: serialized,
|
|
54
|
+
executionStateOwnerId: state.executionStateOwnerId ?? workflowId,
|
|
55
|
+
...state.executionDeadline !== void 0 && { deadline: state.executionDeadline },
|
|
56
|
+
...internals.workflowHeaders.has(workflowId) && {
|
|
57
|
+
headers: [...internals.workflowHeaders.get(workflowId)]
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export function launchWorkflowFromCheckpoint(internals, workflowId, state, checkpoint, registration, resolvedRevision, callbacks) {
|
|
62
|
+
internals.workflowTypeByWorkflowId.set(workflowId, {
|
|
63
|
+
type: state.type,
|
|
64
|
+
revision: resolvedRevision
|
|
65
|
+
});
|
|
66
|
+
internals.checkpoints.set(workflowId, checkpoint);
|
|
67
|
+
internals.workflowVersionTuples.set(workflowId, createWorkflowVersionTuple(internals, registration, callbacks));
|
|
68
|
+
const handle = createWorkflowHandle(internals, workflowId, callbacks);
|
|
69
|
+
callbacks.dispatchEvent(new WorkflowStartedEvent(workflowId, state.type, state.input));
|
|
70
|
+
if (internals.inlineStrategy)
|
|
71
|
+
launchInlineWorkflowFromCheckpoint(internals, workflowId, state, checkpoint, registration, callbacks);
|
|
72
|
+
else
|
|
73
|
+
launchWorkerWorkflowFromCheckpoint(internals, workflowId, state, checkpoint);
|
|
74
|
+
return handle;
|
|
75
|
+
}
|