@lostgradient/weft 0.3.0 → 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.
- package/README.md +79 -24
- package/dist/cli/conformance.js +7 -1
- package/dist/cli/generated/operation-client.generated.d.ts +28 -13
- package/dist/cli/generated/operation-client.generated.js +1 -0
- package/dist/cli/help-text.d.ts +1 -1
- package/dist/cli/help-text.js +1 -0
- package/dist/cli/operation-catalog-snapshot.d.ts +8 -0
- package/dist/cli/operation-catalog-snapshot.js +11 -0
- package/dist/cli/parse-schedule-arguments.js +3 -1
- package/dist/cli/schedule.js +2 -1
- package/dist/cli/types.d.ts +1 -0
- package/dist/cli-main.js +79 -78
- package/dist/client/handle-delegation.d.ts +3 -2
- package/dist/client/handle-delegation.js +3 -1
- package/dist/client/http-client-requests.d.ts +2 -1
- package/dist/client/http-client-requests.js +7 -0
- package/dist/client/http-client.d.ts +9 -6
- package/dist/client/http-client.js +10 -1
- package/dist/client/http-request.d.ts +11 -1
- package/dist/client/http-request.js +17 -7
- package/dist/client/index.d.ts +1 -1
- package/dist/client/interface.d.ts +46 -5
- package/dist/client/local.d.ts +4 -1
- package/dist/client/local.js +12 -4
- package/dist/client/start-body.d.ts +4 -3
- package/dist/core/byte-arrays.d.ts +5 -0
- package/dist/core/byte-arrays.js +5 -0
- package/dist/core/checkpoint/lifecycle.d.ts +3 -0
- package/dist/core/checkpoint/lifecycle.js +9 -4
- package/dist/core/checkpoint/serialization.js +12 -5
- package/dist/core/codec/extension-codec.d.ts +16 -0
- package/dist/core/codec/extension-codec.js +100 -6
- package/dist/core/context/activity-retry-state.d.ts +38 -0
- package/dist/core/context/activity-retry-state.js +89 -0
- package/dist/core/context/activity-schedule-to-close.d.ts +159 -0
- package/dist/core/context/activity-schedule-to-close.js +69 -0
- package/dist/core/context/child-workflow-pipe.d.ts +5 -5
- package/dist/core/context/child-workflow-pipe.js +15 -2
- package/dist/core/context/context-presence.d.ts +19 -0
- package/dist/core/context/context-presence.js +13 -0
- package/dist/core/context/durable-operations.d.ts +25 -0
- package/dist/core/context/durable-operations.js +64 -0
- package/dist/core/context/index.d.ts +9 -5
- package/dist/core/context/index.js +17 -12
- package/dist/core/context/internals.d.ts +20 -0
- package/dist/core/context/internals.js +3 -1
- package/dist/core/context/operation-request.d.ts +35 -0
- package/dist/core/context/parallel-cache-entry.d.ts +14 -5
- package/dist/core/context/run-operation.d.ts +6 -1
- package/dist/core/context/run-operation.js +41 -87
- package/dist/core/context/session-state.js +7 -8
- package/dist/core/context/speculative-child.js +2 -0
- package/dist/core/context/types.d.ts +15 -0
- package/dist/core/context/version-patching.d.ts +8 -0
- package/dist/core/context/version-patching.js +40 -0
- package/dist/core/context/workflow-logger.d.ts +98 -0
- package/dist/core/context/workflow-logger.js +68 -0
- package/dist/core/engine/activity-heartbeat-tracking.d.ts +64 -0
- package/dist/core/engine/activity-heartbeat-tracking.js +42 -0
- package/dist/core/engine/activity-per-attempt-timeout.d.ts +41 -0
- package/dist/core/engine/activity-per-attempt-timeout.js +36 -0
- package/dist/core/engine/activity-reconciliation.d.ts +1 -0
- package/dist/core/engine/activity-reconciliation.js +12 -1
- package/dist/core/engine/activity-resolution.d.ts +23 -0
- package/dist/core/engine/activity-resolution.js +37 -0
- package/dist/core/engine/aggregate.js +66 -30
- package/dist/core/engine/async-activity-completion.d.ts +23 -6
- package/dist/core/engine/async-activity-completion.js +53 -12
- package/dist/core/engine/attributes-tags.js +9 -4
- package/dist/core/engine/bulk-operations-purge.d.ts +26 -0
- package/dist/core/engine/bulk-operations-purge.js +38 -3
- package/dist/core/engine/bulk-operations-shared.d.ts +2 -0
- package/dist/core/engine/bulk-operations-shared.js +8 -2
- package/dist/core/engine/bulk-operations.d.ts +4 -1
- package/dist/core/engine/bulk-operations.js +235 -24
- package/dist/core/engine/callback-creators-bundles.d.ts +9 -0
- package/dist/core/engine/callback-creators-bundles.js +30 -2
- package/dist/core/engine/callback-creators-core.js +6 -4
- package/dist/core/engine/callback-creators-router.js +10 -0
- package/dist/core/engine/callback-creators-schedule.d.ts +2 -2
- package/dist/core/engine/callback-creators-schedule.js +12 -8
- package/dist/core/engine/candidate-read-batching.d.ts +6 -0
- package/dist/core/engine/candidate-read-batching.js +1 -0
- package/dist/core/engine/checkpoint-io.js +61 -25
- package/dist/core/engine/checkpoint-reads.js +3 -2
- package/dist/core/engine/checkpoint-replay.d.ts +20 -0
- package/dist/core/engine/checkpoint-replay.js +242 -0
- package/dist/core/engine/checkpoint-side-effects.d.ts +23 -0
- package/dist/core/engine/checkpoint-side-effects.js +35 -0
- package/dist/core/engine/child-workflow-cancellation.d.ts +10 -0
- package/dist/core/engine/child-workflow-cancellation.js +40 -0
- package/dist/core/engine/child-workflow.js +27 -4
- package/dist/core/engine/condition-waiters.d.ts +14 -0
- package/dist/core/engine/condition-waiters.js +5 -0
- package/dist/core/engine/construction.d.ts +3 -0
- package/dist/core/engine/construction.js +21 -8
- package/dist/core/engine/coordination-branch-executors.d.ts +70 -0
- package/dist/core/engine/coordination-branch-executors.js +107 -0
- package/dist/core/engine/deferred-consume-envelope.d.ts +59 -0
- package/dist/core/engine/deferred-consume-envelope.js +14 -0
- package/dist/core/engine/disposal.js +13 -0
- package/dist/core/engine/engine-create-types.d.ts +14 -4
- package/dist/core/engine/engine-internal-types.d.ts +26 -3
- package/dist/core/engine/errors.d.ts +47 -0
- package/dist/core/engine/errors.js +20 -0
- package/dist/core/engine/event-log-compaction.d.ts +8 -0
- package/dist/core/engine/event-log-compaction.js +20 -2
- package/dist/core/engine/fenced-write.d.ts +65 -0
- package/dist/core/engine/fenced-write.js +71 -0
- package/dist/core/engine/finalizer-state.d.ts +28 -0
- package/dist/core/engine/finalizer-state.js +16 -0
- package/dist/core/engine/handles.d.ts +8 -0
- package/dist/core/engine/index.d.ts +34 -16
- package/dist/core/engine/index.js +133 -8
- package/dist/core/engine/inline-parking.js +3 -2
- package/dist/core/engine/internals.d.ts +107 -3
- package/dist/core/engine/lease-codec.d.ts +35 -0
- package/dist/core/engine/lease-codec.js +32 -0
- package/dist/core/engine/lease-deposition.d.ts +66 -0
- package/dist/core/engine/lease-deposition.js +10 -0
- package/dist/core/engine/lease-errors.d.ts +99 -0
- package/dist/core/engine/lease-errors.js +30 -0
- package/dist/core/engine/lease-manager.d.ts +114 -0
- package/dist/core/engine/lease-manager.js +135 -0
- package/dist/core/engine/lifecycle/persist.js +10 -32
- package/dist/core/engine/lifecycle/recovered-services.d.ts +8 -6
- package/dist/core/engine/lifecycle/recovered-services.js +18 -3
- package/dist/core/engine/lifecycle/resume.js +16 -9
- package/dist/core/engine/lifecycle/shared.d.ts +8 -1
- package/dist/core/engine/lifecycle/start-batch.d.ts +1 -1
- package/dist/core/engine/lifecycle/start-batch.js +2 -1
- package/dist/core/engine/lifecycle/start-commit.d.ts +9 -0
- package/dist/core/engine/lifecycle/start-commit.js +50 -8
- package/dist/core/engine/lifecycle/start-or-signal-create.d.ts +58 -0
- package/dist/core/engine/lifecycle/start-or-signal-create.js +95 -0
- package/dist/core/engine/lifecycle/start-or-signal.d.ts +3 -2
- package/dist/core/engine/lifecycle/start-or-signal.js +11 -81
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.d.ts +39 -0
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.js +28 -0
- package/dist/core/engine/lifecycle/start.d.ts +4 -4
- package/dist/core/engine/lifecycle/start.js +17 -9
- package/dist/core/engine/lifecycle/transition.js +17 -5
- package/dist/core/engine/lifecycle.d.ts +1 -1
- package/dist/core/engine/list-candidate-resolution.js +2 -2
- package/dist/core/engine/listing.js +9 -5
- package/dist/core/engine/operations-activity.d.ts +4 -11
- package/dist/core/engine/operations-activity.js +22 -49
- package/dist/core/engine/operations-coordination.d.ts +10 -0
- package/dist/core/engine/operations-coordination.js +43 -8
- package/dist/core/engine/operations-router.d.ts +6 -0
- package/dist/core/engine/operations-router.js +2 -0
- package/dist/core/engine/operations-speculate.js +6 -2
- package/dist/core/engine/operations-stream.js +12 -2
- package/dist/core/engine/operations-time.d.ts +4 -2
- package/dist/core/engine/operations-time.js +14 -2
- package/dist/core/engine/operations-wait-condition.d.ts +23 -0
- package/dist/core/engine/operations-wait-condition.js +62 -0
- package/dist/core/engine/ownership-options.d.ts +23 -0
- package/dist/core/engine/ownership-options.js +26 -0
- package/dist/core/engine/payload-size-policy.d.ts +3 -0
- package/dist/core/engine/payload-size-policy.js +4 -0
- package/dist/core/engine/pending-updates.d.ts +17 -0
- package/dist/core/engine/pending-updates.js +33 -11
- package/dist/core/engine/queries.js +1 -1
- package/dist/core/engine/registration.d.ts +1 -0
- package/dist/core/engine/registration.js +18 -3
- package/dist/core/engine/schedule-jitter.d.ts +5 -0
- package/dist/core/engine/schedule-jitter.js +10 -0
- package/dist/core/engine/schedule-run.d.ts +17 -0
- package/dist/core/engine/schedule-run.js +38 -0
- package/dist/core/engine/schedule-timer.js +81 -17
- package/dist/core/engine/schedules.d.ts +7 -4
- package/dist/core/engine/schedules.js +37 -16
- package/dist/core/engine/search-attribute-records.d.ts +4 -0
- package/dist/core/engine/search-attribute-records.js +17 -0
- package/dist/core/engine/signals.d.ts +18 -2
- package/dist/core/engine/signals.js +42 -21
- package/dist/core/engine/state-utilities.d.ts +49 -2
- package/dist/core/engine/state-utilities.js +114 -3
- package/dist/core/engine/storage-io.d.ts +16 -2
- package/dist/core/engine/storage-io.js +26 -5
- package/dist/core/engine/stream-chunk-loading.d.ts +2 -0
- package/dist/core/engine/stream-chunk-loading.js +24 -1
- package/dist/core/engine/sub-operation.js +22 -3
- package/dist/core/engine/termination/cleanup.d.ts +3 -1
- package/dist/core/engine/termination/cleanup.js +25 -1
- package/dist/core/engine/termination/complete.js +44 -6
- package/dist/core/engine/termination/finalizer-activity.d.ts +53 -0
- package/dist/core/engine/termination/finalizer-activity.js +30 -0
- package/dist/core/engine/termination/finalizer-claim.d.ts +110 -0
- package/dist/core/engine/termination/finalizer-claim.js +80 -0
- package/dist/core/engine/termination/finalizer.d.ts +48 -0
- package/dist/core/engine/termination/finalizer.js +159 -0
- package/dist/core/engine/termination/suspend.d.ts +3 -1
- package/dist/core/engine/termination.d.ts +1 -0
- package/dist/core/engine/termination.js +4 -0
- package/dist/core/engine/updates.js +5 -25
- package/dist/core/engine/validation/schedule.d.ts +2 -1
- package/dist/core/engine/validation/schedule.js +51 -2
- package/dist/core/engine/validation.js +32 -5
- package/dist/core/engine/waiting-update-response.d.ts +8 -0
- package/dist/core/engine/waiting-update-response.js +22 -0
- package/dist/core/engine/workflow-concurrency.d.ts +10 -0
- package/dist/core/engine/workflow-concurrency.js +136 -0
- package/dist/core/engine/workflow-feed.d.ts +4 -5
- package/dist/core/engine/workflow-feed.js +4 -1
- package/dist/core/engine/workflow-indexes.d.ts +9 -0
- package/dist/core/engine/workflow-indexes.js +10 -0
- package/dist/core/engine/workflow-state-stream.js +33 -13
- package/dist/core/engine/workflow-visibility-queries.d.ts +2 -2
- package/dist/core/engine-helpers.js +1 -0
- package/dist/core/events/activity-events.d.ts +43 -12
- package/dist/core/events/activity-events.js +28 -0
- package/dist/core/events/attribute-events.d.ts +2 -3
- package/dist/core/events/event-map.d.ts +18 -12
- package/dist/core/events/index.d.ts +1 -0
- package/dist/core/events/index.js +1 -0
- package/dist/core/events/schedule-events.d.ts +71 -0
- package/dist/core/events/schedule-events.js +29 -0
- package/dist/core/events/signal-events.d.ts +4 -6
- package/dist/core/events/system-events.d.ts +29 -19
- package/dist/core/events/system-events.js +26 -0
- package/dist/core/events/update-events.d.ts +6 -8
- package/dist/core/events/workflow-events.d.ts +88 -23
- package/dist/core/events/workflow-events.js +26 -0
- package/dist/core/failure-categories.js +5 -17
- package/dist/core/fault-code.d.ts +9 -3
- package/dist/core/fault-code.js +1 -0
- package/dist/core/inline-execution-strategy.context-options.d.ts +69 -0
- package/dist/core/inline-execution-strategy.context-options.js +56 -0
- package/dist/core/inline-execution-strategy.d.ts +31 -36
- package/dist/core/inline-execution-strategy.js +16 -27
- package/dist/core/list-filter-validation.d.ts +1 -1
- package/dist/core/payload-size.d.ts +1 -1
- package/dist/core/persisted-data-incompatible-error.d.ts +9 -7
- package/dist/core/review/events.d.ts +6 -8
- package/dist/core/scheduler/scheduler-class.d.ts +10 -1
- package/dist/core/scheduler/scheduler-class.js +38 -11
- package/dist/core/scheduler/timer-batch.js +9 -1
- package/dist/core/scheduler/timer-sources.d.ts +1 -0
- package/dist/core/scheduler/timer-sources.js +11 -5
- package/dist/core/session-state.d.ts +0 -1
- package/dist/core/session-state.js +2 -2
- package/dist/core/start-workflow-validation.d.ts +34 -0
- package/dist/core/start-workflow-validation.js +19 -0
- package/dist/core/types/activity-verification.d.ts +67 -0
- package/dist/core/types/activity-verification.js +0 -0
- package/dist/core/types/activity.d.ts +80 -61
- package/dist/core/types/bulk.d.ts +50 -9
- package/dist/core/types/checkpoint.d.ts +44 -8
- package/dist/core/types/list-options.d.ts +146 -0
- package/dist/core/types/list-options.js +0 -0
- package/dist/core/types/options.d.ts +121 -165
- package/dist/core/types/schedules.d.ts +39 -3
- package/dist/core/types/services-resolution.d.ts +2 -2
- package/dist/core/types/workflow-builder-runtime.d.ts +12 -3
- package/dist/core/types/workflow-builder-runtime.js +11 -2
- package/dist/core/types/workflow-builder.d.ts +42 -11
- package/dist/core/types/workflow-concurrency.d.ts +39 -0
- package/dist/core/types/workflow-concurrency.js +0 -0
- package/dist/core/types/workflow-context.d.ts +157 -14
- package/dist/core/types/workflow-definition.d.ts +53 -10
- package/dist/core/types/workflow-function.d.ts +84 -9
- package/dist/core/types/workflow-log.d.ts +98 -0
- package/dist/core/types/workflow-log.js +0 -0
- package/dist/core/types/workflow-registries.d.ts +14 -3
- package/dist/core/types/workflow-registry.d.ts +3 -0
- package/dist/core/types.d.ts +4 -0
- package/dist/core/types.js +4 -0
- package/dist/core/versioning.d.ts +9 -39
- package/dist/core/versioning.js +2 -12
- package/dist/core/weft-error.d.ts +44 -1
- package/dist/core/weft-error.js +16 -0
- package/dist/core/worker-execution-strategy-options.d.ts +26 -0
- package/dist/core/worker-execution-strategy.js +40 -36
- package/dist/core/worker-inbound-message.d.ts +38 -0
- package/dist/core/worker-inbound-message.js +37 -0
- package/dist/core/worker-log-abuse-counter.d.ts +175 -0
- package/dist/core/worker-log-abuse-counter.js +107 -0
- package/dist/core/worker-message-helpers.d.ts +47 -0
- package/dist/core/worker-message-helpers.js +26 -0
- package/dist/core/worker-protocol-guard.js +1 -1
- package/dist/core/worker-protocol-log.d.ts +56 -0
- package/dist/core/worker-protocol-log.js +18 -0
- package/dist/core/worker-protocol.d.ts +23 -0
- package/dist/core/worker-protocol.js +12 -2
- package/dist/core/workflow-version-tuple.d.ts +3 -9
- package/dist/core/workflow-version-tuple.js +2 -3
- package/dist/diagnostics/format.js +1 -6
- package/dist/diagnostics/types.d.ts +4 -5
- package/dist/diagnostics/validate.d.ts +0 -1
- package/dist/diagnostics/version-check.d.ts +1 -1
- package/dist/diagnostics/version-check.js +4 -9
- package/dist/index.d.ts +12 -10
- package/dist/index.js +29 -3
- package/dist/json-schema.js +3 -3
- package/dist/mcp/cli.js +27 -27
- package/dist/mcp/dispatcher.js +1 -1
- package/dist/mcp/http.js +16 -6
- package/dist/mcp/protocol.d.ts +2 -0
- package/dist/mcp/protocol.js +1 -1
- package/dist/mcp/session.d.ts +16 -0
- package/dist/mcp/session.js +59 -6
- package/dist/mcp/tools.js +73 -6
- package/dist/observability/index.js +2 -2
- package/dist/server/asyncapi-channels.js +5 -2
- package/dist/server/attribute-filters.d.ts +8 -3
- package/dist/server/attribute-filters.js +6 -1
- package/dist/server/authentication/api-key.d.ts +2 -1
- package/dist/server/authentication/api-key.js +5 -2
- package/dist/server/authentication/constant-time-api-key.d.ts +15 -0
- package/dist/server/authentication/constant-time-api-key.js +24 -0
- package/dist/server/authentication/index.d.ts +1 -1
- package/dist/server/authentication/index.js +7 -4
- package/dist/server/authentication/rotating-api-key-store.d.ts +5 -3
- package/dist/server/authentication/rotating-api-key-store.js +19 -11
- package/dist/server/engine-event-feed-backend.d.ts +4 -5
- package/dist/server/fault-to-http.js +8 -1
- package/dist/server/fault-to-json-rpc.js +1 -0
- package/dist/server/fleet-event-feed.d.ts +31 -0
- package/dist/server/fleet-event-feed.js +157 -0
- package/dist/server/handler/index.js +1 -1
- package/dist/server/handler/response-helpers.js +2 -1
- package/dist/server/handler/route-dispatch.d.ts +6 -3
- package/dist/server/handler/route-dispatch.js +2 -2
- package/dist/server/handler.js +23 -23
- package/dist/server/index.d.ts +32 -2
- package/dist/server/index.js +26 -26
- package/dist/server/json-rpc-transport-helpers.d.ts +1 -0
- package/dist/server/json-rpc-transport-helpers.js +2 -1
- package/dist/server/json-rpc-websocket-runtime.d.ts +11 -2
- package/dist/server/json-rpc-websocket-runtime.js +1 -0
- package/dist/server/json-rpc-websocket-subscriptions.d.ts +10 -0
- package/dist/server/json-rpc-websocket-subscriptions.js +29 -0
- package/dist/server/json-rpc-websocket-types.d.ts +22 -0
- package/dist/server/json-rpc-websocket-types.js +0 -0
- package/dist/server/json-rpc-websocket-validation.js +20 -4
- package/dist/server/json-rpc-websocket.d.ts +2 -43
- package/dist/server/json-rpc-websocket.js +57 -74
- package/dist/server/openapi.d.ts +2 -1
- package/dist/server/openapi.js +1 -3
- package/dist/server/openrpc-document-schema.d.ts +78 -0
- package/dist/server/openrpc-document-schema.js +27 -1
- package/dist/server/openrpc-errors.d.ts +3 -0
- package/dist/server/openrpc-errors.js +2 -1
- package/dist/server/openrpc.js +32 -0
- package/dist/server/operation-catalog/index.d.ts +1 -1
- package/dist/server/operation-catalog/pipeline-helpers.js +1 -0
- package/dist/server/operation-catalog/pipeline-stages.js +26 -12
- package/dist/server/operation-catalog/pipeline.js +8 -1
- package/dist/server/operation-catalog/registry.js +13 -0
- package/dist/server/operation-catalog/types.d.ts +20 -9
- package/dist/server/operation-fault.d.ts +10 -0
- package/dist/server/operation-fault.js +2 -0
- package/dist/server/operation-registry.d.ts +12 -11
- package/dist/server/operation-registry.js +12 -3
- package/dist/server/operations/aggregate-workflows.d.ts +15 -15
- package/dist/server/operations/async-activity.d.ts +2 -2
- package/dist/server/operations/async-activity.js +12 -7
- package/dist/server/operations/bulk-cancel-workflows.d.ts +1 -1
- package/dist/server/operations/bulk-cancel-workflows.js +2 -2
- package/dist/server/operations/bulk-delete-workflows.d.ts +1 -1
- package/dist/server/operations/bulk-delete-workflows.js +2 -2
- package/dist/server/operations/bulk-filter-helpers.d.ts +8 -6
- package/dist/server/operations/bulk-filter-helpers.js +54 -24
- package/dist/server/operations/bulk-mutate-workflow-tags.d.ts +11 -9
- package/dist/server/operations/bulk-mutate-workflow-tags.js +2 -2
- package/dist/server/operations/bulk-operation-helpers.d.ts +2 -2
- package/dist/server/operations/bulk-retry-failed-workflows.d.ts +7 -0
- package/dist/server/operations/bulk-retry-failed-workflows.js +64 -0
- package/dist/server/operations/bulk-signal-workflows.d.ts +11 -9
- package/dist/server/operations/bulk-signal-workflows.js +2 -2
- package/dist/server/operations/cancel-schedule.d.ts +1 -1
- package/dist/server/operations/create-schedule.d.ts +3 -1
- package/dist/server/operations/create-schedule.js +29 -11
- package/dist/server/operations/fleet-events-subscription.d.ts +54 -0
- package/dist/server/operations/fleet-events-subscription.js +99 -0
- package/dist/server/operations/fork-workflow.d.ts +1 -1
- package/dist/server/operations/fork-workflow.js +3 -2
- package/dist/server/operations/get-checkpoint-at.d.ts +1 -1
- package/dist/server/operations/get-registry.d.ts +1 -1
- package/dist/server/operations/get-retention-overview.d.ts +1 -1
- package/dist/server/operations/get-review.d.ts +1 -1
- package/dist/server/operations/get-schedule.d.ts +1 -1
- package/dist/server/operations/get-stream-chunks.d.ts +1 -1
- package/dist/server/operations/get-system-metrics.d.ts +2 -2
- package/dist/server/operations/get-task-diagnostics.d.ts +45 -6
- package/dist/server/operations/get-task-diagnostics.js +101 -7
- package/dist/server/operations/get-update-result.d.ts +1 -1
- package/dist/server/operations/get-workflow-attributes.d.ts +1 -1
- package/dist/server/operations/get-workflow-events.d.ts +1 -1
- package/dist/server/operations/get-workflow-result.d.ts +1 -1
- package/dist/server/operations/get-workflow-timeline.d.ts +1 -1
- package/dist/server/operations/get-workflow.d.ts +1 -1
- package/dist/server/operations/list-checkpoints.d.ts +1 -1
- package/dist/server/operations/list-reviews.d.ts +1 -1
- package/dist/server/operations/list-schedules.d.ts +1 -1
- package/dist/server/operations/list-task-queues.d.ts +2 -2
- package/dist/server/operations/list-workers.d.ts +2 -2
- package/dist/server/operations/list-workflows.d.ts +1 -1
- package/dist/server/operations/operation-helpers.d.ts +16 -1
- package/dist/server/operations/operation-helpers.js +15 -3
- package/dist/server/operations/pause-schedule.d.ts +1 -1
- package/dist/server/operations/purge-workflows.d.ts +5 -5
- package/dist/server/operations/purge-workflows.js +2 -2
- package/dist/server/operations/query-workflow.d.ts +1 -1
- package/dist/server/operations/query-workflow.js +3 -2
- package/dist/server/operations/recover-all.d.ts +1 -1
- package/dist/server/operations/replay-workflow.d.ts +1 -1
- package/dist/server/operations/resume-schedule.d.ts +1 -1
- package/dist/server/operations/set-workflow-attributes.d.ts +1 -1
- package/dist/server/operations/set-workflow-attributes.js +6 -3
- package/dist/server/operations/signal-workflow.js +8 -3
- package/dist/server/operations/single-workflow-tag-mutation.js +13 -3
- package/dist/server/operations/start-or-signal-workflow.d.ts +6 -1
- package/dist/server/operations/start-or-signal-workflow.js +14 -24
- package/dist/server/operations/start-workflow-options.d.ts +6 -0
- package/dist/server/operations/start-workflow-rest-input.d.ts +14 -0
- package/dist/server/operations/start-workflow-rest-input.js +31 -0
- package/dist/server/operations/start-workflow.d.ts +1 -1
- package/dist/server/operations/start-workflow.js +8 -23
- package/dist/server/operations/storage.d.ts +6 -6
- package/dist/server/operations/storage.js +24 -14
- package/dist/server/operations/stream-workflow-sse.d.ts +1 -1
- package/dist/server/operations/submit-review-decision.d.ts +1 -1
- package/dist/server/operations/submit-review-decision.js +6 -3
- package/dist/server/operations/update-schedule.d.ts +1 -1
- package/dist/server/operations/update-schedule.js +7 -4
- package/dist/server/operations/update-workflow.d.ts +1 -1
- package/dist/server/operations/update-workflow.js +7 -3
- package/dist/server/operations/worker-drain.d.ts +8 -8
- package/dist/server/operations/worker-drain.js +11 -8
- package/dist/server/operations/workflow-events-subscription.d.ts +7 -8
- package/dist/server/operations/workflow-events-subscription.js +43 -8
- package/dist/server/rest-binding.d.ts +3 -1
- package/dist/server/rest-bindings.js +12 -0
- package/dist/server/rest-body.d.ts +10 -0
- package/dist/server/rest-body.js +80 -0
- package/dist/server/runtime/authentication-bridge.d.ts +1 -0
- package/dist/server/runtime/authentication-bridge.js +33 -6
- package/dist/server/runtime/client-visible-events.d.ts +3 -0
- package/dist/server/runtime/client-visible-events.js +65 -0
- package/dist/server/runtime/context.d.ts +7 -0
- package/dist/server/runtime/event-broadcasting.d.ts +6 -0
- package/dist/server/runtime/event-broadcasting.js +72 -38
- package/dist/server/runtime/retry.d.ts +1 -0
- package/dist/server/runtime/retry.js +14 -0
- package/dist/server/runtime/shutdown.d.ts +7 -6
- package/dist/server/runtime/shutdown.js +6 -1
- package/dist/server/runtime/task-polling.js +61 -20
- package/dist/server/runtime/task-reconciliation.js +9 -1
- package/dist/server/runtime/task-result-resolution.d.ts +15 -0
- package/dist/server/runtime/task-result-resolution.js +81 -0
- package/dist/server/runtime/websocket-stream.d.ts +20 -1
- package/dist/server/runtime/websocket-stream.js +173 -7
- package/dist/server/runtime/websocket-upgrade.js +22 -3
- package/dist/server/runtime/websocket-worker.d.ts +1 -1
- package/dist/server/runtime/websocket-worker.js +38 -30
- package/dist/server/serve-internals.d.ts +3 -1
- package/dist/server/serve-internals.js +18 -2
- package/dist/server/task-state.d.ts +30 -0
- package/dist/server/task-state.js +28 -0
- package/dist/server/workflow-event-feed.d.ts +36 -115
- package/dist/server/workflow-event-feed.js +92 -27
- package/dist/service-worker/index.js +30 -30
- package/dist/storage/auto.js +1 -1
- package/dist/storage/bun-sql.js +24 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/default-scope.d.ts +7 -4
- package/dist/storage/http.js +2 -2
- package/dist/storage/index.d.ts +76 -4
- package/dist/storage/indexeddb.js +1 -1
- package/dist/storage/interface.d.ts +163 -0
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +10 -0
- package/dist/storage/lmdb.d.ts +4 -3
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon-batch.d.ts +30 -0
- package/dist/storage/neon-batch.js +30 -0
- package/dist/storage/neon-value-mapping.d.ts +30 -3
- package/dist/storage/neon-value-mapping.js +12 -0
- package/dist/storage/neon.d.ts +16 -0
- package/dist/storage/neon.js +9 -4
- package/dist/storage/node-sqlite.js +23 -0
- package/dist/storage/postgres-key-value-queries.d.ts +69 -44
- package/dist/storage/postgres-key-value-queries.js +62 -24
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/testing.d.ts +168 -0
- package/dist/storage/testing.js +2 -0
- package/dist/storage/turso.d.ts +8 -0
- package/dist/storage/turso.js +2 -2
- package/dist/storage/typed-storage.js +1 -1
- package/dist/storage/web-extension.js +1 -1
- package/dist/testing/index.js +28 -28
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/protocol.js +1 -1
- package/dist/workers/worker-replay-state.d.ts +32 -0
- package/dist/workers/worker-replay-state.js +35 -0
- package/dist/workers/worker-state-namespace.d.ts +21 -0
- package/dist/workers/worker-state-namespace.js +13 -0
- package/dist/workers/workflow-runner.d.ts +19 -15
- package/dist/workers/workflow-runner.js +72 -60
- package/dist/workers/workflow-worker-entry.js +5 -2
- package/package.json +5 -1
|
@@ -4,12 +4,12 @@ import type { CompressionOptions } from '../compression.ts';
|
|
|
4
4
|
import type { Interceptor } from '../interceptor.ts';
|
|
5
5
|
import type { ArchiveAdapter } from './archive-adapter.ts';
|
|
6
6
|
import type { HistoryPolicy } from './history-policy.ts';
|
|
7
|
-
import type { FailureCategory, WorkflowStatus } from './identity.ts';
|
|
8
7
|
import type { PayloadSizePolicy } from './payload-size-policy.ts';
|
|
9
8
|
import type { Duration, RetentionPolicy } from './retry-retention.ts';
|
|
10
|
-
import type {
|
|
9
|
+
import type { SearchAttributeValue } from './search-attributes.ts';
|
|
11
10
|
import type { Serializer } from './serializer.ts';
|
|
12
11
|
import type { WorkflowServicesResolution, WorkflowServicesResolverInfo } from './services-resolution.ts';
|
|
12
|
+
import type { WorkflowLogRecord } from './workflow-log.ts';
|
|
13
13
|
/**
|
|
14
14
|
* Options accepted by `engine.start(type, input, options?)`.
|
|
15
15
|
*
|
|
@@ -21,6 +21,13 @@ import type { WorkflowServicesResolution, WorkflowServicesResolverInfo } from '.
|
|
|
21
21
|
* via filters. `id` and `idempotencyKey` are mutually exclusive — idempotency
|
|
22
22
|
* assigns its own generated id and dedups through the key.
|
|
23
23
|
*
|
|
24
|
+
* This is the shared base accepted by every start-like surface
|
|
25
|
+
* (`engine.start`, `engine.startOrSignal`, and the clients). `engine.start`
|
|
26
|
+
* specifically accepts the wider {@link StartWorkflowOptions}, which adds
|
|
27
|
+
* `onTerminalConflict`; that policy is intentionally absent here so it cannot be
|
|
28
|
+
* passed to `startOrSignal` (whose at-most-once identity is the permanent
|
|
29
|
+
* idempotency mapping).
|
|
30
|
+
*
|
|
24
31
|
* The `idempotencyKey` mapping is durable and permanent: it survives the run
|
|
25
32
|
* reaching a terminal state, so repeat calls keep returning the same handle. When
|
|
26
33
|
* the workflow record is purged or swept by retention the mapping itself survives
|
|
@@ -53,7 +60,7 @@ import type { WorkflowServicesResolution, WorkflowServicesResolverInfo } from '.
|
|
|
53
60
|
* void handle;
|
|
54
61
|
* ```
|
|
55
62
|
*/
|
|
56
|
-
export interface StartOptions {
|
|
63
|
+
export interface StartOptions<TServices = unknown> {
|
|
57
64
|
id?: string;
|
|
58
65
|
idempotencyKey?: string;
|
|
59
66
|
executionTimeout?: Duration;
|
|
@@ -72,7 +79,7 @@ export interface StartOptions {
|
|
|
72
79
|
* `workflowExecutionMode: 'worker'` throws at `engine.start()`, because a
|
|
73
80
|
* non-serializable value cannot cross to a Worker.
|
|
74
81
|
*/
|
|
75
|
-
services?:
|
|
82
|
+
services?: TServices;
|
|
76
83
|
/**
|
|
77
84
|
* When `false`, `engine.start()` resolves only after the workflow has begun
|
|
78
85
|
* executing (its generator has been driven its first turn), not merely after
|
|
@@ -87,6 +94,47 @@ export interface StartOptions {
|
|
|
87
94
|
*/
|
|
88
95
|
defer?: boolean;
|
|
89
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Options accepted by `engine.start(type, input, options?)` — the shared
|
|
99
|
+
* {@link StartOptions} plus the start-only `onTerminalConflict` policy.
|
|
100
|
+
*
|
|
101
|
+
* `onTerminalConflict` lives here, not on {@link StartOptions}, so it is
|
|
102
|
+
* structurally rejected on every other start-like surface: `engine.startOrSignal`
|
|
103
|
+
* (whose identity is the permanent at-most-once idempotency mapping),
|
|
104
|
+
* `ctx.startChild` (which re-attaches to an existing run by id on replay), and the
|
|
105
|
+
* REST/JSON-RPC transport (which keeps `weft.workflows.start` honestly
|
|
106
|
+
* `destructive: false`). It is therefore an in-process `engine.start`-only policy.
|
|
107
|
+
*/
|
|
108
|
+
export interface StartWorkflowOptions<TServices = unknown> extends StartOptions<TServices> {
|
|
109
|
+
/**
|
|
110
|
+
* What `engine.start()` does when the supplied `id` already belongs to a run
|
|
111
|
+
* that has reached a **terminal** state (`completed` | `failed` | `cancelled`
|
|
112
|
+
* | `timed-out`). This is Weft's equivalent of Temporal's
|
|
113
|
+
* `WorkflowIdReusePolicy.ALLOW_DUPLICATE`, for the common case of a periodic
|
|
114
|
+
* job keyed by a stable id (e.g. `reconcile:installation-42`) whose previous
|
|
115
|
+
* run has already finished.
|
|
116
|
+
*
|
|
117
|
+
* - `'error'` (default): preserve the existing contract — a duplicate id always
|
|
118
|
+
* throws {@link WorkflowAlreadyExistsError}, terminal or not.
|
|
119
|
+
* - `'start-new'`: if the prior run under this id is terminal, purge it (while
|
|
120
|
+
* holding the in-process start reservation, the same teardown as
|
|
121
|
+
* `engine.purge`, sweeping every key the run owns) and start a fresh run in
|
|
122
|
+
* its place; if the prior run is still **non-terminal** (running/pending),
|
|
123
|
+
* throw {@link WorkflowAlreadyExistsError} unchanged — `'start-new'` never
|
|
124
|
+
* displaces a live run.
|
|
125
|
+
*
|
|
126
|
+
* Requires an explicit `id` (the policy only makes sense for a caller-chosen,
|
|
127
|
+
* reusable id) and is mutually exclusive with `idempotencyKey` (whose mapping
|
|
128
|
+
* is permanent and at-most-once — restarting under it would violate that
|
|
129
|
+
* contract). The previous run's durable record is gone after a `'start-new'`
|
|
130
|
+
* restart, so a {@link WorkflowHandle} held against the old id resolves to the
|
|
131
|
+
* fresh run for every method (`result()`, `snapshot()`, status), because handles
|
|
132
|
+
* are id-scoped, not run-attempt-scoped. The restart holds the same in-process
|
|
133
|
+
* start reservation as a normal start, so two concurrent `'start-new'` calls for
|
|
134
|
+
* one id cannot both win — the loser sees {@link WorkflowAlreadyExistsError}.
|
|
135
|
+
*/
|
|
136
|
+
onTerminalConflict?: 'error' | 'start-new';
|
|
137
|
+
}
|
|
90
138
|
/**
|
|
91
139
|
* Options for {@link Engine.fork}. Controls which checkpoint step to fork
|
|
92
140
|
* from; defaults to the latest persisted checkpoint when omitted.
|
|
@@ -130,7 +178,7 @@ export interface ForkOptions {
|
|
|
130
178
|
* void engine;
|
|
131
179
|
* ```
|
|
132
180
|
*/
|
|
133
|
-
export interface EngineOptions {
|
|
181
|
+
export interface EngineOptions<TServices = unknown> {
|
|
134
182
|
storage?: WeftStorage;
|
|
135
183
|
development?: boolean;
|
|
136
184
|
serializer?: Serializer;
|
|
@@ -156,6 +204,61 @@ export interface EngineOptions {
|
|
|
156
204
|
* well above your deploy drain window. Ignored when detection is disabled.
|
|
157
205
|
*/
|
|
158
206
|
secondInstanceHeartbeatInterval?: Duration;
|
|
207
|
+
/**
|
|
208
|
+
* Single-writer ownership posture over the shared durable store. Default
|
|
209
|
+
* `'none'` — the engine recovers immediately at boot and relies on
|
|
210
|
+
* infrastructure (one replica + a `Recreate` deploy) for mutual exclusion.
|
|
211
|
+
*
|
|
212
|
+
* `'lease'` opts into a storage-keyed ownership lease: at boot the engine
|
|
213
|
+
* acquires the lease (waiting, up to {@link EngineOptions.leaseWaitTimeout}, if
|
|
214
|
+
* another instance still holds it) **before** recovering, renews it on a
|
|
215
|
+
* heartbeat, and releases it on dispose. This turns a rolling deploy into a
|
|
216
|
+
* clean handoff — the incoming instance parks until the outgoing one releases
|
|
217
|
+
* (or its lease expires), so the two never recover concurrently.
|
|
218
|
+
*
|
|
219
|
+
* Requires a storage backend with the `conditionalBatch` capability (every
|
|
220
|
+
* durable recovery backend already provides it).
|
|
221
|
+
*
|
|
222
|
+
* **Step-1 acquisition boundary.** The lease is acquired on the standard boot
|
|
223
|
+
* paths — `Engine.create()` and `Engine.recoverAll()` (so `new Engine({ ownership:
|
|
224
|
+
* 'lease' })` followed by `recoverAll()` acquires it too). It is **not** yet
|
|
225
|
+
* acquired on a first durable write, so a `new Engine({ ownership: 'lease' })`
|
|
226
|
+
* that calls `engine.start(...)` *without* ever calling `recoverAll()` will write
|
|
227
|
+
* without holding the lease. Use `Engine.create()` (or call `recoverAll()` before
|
|
228
|
+
* accepting traffic) so acquisition runs before any write.
|
|
229
|
+
*
|
|
230
|
+
* **Lease alone is deploy ergonomics, not a correctness guarantee.** It
|
|
231
|
+
* prevents the *new* instance from recovering early; it does not by itself stop
|
|
232
|
+
* a stalled *old* instance (e.g. a long GC pause past the lease TTL) from
|
|
233
|
+
* writing after its lease expired. Epoch fencing of durable writes is what
|
|
234
|
+
* closes that gap. Keep infrastructure-level single-instance enforcement as the
|
|
235
|
+
* real control.
|
|
236
|
+
*/
|
|
237
|
+
ownership?: 'none' | 'lease';
|
|
238
|
+
/**
|
|
239
|
+
* Lease time-to-live for `ownership: 'lease'` (default `30s`). A holder renews
|
|
240
|
+
* well within this window; once it lapses without renewal, a waiting instance
|
|
241
|
+
* may steal the lease. Must comfortably exceed the renewal interval plus the
|
|
242
|
+
* worst-case GC pause, clock skew, and storage round-trip. Ignored when
|
|
243
|
+
* `ownership` is not `'lease'`.
|
|
244
|
+
*/
|
|
245
|
+
leaseTtl?: Duration;
|
|
246
|
+
/**
|
|
247
|
+
* Lease renewal interval for `ownership: 'lease'` (default `5s`). The holder
|
|
248
|
+
* re-asserts the lease this often; keep it well below {@link EngineOptions.leaseTtl}
|
|
249
|
+
* so a single slow renewal cannot let the lease lapse. Ignored when `ownership`
|
|
250
|
+
* is not `'lease'`.
|
|
251
|
+
*/
|
|
252
|
+
leaseRenewInterval?: Duration;
|
|
253
|
+
/**
|
|
254
|
+
* How long a booting `ownership: 'lease'` instance waits to acquire the lease
|
|
255
|
+
* when another instance still holds it, before throwing
|
|
256
|
+
* {@link EngineLeaseAcquisitionTimeoutError} (default `60s`). Size this above
|
|
257
|
+
* both the outgoing instance's drain time and the lease TTL, so a graceful
|
|
258
|
+
* handoff and a crash (no clean release, lease expires after TTL) both resolve.
|
|
259
|
+
* Ignored when `ownership` is not `'lease'`.
|
|
260
|
+
*/
|
|
261
|
+
leaseWaitTimeout?: Duration;
|
|
159
262
|
/**
|
|
160
263
|
* History circuit-breaker thresholds. When `history.maxEvents` is set, a
|
|
161
264
|
* workflow whose event-log record count would exceed it is forced to a
|
|
@@ -261,8 +364,9 @@ export interface EngineOptions {
|
|
|
261
364
|
* Return `{ status: 'available', services }` to supply the rebuilt
|
|
262
365
|
* capabilities, or `{ status: 'unavailable', reason }` to fail just that one
|
|
263
366
|
* recovered run — the engine and every other recovered run are unaffected.
|
|
264
|
-
* Without a resolver, a recovered
|
|
265
|
-
*
|
|
367
|
+
* Without a resolver, a recovered run that carries the durable "expects
|
|
368
|
+
* services" marker fails before the generator advances and emits a diagnostic
|
|
369
|
+
* warning naming this option.
|
|
266
370
|
*
|
|
267
371
|
* Contract a fresh integrator must know:
|
|
268
372
|
* - Fires only for recovered inline runs that were launched WITH `services`
|
|
@@ -279,165 +383,17 @@ export interface EngineOptions {
|
|
|
279
383
|
* Engine-scoped: each engine instance carries its own resolver, so two engines
|
|
280
384
|
* in one process never collide on per-run dependency reconstruction.
|
|
281
385
|
*/
|
|
282
|
-
resolveWorkflowServices?: (info: WorkflowServicesResolverInfo) => WorkflowServicesResolution | Promise<WorkflowServicesResolution
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Filter criteria for {@link Engine.list}. All fields are optional and
|
|
286
|
-
* combine with AND semantics. `status` accepts a single value or an array;
|
|
287
|
-
* `attributes` is a list of attribute predicates evaluated on indexed search
|
|
288
|
-
* attributes. Pairs with `limit`/`offset` for pagination.
|
|
289
|
-
*
|
|
290
|
-
* @example
|
|
291
|
-
* ```ts
|
|
292
|
-
* import { Engine, type ListFilter } from '@lostgradient/weft';
|
|
293
|
-
*
|
|
294
|
-
* const engine = new Engine();
|
|
295
|
-
* const filter: ListFilter = {
|
|
296
|
-
* status: ['running', 'pending'],
|
|
297
|
-
* tags: ['nightly'],
|
|
298
|
-
* attributes: [{ key: 'customerId', value: 'acme' }],
|
|
299
|
-
* limit: 20,
|
|
300
|
-
* offset: 0,
|
|
301
|
-
* };
|
|
302
|
-
* const result = await engine.list(filter);
|
|
303
|
-
* console.log(result.items.length);
|
|
304
|
-
* ```
|
|
305
|
-
*/
|
|
306
|
-
/**
|
|
307
|
-
* Numeric half-open range bound, used by visibility filters that match a
|
|
308
|
-
* stored numeric field (timestamps, deadlines). Provide at least one of the
|
|
309
|
-
* four bounds. `gt`/`gte` are mutually exclusive on the lower side; `lt`/`lte`
|
|
310
|
-
* are mutually exclusive on the upper side.
|
|
311
|
-
*/
|
|
312
|
-
export interface TimeRange {
|
|
313
|
-
gte?: number;
|
|
314
|
-
lte?: number;
|
|
315
|
-
gt?: number;
|
|
316
|
-
lt?: number;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Filter passed to {@link Engine.list} (and equivalent visibility transports)
|
|
320
|
-
* to narrow which {@link WorkflowSummary} entries are returned. Every field
|
|
321
|
-
* is optional; combining fields applies them as AND.
|
|
322
|
-
*
|
|
323
|
-
* @example
|
|
324
|
-
* ```ts
|
|
325
|
-
* import { Engine, type ListFilter } from '@lostgradient/weft';
|
|
326
|
-
*
|
|
327
|
-
* const engine = new Engine();
|
|
328
|
-
* const filter: ListFilter = {
|
|
329
|
-
* status: ['running', 'failed'],
|
|
330
|
-
* createdAt: { gte: Date.now() - 60_000 },
|
|
331
|
-
* };
|
|
332
|
-
*
|
|
333
|
-
* const page = await engine.list(filter);
|
|
334
|
-
* ```
|
|
335
|
-
*/
|
|
336
|
-
export interface ListFilter {
|
|
337
|
-
/** Match workflows whose {@link WorkflowState.status} is one of the listed values. */
|
|
338
|
-
status?: WorkflowStatus | WorkflowStatus[];
|
|
386
|
+
resolveWorkflowServices?: (info: WorkflowServicesResolverInfo) => WorkflowServicesResolution<TServices> | Promise<WorkflowServicesResolution<TServices>>;
|
|
339
387
|
/**
|
|
340
|
-
*
|
|
388
|
+
* Optional host sink for `ctx.log` records. When provided, every non-replayed
|
|
389
|
+
* record from inline workflow execution is routed here (into your pino / winston
|
|
390
|
+
* / OpenTelemetry stack, etc.) **instead of** the console; when omitted, records
|
|
391
|
+
* fall back to the matching `console` method, preserving the default behavior.
|
|
341
392
|
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
* ```
|
|
347
|
-
*/
|
|
348
|
-
type?: string;
|
|
349
|
-
/** Match workflows that carry every listed tag. */
|
|
350
|
-
tags?: string[];
|
|
351
|
-
/** Filter on indexed search attributes (equality or range). */
|
|
352
|
-
attributes?: readonly AttributeFilter[];
|
|
353
|
-
/** Maximum number of summaries to return. Server enforces an upper bound. */
|
|
354
|
-
limit?: number;
|
|
355
|
-
/** Number of summaries to skip before returning results. */
|
|
356
|
-
offset?: number;
|
|
357
|
-
/**
|
|
358
|
-
* Workflow id prefix. Restricted to `[A-Za-z0-9_-]+`; values containing
|
|
359
|
-
* other characters are rejected during validation. Matches by raw
|
|
360
|
-
* `state.id.startsWith(idPrefix)` after candidate enumeration.
|
|
393
|
+
* Engine-scoped infrastructure: set once at construction, never per run. The sink
|
|
394
|
+
* is not invoked for records suppressed during replay, so a recovered run does
|
|
395
|
+
* not re-emit its replayed prefix. Worker-mode records still log to the worker
|
|
396
|
+
* process's console — routing them back to the host is tracked separately.
|
|
361
397
|
*/
|
|
362
|
-
|
|
363
|
-
/** Range filter on `WorkflowState.createdAt` (ms epoch). */
|
|
364
|
-
createdAt?: TimeRange;
|
|
365
|
-
/** Range filter on `WorkflowState.updatedAt` (ms epoch). */
|
|
366
|
-
updatedAt?: TimeRange;
|
|
367
|
-
/** Range filter on `WorkflowState.executionDeadline` (ms epoch). */
|
|
368
|
-
executionDeadline?: TimeRange;
|
|
369
|
-
/**
|
|
370
|
-
* Match by the workflow's `failureCategory`. The engine uses the
|
|
371
|
-
* `failureCategory` search-attribute index to narrow candidate workflow IDs,
|
|
372
|
-
* then still verifies the loaded `WorkflowState.failureCategory` so state
|
|
373
|
-
* remains authoritative when index entries are stale.
|
|
374
|
-
*/
|
|
375
|
-
failureCategory?: FailureCategory | FailureCategory[];
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Projection options for {@link Engine.list}. These options do not change
|
|
379
|
-
* which workflows match the list filter; they only control optional summary
|
|
380
|
-
* fields that may require additional storage reads.
|
|
381
|
-
*
|
|
382
|
-
* @example Include failure categories projected from search attributes
|
|
383
|
-
* ```ts
|
|
384
|
-
* import { Engine, type ListOptions } from '@lostgradient/weft';
|
|
385
|
-
*
|
|
386
|
-
* const engine = new Engine();
|
|
387
|
-
* const options: ListOptions = { includeFailureCategory: true };
|
|
388
|
-
* const page = await engine.list({ status: 'failed' }, options);
|
|
389
|
-
* void page;
|
|
390
|
-
* ```
|
|
391
|
-
*/
|
|
392
|
-
export interface ListOptions {
|
|
393
|
-
/**
|
|
394
|
-
* Populate `WorkflowSummary.failureCategory` for failed workflows from the
|
|
395
|
-
* stored `failureCategory` search attribute when the workflow state itself
|
|
396
|
-
* does not carry a category. Defaults to `false`.
|
|
397
|
-
*/
|
|
398
|
-
includeFailureCategory?: boolean;
|
|
399
|
-
}
|
|
400
|
-
export type AttributeFilterKey = string | SearchAttributeHandle;
|
|
401
|
-
export type AttributeFilterValue<TKey extends AttributeFilterKey> = TKey extends SearchAttributeHandle<infer TValue> ? TValue extends string[] ? string : TValue : SearchAttributeValue;
|
|
402
|
-
export type AttributeRangeValue<TKey extends AttributeFilterKey> = TKey extends SearchAttributeHandle<infer TValue> ? Extract<TValue, Date | number> : SearchAttributeValue;
|
|
403
|
-
export type AttributeFilter<TKey extends AttributeFilterKey = AttributeFilterKey> = TKey extends SearchAttributeHandle ? {
|
|
404
|
-
key: TKey;
|
|
405
|
-
value?: AttributeFilterValue<TKey>;
|
|
406
|
-
gt?: never;
|
|
407
|
-
lt?: never;
|
|
408
|
-
gte?: never;
|
|
409
|
-
lte?: never;
|
|
410
|
-
} | {
|
|
411
|
-
key: TKey;
|
|
412
|
-
value?: never;
|
|
413
|
-
gt?: AttributeRangeValue<TKey>;
|
|
414
|
-
lt?: AttributeRangeValue<TKey>;
|
|
415
|
-
gte?: AttributeRangeValue<TKey>;
|
|
416
|
-
lte?: AttributeRangeValue<TKey>;
|
|
417
|
-
} : {
|
|
418
|
-
key: TKey;
|
|
419
|
-
value?: SearchAttributeValue;
|
|
420
|
-
gt?: SearchAttributeValue;
|
|
421
|
-
lt?: SearchAttributeValue;
|
|
422
|
-
gte?: SearchAttributeValue;
|
|
423
|
-
lte?: SearchAttributeValue;
|
|
424
|
-
};
|
|
425
|
-
export type AttributeFilterList<TAttributeKeys extends readonly AttributeFilterKey[]> = {
|
|
426
|
-
readonly [TIndex in keyof TAttributeKeys]: AttributeFilter<TAttributeKeys[TIndex]>;
|
|
427
|
-
};
|
|
428
|
-
export type TypedListFilter<TAttributeKeys extends readonly AttributeFilterKey[]> = Omit<ListFilter, 'attributes'> & {
|
|
429
|
-
attributes?: AttributeFilterList<TAttributeKeys>;
|
|
430
|
-
};
|
|
431
|
-
/**
|
|
432
|
-
* Generic paginated response envelope returned by list operations such as
|
|
433
|
-
* {@link Engine.list} and `engine.listSchedules`. `total` is the full count
|
|
434
|
-
* matching the filter; `items` is the current page slice. `items.length` is
|
|
435
|
-
* bounded by `limit`; the consumer reaches the end of the result set when
|
|
436
|
-
* `offset + items.length >= total`.
|
|
437
|
-
*/
|
|
438
|
-
export interface PaginatedResult<T> {
|
|
439
|
-
items: T[];
|
|
440
|
-
total: number;
|
|
441
|
-
offset: number;
|
|
442
|
-
limit: number;
|
|
398
|
+
onLog?: (record: WorkflowLogRecord) => void;
|
|
443
399
|
}
|
|
@@ -51,8 +51,8 @@ export type ScheduleSpec = {
|
|
|
51
51
|
/**
|
|
52
52
|
* Options accepted by {@link Engine.schedule}. `id` assigns a deterministic
|
|
53
53
|
* schedule identifier; `overlap` controls what happens when a tick fires while a
|
|
54
|
-
* previous run is still active; `backfill`
|
|
55
|
-
*
|
|
54
|
+
* previous run is still active; `backfill` controls missed ticks after downtime;
|
|
55
|
+
* `jitter` deterministically spreads each occurrence's effective dispatch time.
|
|
56
56
|
*
|
|
57
57
|
* @example
|
|
58
58
|
* ```ts
|
|
@@ -60,7 +60,12 @@ export type ScheduleSpec = {
|
|
|
60
60
|
*
|
|
61
61
|
* const engine = new Engine();
|
|
62
62
|
* engine.register(workflow({ name: 'report' }).execute(async function* () { return 'ok'; }));
|
|
63
|
-
* const options: ScheduleOptions = {
|
|
63
|
+
* const options: ScheduleOptions = {
|
|
64
|
+
* id: 'daily-report',
|
|
65
|
+
* overlap: 'skip',
|
|
66
|
+
* backfill: false,
|
|
67
|
+
* jitter: '30s',
|
|
68
|
+
* };
|
|
64
69
|
* const handle = await engine.schedule('report', null, '0 9 * * *', options);
|
|
65
70
|
* void handle;
|
|
66
71
|
* ```
|
|
@@ -68,7 +73,23 @@ export type ScheduleSpec = {
|
|
|
68
73
|
export interface ScheduleOptions {
|
|
69
74
|
id?: string;
|
|
70
75
|
overlap?: ScheduleOverlapPolicy;
|
|
76
|
+
/**
|
|
77
|
+
* When `false` (the default), a tick that is more than one second late is
|
|
78
|
+
* skipped instead of backfilled. Skipped ticks increment
|
|
79
|
+
* {@link ScheduleState.missedFireCount}, update
|
|
80
|
+
* {@link ScheduleState.lastMissedFireAt}, and emit a
|
|
81
|
+
* `ScheduleMissedFireEvent`.
|
|
82
|
+
*
|
|
83
|
+
* When `true`, missed ticks are processed immediately, up to the engine's
|
|
84
|
+
* per-tick backfill cap.
|
|
85
|
+
*/
|
|
71
86
|
backfill?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Deterministic per-occurrence delay applied to the effective dispatch timer.
|
|
89
|
+
* The persisted {@link ScheduleState.nextFireAt} remains the nominal
|
|
90
|
+
* pre-jitter occurrence timestamp.
|
|
91
|
+
*/
|
|
92
|
+
jitter?: Duration;
|
|
72
93
|
}
|
|
73
94
|
/**
|
|
74
95
|
* Declarative recurring schedule definition returned by {@link schedule}. Supply
|
|
@@ -99,6 +120,7 @@ export type ScheduleDefinition<TInput = unknown> = ScheduleSpec & {
|
|
|
99
120
|
id?: string;
|
|
100
121
|
overlapPolicy?: ScheduleOverlapPolicy;
|
|
101
122
|
backfill?: boolean;
|
|
123
|
+
jitter?: Duration;
|
|
102
124
|
};
|
|
103
125
|
/**
|
|
104
126
|
* Create a recurring schedule definition for `engine.schedule(definition)`.
|
|
@@ -134,9 +156,16 @@ export interface ScheduleState {
|
|
|
134
156
|
status: ScheduleStatus;
|
|
135
157
|
overlap: ScheduleOverlapPolicy;
|
|
136
158
|
backfill: boolean;
|
|
159
|
+
/** Normalized deterministic jitter window in milliseconds. */
|
|
160
|
+
jitterMs?: number;
|
|
137
161
|
createdAt: number;
|
|
138
162
|
updatedAt: number;
|
|
163
|
+
/** Most recent occurrence that started a scheduled workflow. */
|
|
139
164
|
lastFireAt?: number;
|
|
165
|
+
/** Most recent occurrence skipped because a non-backfill timer was late. */
|
|
166
|
+
lastMissedFireAt?: number;
|
|
167
|
+
/** Lifetime count of occurrences skipped because a non-backfill timer was late. */
|
|
168
|
+
missedFireCount: number;
|
|
140
169
|
nextFireAt: number | null;
|
|
141
170
|
currentWorkflowId?: string;
|
|
142
171
|
queuedRuns: number;
|
|
@@ -157,9 +186,16 @@ export interface ScheduleSummary {
|
|
|
157
186
|
status: ScheduleStatus;
|
|
158
187
|
overlap: ScheduleOverlapPolicy;
|
|
159
188
|
backfill: boolean;
|
|
189
|
+
/** Normalized deterministic jitter window in milliseconds. */
|
|
190
|
+
jitterMs?: number;
|
|
160
191
|
createdAt: number;
|
|
161
192
|
updatedAt: number;
|
|
193
|
+
/** Most recent occurrence that started a scheduled workflow. */
|
|
162
194
|
lastFireAt?: number;
|
|
195
|
+
/** Most recent occurrence skipped because a non-backfill timer was late. */
|
|
196
|
+
lastMissedFireAt?: number;
|
|
197
|
+
/** Lifetime count of occurrences skipped because a non-backfill timer was late. */
|
|
198
|
+
missedFireCount: number;
|
|
163
199
|
nextFireAt: number | null;
|
|
164
200
|
currentWorkflowId?: string;
|
|
165
201
|
queuedRuns: number;
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* void no;
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export type WorkflowServicesResolution = {
|
|
21
|
+
export type WorkflowServicesResolution<TServices = unknown> = {
|
|
22
22
|
status: 'available';
|
|
23
|
-
services:
|
|
23
|
+
services: TServices;
|
|
24
24
|
} | {
|
|
25
25
|
status: 'unavailable';
|
|
26
26
|
reason: string;
|
|
@@ -11,7 +11,9 @@ import type { RetentionPolicy } from './retry-retention.ts';
|
|
|
11
11
|
import type { SearchAttributeSchema } from './search-attributes.ts';
|
|
12
12
|
import type { ActivityMap, ActivityMapInput, QueryMap, SignalMap, UpdateMap } from './workflow-builder-helpers.ts';
|
|
13
13
|
import type { BuiltWorkflowDefinition } from './workflow-builder.ts';
|
|
14
|
+
import type { WorkflowConcurrencyOptions } from './workflow-concurrency.ts';
|
|
14
15
|
import type { WorkflowFunction } from './workflow-function.ts';
|
|
16
|
+
import type { AnyActivityDefinition } from './workflow-registries.ts';
|
|
15
17
|
/**
|
|
16
18
|
* Thrown by the chained workflow builder for runtime invariants that the type
|
|
17
19
|
* system cannot reliably catch — duplicate chain calls, key/name collisions
|
|
@@ -44,7 +46,7 @@ export declare class WorkflowBuilderError extends WeftError<'WorkflowBuilderErro
|
|
|
44
46
|
/**
|
|
45
47
|
* Initial options accepted by the builder-form `workflow({ name, ... })` call.
|
|
46
48
|
* Extra metadata fields (`version`, `description`, `tags`, `retention`,
|
|
47
|
-
* `
|
|
49
|
+
* `concurrency`, `inputSchema`, `outputSchema`, `constraints`) are passed through
|
|
48
50
|
* onto the returned {@link BuiltWorkflowDefinition} when `.execute(fn)` runs.
|
|
49
51
|
* Only `name` is required.
|
|
50
52
|
*
|
|
@@ -60,14 +62,20 @@ export declare class WorkflowBuilderError extends WeftError<'WorkflowBuilderErro
|
|
|
60
62
|
* void welcome;
|
|
61
63
|
* ```
|
|
62
64
|
*/
|
|
63
|
-
export interface WorkflowBuilderOptions<TName extends string = string> {
|
|
65
|
+
export interface WorkflowBuilderOptions<TName extends string = string, TConcurrencyInput = unknown> {
|
|
64
66
|
name: TName;
|
|
65
67
|
version?: string;
|
|
66
68
|
description?: string;
|
|
67
69
|
tags?: ReadonlyArray<string>;
|
|
68
70
|
retention?: RetentionPolicy;
|
|
71
|
+
concurrency?: WorkflowConcurrencyOptions<TConcurrencyInput>;
|
|
69
72
|
constraints?: ConstraintDefinition[];
|
|
70
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Definition-level teardown activity driven by the engine after a
|
|
75
|
+
* `cancelled`/`timed-out` terminal (issue #446). See
|
|
76
|
+
* {@link WorkflowDefinition.finalizer}.
|
|
77
|
+
*/
|
|
78
|
+
finalizer?: AnyActivityDefinition;
|
|
71
79
|
inputSchema?: DefinitionSchema<unknown, unknown>;
|
|
72
80
|
outputSchema?: DefinitionSchema<unknown, unknown>;
|
|
73
81
|
/**
|
|
@@ -93,5 +101,6 @@ export declare class WorkflowBuilderImpl<TName extends string> {
|
|
|
93
101
|
updates: (map: UpdateMap) => this;
|
|
94
102
|
queries: (map: QueryMap) => this;
|
|
95
103
|
searchAttributes: (schema: SearchAttributeSchema) => this;
|
|
104
|
+
services: () => this;
|
|
96
105
|
execute: (fn: WorkflowFunction) => BuiltWorkflowDefinition<unknown, unknown, TName, ActivityMap, SignalMap, UpdateMap, QueryMap, SearchAttributeSchema>;
|
|
97
106
|
}
|
|
@@ -16,7 +16,8 @@ export class WorkflowBuilderImpl {
|
|
|
16
16
|
signals: !1,
|
|
17
17
|
updates: !1,
|
|
18
18
|
queries: !1,
|
|
19
|
-
searchAttributes: !1
|
|
19
|
+
searchAttributes: !1,
|
|
20
|
+
services: !1
|
|
20
21
|
};
|
|
21
22
|
#executed = !1;
|
|
22
23
|
#activities = {};
|
|
@@ -66,6 +67,11 @@ export class WorkflowBuilderImpl {
|
|
|
66
67
|
this.#searchAttributes = { ...schema };
|
|
67
68
|
return this;
|
|
68
69
|
};
|
|
70
|
+
services = () => {
|
|
71
|
+
this.#assertOpen("services");
|
|
72
|
+
this.#markCalled("services");
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
69
75
|
execute = (fn) => {
|
|
70
76
|
this.#assertOpen("execute");
|
|
71
77
|
this.#executed = !0;
|
|
@@ -81,8 +87,11 @@ export class WorkflowBuilderImpl {
|
|
|
81
87
|
...this.#options.description !== void 0 ? { description: this.#options.description } : {},
|
|
82
88
|
...this.#options.tags !== void 0 ? { tags: this.#options.tags } : {},
|
|
83
89
|
...this.#options.retention !== void 0 ? { retention: this.#options.retention } : {},
|
|
90
|
+
...this.#options.concurrency !== void 0 ? {
|
|
91
|
+
concurrency: deepFreeze(clonePlain(this.#options.concurrency))
|
|
92
|
+
} : {},
|
|
84
93
|
...this.#options.constraints !== void 0 ? { constraints: this.#options.constraints } : {},
|
|
85
|
-
...this.#options.
|
|
94
|
+
...this.#options.finalizer !== void 0 ? { finalizer: this.#options.finalizer } : {},
|
|
86
95
|
...this.#options.inputSchema !== void 0 ? { inputSchema: this.#options.inputSchema } : {},
|
|
87
96
|
...this.#options.outputSchema !== void 0 ? { outputSchema: this.#options.outputSchema } : {}
|
|
88
97
|
};
|